diff --git a/app/config/APIAccessConfig.scala b/app/config/APIAccessConfig.scala index 8aa71e5..a2367df 100644 --- a/app/config/APIAccessConfig.scala +++ b/app/config/APIAccessConfig.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/config/AppContext.scala b/app/config/AppContext.scala index 854e5ac..140678c 100644 --- a/app/config/AppContext.scala +++ b/app/config/AppContext.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,13 @@ package config -import javax.inject.{Inject, Singleton} import com.typesafe.config.ConfigObject -import play.api.Mode -import play.api.{Configuration, Environment} -import uk.gov.hmrc.play.bootstrap.config.{RunMode, ServicesConfig} +import javax.inject.{Inject, Singleton} +import play.api.{Configuration, Environment, Mode} +import uk.gov.hmrc.play.bootstrap.config.ServicesConfig @Singleton -class AppContext @Inject() (val runModeConfiguration: Configuration, environment: Environment, runMode: RunMode) extends ServicesConfig(runModeConfiguration, runMode) { +class AppContext @Inject() (val runModeConfiguration: Configuration, environment: Environment) extends ServicesConfig(runModeConfiguration) { protected def mode: Mode = environment.mode lazy val appName: String = runModeConfiguration.get[String]("appName") @@ -31,7 +30,7 @@ class AppContext @Inject() (val runModeConfiguration: Configuration, environment lazy val authUrl: String = baseUrl("auth") lazy val thirdPartyDelegatedAuthorityUrl: String = baseUrl("third-party-delegated-authority") lazy val access: Option[ConfigObject] = runModeConfiguration.getOptional[ConfigObject]("api.access.version") - lazy val desEnvironment: String = runModeConfiguration.get[String](s"$runMode.env.microservice.services.des.environment") - lazy val desBearerToken: String = runModeConfiguration.get[String](s"$runMode.env.microservice.services.des.bearer-token") + lazy val desEnvironment: String = runModeConfiguration.get[String](s"microservice.services.des.environment") + lazy val desBearerToken: String = runModeConfiguration.get[String](s"microservice.services.des.bearer-token") lazy val logUserInfoResponsePayload: Boolean = runModeConfiguration.underlying.getBoolean("log-user-info-response-payload") } diff --git a/app/config/FeatureSwitch.scala b/app/config/FeatureSwitch.scala index a94787b..0ae595e 100644 --- a/app/config/FeatureSwitch.scala +++ b/app/config/FeatureSwitch.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/config/GuiceModule.scala b/app/config/GuiceModule.scala index 04fee74..5e861aa 100644 --- a/app/config/GuiceModule.scala +++ b/app/config/GuiceModule.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/AuthConnector.scala b/app/connectors/AuthConnector.scala index 779a0f1..82024f5 100644 --- a/app/connectors/AuthConnector.scala +++ b/app/connectors/AuthConnector.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/AuthV1UserDetailsFetcher.scala b/app/connectors/AuthV1UserDetailsFetcher.scala index f470dbc..234de5c 100644 --- a/app/connectors/AuthV1UserDetailsFetcher.scala +++ b/app/connectors/AuthV1UserDetailsFetcher.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/AuthV2UserDetailsFetcher.scala b/app/connectors/AuthV2UserDetailsFetcher.scala index e68dad3..618f242 100644 --- a/app/connectors/AuthV2UserDetailsFetcher.scala +++ b/app/connectors/AuthV2UserDetailsFetcher.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala b/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala index 02a8164..6b78e23 100644 --- a/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala +++ b/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/connectors/UserDetailsFetcher.scala b/app/connectors/UserDetailsFetcher.scala index 43bf5dc..76ca246 100644 --- a/app/connectors/UserDetailsFetcher.scala +++ b/app/connectors/UserDetailsFetcher.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/DocumentationController.scala b/app/controllers/DocumentationController.scala index 3169df5..beedb54 100644 --- a/app/controllers/DocumentationController.scala +++ b/app/controllers/DocumentationController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/ErrorResponses.scala b/app/controllers/ErrorResponses.scala index 0763c5f..dcfb9fb 100644 --- a/app/controllers/ErrorResponses.scala +++ b/app/controllers/ErrorResponses.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/UserInfoController.scala b/app/controllers/UserInfoController.scala index f29dc1f..3ba543d 100644 --- a/app/controllers/UserInfoController.scala +++ b/app/controllers/UserInfoController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,16 @@ package controllers -import javax.inject.{Inject, Singleton} import com.google.inject.name.Named +import config.AppContext +import javax.inject.{Inject, Singleton} import play.api.Logger import play.api.libs.json.Json import play.api.mvc.{AnyContent, BodyParser, ControllerComponents} +import services.UserInfoService import uk.gov.hmrc.api.controllers.HeaderValidator import uk.gov.hmrc.http.{BadRequestException, Upstream4xxResponse, Upstream5xxResponse} -import config.AppContext -import services.{LiveUserInfoService, SandboxUserInfoService, UserInfoService} -import uk.gov.hmrc.play.bootstrap.controller.BackendBaseController +import uk.gov.hmrc.play.bootstrap.backend.controller.BackendBaseController import scala.concurrent.ExecutionContext diff --git a/app/controllers/package.scala b/app/controllers/package.scala index 29cd255..1fe8f40 100644 --- a/app/controllers/package.scala +++ b/app/controllers/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/controllers/testOnly/FeatureSwitchController.scala b/app/controllers/testOnly/FeatureSwitchController.scala index 6ab05d1..e0a3b69 100644 --- a/app/controllers/testOnly/FeatureSwitchController.scala +++ b/app/controllers/testOnly/FeatureSwitchController.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import javax.inject.{Inject, Singleton} import play.api.libs.json.Json import play.api.mvc.{Action, ControllerComponents} import config.{FeatureSwitch, UserInfoFeatureSwitches} -import uk.gov.hmrc.play.bootstrap.controller.BackendController +import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future diff --git a/app/data/UserInfoGenerator.scala b/app/data/UserInfoGenerator.scala index 3ff79b4..7bdf5c9 100644 --- a/app/data/UserInfoGenerator.scala +++ b/app/data/UserInfoGenerator.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/APIDefinition.scala b/app/domain/APIDefinition.scala index 9c68d62..32cf255 100644 --- a/app/domain/APIDefinition.scala +++ b/app/domain/APIDefinition.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/Authority.scala b/app/domain/Authority.scala index 0e564ca..fb8723c 100644 --- a/app/domain/Authority.scala +++ b/app/domain/Authority.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/Enrolment.scala b/app/domain/Enrolment.scala index 13b0f50..aac996f 100644 --- a/app/domain/Enrolment.scala +++ b/app/domain/Enrolment.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/GovernmentGatewayDetails.scala b/app/domain/GovernmentGatewayDetails.scala index 68eda0a..639b0b7 100644 --- a/app/domain/GovernmentGatewayDetails.scala +++ b/app/domain/GovernmentGatewayDetails.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/NinoNotFoundException.scala b/app/domain/NinoNotFoundException.scala index 1a8be7e..b7b4afb 100644 --- a/app/domain/NinoNotFoundException.scala +++ b/app/domain/NinoNotFoundException.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/UserDetails.scala b/app/domain/UserDetails.scala index 4511951..599db85 100644 --- a/app/domain/UserDetails.scala +++ b/app/domain/UserDetails.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/UserInfo.scala b/app/domain/UserInfo.scala index 03a5d91..d3cba69 100644 --- a/app/domain/UserInfo.scala +++ b/app/domain/UserInfo.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/domain/package.scala b/app/domain/package.scala index fe3876d..36db9f9 100644 --- a/app/domain/package.scala +++ b/app/domain/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import org.joda.time._ import play.api.libs.json._ import uk.gov.hmrc.auth.core.retrieve.{GatewayInformation, ItmpAddress, ItmpName, MdtpInformation} import uk.gov.hmrc.auth.core.{Enrolment, EnrolmentIdentifier} -import uk.gov.hmrc.http.Token package object domain { implicit val dFormat: Format[LocalDate] = new Format[LocalDate] { @@ -33,7 +32,6 @@ package object domain { implicit val enrolmentIdentifier = Json.format[EnrolmentIdentifier] implicit val enrloment = Json.format[Enrolment] - implicit val token = Json.format[Token] implicit val gatewayInformationFmt: Format[GatewayInformation] = Json.format[GatewayInformation] implicit val mdtpInformationFmt: Format[MdtpInformation] = Json.format[MdtpInformation] implicit val userDetails = Json.format[UserDetails] diff --git a/app/filters/MicroserviceAuthFilter.scala b/app/filters/MicroserviceAuthFilter.scala index d19027c..4b0da29 100644 --- a/app/filters/MicroserviceAuthFilter.scala +++ b/app/filters/MicroserviceAuthFilter.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/filters/MicroserviceFilters.scala b/app/filters/MicroserviceFilters.scala index ff44839..5d4a5b7 100644 --- a/app/filters/MicroserviceFilters.scala +++ b/app/filters/MicroserviceFilters.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/handlers/ErrorHandler.scala b/app/handlers/ErrorHandler.scala index be2c54f..6289d71 100644 --- a/app/handlers/ErrorHandler.scala +++ b/app/handlers/ErrorHandler.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/services/UserInfoService.scala b/app/services/UserInfoService.scala index 97cd115..1390e0f 100644 --- a/app/services/UserInfoService.scala +++ b/app/services/UserInfoService.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/app/services/UserInfoTransformer.scala b/app/services/UserInfoTransformer.scala index edc343e..aeae4b8 100644 --- a/app/services/UserInfoTransformer.scala +++ b/app/services/UserInfoTransformer.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/conf/application.conf b/conf/application.conf index 462b581..06fc809 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -1,4 +1,4 @@ -# Copyright 2020 HM Revenue & Customs +# Copyright 2021 HM Revenue & Customs # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # ~~~~~ include "backend.conf" -appName=openid-connect-userinfo +appName = openid-connect-userinfo # Provides an implementation of AuditConnector. Use `uk.gov.hmrc.play.bootstrap.AuditModule` or create your own. # An audit connector must be provided. @@ -38,7 +38,7 @@ play.application.loader = "uk.gov.hmrc.play.bootstrap.ApplicationLoader" play.http.errorHandler = "handlers.ErrorHandler" -appUrl="https://"${appName}".protected.mdtp" +appUrl = "https://"${appName}".protected.mdtp" # Session Timeout # ~~~~ @@ -50,11 +50,11 @@ appUrl="https://"${appName}".protected.mdtp" # Session configuration # ~~~~~ -play.http.session.httpOnly=false +play.http.session.httpOnly = false # The application languages # ~~~~~ -play.i18n.langs=["en"] +play.i18n.langs = ["en"] # Router # ~~~~~ @@ -66,10 +66,10 @@ play.i18n.langs=["en"] # you may need to define a router file `conf/my.application.routes`. # Default to Routes in the root package (and conf/routes) # !!!WARNING!!! DO NOT CHANGE THIS ROUTER -play.http.router=prod.Routes +play.http.router = prod.Routes # DES API endpoint -des.individual.endpoint=/pay-as-you-earn/02.00.00/individuals/ +des.individual.endpoint = /pay-as-you-earn/02.00.00/individuals/ # Controller # ~~~~~ @@ -78,57 +78,57 @@ des.individual.endpoint=/pay-as-you-earn/02.00.00/individuals/ # The below controllers are the default exceptions to this rule. controllers { - confidenceLevel = 50 - - com.kenshoo.play.metrics.MetricsController = { - needsAuth = false - needsLogging = false - needsAuditing = false - } - - controllers.DocumentationController = { - needsAuth = false - needsLogging = true - needsAuditing = false - } - - controllers.LiveUserInfoController = { - needsAuth = true - needsLogging = true - needsAuditing = false - authParams.pattern = "/([\\d\\w-]+).*" - } - - controllers.SandboxUserInfoController = { - needsAuth = false - needsLogging = true - needsAuditing = false - } - - controllers.testOnly.FeatureSwitchController = { - needsAuth = false - needsLogging = true - needsAuditing = false - } + confidenceLevel = 50 + + com.kenshoo.play.metrics.MetricsController = { + needsAuth = false + needsLogging = false + needsAuditing = false + } + + controllers.DocumentationController = { + needsAuth = false + needsLogging = true + needsAuditing = false + } + + controllers.LiveUserInfoController = { + needsAuth = true + needsLogging = true + needsAuditing = false + authParams.pattern = "/([\\d\\w-]+).*" + } + + controllers.SandboxUserInfoController = { + needsAuth = false + needsLogging = true + needsAuditing = false + } + + controllers.testOnly.FeatureSwitchController = { + needsAuth = false + needsLogging = true + needsAuditing = false + } } # Root logger: -logger.root=ERROR +logger.root = ERROR # Logger used by the framework: -logger.play=INFO +logger.play = INFO # Logger provided to your application: -logger.application=DEBUG +logger.application = DEBUG # Metrics plugin settings - graphite reporting is configured on a per env basis metrics { - name = ${appName} - rateUnit = SECONDS - durationUnit = SECONDS - showSamples = true - jvm = true - enabled = true + name = ${appName} + rateUnit = SECONDS + durationUnit = SECONDS + showSamples = true + jvm = true + enabled = true } # Microservice specific config @@ -137,213 +137,87 @@ wiremock-port = 6008 wiremock-port = ${?WIREMOCK_PORT} api.access.version { - 1_0 { - type = PRIVATE - status = STABLE - white-list { - applicationIds.0 = 649def0f-3ed3-4df5-8ae1-3e687a9143ea - applicationIds.1 = df8c10db-01fb-4543-b77e-859267462231 - applicationIds.2 = 9a32c713-7741-4aae-b39d-957021fb97a9 - } - endpointsEnabled = true - } - 1_1 { - type = PRIVATE - status = BETA - white-list { - applicationIds.0 = 649def0f-3ed3-4df5-8ae1-3e687a9143ea - } - endpointsEnabled = false - } + 1_0 { + type = PRIVATE + status = STABLE + white-list { + applicationIds.0 = 649def0f-3ed3-4df5-8ae1-3e687a9143ea + applicationIds.1 = df8c10db-01fb-4543-b77e-859267462231 + applicationIds.2 = 9a32c713-7741-4aae-b39d-957021fb97a9 + } + endpointsEnabled = true + } + 1_1 { + type = PRIVATE + status = BETA + white-list { + applicationIds.0 = 649def0f-3ed3-4df5-8ae1-3e687a9143ea + } + endpointsEnabled = false + } } -Test { - - api.access { - type = PRIVATE - white-list.applicationIds = [] - } - auditing { - enabled=true - traceRequests=false +api.access { + type = PRIVATE + white-list.applicationIds = [] +} - consumer { - baseUri { - host = localhost - port = ${wiremock-port} - } - } - } +auditing { + enabled = false + traceRequests = false - microservice { - metrics { - graphite { - host = graphite - port = 2003 - prefix = play.${appName}. - enabled = true - } - } - - services { - - auth { - host=localhost - port=${wiremock-port} - } - - datastream { - host=localhost - port=${wiremock-port} - } - - des { - host=localhost - port=22222 - bearer-token = "local" - environment = "local" - } - - third-party-delegated-authority { - host=localhost - port=${wiremock-port} - } - - user-details { - host=localhost - port=22224 - } - } + consumer { + baseUri { + host = localhost + port = 8100 } + } } -Dev { - - api.access { - type = PRIVATE - white-list.applicationIds = [] +microservice { + metrics { + graphite { + host = graphite + port = 2003 + prefix = play.${appName}. + enabled = false } + } - auditing { - enabled=true - traceRequests=false + services { - consumer { - baseUri { - host = localhost - port = 8100 - } - } + auth { + host = localhost + port = 8500 } - microservice { - metrics { - graphite { - host = graphite - port = 2003 - prefix = play.${appName}. - enabled = true - } - } - - services { - - auth { - host=localhost - port=8500 - } - - datastream { - host=localhost - port=8100 - } - - des { - host=localhost - port=9625 - bearer-token = "local" - environment = "local" - } - - third-party-delegated-authority { - host=localhost - port=9609 - } - - user-details { - host=localhost - port=9978 - } - } + datastream { + host = localhost + port = 8100 } -} - -Prod { - api.access { - type = PUBLIC - white-list.applicationIds = [] + des { + host = localhost + port = 9625 + bearer-token = "local" + environment = "local" } - auditing { - enabled=true - traceRequests=true - consumer { - baseUri { - host = datastream.protected.mdtp - port = 443 - protocol = https - } - } + third-party-delegated-authority { + host = localhost + port = 9609 } - microservice { - metrics { - graphite { - host = graphite - port = 2003 - prefix = play.${appName}. - enabled = true - } - } - - services { - - auth { - host = auth.protected.mdtp - port = 443 - protocol = https - } - - datastream { - host = datastream.protected.mdtp - port = 443 - protocol = https - } - - des { - host = hods-proxy - port = 443 - protocol = https - bearer-token = "TO_DEFINE" - environment = "live" - } - - third-party-delegated-authority { - host = localhost - port = 9609 - } - - user-details { - host = user-details.protected.mdtp - port = 443 - protocol = https - } - } + user-details { + host = localhost + port = 9978 } + } } + + log-user-info-response-payload = false http-verbs.retries.ssl-engine-closed-already.enabled = true diff --git a/it/BaseFeatureISpec.scala b/it/BaseFeatureISpec.scala index ec9df8b..8330c4e 100644 --- a/it/BaseFeatureISpec.scala +++ b/it/BaseFeatureISpec.scala @@ -2,28 +2,52 @@ import com.github.tomakehurst.wiremock.WireMockServer import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.client.WireMock.{aResponse, post, stubFor, urlPathMatching} import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig +import com.typesafe.config.{Config, ConfigFactory} import org.scalatest._ +import org.scalatestplus.play.guice.GuiceOneServerPerSuite +import play.api.Application +import play.api.inject.guice.GuiceApplicationBuilder import uk.gov.hmrc.integration.ServiceSpec -import scala.concurrent.duration.{Duration,_} +import scala.concurrent.duration.{Duration, _} import scala.concurrent.{Await, Future} +import scala.collection.JavaConverters._ + +import scala.util.Try trait BaseFeatureISpec extends FeatureSpec with GivenWhenThen with Matchers - with ServiceSpec + with GuiceOneServerPerSuite with BeforeAndAfterEach with BeforeAndAfterAll { implicit val timeout: Duration = 1.minutes + override def fakeApplication(): Application = GuiceApplicationBuilder().configure( + flatStructurePortMapping() + ++ extraConfig + ).build() + + protected def resource(resource: String) = s"http://localhost:$port$resource" + def await[A](future: Future[A])(implicit timeout: Duration): A = Await.result(future, timeout) - override val externalServices: Seq[Nothing] = Seq.empty + private def flatStructurePortMapping(): Map[String, Int] = { + lazy val config: Config = ConfigFactory.load() + Try(config.getConfig("microservice.services")) + .getOrElse(ConfigFactory.empty()) + .entrySet() + .asScala + .collect { + case e if e.getKey.endsWith("port") => + "microservice.services." + e.getKey -> stubPort + }.toMap + + } - override lazy val additionalConfig: Map[String, Any] = - Map[String, Any]( + def extraConfig: Map[String, Any] = Map[String, Any]( "run.mode" -> "Test", "application.router" -> "testOnlyDoNotUseInAppConf.Routes" ) diff --git a/it/UserInfoServiceISpec.scala b/it/UserInfoServiceISpec.scala index ea5ccfa..550f56f 100644 --- a/it/UserInfoServiceISpec.scala +++ b/it/UserInfoServiceISpec.scala @@ -170,6 +170,7 @@ class UserInfoServiceISpec extends BaseFeatureISpec with AuthStub with ThirdPart val report = validator.validate(schema, mapper.readTree(json.toString())) Then("The user information is returned") + println(result.body) result.code shouldBe 200 import scala.collection.JavaConverters._ diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index e5808ee..86ba937 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -8,10 +8,10 @@ object AppDependencies { val compile: Seq[ModuleID] = Seq( ws, - "uk.gov.hmrc" %% "bootstrap-play-26" % "1.16.0", - "uk.gov.hmrc" %% "play-hmrc-api" % "4.1.0-play-26", - "uk.gov.hmrc" %% "domain" % "5.10.0-play-26", - "com.typesafe.play" %% "play-json-joda" % "2.6.14" + "uk.gov.hmrc" %% "bootstrap-backend-play-27" % "3.2.0", + "uk.gov.hmrc" %% "domain" % "5.10.0-play-27", + "uk.gov.hmrc" %% "play-hmrc-api" % "5.3.0-play-27", + "com.typesafe.play" %% "play-json-joda" % "2.7.4" ) val test: Seq[ModuleID] = Seq( @@ -19,7 +19,7 @@ object AppDependencies { "org.scalacheck" %% "scalacheck" % "1.13.5", "com.github.tomakehurst" % "wiremock-jre8" % "2.24.1" % testScope, "uk.gov.hmrc" %% "service-integration-test" % "0.12.0-play-26" % testScope, - "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % testScope, + "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.3" % testScope, "org.scoverage" %% "scalac-scoverage-plugin" % "1.3.1" % testScope, "org.pegdown" % "pegdown" % "1.6.0" % testScope, "org.jsoup" % "jsoup" % "1.10.3" % testScope, diff --git a/project/plugins.sbt b/project/plugins.sbt index f43ca89..f0cd193 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,7 +4,7 @@ resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/ addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.0.0") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.25") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.5") addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "2.9.0") diff --git a/test/config/APIAccessConfigSpec.scala b/test/config/APIAccessConfigSpec.scala index 2678e89..0d1a346 100644 --- a/test/config/APIAccessConfigSpec.scala +++ b/test/config/APIAccessConfigSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala b/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala index 2aa609a..7a08f34 100644 --- a/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala +++ b/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,11 @@ import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.client.WireMock._ import com.github.tomakehurst.wiremock.core.WireMockConfiguration._ import org.scalatest.BeforeAndAfterEach -import org.scalatest.mockito.MockitoSugar import org.mockito.Mockito._ import org.scalatestplus.play.guice.GuiceOneAppPerSuite import config.AppContext -import uk.gov.hmrc.http.HeaderCarrier -import uk.gov.hmrc.play.bootstrap.http.HttpClient +import org.scalatestplus.mockito.MockitoSugar +import uk.gov.hmrc.http.{HeaderCarrier, HttpClient} import scala.concurrent.ExecutionContext.Implicits.global import testSupport.UnitSpec diff --git a/test/controllers/ErrorResponseSpec.scala b/test/controllers/ErrorResponseSpec.scala index e75662c..15d64a9 100644 --- a/test/controllers/ErrorResponseSpec.scala +++ b/test/controllers/ErrorResponseSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test/controllers/UserInfoControllerSpec.scala b/test/controllers/UserInfoControllerSpec.scala index 0417677..bc81762 100644 --- a/test/controllers/UserInfoControllerSpec.scala +++ b/test/controllers/UserInfoControllerSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,23 +18,23 @@ package controllers import akka.actor.ActorSystem import akka.stream.ActorMaterializer +import config.AppContext +import domain.{Address, GovernmentGatewayDetails, UserInfo} import org.joda.time.LocalDate import org.mockito.BDDMockito.given import org.mockito.Matchers import org.mockito.Matchers.{any, eq => eqTo} import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import play.api.libs.json.Json import play.api.mvc.ControllerComponents import play.api.test.FakeRequest +import services.{LiveUserInfoService, SandboxUserInfoService} +import testSupport.UnitSpec import uk.gov.hmrc.auth.core.{Enrolment, EnrolmentIdentifier} import uk.gov.hmrc.http.{BadRequestException, HeaderCarrier} -import config.AppContext -import domain.{Address, GovernmentGatewayDetails, UserInfo} -import services.{LiveUserInfoService, SandboxUserInfoService} import scala.concurrent.{ExecutionContext, Future} -import testSupport.UnitSpec class UserInfoControllerSpec(implicit val cc: ControllerComponents, ex: ExecutionContext) extends UnitSpec with MockitoSugar with ScalaFutures { diff --git a/test/controllers/testOnly/FeatureSwitchControllerSpec.scala b/test/controllers/testOnly/FeatureSwitchControllerSpec.scala index dabd8c3..8a891f2 100644 --- a/test/controllers/testOnly/FeatureSwitchControllerSpec.scala +++ b/test/controllers/testOnly/FeatureSwitchControllerSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/test/data/UserInfoGeneratorSpec.scala b/test/data/UserInfoGeneratorSpec.scala index 064dd26..4bc7968 100644 --- a/test/data/UserInfoGeneratorSpec.scala +++ b/test/data/UserInfoGeneratorSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +18,12 @@ package data import org.joda.time.LocalDate import org.scalatest.BeforeAndAfterEach -import org.scalatest.prop.PropertyChecks import config.{FeatureSwitch, UserInfoFeatureSwitches} import domain.UserInfo +import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import testSupport.UnitSpec -class UserInfoGeneratorSpec extends UnitSpec with PropertyChecks with BeforeAndAfterEach { +class UserInfoGeneratorSpec extends UnitSpec with ScalaCheckPropertyChecks with BeforeAndAfterEach { val ninoPattern = "^[A-CEGHJ-NOPR-TW-Z]{2}[0-9]{6}[ABCD\\s]{1}$".r val from = new LocalDate(1939, 12, 27) val until = new LocalDate(1998, 12, 29) diff --git a/test/services/UserInfoServiceSpec.scala b/test/services/UserInfoServiceSpec.scala index 25753be..b63d4f4 100644 --- a/test/services/UserInfoServiceSpec.scala +++ b/test/services/UserInfoServiceSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,24 +16,25 @@ package services +import connectors.{AuthConnector, AuthConnectorV1, ThirdPartyDelegatedAuthorityConnector} +import controllers.{Version_1_0, Version_1_1} +import data.UserInfoGenerator +import domain._ import org.mockito.BDDMockito._ import org.mockito.Matchers.{any, eq => eqTo} import org.mockito.Mockito.{never, verify, when} import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar +import org.mockito.Mockito._ +import org.scalatestplus.mockito.MockitoSugar +import testSupport.UnitSpec import uk.gov.hmrc.auth.core.retrieve.{ItmpAddress, ItmpName} import uk.gov.hmrc.auth.core.{Enrolment, EnrolmentIdentifier, Enrolments} import uk.gov.hmrc.domain.Nino import uk.gov.hmrc.http.logging.Authorization -import uk.gov.hmrc.http.{BadRequestException, HeaderCarrier, Token} -import connectors.{AuthConnector, AuthConnectorV1, ThirdPartyDelegatedAuthorityConnector} -import controllers.{Version_1_0, Version_1_1} -import data.UserInfoGenerator -import domain._ +import uk.gov.hmrc.http.{BadRequestException, HeaderCarrier} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.{ExecutionContext, Future} -import testSupport.UnitSpec class UserInfoServiceSpec extends UnitSpec with MockitoSugar with ScalaFutures { @@ -50,8 +51,6 @@ class UserInfoServiceSpec extends UnitSpec with MockitoSugar with ScalaFutures { Some("affinityGroup"), Some("agent-code-12345"), Some("agent-id-12345"), Some("agent-friendly-name"), Some("gateway-token-val"), Some(11), None, None) val mdtp = Mdtp("device-id-12", "session-id-133") - val ggToken = Token("ggToken") - val userInfo = UserInfo(Some("John"), Some("Smith"), None, Some(Address("1 Station Road\nTown Centre", None, None, None)), None, None, Some(nino).map(_.nino), Some(enrolments.enrolments), Some(governmentGateway), Some(mdtp)) diff --git a/test/services/UserInfoTransformerSpec.scala b/test/services/UserInfoTransformerSpec.scala index 2ac626e..547a50d 100644 --- a/test/services/UserInfoTransformerSpec.scala +++ b/test/services/UserInfoTransformerSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,18 +16,18 @@ package services +import config.{FeatureSwitch, UserInfoFeatureSwitches} +import domain._ import org.joda.time.LocalDate import org.scalatest.BeforeAndAfterEach -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar +import testSupport.UnitSpec import uk.gov.hmrc.auth.core.retrieve.{GatewayInformation, ItmpAddress, ItmpName, MdtpInformation} import uk.gov.hmrc.auth.core.{Enrolment, EnrolmentIdentifier, Enrolments} import uk.gov.hmrc.domain.Nino -import uk.gov.hmrc.http.{HeaderCarrier, Token} -import config.{FeatureSwitch, UserInfoFeatureSwitches} -import domain._ +import uk.gov.hmrc.http.HeaderCarrier import scala.concurrent.ExecutionContext.Implicits.global -import testSupport.UnitSpec class UserInfoTransformerSpec extends UnitSpec with MockitoSugar with BeforeAndAfterEach { @@ -51,8 +51,6 @@ class UserInfoTransformerSpec extends UnitSpec with MockitoSugar with BeforeAndA unreadMessageCount = Some(10), profile = None, groupProfile = None ) - val ggToken = Token("ggToken") - val government_gateway: GovernmentGatewayDetails = GovernmentGatewayDetails(Some("1304372065861347"), Some(Seq("User")), Some("John"), Some("affinityGroup"), userDetails.agentCode, agent_id = userDetails.agentId, agent_friendly_name = userDetails.agentFriendlyName, gateway_token = Some("gateway-token-abc"), unread_message_count = Some(10), profile_uri = None, group_profile_uri = None) diff --git a/test/testSupport/UnitSpec.scala b/test/testSupport/UnitSpec.scala index 0862bb8..ed1d4aa 100644 --- a/test/testSupport/UnitSpec.scala +++ b/test/testSupport/UnitSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2020 HM Revenue & Customs + * Copyright 2021 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.