From af454096f334ea6b411495267281a112a29f8341 Mon Sep 17 00:00:00 2001 From: Pasquale Gatto <47112536+PasGat@users.noreply.github.com> Date: Fri, 21 Aug 2020 11:05:45 +0100 Subject: [PATCH 1/4] MIBM-38: Redirect to pay-api-FE --- .../controllers/PaymentController.scala | 2 +- .../controllers/PaymentControllerSpec.scala | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentController.scala b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentController.scala index 536199cdf..c1b7f24a6 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentController.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentController.scala @@ -37,7 +37,7 @@ class PaymentController @Inject()( TraderDetails("Trader Inc, 239 Old Street, Berlin, Germany, EC1V 9EY"), MerchandiseDetails("Parts and technical crew for the forest moon") ) - makePayment(httpClient, body).map(response => Ok(response.body)) + makePayment(httpClient, body).map { response => Redirect(extractUrl(response).nextUrl.value) } .recoverWith { case _: Throwable => Future.successful(InternalServerError(errorHandler.internalServerErrorTemplate)) } diff --git a/test/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentControllerSpec.scala b/test/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentControllerSpec.scala index 8d85af435..668291fac 100644 --- a/test/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentControllerSpec.scala +++ b/test/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/PaymentControllerSpec.scala @@ -46,8 +46,10 @@ class PaymentControllerSpec extends BaseSpecWithApplication { } val getRequest = buildGet(routes.PaymentController.onSubmit().url) + val eventualResult = controller.onSubmit()(getRequest) - contentAsString(controller.onSubmit()(getRequest)) mustBe stubbedApiResponse + status(eventualResult) mustBe 303 + redirectLocation(eventualResult) mustBe Some("http://host") } "on submit will return error page if call to pay-api fails" in { From e961c620e1e8cf1d16a6d636107f1c05912edc46 Mon Sep 17 00:00:00 2001 From: Pasquale Gatto <47112536+PasGat@users.noreply.github.com> Date: Fri, 21 Aug 2020 11:37:23 +0100 Subject: [PATCH 2/4] MIBM-38: move conf inside services --- .../merchandiseinbaggagefrontend/config/AppConfig.scala | 2 +- conf/application.conf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/config/AppConfig.scala b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/config/AppConfig.scala index cd8689405..807669b4d 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/config/AppConfig.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/config/AppConfig.scala @@ -18,7 +18,7 @@ class AppConfig() extends PaymentServiceConf { } trait PaymentServiceConf { - lazy val paymentServiceConf: PaymentServiceConfiguration = ConfigSource.default.at("payment").loadOrThrow[PaymentServiceConfiguration] + lazy val paymentServiceConf: PaymentServiceConfiguration = ConfigSource.default.at("microservice.services.payment").loadOrThrow[PaymentServiceConfiguration] import paymentServiceConf._ lazy val paymentBaseUri = s"$protocol://$host:$port/" } diff --git a/conf/application.conf b/conf/application.conf index c06bad40e..fe5888309 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -61,6 +61,9 @@ microservice { host = localhost port = 9250 } + + payment = + { type = payment-service-configuration, protocol = "http", port = 9057, host = "localhost" , url = "pay-api/mib-frontend/mib/journey/start" } } } @@ -91,8 +94,5 @@ google-analytics { footerLinkItems = ["cookies", "privacy", "termsConditions", "govukHelp"] -payment = - { type = payment-service-configuration, protocol = "http", port = 9057, host = "localhost" , url = "pay-api/mib-frontend/mib/journey/start" } - From e3ae51d89a3df78506c9263995e42ca95dcaac47 Mon Sep 17 00:00:00 2001 From: Pasquale Gatto <47112536+PasGat@users.noreply.github.com> Date: Fri, 21 Aug 2020 11:42:46 +0100 Subject: [PATCH 3/4] MIBM-38: modify base url --- conf/prod.routes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/prod.routes b/conf/prod.routes index 7a49f991c..f19af7a04 100644 --- a/conf/prod.routes +++ b/conf/prod.routes @@ -1,5 +1,5 @@ # Add all the application routes to the app.routes file --> /merchandise-in-baggage-frontend app.Routes +-> /merchandise-in-baggage app.Routes -> / health.Routes GET /admin/metrics com.kenshoo.play.metrics.MetricsController.metrics From b2dedb4959c2b493f6ff8debecdfb5603802bd27 Mon Sep 17 00:00:00 2001 From: Pasquale Gatto <47112536+PasGat@users.noreply.github.com> Date: Mon, 24 Aug 2020 11:44:34 +0100 Subject: [PATCH 4/4] MIBM-38: upgrade scala test --- project/AppDependencies.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index 36f5ce204..782bb883a 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -13,12 +13,12 @@ object AppDependencies { ) val test = Seq( - "uk.gov.hmrc" %% "bootstrap-test-play-27" % "2.24.0" % Test, - "org.scalatest" %% "scalatest" % "3.1.2" % Test, - "org.jsoup" % "jsoup" % "1.10.2" % Test, - "com.typesafe.play" %% "play-test" % current % Test, - "com.vladsch.flexmark" % "flexmark-all" % "0.35.10" % "test, it", - "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3" % "test, it", - "com.github.tomakehurst" % "wiremock-standalone" % "2.27.1" % Test + "uk.gov.hmrc" %% "bootstrap-test-play-27" % "2.24.0" % Test, + "org.scalatest" %% "scalatest" % "3.2.2" % Test, + "org.jsoup" % "jsoup" % "1.10.2" % Test, + "com.typesafe.play" %% "play-test" % current % Test, + "com.vladsch.flexmark" % "flexmark-all" % "0.35.10" % "test, it", + "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3" % "test, it", + "com.github.tomakehurst" % "wiremock-standalone" % "2.27.1" % Test ) }