-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dtsrd 2140 #1583
base: master
Are you sure you want to change the base?
Dtsrd 2140 #1583
Changes from 6 commits
9a50a6d
a7e03dd
3c3c8b0
079a36a
32334dd
44e0348
86f7180
f9127ca
7edaedb
df8f113
8fe15f3
55c4eca
c7061b2
e44d1a1
1395bbe
a62cb16
06d015b
e1bbd1c
82d3290
80d5dd2
1f6254a
09af566
c0071af
90b15c6
105f7a3
ace6c6b
3e318ee
102219a
582530e
9a1d5a3
a6d93b3
a7cee3c
5868e2d
359748f
6b4cb25
eb47f62
88a26ae
25f64fb
b65f862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<String, Object> organisations = professionalApiClient | ||
.retrieveAllOrganisationsWithPagination(hmctsAdmin, "1", "2"); | ||
.retrieveAllOrganisationsWithPagination(hmctsAdmin, "1", "2"); | ||
|
||
assertThat(organisations).isNotNull().hasSize(2); | ||
|
||
|
@@ -1231,4 +1231,59 @@ private static List<Map<String, Object>> sortByValue(final List<Map<String, Obje | |
.sorted(Comparator.comparing(map -> (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<String> 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<String> 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line making a call to existing external endpoint, so this test is invalid. make change to call new internal endpoint with prd-admin user |
||
professionalApiClient.getMultipleAuthHeaders(null), NO_CONTENT); | ||
|
||
Map<String, Object> response = professionalApiClient.retrieveOrganisationByOrgIdExternal(OK, | ||
professionalApiClient.getMultipleAuthHeaders(null)); | ||
|
||
var paymentAccounts = (List<String>) response.get("paymentAccount"); | ||
assertThat(paymentAccounts).isEmpty(); | ||
log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: END"); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,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; | ||
|
@@ -697,6 +702,65 @@ public ResponseEntity<OrganisationEntityResponse> retrieveOrganisationByUserId( | |
return organisationService.retrieveOrganisationByUserId(userId); | ||
} | ||
|
||
|
||
|
||
@Operation( | ||
summary = "Deletes the provided list of payment accounts from the organisation.", | ||
description = "**IDAM Roles to access API** : <br> - pui-finance-manager", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrong role , it should be prd-admin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
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); | ||
|
||
} | ||
|
||
|
||
@Operation( | ||
summary = "Retrieves Organisations by Organisation Profile IDs", | ||
description = "**Bearer token not required to access API. Only a valid s2s token**", | ||
|
@@ -745,4 +809,5 @@ public ResponseEntity<Object> retrieveOrganisationsByProfileIds( | |
.status(HttpStatus.OK) | ||
.body(response); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line making a call to existing external endpoint, so this test is invalid. make change to call new internal endpoint with prd-admin user