Skip to content

Commit

Permalink
[PPANTT-183] rollback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelemella committed Dec 17, 2024
1 parent c9f2a62 commit b73f287
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum Subscription {
BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false),
FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true),
FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true),
QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdrkpiservice-", PSP, "qi", false),
QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdrkpiservice-", PSP, "qi", true),
BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false),
BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false),
PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private AuthorizationEntity getAuthorizationEntity(
String taxCode
) {
String value = taxCode;
if (subscription.equals(Subscription.FDR_PSP)) {
if (subscription.equals(Subscription.FDR_PSP) || subscription.equals(Subscription.QI_FDR_KPI)) {
try {
value = this.legacyPspCodeUtil.retrievePspCode(taxCode, false);
} catch (Exception e) {
Expand Down Expand Up @@ -603,6 +603,7 @@ private record AuthorizationConfig(List<AuthorizationEntity> authorizationEntiti
}

private boolean isPSPCodeRequiredForProvidedSubscriptionAnInstitution(Subscription subscriptionCode, InstitutionResponse institution) {
return subscriptionCode.equals(Subscription.FDR_PSP) && !InstitutionType.PT.equals(institution.getInstitutionType());
return (subscriptionCode.equals(Subscription.FDR_PSP) || subscriptionCode.equals(Subscription.QI_FDR_KPI))
&& !InstitutionType.PT.equals(institution.getInstitutionType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,16 @@ void createSubscriptionKeysForGPDSuccess(Subscription sub) {
assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey());
}

@Test
void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() {
@ParameterizedTest
@EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"})
void createSubscriptionKeysForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) {
it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP);

when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse);
when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class);

AppException e = assertThrows(AppException.class, () ->
service.createSubscriptionKeys(INSTITUTION_ID, Subscription.FDR_PSP));
service.createSubscriptionKeys(INSTITUTION_ID, sub));

assertNotNull(e);
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, e.getHttpStatus());
Expand Down Expand Up @@ -561,10 +562,11 @@ void regeneratePrimaryKeyForGPDSuccess(Subscription sub) {
assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey());
}

@Test
void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() {
@ParameterizedTest
@EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"})
void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) {
it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP);
String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode());
String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode());

when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse);
when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class);
Expand All @@ -582,10 +584,11 @@ void regeneratePrimaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() {
verify(authorizerConfigClient, never()).createAuthorization(any());
}

@Test
void regeneratePrimaryKeyForFDRPSPSuccess() {
@ParameterizedTest
@EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"})
void regeneratePrimaryKeyForFDRPSPSuccess(Subscription sub) {
it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP);
String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode());
String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode());
InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId);

when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys));
Expand Down Expand Up @@ -711,10 +714,11 @@ void regenerateSecondaryKeyForGPDSuccess(Subscription sub) {
assertEquals(AUTHORIZER_SEGREGATION_CODES_METADATA_SHORT_KEY, captorValue.getOtherMetadata().get(0).getShortKey());
}

@Test
void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound() {
@ParameterizedTest
@EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"})
void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound(Subscription sub) {
it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP);
String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode());
String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode());

when(externalApiClient.getInstitution(any())).thenReturn(institutionResponse);
when(legacyPspCodeUtil.retrievePspCode(INSTITUTION_TAX_CODE, false)).thenThrow(AppException.class);
Expand All @@ -732,10 +736,11 @@ void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeFailNoPSPCodeFound()
verify(authorizerConfigClient, never()).createAuthorization(any());
}

@Test
void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess() {
@ParameterizedTest
@EnumSource(value = Subscription.class, names = {"FDR_PSP", "QI_FDR_KPI"})
void regenerateSecondaryKeyForSubscriptionThatRequirePSPCodeSuccess(Subscription sub) {
it.pagopa.selfcare.pagopa.backoffice.model.institutions.client.Institution institutionResponse = buildInstitutionResponse(InstitutionType.PSP);
String subscriptionId = String.format("%s%s", Subscription.FDR_PSP.getPrefixId(), institutionResponse.getTaxCode());
String subscriptionId = String.format("%s%s", sub.getPrefixId(), institutionResponse.getTaxCode());
InstitutionApiKeys institutionApiKeys = buildInstitutionApiKeys(subscriptionId);

when(apimClient.getApiSubscriptions(anyString())).thenReturn(Collections.singletonList(institutionApiKeys));
Expand Down

0 comments on commit b73f287

Please sign in to comment.