From 9a50a6d704e5b78e86b013ab3973c8541d277344 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Mon, 11 Dec 2023 14:47:03 +0000 Subject: [PATCH 01/32] Upgrading perftest branch to V16 and adding subnet_suffix --- src/integrationTest/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/integrationTest/resources/application.yml b/src/integrationTest/resources/application.yml index 38370e63d4..670257b215 100644 --- a/src/integrationTest/resources/application.yml +++ b/src/integrationTest/resources/application.yml @@ -1,6 +1,6 @@ spring: flyway: - schemas: DBREFDATA + schemas: dbrefdata locations: classpath:db/migration jpa: From a7e03dd81abbeb984e670616f911ba9b5d3c8eb4 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Fri, 9 Feb 2024 10:05:10 +0000 Subject: [PATCH 02/32] End point to delete Payment account for an organisation --- .../controller/SuperController.java | 3 +- .../OrganisationInternalController.java | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/SuperController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/SuperController.java index ff83b82cb1..457ea2ca91 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/SuperController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/SuperController.java @@ -417,8 +417,7 @@ protected ResponseEntity> retrieveAllOrgan var organisationMinimalInfoResponses = organisations.stream() - .map(organisation -> new OrganisationMinimalInfoResponse(organisation, address)) - .collect(Collectors.toList()); + .map(organisation -> new OrganisationMinimalInfoResponse(organisation, address)).toList(); return ResponseEntity.status(200).body(organisationMinimalInfoResponses); } diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java index ec1b05682e..72233e1666 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java @@ -52,6 +52,11 @@ import static org.apache.commons.lang3.BooleanUtils.isNotTrue; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.DEL_ORG_PBA_NOTES_1; +import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.DEL_ORG_PBA_NOTES_2; +import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.DEL_ORG_PBA_NOTES_3; +import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.DEL_ORG_PBA_NOTES_4; +import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.DEL_ORG_PBA_NOTES_5; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORGANISATION_IDENTIFIER_FORMAT_REGEX; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORG_ID_VALIDATION_ERROR_MESSAGE; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORG_NOT_ACTIVE; @@ -680,4 +685,62 @@ public ResponseEntity retrieveOrganisationByUserId( @PathVariable("userId") String userId) { return organisationService.retrieveOrganisationByUserId(userId); } + + + @Operation( + summary = "Deletes the provided list of payment accounts from the organisation.", + description = "**IDAM Roles to access API** :
- pui-finance-manager", + security = { + @SecurityRequirement(name = "ServiceAuthorization"), + @SecurityRequirement(name = "Authorization") + } + ) + @ApiResponse( + responseCode = "204", + description = "Successfully deleted the list of provided payment accounts from the organisation.", + content = @Content + ) + @ApiResponse( + responseCode = "400", + description = DEL_ORG_PBA_NOTES_1 + DEL_ORG_PBA_NOTES_2 + DEL_ORG_PBA_NOTES_3 + + DEL_ORG_PBA_NOTES_4 + DEL_ORG_PBA_NOTES_5, + content = @Content + ) + @ApiResponse( + responseCode = "401", + description = "Unauthorized Error : " + + "The requested resource is restricted and requires authentication", + content = @Content + ) + @ApiResponse( + responseCode = "403", + description = "Forbidden Error: " + + "Access denied for either invalid permissions or user is pending", + content = @Content + ) + @ApiResponse( + responseCode = "404", + description = "Resource Not Found Error: The Organisation does not exist" + + " to delete Payment Accounts from", + content = @Content + ) + @ApiResponse( + responseCode = "500", + description = "Internal Server Error", + content = @Content + ) + + @DeleteMapping(path = "/pba/{orgId}") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + @Secured({"prd-admin"}) + public void deletePaymentAccountsOfOrganisation( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "deletePbaRequest") + @Valid @NotNull @RequestBody PbaRequest deletePbaRequest, + @PathVariable("orgId") @NotBlank String organisationIdentifier, + @Parameter(hidden = true) @UserId String userId) { + + deletePaymentAccountsOfGivenOrganisation(deletePbaRequest, organisationIdentifier, userId); + + } + } From 3c3c8b052ab0d9523a242185279599992bd04264 Mon Sep 17 00:00:00 2001 From: aneesahmcts Date: Thu, 9 May 2024 13:49:20 +0100 Subject: [PATCH 03/32] unit tests added --- .../OrganisationInternalControllerTest.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java index 5c89767f75..4257c874e1 100644 --- a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java @@ -76,6 +76,7 @@ import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORG_NAME; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORG_STATUS; + @ExtendWith(MockitoExtension.class) @SuppressWarnings("checkstyle:AbbreviationAsWordInName") class OrganisationInternalControllerTest { @@ -108,8 +109,14 @@ class OrganisationInternalControllerTest { private List prdEnumList; private ProfessionalUser professionalUser; + private OrganisationIdentifierValidatorImpl organisationIdentifierValidatorImplMock; + + private NewUserCreationRequest newUserCreationRequest; private UserProfileFeignClient userProfileFeignClient; + + + private DeleteOrganisationResponse deleteOrganisationResponse; HttpServletRequest httpRequest = mock(HttpServletRequest.class); @@ -119,6 +126,8 @@ class OrganisationInternalControllerTest { @InjectMocks private OrganisationInternalControllerV2 organisationInternalControllerV2; + + @BeforeEach void setUp() throws Exception { organisation = new Organisation("Org-Name", OrganisationStatus.PENDING, "sra-id", @@ -136,6 +145,7 @@ void setUp() throws Exception { new OrganisationEntityResponse(organisation, false, true, true); organisationServiceMock = mock(OrganisationService.class); + //organisationIdentifierValidatorImplMock = mock(OrganisationIdentifierValidatorImpl.class); professionalUserServiceMock = mock(ProfessionalUserService.class); paymentAccountServiceMock = mock(PaymentAccountService.class); organisationCreationRequestValidatorMock = mock(OrganisationCreationRequestValidator.class); @@ -566,4 +576,47 @@ void testRetrieveOrgByPbaStatus() { .getOrganisationsByPbaStatus(pbaStatus.toString()); } + + + + @Test + void testDeletePaymentAccounts() { + PbaRequest deletePbaRequest = new PbaRequest(); + var accountsToDelete = new HashSet(); + accountsToDelete.add("PBA1234567"); + deletePbaRequest.setPaymentAccounts(accountsToDelete); + final List paymentAccounts = new ArrayList<>(); + paymentAccounts.add(new PaymentAccount()); + organisation.setPaymentAccounts(paymentAccounts); + when(organisationServiceMock.getOrganisationByOrgIdentifier(anyString())).thenReturn(organisation); + + String orgId = UUID.randomUUID().toString().substring(0, 7); + String userId = UUID.randomUUID().toString(); + organisationInternalController + .deletePaymentAccountsOfOrganisation(deletePbaRequest, orgId, userId); + + verify(professionalUserServiceMock, times(1)) + .checkUserStatusIsActiveByUserId(anyString()); + verify(orgIdValidatorMock, times(1)) + .validateOrganisationIsActive(any(Organisation.class), any(HttpStatus.class)); + verify(paymentAccountServiceMock, times(1)) + .deletePaymentsOfOrganisation(any(PbaRequest.class), any(Organisation.class)); + + } + + + + + @Test + void test_deletePaymentAccounts_NoPaymentAccountsPassed() { + PbaRequest deletePbaRequest = new PbaRequest(); + var accountsToDelete = new HashSet(); + deletePbaRequest.setPaymentAccounts(accountsToDelete); + String orgId = UUID.randomUUID().toString().substring(0, 7); + String userId = UUID.randomUUID().toString(); + assertThrows(InvalidRequest.class,() -> + organisationInternalController + .deletePaymentAccountsOfOrganisation(deletePbaRequest, orgId, userId)); + + } } \ No newline at end of file From 32334dd9cbb6e4af65a7865e123c75e6a117b673 Mon Sep 17 00:00:00 2001 From: aneesahmcts Date: Wed, 22 May 2024 11:15:18 +0100 Subject: [PATCH 04/32] unit tests added --- ...rofessionalInternalUserFunctionalTest.java | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 82c1179593..bd535b0415 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -622,7 +622,7 @@ void updateOrgMfaShouldReturn403WhenToggledOff() { log.info("updateOrgMFAShouldReturn403 :: END"); } - public void updateOrgStatusScenarios() { + public void updateOrgStatusScenarios() { updateOrgStatusShouldBeSuccess(); } @@ -785,7 +785,7 @@ void findOrganisationsWithPaginationShouldReturnSuccess() { log.info("findOrganisationsWithPaginationShouldReturnSuccess :: STARTED"); professionalApiClient.createOrganisation(); Map organisations = professionalApiClient - .retrieveAllOrganisationsWithPagination(hmctsAdmin, "1", "2"); + .retrieveAllOrganisationsWithPagination(hmctsAdmin, "1", "2"); assertThat(organisations).isNotNull().hasSize(2); @@ -1231,4 +1231,59 @@ private static List> sortByValue(final List (String) map.get(key))) .collect(Collectors.toList()); } + + @Test + @ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) + @ExtendWith(FeatureToggleConditionExtension.class) + @SuppressWarnings("checkstyle:AbbreviationAsWordInName") + void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() { + log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: STARTED"); + + Set paymentAccounts = new HashSet<>(); + paymentAccounts.add("PBA0000021"); + paymentAccounts.add("PBA0000022"); + paymentAccounts.add("PBA0000023"); + + setUpTestData(); + setUpUserBearerTokens(List.of(puiFinanceManager)); + + PbaRequest deletePbaRequest = new PbaRequest(); + deletePbaRequest.setPaymentAccounts(Set.of("PBA0000021", "PBA0000022", "PBA0000023")); + + String pfmBearerTokens = null; + professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, + professionalApiClient.getMultipleAuthHeaders(null), FORBIDDEN); + + log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: END"); + } + + private void setUpUserBearerTokens(List puiFinanceManager) { + } + + @Test + //@ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) + //@ExtendWith(FeatureToggleConditionExtension.class) + void deletePbaOfExistingOrganisationShouldBeSuccess() { + log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: STARTED"); + + + + setUpTestData(); + setUpUserBearerTokens(List.of(puiFinanceManager)); + + PbaRequest deletePbaRequest = new PbaRequest(); + deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); + + String pfmBearerToken = null; + professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, + professionalApiClient.getMultipleAuthHeaders(null), NO_CONTENT); + + Map response = professionalApiClient.retrieveOrganisationByOrgIdExternal(OK, + professionalApiClient.getMultipleAuthHeaders(null)); + + var paymentAccounts = (List) response.get("paymentAccount"); + assertThat(paymentAccounts).isEmpty(); + log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: END"); + } } + From 86f7180d906800fa9271a5993d9c794bb4ddf81c Mon Sep 17 00:00:00 2001 From: James Turnbull <81160745+jthmcts@users.noreply.github.com> Date: Thu, 23 May 2024 17:24:13 +0100 Subject: [PATCH 05/32] Add Pact state for calls to ProfessionalUserService.findUserStatusByEmailAddress (#1610) --- ...ationalExternalControllerProviderUsersTest.java | 14 ++++++++++++++ ...alControllerProviderUsersTestConfiguration.java | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTest.java b/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTest.java index 188fec5fe2..7aa9394615 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTest.java @@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; @@ -23,6 +25,7 @@ import uk.gov.hmcts.reform.professionalapi.controller.feign.UserProfileFeignClient; import uk.gov.hmcts.reform.professionalapi.controller.request.UserProfileCreationRequest; import uk.gov.hmcts.reform.professionalapi.controller.response.GetUserProfileResponse; +import uk.gov.hmcts.reform.professionalapi.controller.response.NewUserResponse; import uk.gov.hmcts.reform.professionalapi.controller.response.UserProfileCreationResponse; import uk.gov.hmcts.reform.professionalapi.domain.Organisation; import uk.gov.hmcts.reform.professionalapi.domain.PaymentAccount; @@ -213,6 +216,17 @@ public void toRetrieveActiveOrganisations() throws IOException { } + @State({"User exists"}) + public void toRetrieveUser() { + ProfessionalUser professionalUser = setUpProfessionalUser(); + professionalUser.setUserIdentifier("someUserIdentifier"); + ResponseEntity response = ResponseEntity + .status(HttpStatus.OK) + .body(new NewUserResponse(professionalUser)); + + when(professionalUserServiceMock.findUserStatusByEmailAddress(anyString())) + .thenReturn(response); + } private void setUpUserProfileClientInteraction() throws JsonProcessingException { UserProfileCreationResponse userProfileCreationResponse = new UserProfileCreationResponse(); diff --git a/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTestConfiguration.java b/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTestConfiguration.java index 1f7060e4ee..6bbf2854f6 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTestConfiguration.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalExternalControllerProviderUsersTestConfiguration.java @@ -7,6 +7,7 @@ import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; import uk.gov.hmcts.reform.authorisation.filters.ServiceAuthFilter; import uk.gov.hmcts.reform.professionalapi.controller.external.OrganisationExternalController; +import uk.gov.hmcts.reform.professionalapi.controller.external.ProfessionalExternalUserController; import uk.gov.hmcts.reform.professionalapi.controller.request.validator.UserProfileUpdateRequestValidator; import uk.gov.hmcts.reform.professionalapi.repository.BulkCustomerDetailsRepository; import uk.gov.hmcts.reform.professionalapi.repository.ContactInformationRepository; @@ -88,6 +89,11 @@ public OrganisationExternalController organisationExternalController() { return new OrganisationExternalController(); } + @Bean + @Primary + public ProfessionalExternalUserController professionalExternalUserController() { + return new ProfessionalExternalUserController(); + } @Bean @Primary From f9127ca06c993ea027fb1d789615469d73682eb5 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Yenigala <51748133+kiran-yenigala-hmcts@users.noreply.github.com> Date: Thu, 23 May 2024 17:42:17 +0100 Subject: [PATCH 06/32] DTSRD-2525: handle flyway out of order (#1613) --- src/integrationTest/resources/application.yml | 3 ++- src/main/resources/application.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/integrationTest/resources/application.yml b/src/integrationTest/resources/application.yml index 429173e1d4..e38bb2e555 100644 --- a/src/integrationTest/resources/application.yml +++ b/src/integrationTest/resources/application.yml @@ -2,7 +2,8 @@ spring: flyway: schemas: DBREFDATA locations: classpath:db/testmigration - + out-of-order: true + jpa: show-sql: true properties: diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index ff798e5e81..dee79104ec 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -45,6 +45,7 @@ spring: client-secret: ${PROFESSIONAL_API_S2S_SECRET:} jackson.date-format: yyyy-MM-dd flyway.enabled: true + flyway.out-of-order: true flyway.schemas: dbrefdata flyway.locations: classpath:db/migration,classpath:db/postgres cache: From 7edaedbe7316695991807dc1e3d5d152b3112404 Mon Sep 17 00:00:00 2001 From: Kiran Kumar Yenigala <51748133+kiran-yenigala-hmcts@users.noreply.github.com> Date: Thu, 23 May 2024 18:03:55 +0100 Subject: [PATCH 07/32] Add out of order to db migration (#1614) * DTSRD-2525: handle flyway out of order * DTSRD-2525: handle flyway out of order --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 1af696973b..8464ff1380 100644 --- a/build.gradle +++ b/build.gradle @@ -202,6 +202,7 @@ task smoke(type: Test, description: 'Runs the smoke tests.', group: 'Verificatio task migratePostgresDatabase(type: org.flywaydb.gradle.task.FlywayMigrateTask) { baselineOnMigrate = true + outOfOrder = true locations = ["filesystem:src/main/resources/db/migration", "filesystem:src/main/resources/db/postgres"] if (project.hasProperty("dburl")) { url = "jdbc:postgresql://${dburl}" From df8f1131ffb006a9524240fce5c786c5b4fd32bc Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Fri, 9 Feb 2024 10:05:10 +0000 Subject: [PATCH 08/32] End point to delete Payment account for an organisation --- .../controller/internal/OrganisationInternalController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java index d4d2bf4222..8dab1a844e 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java @@ -810,4 +810,5 @@ public ResponseEntity retrieveOrganisationsByProfileIds( .body(response); } + } From 8fe15f34a946eaa8ce974e814cab85cc5102008b Mon Sep 17 00:00:00 2001 From: aneesahmcts Date: Thu, 9 May 2024 13:49:20 +0100 Subject: [PATCH 09/32] unit tests added --- .../internal/OrganisationInternalControllerTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java index 9e3edbe2fe..426e05f912 100644 --- a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java @@ -77,7 +77,6 @@ import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORG_NAME; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ORG_STATUS; - @ExtendWith(MockitoExtension.class) @SuppressWarnings("checkstyle:AbbreviationAsWordInName") class OrganisationInternalControllerTest { @@ -115,9 +114,6 @@ class OrganisationInternalControllerTest { private NewUserCreationRequest newUserCreationRequest; private UserProfileFeignClient userProfileFeignClient; - - - private DeleteOrganisationResponse deleteOrganisationResponse; HttpServletRequest httpRequest = mock(HttpServletRequest.class); @@ -127,8 +123,6 @@ class OrganisationInternalControllerTest { @InjectMocks private OrganisationInternalControllerV2 organisationInternalControllerV2; - - @BeforeEach void setUp() throws Exception { organisation = new Organisation("Org-Name", OrganisationStatus.PENDING, "sra-id", @@ -146,7 +140,6 @@ void setUp() throws Exception { new OrganisationEntityResponse(organisation, false, true, true); organisationServiceMock = mock(OrganisationService.class); - //organisationIdentifierValidatorImplMock = mock(OrganisationIdentifierValidatorImpl.class); professionalUserServiceMock = mock(ProfessionalUserService.class); paymentAccountServiceMock = mock(PaymentAccountService.class); organisationCreationRequestValidatorMock = mock(OrganisationCreationRequestValidator.class); From c7061b2ca24e7c0b391f74e139582dc31a0f79ba Mon Sep 17 00:00:00 2001 From: Chi Cho Date: Fri, 31 May 2024 16:23:16 +0100 Subject: [PATCH 10/32] Fix functional tests --- ...rofessionalInternalUserFunctionalTest.java | 65 ++++++++++++------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index bd535b0415..a1bb173b55 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import net.thucydides.core.annotations.WithTag; import net.thucydides.core.annotations.WithTags; +import org.apache.commons.lang3.RandomStringUtils; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -46,12 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.FORBIDDEN; -import static org.springframework.http.HttpStatus.NOT_FOUND; -import static org.springframework.http.HttpStatus.NO_CONTENT; -import static org.springframework.http.HttpStatus.OK; -import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS; +import static org.springframework.http.HttpStatus.*; import static uk.gov.hmcts.reform.professionalapi.client.ProfessionalApiClient.createOrganisationRequest; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.PBA_STATUS_MESSAGE_ACCEPTED; import static uk.gov.hmcts.reform.professionalapi.controller.request.OrganisationCreationRequest.anOrganisationCreationRequest; @@ -1233,31 +1229,41 @@ private static List> sortByValue(final List paymentAccounts = new HashSet<>(); - paymentAccounts.add("PBA0000021"); - paymentAccounts.add("PBA0000022"); - paymentAccounts.add("PBA0000023"); - setUpTestData(); - setUpUserBearerTokens(List.of(puiFinanceManager)); + String bearerToken = inviteUser(puiFinanceManager, intActiveOrgId, generateRandomEmail(), + "firstName2", "lastName2"); PbaRequest deletePbaRequest = new PbaRequest(); - deletePbaRequest.setPaymentAccounts(Set.of("PBA0000021", "PBA0000022", "PBA0000023")); + deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); - String pfmBearerTokens = null; professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, - professionalApiClient.getMultipleAuthHeaders(null), FORBIDDEN); + professionalApiClient.getMultipleAuthHeaders(bearerToken), FORBIDDEN); log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: END"); } - private void setUpUserBearerTokens(List puiFinanceManager) { + public String inviteUser(String role, + String orgId, + String email, + String firstName, + String lastName) { + List userRoles = new ArrayList<>(); + userRoles.add(role); + NewUserCreationRequest newUserCreationRequest = createUserRequest(userRoles); + newUserCreationRequest.setEmail(email); + String bearerToken = idamOpenIdClient.getExternalOpenIdToken(puiUserManager, + firstName, lastName, email); + + Map pumInternalUserResponse = professionalApiClient + .addNewUserToAnOrganisation(orgId, hmctsAdmin, newUserCreationRequest, CREATED); + assertThat(pumInternalUserResponse.get("userIdentifier")).isNotNull(); + return bearerToken; } @Test @@ -1266,20 +1272,31 @@ private void setUpUserBearerTokens(List puiFinanceManager) { void deletePbaOfExistingOrganisationShouldBeSuccess() { log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: STARTED"); + organisationCreationRequest = createOrganisationRequest() + .superUser(aUserCreationRequest() + .firstName("firstName") + .lastName("lastName") + .email(generateRandomEmail()) + .build()) + .paymentAccount(Set.of("PBA".concat(RandomStringUtils.randomAlphanumeric(7)), + "PBA".concat(RandomStringUtils.randomAlphanumeric(7)), + "PBA".concat(RandomStringUtils.randomAlphanumeric(7)))) + .status("ACTIVE") + .build(); + String intActiveOrgId = createAndActivateOrganisationWithGivenRequest(organisationCreationRequest, + hmctsAdmin); - - setUpTestData(); - setUpUserBearerTokens(List.of(puiFinanceManager)); + String bearerToken = inviteUser(puiFinanceManager, intActiveOrgId, generateRandomEmail(), + "firstName2", "lastName2"); PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); - String pfmBearerToken = null; professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, - professionalApiClient.getMultipleAuthHeaders(null), NO_CONTENT); + professionalApiClient.getMultipleAuthHeaders(bearerToken), NO_CONTENT); Map response = professionalApiClient.retrieveOrganisationByOrgIdExternal(OK, - professionalApiClient.getMultipleAuthHeaders(null)); + professionalApiClient.getMultipleAuthHeaders(bearerToken)); var paymentAccounts = (List) response.get("paymentAccount"); assertThat(paymentAccounts).isEmpty(); From e44d1a15f6e6cf3546cd5050d36334b9aafabac1 Mon Sep 17 00:00:00 2001 From: Chi Cho Date: Fri, 31 May 2024 16:46:02 +0100 Subject: [PATCH 11/32] Fix functional tests --- .../ProfessionalInternalUserFunctionalTest.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index a1bb173b55..f34236ba08 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -47,7 +47,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.springframework.http.HttpStatus.*; +import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.FORBIDDEN; +import static org.springframework.http.HttpStatus.NOT_FOUND; +import static org.springframework.http.HttpStatus.NO_CONTENT; +import static org.springframework.http.HttpStatus.OK; +import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS; import static uk.gov.hmcts.reform.professionalapi.client.ProfessionalApiClient.createOrganisationRequest; import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.PBA_STATUS_MESSAGE_ACCEPTED; import static uk.gov.hmcts.reform.professionalapi.controller.request.OrganisationCreationRequest.anOrganisationCreationRequest; @@ -1229,8 +1235,8 @@ private static List> sortByValue(final List Date: Fri, 31 May 2024 17:22:22 +0100 Subject: [PATCH 12/32] Fix functional tests --- .../ProfessionalInternalUserFunctionalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index f34236ba08..4c2bfabb8d 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1246,10 +1246,10 @@ void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() { "firstName2", "lastName2"); PbaRequest deletePbaRequest = new PbaRequest(); - deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); + deletePbaRequest.setPaymentAccounts(Set.of("PBA0000021", "PBA0000022", "PBA0000023")); professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, - professionalApiClient.getMultipleAuthHeaders(bearerToken), FORBIDDEN); + professionalApiClient.getMultipleAuthHeaders(bearerToken), BAD_REQUEST); log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: END"); } From a62cb1642771e7b1bd581b84e3fb32593f2d97da Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 19 Jun 2024 15:11:33 +0100 Subject: [PATCH 13/32] update admin unit tests --- ...rofessionalInternalUserFunctionalTest.java | 33 +++---------------- .../client/ProfessionalApiClient.java | 19 ++++++++++- .../OrganisationInternalController.java | 2 +- .../OrganisationInternalControllerTest.java | 3 -- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 4c2bfabb8d..a9bd99b0f7 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1242,36 +1242,16 @@ void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() { log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: STARTED"); setUpTestData(); - String bearerToken = inviteUser(puiFinanceManager, intActiveOrgId, generateRandomEmail(), - "firstName2", "lastName2"); PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(Set.of("PBA0000021", "PBA0000022", "PBA0000023")); - professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, - professionalApiClient.getMultipleAuthHeaders(bearerToken), BAD_REQUEST); + professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest,intActiveOrgId, + professionalApiClient.getMultipleAuthHeadersInternal(), FORBIDDEN); log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: END"); } - public String inviteUser(String role, - String orgId, - String email, - String firstName, - String lastName) { - List userRoles = new ArrayList<>(); - userRoles.add(role); - NewUserCreationRequest newUserCreationRequest = createUserRequest(userRoles); - newUserCreationRequest.setEmail(email); - String bearerToken = idamOpenIdClient.getExternalOpenIdToken(puiUserManager, - firstName, lastName, email); - - Map pumInternalUserResponse = professionalApiClient - .addNewUserToAnOrganisation(orgId, hmctsAdmin, newUserCreationRequest, CREATED); - assertThat(pumInternalUserResponse.get("userIdentifier")).isNotNull(); - return bearerToken; - } - @Test @ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) @ExtendWith(FeatureToggleConditionExtension.class) @@ -1292,17 +1272,14 @@ void deletePbaOfExistingOrganisationShouldBeSuccess() { String intActiveOrgId = createAndActivateOrganisationWithGivenRequest(organisationCreationRequest, hmctsAdmin); - String bearerToken = inviteUser(puiFinanceManager, intActiveOrgId, generateRandomEmail(), - "firstName2", "lastName2"); - PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); - professionalApiClient.deletePaymentAccountsOfOrganisation(deletePbaRequest, - professionalApiClient.getMultipleAuthHeaders(bearerToken), NO_CONTENT); + professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest,intActiveOrgId + professionalApiClient.getMultipleAuthHeadersInternal(), NO_CONTENT); Map response = professionalApiClient.retrieveOrganisationByOrgIdExternal(OK, - professionalApiClient.getMultipleAuthHeaders(bearerToken)); + professionalApiClient.getMultipleAuthHeadersInternal()); var paymentAccounts = (List) response.get("paymentAccount"); assertThat(paymentAccounts).isEmpty(); diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java index f9801c26d2..bbb5ec08b9 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java @@ -1579,7 +1579,7 @@ private RequestSpecification getS2sTokenHeaders() { .header(SERVICE_HEADER, "Bearer " + s2sToken); } - private RequestSpecification getMultipleAuthHeadersInternal() { + public RequestSpecification getMultipleAuthHeadersInternal() { return getMultipleAuthHeaders(idamOpenIdClient.getcwdAdminOpenIdToken("prd-admin")); } @@ -1702,6 +1702,23 @@ public void deletePaymentAccountsOfOrganisation(PbaRequest deletePbaRequest, loggingComponentName, response.getStatusCode()); } + public void deletePaymentAccountsOfOrganisationInternal(PbaRequest deletePbaRequest,String organisationId, + RequestSpecification requestSpecification, + HttpStatus expectedStatus) { + Response response = requestSpecification + .body(deletePbaRequest) + .delete("/refdata/internal/v1/organisations/pba") + .andReturn(); + + response.then() + .assertThat() + .statusCode(expectedStatus.value()); + + log.info("{}:: Delete PBA of organisation status response: {}", + loggingComponentName, response.getStatusCode()); + } + + public Object findOrganisationsByPbaStatus(HttpStatus expectedStatus, PbaStatus pbaStatus) { Response response = getMultipleAuthHeadersInternal() diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java index 8dab1a844e..6a0285d6c2 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java @@ -706,7 +706,7 @@ public ResponseEntity retrieveOrganisationByUserId( @Operation( summary = "Deletes the provided list of payment accounts from the organisation.", - description = "**IDAM Roles to access API** :
- pui-finance-manager", + description = "**IDAM Roles to access API** :
- prd-admin", security = { @SecurityRequirement(name = "ServiceAuthorization"), @SecurityRequirement(name = "Authorization") diff --git a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java index 426e05f912..0d2a5663ed 100644 --- a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java @@ -576,9 +576,6 @@ void testRetrieveOrgByPbaStatus() { } - - - @Test void testDeletePaymentAccounts() { PbaRequest deletePbaRequest = new PbaRequest(); From 06d015b30e0e3221d5252515910ac1810d514da1 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 19 Jun 2024 15:14:42 +0100 Subject: [PATCH 14/32] update admin unit tests --- .../professionalapi/ProfessionalInternalUserFunctionalTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index a9bd99b0f7..e53f096a23 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1275,7 +1275,7 @@ void deletePbaOfExistingOrganisationShouldBeSuccess() { PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); - professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest,intActiveOrgId + professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest,intActiveOrgId, professionalApiClient.getMultipleAuthHeadersInternal(), NO_CONTENT); Map response = professionalApiClient.retrieveOrganisationByOrgIdExternal(OK, From 82d3290d93cfc9f69a747c0ca48c1dece9fdf9e3 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 19 Jun 2024 15:15:52 +0100 Subject: [PATCH 15/32] update admin unit tests --- .../professionalapi/ProfessionalInternalUserFunctionalTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index e53f096a23..80e9bad7a4 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -48,7 +48,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; From 80d5dd2c6d6046f271bea3e250c99c402a28de49 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Fri, 21 Jun 2024 14:04:46 +0100 Subject: [PATCH 16/32] update admin functional tests --- .../ProfessionalInternalUserFunctionalTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 80e9bad7a4..71f7c2e2d2 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1240,13 +1240,11 @@ private static List> sortByValue(final List Date: Mon, 24 Jun 2024 13:04:18 +0100 Subject: [PATCH 17/32] update admin functional tests --- ...rofessionalInternalUserFunctionalTest.java | 29 +++++-------------- .../client/ProfessionalApiClient.java | 2 +- .../OrganisationInternalController.java | 5 ++-- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 71f7c2e2d2..e22963ac00 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -5,7 +5,6 @@ import lombok.extern.slf4j.Slf4j; import net.thucydides.core.annotations.WithTag; import net.thucydides.core.annotations.WithTags; -import org.apache.commons.lang3.RandomStringUtils; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -1243,42 +1242,30 @@ void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() { PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(Set.of("PBA0000021", "PBA0000022", "PBA0000023")); - professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest,intActiveOrgId, + professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest, professionalApiClient.getMultipleAuthHeadersWithGivenRole("pui-user-manager"), FORBIDDEN); log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: END"); } @Test - @ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) - @ExtendWith(FeatureToggleConditionExtension.class) + //@ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) + //@ExtendWith(FeatureToggleConditionExtension.class) void deletePbaOfExistingOrganisationShouldBeSuccess() { log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: STARTED"); - organisationCreationRequest = createOrganisationRequest() - .superUser(aUserCreationRequest() - .firstName("firstName") - .lastName("lastName") - .email(generateRandomEmail()) - .build()) - .paymentAccount(Set.of("PBA".concat(RandomStringUtils.randomAlphanumeric(7)), - "PBA".concat(RandomStringUtils.randomAlphanumeric(7)), - "PBA".concat(RandomStringUtils.randomAlphanumeric(7)))) - .status("ACTIVE") - .build(); - String intActiveOrgId = createAndActivateOrganisationWithGivenRequest(organisationCreationRequest, - hmctsAdmin); + setUpTestData(); PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); - professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest,intActiveOrgId, + professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest, professionalApiClient.getMultipleAuthHeadersInternal(), NO_CONTENT); - Map response = professionalApiClient.retrieveOrganisationByOrgIdExternal(OK, - professionalApiClient.getMultipleAuthHeadersInternal()); + JsonPath jsonPath = professionalApiClient.retrieveOrganisationDetails(intActiveOrgId, hmctsAdmin, OK); + assertThat(jsonPath).isNotNull(); + var paymentAccounts = (List) jsonPath.get("paymentAccount"); - var paymentAccounts = (List) response.get("paymentAccount"); assertThat(paymentAccounts).isEmpty(); log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: END"); } diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java index bbb5ec08b9..a84b058a01 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java @@ -1702,7 +1702,7 @@ public void deletePaymentAccountsOfOrganisation(PbaRequest deletePbaRequest, loggingComponentName, response.getStatusCode()); } - public void deletePaymentAccountsOfOrganisationInternal(PbaRequest deletePbaRequest,String organisationId, + public void deletePaymentAccountsOfOrganisationInternal(PbaRequest deletePbaRequest, RequestSpecification requestSpecification, HttpStatus expectedStatus) { Response response = requestSpecification diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java index 6a0285d6c2..71919db288 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import uk.gov.hmcts.reform.professionalapi.configuration.resolver.OrgId; import uk.gov.hmcts.reform.professionalapi.configuration.resolver.UserId; import uk.gov.hmcts.reform.professionalapi.controller.SuperController; import uk.gov.hmcts.reform.professionalapi.controller.advice.ErrorResponse; @@ -747,13 +748,13 @@ public ResponseEntity retrieveOrganisationByUserId( content = @Content ) - @DeleteMapping(path = "/pba/{orgId}") + @DeleteMapping(path = "/pba") @ResponseStatus(value = HttpStatus.NO_CONTENT) @Secured({"prd-admin"}) public void deletePaymentAccountsOfOrganisation( @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "deletePbaRequest") @Valid @NotNull @RequestBody PbaRequest deletePbaRequest, - @PathVariable("orgId") @NotBlank String organisationIdentifier, + @Parameter(hidden = true) @OrgId String organisationIdentifier, @Parameter(hidden = true) @UserId String userId) { deletePaymentAccountsOfGivenOrganisation(deletePbaRequest, organisationIdentifier, userId); From 09af566edfebc71ca6e06e5f133d5285d73e6ccf Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Mon, 24 Jun 2024 13:40:57 +0100 Subject: [PATCH 18/32] update admin functional tests --- .../ProfessionalInternalUserFunctionalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index e22963ac00..8b70d2aee7 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1249,8 +1249,8 @@ void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() { } @Test - //@ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) - //@ExtendWith(FeatureToggleConditionExtension.class) + @ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) + @ExtendWith(FeatureToggleConditionExtension.class) void deletePbaOfExistingOrganisationShouldBeSuccess() { log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: STARTED"); From c0071af9f353572225b59a25b9726dc4a01810f2 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Mon, 24 Jun 2024 14:12:25 +0100 Subject: [PATCH 19/32] update admin functional tests --- .../internal/OrganisationInternalController.java | 12 ++++++------ .../internal/OrganisationInternalControllerTest.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java index 71919db288..04a010fbae 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java @@ -706,8 +706,8 @@ public ResponseEntity retrieveOrganisationByUserId( @Operation( - summary = "Deletes the provided list of payment accounts from the organisation.", - description = "**IDAM Roles to access API** :
- prd-admin", + summary = "Deletes the provided list of payment accounts from the organisation (internal api).", + description = "IDAM Roles to access API :
- prd-admin", security = { @SecurityRequirement(name = "ServiceAuthorization"), @SecurityRequirement(name = "Authorization") @@ -715,7 +715,7 @@ public ResponseEntity retrieveOrganisationByUserId( ) @ApiResponse( responseCode = "204", - description = "Successfully deleted the list of provided payment accounts from the organisation.", + description = "Successfully deleted the list of payment accounts from the provided organisation.", content = @Content ) @ApiResponse( @@ -751,13 +751,13 @@ public ResponseEntity retrieveOrganisationByUserId( @DeleteMapping(path = "/pba") @ResponseStatus(value = HttpStatus.NO_CONTENT) @Secured({"prd-admin"}) - public void deletePaymentAccountsOfOrganisation( + public void deletePaymentAccountsForOrganisation( @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "deletePbaRequest") @Valid @NotNull @RequestBody PbaRequest deletePbaRequest, - @Parameter(hidden = true) @OrgId String organisationIdentifier, + @Parameter(hidden = true) @OrgId String orgIdentifier, @Parameter(hidden = true) @UserId String userId) { - deletePaymentAccountsOfGivenOrganisation(deletePbaRequest, organisationIdentifier, userId); + deletePaymentAccountsOfGivenOrganisation(deletePbaRequest, orgIdentifier, userId); } diff --git a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java index 0d2a5663ed..3c6f6fd830 100644 --- a/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalControllerTest.java @@ -590,7 +590,7 @@ void testDeletePaymentAccounts() { String orgId = UUID.randomUUID().toString().substring(0, 7); String userId = UUID.randomUUID().toString(); organisationInternalController - .deletePaymentAccountsOfOrganisation(deletePbaRequest, orgId, userId); + .deletePaymentAccountsForOrganisation(deletePbaRequest, orgId, userId); verify(professionalUserServiceMock, times(1)) .checkUserStatusIsActiveByUserId(anyString()); @@ -611,7 +611,7 @@ void test_deletePaymentAccounts_NoPaymentAccountsPassed() { String userId = UUID.randomUUID().toString(); assertThrows(InvalidRequest.class,() -> organisationInternalController - .deletePaymentAccountsOfOrganisation(deletePbaRequest, orgId, userId)); + .deletePaymentAccountsForOrganisation(deletePbaRequest, orgId, userId)); } } From 90b15c6908baf84477089109bfbaf502411a0448 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Tue, 25 Jun 2024 15:16:31 +0100 Subject: [PATCH 20/32] update functional tests --- ...rofessionalInternalUserFunctionalTest.java | 37 +++++++++++++++++-- .../client/ProfessionalApiClient.java | 3 +- .../OrganisationInternalController.java | 13 ++++--- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 8b70d2aee7..1e93b4d622 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -154,6 +154,7 @@ public void setUpTestData() { roles.add(puiCaseManager); roles.add(puiOrgManager); roles.add(puiFinanceManager); + roles.add(hmctsAdmin); idamOpenIdClient.createUser(roles, invitedUserEmail, "firstName", "lastName"); } @@ -1243,24 +1244,52 @@ void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() { deletePbaRequest.setPaymentAccounts(Set.of("PBA0000021", "PBA0000022", "PBA0000023")); professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest, - professionalApiClient.getMultipleAuthHeadersWithGivenRole("pui-user-manager"), FORBIDDEN); + professionalApiClient.getMultipleAuthHeadersWithGivenRole("pui-user-manager"), + intActiveOrgId,FORBIDDEN); log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: END"); } + @Test - @ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true) + @ToggleEnable(mapKey = "OrganisationInternalController.deletePaymentAccountsForOrganisation", withFeature = true) @ExtendWith(FeatureToggleConditionExtension.class) void deletePbaOfExistingOrganisationShouldBeSuccess() { log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: STARTED"); + superUserEmail = generateRandomEmail(); + invitedUserEmail = generateRandomEmail(); + organisationCreationRequest = createOrganisationRequest() + .superUser(aUserCreationRequest() + .firstName("firstName") + .lastName("lastName") + .email(superUserEmail) + .build()) + .build(); + intActiveOrgId = createAndUpdateOrganisationToActive(hmctsAdmin, organisationCreationRequest); - setUpTestData(); + List roles = new ArrayList<>(); + roles.add(puiCaseManager); + roles.add(puiOrgManager); + roles.add(puiFinanceManager); + roles.add(hmctsAdmin); + Map userResponse = idamOpenIdClient.createUser(roles, invitedUserEmail, + "firstName", "lastName"); + String activeUserId = (String) userResponse.get("userIdentifier"); + + UserProfileUpdatedData userProfileUpdatedData = new UserProfileUpdatedData(); + userProfileUpdatedData.setIdamStatus("ACTIVE"); + userProfileUpdatedData.setEmail(invitedUserEmail); + userProfileUpdatedData.setFirstName("firstName"); + userProfileUpdatedData.setLastName("lastName"); + Map modifiedUserResponse = professionalApiClient + .modifyUserToExistingUserForPrdAdmin(HttpStatus.OK, userProfileUpdatedData, intActiveOrgId, + activeUserId); PbaRequest deletePbaRequest = new PbaRequest(); deletePbaRequest.setPaymentAccounts(organisationCreationRequest.getPaymentAccount()); professionalApiClient.deletePaymentAccountsOfOrganisationInternal(deletePbaRequest, - professionalApiClient.getMultipleAuthHeadersInternal(), NO_CONTENT); + professionalApiClient.getMultipleAuthHeadersInternal(),intActiveOrgId, NO_CONTENT); JsonPath jsonPath = professionalApiClient.retrieveOrganisationDetails(intActiveOrgId, hmctsAdmin, OK); assertThat(jsonPath).isNotNull(); diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java index a84b058a01..d968a51b43 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/client/ProfessionalApiClient.java @@ -1704,10 +1704,11 @@ public void deletePaymentAccountsOfOrganisation(PbaRequest deletePbaRequest, public void deletePaymentAccountsOfOrganisationInternal(PbaRequest deletePbaRequest, RequestSpecification requestSpecification, + String organisationIdentifier, HttpStatus expectedStatus) { Response response = requestSpecification .body(deletePbaRequest) - .delete("/refdata/internal/v1/organisations/pba") + .delete("/refdata/internal/v1/organisations/pba/" + organisationIdentifier) .andReturn(); response.then() diff --git a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java index 04a010fbae..cbc53ce830 100644 --- a/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java +++ b/src/main/java/uk/gov/hmcts/reform/professionalapi/controller/internal/OrganisationInternalController.java @@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import uk.gov.hmcts.reform.professionalapi.configuration.resolver.OrgId; import uk.gov.hmcts.reform.professionalapi.configuration.resolver.UserId; import uk.gov.hmcts.reform.professionalapi.controller.SuperController; import uk.gov.hmcts.reform.professionalapi.controller.advice.ErrorResponse; @@ -748,16 +747,19 @@ public ResponseEntity retrieveOrganisationByUserId( content = @Content ) - @DeleteMapping(path = "/pba") + @DeleteMapping( + value = "/pba/{orgId}" + ) @ResponseStatus(value = HttpStatus.NO_CONTENT) - @Secured({"prd-admin"}) + @ResponseBody + @Secured("prd-admin") public void deletePaymentAccountsForOrganisation( @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "deletePbaRequest") @Valid @NotNull @RequestBody PbaRequest deletePbaRequest, - @Parameter(hidden = true) @OrgId String orgIdentifier, + @PathVariable("orgId") @NotBlank String organisationIdentifier, @Parameter(hidden = true) @UserId String userId) { - deletePaymentAccountsOfGivenOrganisation(deletePbaRequest, orgIdentifier, userId); + deletePaymentAccountsOfGivenOrganisation(deletePbaRequest, organisationIdentifier, userId); } @@ -769,7 +771,6 @@ public void deletePaymentAccountsForOrganisation( @SecurityRequirement(name = "ServiceAuthorization") } ) - @ApiResponse( responseCode = "200", description = "List of matching organisations", From 105f7a348f2e25442257d177ec2eae9b45fc91d1 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Tue, 16 Jul 2024 10:07:59 +0100 Subject: [PATCH 21/32] update functional tests --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8464ff1380..5e2b9de7af 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ def versions = [ serenity : '2.0.76', springBoot : '2.7.18', camel : '3.8.0', - pact_version : '4.1.7', + pact_version : '4.6.11', launchDarklySdk : '5.10.9', junit : '5.9.2', junitPlatform : '1.9.2', From ace6c6b9013815130fa941db311819348223689e Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Tue, 16 Jul 2024 15:34:34 +0100 Subject: [PATCH 22/32] update pact tests --- .../OrganisationalInternalControllerProviderTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalInternalControllerProviderTest.java b/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalInternalControllerProviderTest.java index 2e2f8719be..5fc73a69e6 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalInternalControllerProviderTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/professionalapi/provider/OrganisationalInternalControllerProviderTest.java @@ -356,6 +356,13 @@ private Organisation getOrganisation() { contactInformation.setCreated(LocalDateTime.now()); contactInformation.setId(UUID.randomUUID()); organisation.setContactInformations(List.of(contactInformation)); + + SuperUser superUser = new SuperUser("firstName", "lastName", + "email", organisation); + superUser.setUserIdentifier(UUID.randomUUID().toString()); + List users = new ArrayList<>(); + users.add(superUser); + organisation.setUsers(users); return organisation; } From 3e318ee12228013f1dab45a3c3b6fc2879f9f655 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Tue, 16 Jul 2024 15:35:48 +0100 Subject: [PATCH 23/32] update pact tests --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5e2b9de7af..8464ff1380 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ def versions = [ serenity : '2.0.76', springBoot : '2.7.18', camel : '3.8.0', - pact_version : '4.6.11', + pact_version : '4.1.7', launchDarklySdk : '5.10.9', junit : '5.9.2', junitPlatform : '1.9.2', From 102219a28474c1636d42b2a935287518138ba8c5 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 17 Jul 2024 11:08:22 +0100 Subject: [PATCH 24/32] update functional tests --- .../ProfessionalInternalUserFunctionalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 1e93b4d622..d1066bd492 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1234,7 +1234,7 @@ private static List> sortByValue(final List Date: Wed, 17 Jul 2024 10:18:37 +0000 Subject: [PATCH 25/32] Updating Terraform Formatting --- infrastructure/aat.tfvars | 4 +- infrastructure/main.tf | 84 ++++++++++++++++++------------------- infrastructure/prod.tfvars | 6 +-- infrastructure/terraform.tf | 2 +- infrastructure/variables.tf | 12 +++--- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/infrastructure/aat.tfvars b/infrastructure/aat.tfvars index ab7af3699f..1ba45d7e98 100644 --- a/infrastructure/aat.tfvars +++ b/infrastructure/aat.tfvars @@ -1,4 +1,4 @@ -sku_name = "GP_Gen5_4" +sku_name = "GP_Gen5_4" sku_capacity = "4" pgsql_server_configuration = [ { @@ -8,4 +8,4 @@ pgsql_server_configuration = [ { name = "backslash_quote" value = "ON" - }] +}] diff --git a/infrastructure/main.tf b/infrastructure/main.tf index 1196997858..dff95f6c14 100644 --- a/infrastructure/main.tf +++ b/infrastructure/main.tf @@ -1,11 +1,11 @@ locals { - preview_vault_name = join("-", [var.raw_product, "aat"]) - non_preview_vault_name = join("-", [var.raw_product, var.env]) - key_vault_name = var.env == "preview" || var.env == "spreview" ? local.preview_vault_name : local.non_preview_vault_name + preview_vault_name = join("-", [var.raw_product, "aat"]) + non_preview_vault_name = join("-", [var.raw_product, var.env]) + key_vault_name = var.env == "preview" || var.env == "spreview" ? local.preview_vault_name : local.non_preview_vault_name - s2s_rg_prefix = "rpe-service-auth-provider" - s2s_key_vault_name = var.env == "preview" || var.env == "spreview" ? join("-", ["s2s", "aat"]) : join("-", ["s2s", var.env]) - s2s_vault_resource_group = var.env == "preview" || var.env == "spreview" ? join("-", [local.s2s_rg_prefix, "aat"]) : join("-", [local.s2s_rg_prefix, var.env]) + s2s_rg_prefix = "rpe-service-auth-provider" + s2s_key_vault_name = var.env == "preview" || var.env == "spreview" ? join("-", ["s2s", "aat"]) : join("-", ["s2s", var.env]) + s2s_vault_resource_group = var.env == "preview" || var.env == "spreview" ? join("-", [local.s2s_rg_prefix, "aat"]) : join("-", [local.s2s_rg_prefix, var.env]) } data "azurerm_key_vault" "rd_key_vault" { @@ -19,23 +19,23 @@ data "azurerm_key_vault" "s2s_key_vault" { } data "azurerm_key_vault_secret" "s2s_secret" { - name = "microservicekey-rd-professional-api" - key_vault_id = data.azurerm_key_vault.s2s_key_vault.id + name = "microservicekey-rd-professional-api" + key_vault_id = data.azurerm_key_vault.s2s_key_vault.id } resource "azurerm_key_vault_secret" "professional_s2s_secret" { - name = "professional-api-s2s-secret" - value = data.azurerm_key_vault_secret.s2s_secret.value - key_vault_id = data.azurerm_key_vault.rd_key_vault.id + name = "professional-api-s2s-secret" + value = data.azurerm_key_vault_secret.s2s_secret.value + key_vault_id = data.azurerm_key_vault.rd_key_vault.id } resource "azurerm_resource_group" "rg" { - name = join("-", [var.product, var.component, var.env]) - location = var.location - tags = { - "Deployment Environment" = var.env - "Team Name" = var.team_name - "lastUpdated" = timestamp() + name = join("-", [var.product, var.component, var.env]) + location = var.location + tags = { + "Deployment Environment" = var.env + "Team Name" = var.team_name + "lastUpdated" = timestamp() } } @@ -63,49 +63,49 @@ module "db-professional-ref-data-v16" { force_user_permissions_trigger = "3" # Sets correct DB owner after migration to fix permissions - enable_schema_ownership = var.enable_schema_ownership + enable_schema_ownership = var.enable_schema_ownership force_schema_ownership_trigger = "3" - kv_subscription = var.kv_subscription - kv_name = data.azurerm_key_vault.rd_key_vault.name - user_secret_name = azurerm_key_vault_secret.POSTGRES-USER.name - pass_secret_name = azurerm_key_vault_secret.POSTGRES-PASS.name + kv_subscription = var.kv_subscription + kv_name = data.azurerm_key_vault.rd_key_vault.name + user_secret_name = azurerm_key_vault_secret.POSTGRES-USER.name + pass_secret_name = azurerm_key_vault_secret.POSTGRES-PASS.name - subnet_suffix = "expanded" - pgsql_version = "16" - pgsql_sku = var.pgsql_sku - product = "rd" - name = join("-", [var.product-v16, var.component-v16]) + subnet_suffix = "expanded" + pgsql_version = "16" + pgsql_sku = var.pgsql_sku + product = "rd" + name = join("-", [var.product-v16, var.component-v16]) pgsql_server_configuration = var.pgsql_server_configuration } resource "azurerm_key_vault_secret" "POSTGRES-USER" { - name = join("-", [var.component, "POSTGRES-USER"]) - value = module.db-professional-ref-data-v16.username - key_vault_id = data.azurerm_key_vault.rd_key_vault.id + name = join("-", [var.component, "POSTGRES-USER"]) + value = module.db-professional-ref-data-v16.username + key_vault_id = data.azurerm_key_vault.rd_key_vault.id } resource "azurerm_key_vault_secret" "POSTGRES_HOST" { - name = join("-", [var.component, "POSTGRES-HOST"]) - value = module.db-professional-ref-data-v16.fqdn - key_vault_id = data.azurerm_key_vault.rd_key_vault.id + name = join("-", [var.component, "POSTGRES-HOST"]) + value = module.db-professional-ref-data-v16.fqdn + key_vault_id = data.azurerm_key_vault.rd_key_vault.id } resource "azurerm_key_vault_secret" "POSTGRES-PASS" { - name = join("-", [var.component, "POSTGRES-PASS"]) - value = module.db-professional-ref-data-v16.password - key_vault_id = data.azurerm_key_vault.rd_key_vault.id + name = join("-", [var.component, "POSTGRES-PASS"]) + value = module.db-professional-ref-data-v16.password + key_vault_id = data.azurerm_key_vault.rd_key_vault.id } resource "azurerm_key_vault_secret" "POSTGRES_DATABASE" { - name = join("-", [var.component, "POSTGRES-DATABASE"]) - value = "dbrefdata" - key_vault_id = data.azurerm_key_vault.rd_key_vault.id + name = join("-", [var.component, "POSTGRES-DATABASE"]) + value = "dbrefdata" + key_vault_id = data.azurerm_key_vault.rd_key_vault.id } resource "azurerm_key_vault_secret" "POSTGRES_PORT" { - name = join("-", [var.component, "POSTGRES-PORT"]) - value = "5432" - key_vault_id = data.azurerm_key_vault.rd_key_vault.id + name = join("-", [var.component, "POSTGRES-PORT"]) + value = "5432" + key_vault_id = data.azurerm_key_vault.rd_key_vault.id } \ No newline at end of file diff --git a/infrastructure/prod.tfvars b/infrastructure/prod.tfvars index a1a128c564..83a49aed5f 100644 --- a/infrastructure/prod.tfvars +++ b/infrastructure/prod.tfvars @@ -1,4 +1,4 @@ -sku_name = "GP_Gen5_4" -sku_capacity = "4" +sku_name = "GP_Gen5_4" +sku_capacity = "4" enable_schema_ownership = true -kv_subscription = "DCD-CNP-Prod" \ No newline at end of file +kv_subscription = "DCD-CNP-Prod" \ No newline at end of file diff --git a/infrastructure/terraform.tf b/infrastructure/terraform.tf index a599082d9a..d07b7ced07 100644 --- a/infrastructure/terraform.tf +++ b/infrastructure/terraform.tf @@ -18,7 +18,7 @@ terraform { required_providers { azurerm = { - source = "hashicorp/azurerm" + source = "hashicorp/azurerm" version = "~> 3.106" } azuread = { diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index a91434909c..550b2d859b 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -33,21 +33,21 @@ variable "team_name" { default = "RD" } -variable sku_name { +variable "sku_name" { default = "GP_Gen5_2" } -variable sku_capacity { +variable "sku_capacity" { default = "2" } variable "product-v16" { - type = string - default="rd-professional-api" + type = string + default = "rd-professional-api" } variable "component-v16" { - type = string - default="postgres-db-v16" + type = string + default = "postgres-db-v16" } variable "aks_subscription_id" { From 9a1d5a3420b79c3a2b4cc1f61b40d951dfa7d9b8 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 17 Jul 2024 12:16:41 +0100 Subject: [PATCH 26/32] update pact tests --- .../professionalapi/ProfessionalInternalUserFunctionalTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index d1066bd492..753bcbca1b 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1298,5 +1298,6 @@ void deletePbaOfExistingOrganisationShouldBeSuccess() { assertThat(paymentAccounts).isEmpty(); log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: END"); } + } From a6d93b3e70f4c0084b482aadbd20753d44c449c0 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 17 Jul 2024 12:21:13 +0100 Subject: [PATCH 27/32] update pact tests --- infrastructure/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 550b2d859b..53a9edc566 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -33,11 +33,11 @@ variable "team_name" { default = "RD" } -variable "sku_name" { +variable sku_name { default = "GP_Gen5_2" } -variable "sku_capacity" { +variable sku_capacity { default = "2" } From a7cee3c5febe6cb0e8674a08567a7e939999be6a Mon Sep 17 00:00:00 2001 From: 54687 <61242337+hmcts-jenkins-j-to-z[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:31:26 +0000 Subject: [PATCH 28/32] Updating Terraform Formatting --- infrastructure/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 53a9edc566..550b2d859b 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -33,11 +33,11 @@ variable "team_name" { default = "RD" } -variable sku_name { +variable "sku_name" { default = "GP_Gen5_2" } -variable sku_capacity { +variable "sku_capacity" { default = "2" } From 5868e2d41132cd73a13d530211eb724035a2dcde Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 17 Jul 2024 13:22:26 +0100 Subject: [PATCH 29/32] update infrastructure tests --- infrastructure/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 550b2d859b..53a9edc566 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -33,11 +33,11 @@ variable "team_name" { default = "RD" } -variable "sku_name" { +variable sku_name { default = "GP_Gen5_2" } -variable "sku_capacity" { +variable sku_capacity { default = "2" } From 359748f4aceae0cb8e6744805c80bc227490d882 Mon Sep 17 00:00:00 2001 From: 54687 <61242337+hmcts-jenkins-j-to-z[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:32:50 +0000 Subject: [PATCH 30/32] Updating Terraform Formatting --- infrastructure/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 53a9edc566..550b2d859b 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -33,11 +33,11 @@ variable "team_name" { default = "RD" } -variable sku_name { +variable "sku_name" { default = "GP_Gen5_2" } -variable sku_capacity { +variable "sku_capacity" { default = "2" } From 6b4cb25df698f25271d96f8cacf4030db27d519b Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 17 Jul 2024 13:57:44 +0100 Subject: [PATCH 31/32] update infrastructure tests --- infrastructure/terraform.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/terraform.tf b/infrastructure/terraform.tf index d07b7ced07..a599082d9a 100644 --- a/infrastructure/terraform.tf +++ b/infrastructure/terraform.tf @@ -18,7 +18,7 @@ terraform { required_providers { azurerm = { - source = "hashicorp/azurerm" + source = "hashicorp/azurerm" version = "~> 3.106" } azuread = { From 88a26aea49a7681cc9797d21fd6b591b93cee316 Mon Sep 17 00:00:00 2001 From: SabinaHMCTS Date: Wed, 17 Jul 2024 14:24:05 +0100 Subject: [PATCH 32/32] update functional tests --- .../ProfessionalInternalUserFunctionalTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java index 753bcbca1b..c52ff324ec 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/professionalapi/ProfessionalInternalUserFunctionalTest.java @@ -1234,8 +1234,7 @@ private static List> sortByValue(final List