Skip to content

Commit

Permalink
Merge pull request #106 from hmrc/GG-7473
Browse files Browse the repository at this point in the history
GG-7473 - Fix service configuration warnings - batch 4
  • Loading branch information
AadilAkhtar authored Feb 1, 2024
2 parents 90254a5 + a57f125 commit a92bd24
Show file tree
Hide file tree
Showing 56 changed files with 190 additions and 200 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ User details data structures follow the OpenId Connect UserInfo specification (s

You can dive deeper into the documentation in the [API Developer Hub](https://developer.service.hmrc.gov.uk/api-documentation/docs/api#openid-connect-userinfo).

## Deprecated Class Usage
You can find the deprecation suppression `@nowarn("cat=deprecation")` in the code in few places.

The reason is that when the latest `v2.Retrievals` was used then the integration tests were broken and wasn't obvious why.

## Running Locally
Run the service `sbt run -Drun.mode=Dev`

Run the tests & test coverage report `sbt clean compile coverage test it:test coverageReport`
Run the tests & test coverage report `sbt clean coverage test it/test coverageReport`

Run the service in service manager; if you want live endpoints, then start dependencies thus: `sm2 --start AUTH DATASTREAM -r`

Expand Down
2 changes: 1 addition & 1 deletion app/config/APIAccessConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/AppContext.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/config/FeatureSwitch.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
5 changes: 4 additions & 1 deletion app/config/GuiceModule.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -26,6 +26,8 @@ import services.{LiveUserInfoService, SandboxUserInfoService, UserInfoService}
import uk.gov.hmrc.play.bootstrap.http.DefaultHttpClient
import uk.gov.hmrc.play.bootstrap.config.ControllerConfig

import scala.annotation.unused

class GuiceModule(val environment: Environment, val configuration: Configuration) extends AbstractModule {
override def configure() = {
bind(classOf[AuthConnector]).to(classOf[AuthConnectorV1])
Expand All @@ -36,6 +38,7 @@ class GuiceModule(val environment: Environment, val configuration: Configuration
bind(classOf[HttpGet]).to(classOf[DefaultHttpClient])
bind(classOf[ControllerConfig]).toInstance {
new ControllerConfig {
@unused
def controllerConfigs: Config = configuration.underlying.getConfig("controllers")
}
}
Expand Down
17 changes: 9 additions & 8 deletions app/connectors/AuthConnector.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -17,17 +17,18 @@
package connectors

import javax.inject.{Inject, Singleton}

import com.github.ghik.silencer.silent
import uk.gov.hmrc.auth.core.retrieve.{Retrievals, ~}
import uk.gov.hmrc.auth.core.retrieve.Retrievals
import uk.gov.hmrc.auth.core.retrieve.~
import uk.gov.hmrc.auth.core.{AuthorisedFunctions, Enrolments, PlayAuthConnector}
import uk.gov.hmrc.http.{CorePost, HeaderCarrier, NotFoundException}
import domain.{Authority, DesUserInfo, UserDetails}
import config.AppContext

import scala.annotation.nowarn
import scala.concurrent.{ExecutionContext, Future}

@silent abstract class AuthConnector extends PlayAuthConnector with AuthorisedFunctions {
@nowarn("cat=deprecation")
abstract class AuthConnector extends PlayAuthConnector with AuthorisedFunctions {
self: UserDetailsFetcher =>

val appContext: AppContext
Expand All @@ -41,7 +42,7 @@ import scala.concurrent.{ExecutionContext, Future}
.retrieve(Retrievals.allEnrolments) { enrolments =>
Future.successful(Some(enrolments))
}
.recover { case e: NotFoundException =>
.recover { case _: NotFoundException =>
None
}
}
Expand All @@ -52,7 +53,7 @@ import scala.concurrent.{ExecutionContext, Future}
case credentials ~ nino => Future.successful(Some(Authority(credentials.providerId, nino)))
case _ => Future.successful(None)
}
.recover { case e: NotFoundException =>
.recover { case _: NotFoundException =>
None
}
}
Expand All @@ -67,7 +68,7 @@ import scala.concurrent.{ExecutionContext, Future}
Future.successful(Some(DesUserInfo(name, dateOfBirth, address)))
case _ => nothing
}
.recoverWith { case ex: NotFoundException =>
.recoverWith { case _: NotFoundException =>
nothing
}
}
Expand Down
12 changes: 7 additions & 5 deletions app/connectors/AuthV1UserDetailsFetcher.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -16,15 +16,17 @@

package connectors

import com.github.ghik.silencer.silent
import uk.gov.hmrc.auth.core.AuthorisedFunctions
import uk.gov.hmrc.auth.core.retrieve.{Retrievals, ~}
import uk.gov.hmrc.auth.core.retrieve.Retrievals
import uk.gov.hmrc.auth.core.retrieve.~
import uk.gov.hmrc.http.{HeaderCarrier, NotFoundException}
import domain.UserDetails

import scala.annotation.nowarn
import scala.concurrent.{ExecutionContext, Future}

@silent trait AuthV1UserDetailsFetcher extends UserDetailsFetcher {
@nowarn("cat=deprecation")
trait AuthV1UserDetailsFetcher extends UserDetailsFetcher {
self: AuthorisedFunctions =>

def fetchDetails()(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Option[UserDetails]] = {
Expand Down Expand Up @@ -58,7 +60,7 @@ import scala.concurrent.{ExecutionContext, Future}
)
case _ => Future.successful(None)
}
.recover { case e: NotFoundException =>
.recover { case _: NotFoundException =>
None
}
}
Expand Down
12 changes: 5 additions & 7 deletions app/connectors/ThirdPartyDelegatedAuthorityConnector.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -16,15 +16,13 @@

package connectors

import javax.inject.{Inject, Singleton}
import play.api.http.Status

import scala.concurrent.{ExecutionContext, Future}
import uk.gov.hmrc.http.{HeaderCarrier, HttpGet, HttpResponse, NotFoundException}
import config.AppContext
import play.api.http.Status
import uk.gov.hmrc.http.HttpReads.Implicits.readRaw
import uk.gov.hmrc.http.{HeaderCarrier, HttpGet}

import scala.util.control.NonFatal
import javax.inject.{Inject, Singleton}
import scala.concurrent.{ExecutionContext, Future}

@Singleton
class ThirdPartyDelegatedAuthorityConnector @Inject() (appContext: AppContext, http: HttpGet) {
Expand Down
2 changes: 1 addition & 1 deletion app/connectors/UserDetailsFetcher.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/DocumentationController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -22,8 +22,6 @@ import play.api.mvc.{Action, AnyContent, ControllerComponents}
import config.{APIAccessVersions, AppContext}
import views._

import scala.language.dynamics

@Singleton
class DocumentationController @Inject() (errorHandler: HttpErrorHandler, appContext: AppContext, assets: Assets, cc: ControllerComponents)
extends uk.gov.hmrc.api.controllers.DocumentationController(cc, assets, errorHandler) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ErrorResponses.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/UserInfoController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
20 changes: 9 additions & 11 deletions app/controllers/package.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -14,18 +14,16 @@
* limitations under the License.
*/

import play.api.libs.json.{JsValue, Json, Writes}
import play.api.libs.json.{Json, Writes}

package object controllers {

def errorWrites[T <: ErrorResponse] = new Writes[T] {
override def writes(o: T): JsValue = Json.obj("code" -> o.errorCode, "message" -> o.message)
}
private def errorWrites[T <: ErrorResponse]: Writes[T] = (o: T) => Json.obj("code" -> o.errorCode, "message" -> o.message)

implicit val errorResponseWrites = errorWrites[ErrorResponse]
implicit val errorUnauthorizedWrites = errorWrites[ErrorUnauthorized]
implicit val errorNotFoundWrites = errorWrites[ErrorNotFound]
implicit val errorAcceptHeaderInvalidWrites = errorWrites[ErrorAcceptHeaderInvalid]
implicit val errorBadGatewayWrites = errorWrites[ErrorBadGateway]
implicit val errorBadRequestWrites = errorWrites[ErrorBadRequest]
implicit val errorResponseWrites: Writes[ErrorResponse] = errorWrites[ErrorResponse]
implicit val errorUnauthorizedWrites: Writes[ErrorUnauthorized] = errorWrites[ErrorUnauthorized]
implicit val errorNotFoundWrites: Writes[ErrorNotFound] = errorWrites[ErrorNotFound]
implicit val errorAcceptHeaderInvalidWrites: Writes[ErrorAcceptHeaderInvalid] = errorWrites[ErrorAcceptHeaderInvalid]
implicit val errorBadGatewayWrites: Writes[ErrorBadGateway] = errorWrites[ErrorBadGateway]
implicit val errorBadRequestWrites: Writes[ErrorBadRequest] = errorWrites[ErrorBadRequest]
}
2 changes: 1 addition & 1 deletion app/controllers/testOnly/FeatureSwitchController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
4 changes: 2 additions & 2 deletions app/data/UserInfoGenerator.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down Expand Up @@ -141,7 +141,7 @@ class UserInfoGenerator {
private def formattedNino = {
val first = ninoPrefixGenerator.getOrElse("")
val second = ninoPrefixGenerator.getOrElse("")
val number = numbersGenerator.getOrElse("")
val number = numbersGenerator.map(_.toString).getOrElse("")
val suffix = ninoSuffixGenerator.getOrElse("")
s"$first$second$number$suffix"
}
Expand Down
2 changes: 1 addition & 1 deletion app/domain/APIDefinition.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/domain/Authority.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/domain/Enrolment.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/domain/GovernmentGatewayDetails.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/domain/NinoNotFoundException.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/domain/UserDetails.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
2 changes: 1 addition & 1 deletion app/domain/UserInfo.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
26 changes: 13 additions & 13 deletions app/domain/package.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -20,21 +20,21 @@ import uk.gov.hmrc.auth.core.{Enrolment, EnrolmentIdentifier}

package object domain {

implicit val desUserName = Json.format[ItmpName]
implicit val desUserName: OFormat[ItmpName] = Json.format

implicit val desAddress = Json.format[ItmpAddress]
implicit val desAddress: OFormat[ItmpAddress] = Json.format

implicit val enrolmentIdentifier = Json.format[EnrolmentIdentifier]
implicit val enrloment = Json.format[Enrolment]
implicit val enrolmentIdentifier: OFormat[EnrolmentIdentifier] = Json.format
implicit val enrloment: OFormat[Enrolment] = Json.format

implicit val gatewayInformationFmt: Format[GatewayInformation] = Json.format[GatewayInformation]
implicit val mdtpInformationFmt: Format[MdtpInformation] = Json.format[MdtpInformation]
implicit val userDetails = Json.format[UserDetails]
implicit val mdtp = Json.format[Mdtp]
implicit val governmentGatewayDetails = Json.format[GovernmentGatewayDetails]
implicit val gatewayInformationFmt: Format[GatewayInformation] = Json.format
implicit val mdtpInformationFmt: Format[MdtpInformation] = Json.format
implicit val userDetails: OFormat[UserDetails] = Json.format
implicit val mdtp: OFormat[Mdtp] = Json.format
implicit val governmentGatewayDetails: OFormat[GovernmentGatewayDetails] = Json.format

implicit val addressFmt = Json.format[Address]
implicit val userInfoFmt = Json.format[UserInfo]
implicit val apiAccessFmt = Json.format[APIAccess]
implicit val addressFmt: OFormat[Address] = Json.format
implicit val userInfoFmt: OFormat[UserInfo] = Json.format
implicit val apiAccessFmt: OFormat[APIAccess] = Json.format

}
2 changes: 1 addition & 1 deletion app/filters/MicroserviceAuthFilter.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand Down
6 changes: 3 additions & 3 deletions app/filters/MicroserviceFilters.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -17,13 +17,13 @@
package filters

import javax.inject.{Inject, Singleton}
import com.kenshoo.play.metrics.MetricsFilter
import play.api.http.DefaultHttpFilters
import uk.gov.hmrc.play.bootstrap.filters.{AuditFilter, CacheControlFilter, LoggingFilter, MDCFilter}
import uk.gov.hmrc.play.bootstrap.metrics.MetricsFilterImpl

@Singleton
class MicroserviceFilters @Inject() (
metricsFilter: MetricsFilter,
metricsFilter: MetricsFilterImpl,
auditFilter: AuditFilter,
loggingFilter: LoggingFilter,
cacheFilter: CacheControlFilter,
Expand Down
Loading

0 comments on commit a92bd24

Please sign in to comment.