From b42ecbb92d4bc2b7fb7e12ce02aefee2512ecaa3 Mon Sep 17 00:00:00 2001 From: martinarmstrong Date: Tue, 9 Aug 2022 16:52:28 +0100 Subject: [PATCH] GG-6516 --- app/connectors/ThirdPartyDelegatedAuthorityConnector.scala | 4 ++-- it/UserInfoServiceISpec.scala | 3 +-- it/stubs/AuthStub.scala | 2 +- it/stubs/ThirdPartyDelegatedAuthorityStub.scala | 7 ++++--- project/ScoverageSettings.scala | 4 ++-- .../ThirdPartyDelegatedAuthorityConnectorSpec.scala | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala b/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala index 8b2953d..36d31ab 100644 --- a/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala +++ b/app/connectors/ThirdPartyDelegatedAuthorityConnector.scala @@ -31,9 +31,9 @@ class ThirdPartyDelegatedAuthorityConnector @Inject() (appContext: AppContext, h val serviceUrl: String = appContext.thirdPartyDelegatedAuthorityUrl def fetchScopes(authBearerToken: String)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Set[String]] = { - http.GET(s"$serviceUrl/delegated-authority", Seq("auth_bearer_token" -> authBearerToken))(readRaw, hc, ec) map { response => + http.GET(s"$serviceUrl/delegated-authority", Nil, Seq("auth-bearer-token" -> authBearerToken))(readRaw, hc, ec) map { response => if (response.status == Status.NOT_FOUND) { - Set.empty + Set[String]() } else { (response.json \ "token" \ "scopes").as[Set[String]] } diff --git a/it/UserInfoServiceISpec.scala b/it/UserInfoServiceISpec.scala index 080183b..ad99919 100644 --- a/it/UserInfoServiceISpec.scala +++ b/it/UserInfoServiceISpec.scala @@ -15,17 +15,16 @@ */ import java.nio.file.Paths - import com.fasterxml.jackson.databind.ObjectMapper import com.github.fge.jsonschema.core.report.LogLevel import com.github.fge.jsonschema.main.JsonSchemaFactory import config.{FeatureSwitch, UserInfoFeatureSwitches} import controllers.Version_1_1 import domain._ -import it.stubs.{AuthStub, ThirdPartyDelegatedAuthorityStub} import org.joda.time.LocalDate import play.api.libs.json.Json import scalaj.http.{Http, HttpOptions} +import stubs.{AuthStub, ThirdPartyDelegatedAuthorityStub} import uk.gov.hmrc.auth.core._ import uk.gov.hmrc.auth.core.retrieve._ import uk.gov.hmrc.domain.Nino diff --git a/it/stubs/AuthStub.scala b/it/stubs/AuthStub.scala index cb8c771..cc2b7ef 100644 --- a/it/stubs/AuthStub.scala +++ b/it/stubs/AuthStub.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package it.stubs +package stubs import com.github.tomakehurst.wiremock.client.WireMock._ import play.api.libs.json._ diff --git a/it/stubs/ThirdPartyDelegatedAuthorityStub.scala b/it/stubs/ThirdPartyDelegatedAuthorityStub.scala index 103e2f4..4f8a097 100644 --- a/it/stubs/ThirdPartyDelegatedAuthorityStub.scala +++ b/it/stubs/ThirdPartyDelegatedAuthorityStub.scala @@ -14,15 +14,16 @@ * limitations under the License. */ -package it.stubs +package stubs import com.github.tomakehurst.wiremock.client.WireMock._ +import com.github.tomakehurst.wiremock.stubbing.StubMapping import play.api.libs.json.Json trait ThirdPartyDelegatedAuthorityStub { - def willReturnScopesForAuthBearerToken(authBearerToken: String, scopes: Set[String]) = { + def willReturnScopesForAuthBearerToken(authBearerToken: String, scopes: Set[String]):StubMapping = { stubFor(get(urlPathEqualTo(s"/delegated-authority")) - .withQueryParam("auth_bearer_token", equalTo(authBearerToken)) + .withHeader("auth-bearer-token", equalTo(authBearerToken)) .willReturn(aResponse().withBody( s""" |{"token": diff --git a/project/ScoverageSettings.scala b/project/ScoverageSettings.scala index dd5417e..e5f5a34 100644 --- a/project/ScoverageSettings.scala +++ b/project/ScoverageSettings.scala @@ -21,9 +21,9 @@ object ScoverageSettings { ".*DateTimeQueryStringBinder.*", // better covered via wiremock/E2E integration tests ".*Test.*" ).mkString(";"), - ScoverageKeys.coverageMinimum := 78, + ScoverageKeys.coverageMinimumStmtTotal := 78, ScoverageKeys.coverageFailOnMinimum := true, ScoverageKeys.coverageHighlighting := true, - parallelExecution in Test := false + Test / parallelExecution := false ) } diff --git a/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala b/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala index e819503..102e906 100644 --- a/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala +++ b/test/connectors/ThirdPartyDelegatedAuthorityConnectorSpec.scala @@ -62,7 +62,7 @@ class ThirdPartyDelegatedAuthorityConnectorSpec extends UnitSpec with MockitoSug "return the scopes of the delegated authority" in new Setup { val authBearerToken = "AUTH_TOKEN" - stubFor(get(urlPathMatching(s"/delegated-authority")).withQueryParam("auth_bearer_token", equalTo(authBearerToken)). + stubFor(get(urlPathMatching(s"/delegated-authority")).withHeader("auth-bearer-token", equalTo(authBearerToken)). willReturn( aResponse() .withStatus(200) @@ -83,7 +83,7 @@ class ThirdPartyDelegatedAuthorityConnectorSpec extends UnitSpec with MockitoSug "return an empty set when delegated authority is not found" in new Setup { val authBearerToken = "AUTH_TOKEN" - stubFor(get(urlPathMatching(s"/delegated-authority")).withQueryParam("auth_bearer_token", equalTo(authBearerToken)). + stubFor(get(urlPathMatching(s"/delegated-authority")).withHeader("auth-bearer-token", equalTo(authBearerToken)). willReturn(aResponse().withStatus(404))) val scopes: Set[String] = await(connector.fetchScopes(authBearerToken))