Skip to content

Commit

Permalink
Reverted the previous supported services config (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
VLukovski authored Dec 19, 2024
1 parent 3b1ac42 commit ccf29c1
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ class AppConfig @Inject() (config: Configuration, servicesConfig: ServicesConfig
val altItsaEnabled =
servicesConfig.getBoolean("alt-itsa.enabled")

// Note: Personal Income Record is not handled through agent-client-relationships
// Note: Personal Income Record is not handled through agent-client-relationships for many of the endpoints
val supportedServicesWithoutPir: Seq[Service] = Service.supportedServices.filterNot(_ == Service.PersonalIncomeRecord)
val supportedServices: Seq[Service] = Service.supportedServices
// TODO: Keeping this list in appConfig to enable reading it from config in future if necessary
// If this is not needed, could be moved somewhere else where constants are kept

val internalHostPatterns: Seq[Regex] = config.get[Seq[String]]("internalServiceHostPatterns").map(_.r)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AgentDetailsController @Inject() (
extends BackendController(cc)
with AuthActions {

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

def getAgentDetails(arn: Arn): Action[AnyContent] = Action.async { implicit request =>
withAuthorisedAsAgent { _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AuthorisationRequestInfoController @Inject() (
extends BackendController(cc)
with AuthActions {

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

def get(arn: Arn, invitationId: String): Action[AnyContent] = Action.async { implicit request =>
withAuthorisedAsAgent { _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ClientDetailsController @Inject() (
extends BackendController(cc)
with AuthActions {

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

private def expectedResults(results: Seq[Result]): Boolean =
results.forall(result => result.header.status == 200 | result.header.status == 404)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class InvitationController @Inject() (
extends BackendController(cc)
with AuthActions {

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

def createInvitation(arn: Arn): Action[JsValue] = Action.async(parse.json) { implicit request =>
request.body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class InvitationLinkController @Inject() (
extends BackendController(cc)
with AuthActions {

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

def validateLink(uid: String, normalizedAgentName: String): Action[AnyContent] = Action.async { implicit request =>
agentReferenceService.validateLink(uid, normalizedAgentName).map { response =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RelationshipsController @Inject() (

private val strideRoles = Seq(appConfig.oldAuthStrideRole, appConfig.newAuthStrideRole)

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

def checkForRelationship(
arn: Arn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RemoveAuthorisationController @Inject() (
extends BackendController(cc)
with AuthActions {

val supportedServices: Seq[Service] = appConfig.supportedServices
val supportedServices: Seq[Service] = appConfig.supportedServicesWithoutPir

def removeAuthorisation(arn: Arn): Action[JsValue] = Action.async(parse.json) { implicit request =>
request.body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private[services] abstract class DeleteRelationshipsService(
(for {
clientIdTypeStr <- deleteRecord.clientIdentifierType
clientIdStr <- deleteRecord.clientIdentifier
service <- appConfig.supportedServices.find(_.supportedClientIdType.enrolmentId == clientIdTypeStr)
service <- appConfig.supportedServicesWithoutPir.find(_.supportedClientIdType.enrolmentId == clientIdTypeStr)
} yield EnrolmentKey(
service.id,
Seq(Identifier(clientIdTypeStr, clientIdStr))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FindRelationshipsService @Inject() (
)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Option[ActiveRelationship]] =
// If the tax id type is among one of the supported ones...
if (
appConfig.supportedServices
appConfig.supportedServicesWithoutPir
.map(_.supportedClientIdType.enrolmentId)
.contains(ClientIdentifier(taxIdentifier).enrolmentId)
)
Expand All @@ -71,7 +71,7 @@ class FindRelationshipsService @Inject() (
identifiers: Map[Service, TaxIdentifier]
)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Map[Service, Seq[Arn]]] =
Future
.traverse(appConfig.supportedServices) { service =>
.traverse(appConfig.supportedServicesWithoutPir) { service =>
identifiers.get(service).map(eiv => service.supportedClientIdType.createUnderlying(eiv.value)) match {
case Some(taxId) =>
getActiveRelationshipsForClient(taxId).map(_.map(r => (service, r.arn)))
Expand All @@ -84,7 +84,7 @@ class FindRelationshipsService @Inject() (
identifiers: Map[Service, TaxIdentifier]
)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Seq[InactiveRelationship]] =
Future
.traverse(appConfig.supportedServices) { service =>
.traverse(appConfig.supportedServicesWithoutPir) { service =>
identifiers.get(service) match {
case Some(taxId) => getInactiveRelationshipsForClient(taxId)
case None => Future.successful(Seq.empty)
Expand All @@ -97,7 +97,7 @@ class FindRelationshipsService @Inject() (
)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Seq[InactiveRelationship]] =
// if it is one of the tax ids that we support...
if (
appConfig.supportedServices.exists(
appConfig.supportedServicesWithoutPir.exists(
_.supportedClientIdType.enrolmentId == ClientIdentifier(taxIdentifier).enrolmentId
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ValidationService @Inject() (
makeSanitisedCbcEnrolmentKey(CbcId(clientId))
// "normal" cases
case (serviceKey, _) =>
if (appConfig.supportedServices.exists(_.id == serviceKey))
if (appConfig.supportedServicesWithoutPir.exists(_.id == serviceKey))
validateSupportedServiceForEnrolmentKey(serviceKey, clientType, clientId)
else
Future.successful(Left(s"Unknown service $serviceKey"))
Expand Down

0 comments on commit ccf29c1

Please sign in to comment.