diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/DeviceDetailController.java b/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/DeviceDetailController.java index 649a3d239d..9012309204 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/DeviceDetailController.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/DeviceDetailController.java @@ -11,7 +11,7 @@ import io.mosip.pms.partner.request.dto.SbiAndDeviceMappingRequestDto; import io.mosip.pms.device.response.dto.DeviceDetailResponseDto; import io.mosip.pms.partner.util.PartnerHelper; -import io.mosip.pms.partner.util.RequestValidator; +import io.mosip.pms.common.util.RequestValidator; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.media.Content; @@ -283,7 +283,7 @@ public ResponseWrapperV2 approveOrRejectMappingDeviceToSbi(@PathVariabl } @PreAuthorize("hasAnyRole(@authorizedRoles.getGetalldevicedetails())") - @GetMapping(value = "/search/v2") + @GetMapping(value = "/v2") @Operation(summary = "This endpoint retrieves a list of all the Devices.", description = "Avaiable since release-1.3.x. This endpoint supports pagination, sorting, and filtering. It is configured for the role PARTNER_ADMIN.") @io.swagger.v3.oas.annotations.responses.ApiResponses(value = { diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/FTPChipDetailController.java b/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/FTPChipDetailController.java index cc7c75cd51..1562efe8f8 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/FTPChipDetailController.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/FTPChipDetailController.java @@ -18,7 +18,7 @@ import io.mosip.pms.device.response.dto.*; import io.mosip.pms.partner.response.dto.FtmCertificateDownloadResponseDto; import io.mosip.pms.partner.util.PartnerHelper; -import io.mosip.pms.partner.util.RequestValidator; +import io.mosip.pms.common.util.RequestValidator; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.media.Content; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/SecureBiometricInterfaceController.java b/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/SecureBiometricInterfaceController.java index 75c6371393..c9312595b6 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/SecureBiometricInterfaceController.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/device/controller/SecureBiometricInterfaceController.java @@ -11,7 +11,7 @@ import io.mosip.pms.device.response.dto.SbiDetailsResponseDto; import io.mosip.pms.device.dto.SbiDetailsDto; import io.mosip.pms.partner.util.PartnerHelper; -import io.mosip.pms.partner.util.RequestValidator; +import io.mosip.pms.common.util.RequestValidator; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.media.Content; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/ErrorCode.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/ErrorCode.java index a69e7261f0..25a3ab917f 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/ErrorCode.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/ErrorCode.java @@ -86,8 +86,8 @@ public enum ErrorCode { PARTNER_DOES_NOT_BELONG_TO_THE_USER("PMS_CERTIFICATE_ERROR_007", "The given partner ID does not belong to the user.So unable to get the original partner certificates"), CERTIFICATE_FETCH_ERROR("PMS_CERTIFICATE_ERROR_008","Error while fetching certificate."), DEACTIVATED_PARTNER_CERTIFICATE_DOWNLOAD_ERROR("PMS_CERTIFICATE_ERROR_009","Unable to download the certificate for a deactivated partner"), - CA_CERTIFICATES_FETCH_ERROR("PMS_CERTIFICATE_ERROR_010", "Error while fetching CA certificates."), - DOWNLOAD_CA_CERTIFICATE_ERROR("PMS_CERTIFICATE_ERROR_011", "Error while downloading CA certificate."), + TRUST_CERTIFICATES_FETCH_ERROR("PMS_CERTIFICATE_ERROR_010", "Error while fetching trust certificates."), + DOWNLOAD_TRUST_CERTIFICATE_ERROR("PMS_CERTIFICATE_ERROR_011", "Error while downloading trust certificates."), INVALID_CERTIFICATE_ID("PMS_CERTIFICATE_ERROR_012", "Certificate id is null or empty"), POLICY_GROUP_NOT_EXISTS("PMS_POLICY_ERROR_001","Policy Group does not exists."), PARTNER_POLICY_FETCH_ERROR("PMS_POLICY_ERROR_002","Error while fetching partner policies."), @@ -108,11 +108,6 @@ public enum ErrorCode { INVALID_DEVICE_PARTNER_TYPE("PMS_DEVICE_ERROR_003", "Invalid partner type."), DEVICES_LIST_FOR_SBI_FETCH_ERROR("PMS_SF_ERROR_001", "Error while fetching devices list for SBI."), INVALID_REQUEST_PARAM("PMS_REQUEST_ERROR_001", "Invalid request."), - INVALID_REQUEST_ID("PMS_REQUEST_ERROR_002", "Invalid Request Id"), - INVALID_REQUEST_VERSION("PMS_REQUEST_ERROR_003", "Request version is invalid"), - INVALID_REQUEST_DATETIME("PMS_REQUEST_ERROR_004", "Invalid request time"), - INVALID_REQUEST_BODY("PMS_REQUEST_ERROR_005", "Request body is invalid"), - INVALID_REQUEST_DATETIME_NOT_CURRENT_DATE("PMS_REQUEST_ERROR_006", "Request date should be current date"), SBI_DEVICE_MAPPING_ALREADY_EXIST("PMS_DEVICE_ERROR_004", "SBI and Device mapping already exists."), SBI_NOT_EXISTS("PMS_DEVICE_ERROR_005", "SBI do not exists."), DEVICE_NOT_EXISTS("PMS_DEVICE_ERROR_006", "Device do not exists."), diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java index 5854f78779..4e739031ad 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java @@ -371,19 +371,19 @@ public ResponseWrapperV2> getPartnerCertificatesDetails() { return partnerService.getPartnerCertificatesDetails(); } - @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersv4())") - @GetMapping(value = "/v4") + @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersv3())") + @GetMapping(value = "/v3") @Operation(summary = "This endpoint retrieves a list of Partners associated with the logged in user, based on the query parameters", description = "Avaiable since release-1.3.x. It is configured for role any of the partner type or PARTNER_ADMIN.") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true)))}) - public ResponseWrapperV2> getPartnersV4( + public ResponseWrapperV2> getPartnersV3( @RequestParam(name = "status") String status, @RequestParam(name = "policyGroupAvailable", required = false) Boolean policyGroupAvailable, @RequestParam(name = "partnerType", required = false) String partnerType) { - return partnerService.getPartnersV4(status, policyGroupAvailable, partnerType); + return partnerService.getPartnersV3(status, policyGroupAvailable, partnerType); } @PreAuthorize("hasAnyRole(@authorizedRoles.getGetapikeysforauthpartners())") diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java index 418a53afac..216a462877 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java @@ -135,7 +135,7 @@ public class AuthorizedRolesDto { private List patchpartnerspolicyapikeystatus; - private List getallpartners; + private List getadminpartners; //MISP License controller @@ -189,10 +189,10 @@ public class AuthorizedRolesDto { private List getalldevicedetails; - private List getallcacertificates; + private List gettrustcertificates; - private List getdownloadrootcertificate; + private List getdownloadtrustcertificates; - private List getpartnersv4; + private List getpartnersv3; } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/PartnerDtoV4.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/PartnerDtoV3.java similarity index 96% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/PartnerDtoV4.java rename to partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/PartnerDtoV3.java index e01eeaf410..3c6cff2563 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/PartnerDtoV4.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/PartnerDtoV3.java @@ -8,7 +8,7 @@ @Data @Getter @Setter -public class PartnerDtoV4 { +public class PartnerDtoV3 { @Schema(description = "Unique identifier for the partner", example = "partner123") private String partnerId; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/controller/PartnerManagementController.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/controller/PartnerManagementController.java index fbe523e207..43d06b9855 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/controller/PartnerManagementController.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/controller/PartnerManagementController.java @@ -8,9 +8,9 @@ import io.mosip.pms.common.dto.PageResponseV2Dto; import io.mosip.pms.common.response.dto.ResponseWrapperV2; -import io.mosip.pms.partner.manager.dto.CaCertificateFilterDto; +import io.mosip.pms.partner.manager.dto.TrustCertificateFilterDto; import io.mosip.pms.partner.manager.dto.*; -import io.mosip.pms.partner.manager.dto.CaCertificateSummaryDto; +import io.mosip.pms.partner.manager.dto.TrustCertificateSummaryDto; import io.mosip.pms.partner.util.PartnerHelper; import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.Parameter; @@ -57,7 +57,6 @@ */ @RestController -@RequestMapping(value = "/partners") @Api(tags = { "Partner Management Controller" }) public class PartnerManagementController { @@ -82,7 +81,7 @@ public class PartnerManagementController { * @return response this class contains massage about API key created successfully */ @PreAuthorize("hasAnyRole(@authorizedRoles.getPutpartnersapikeypolicies())") - @RequestMapping(value = "/{partnerId}/apikey/{apikey}/policies", method = RequestMethod.PUT) + @RequestMapping(value = "/partners/{partnerId}/apikey/{apikey}/policies", method = RequestMethod.PUT) @Operation(summary = "Service to update policies against to API key", description = "Service to update policies against to API key") public ResponseEntity> partnerApiKeyToPolicyMappings( @RequestBody @Valid RequestWrapper request, @@ -108,7 +107,7 @@ public ResponseEntity> partnerApi * @return respons this class contains massage about Partner status updated successfully */ @PreAuthorize("hasAnyRole(@authorizedRoles.getPatchpartners())") - @RequestMapping(value = "/{partnerId}", method = RequestMethod.PATCH) + @RequestMapping(value = "/partners/{partnerId}", method = RequestMethod.PATCH) @Operation(summary = "Service to activate/de-activate partner", description = "Service to activate/de-activate partner") public ResponseEntity> activateDeactivatePartner( @PathVariable String partnerId, @@ -134,7 +133,7 @@ public ResponseEntity> activateDe */ @Deprecated(since = "release-1.3.x") @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartners())") - @RequestMapping(method = RequestMethod.GET) + @RequestMapping(value = "/partners", method = RequestMethod.GET) @Operation(summary = "Service to get partner details - deprecated since release-1.3.x.", description = "This endpoint has been deprecated since the release-1.3.x and replaced by the GET /partners/v3 endpoint") public ResponseEntity> getPartners( @@ -156,7 +155,7 @@ public ResponseEntity> getPartne */ @Deprecated(since = "release-1.3.x") @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersnew())") - @RequestMapping(value = "/v2", method = RequestMethod.GET) + @RequestMapping(value = "/partners/v2", method = RequestMethod.GET) @Operation(summary = "Service to get partner details - deprecated since release-1.3.x.", description = "This endpoint has been deprecated since the release-1.3.x and replaced by the GET /partners/v3 endpoint") public ResponseEntity> getPartnersDeatils( @@ -182,7 +181,7 @@ public ResponseEntity> getPartnersDeatil * @return response this class contains partnerID and policyId */ @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersapikey())") - @RequestMapping(value = "/{partnerId}/apikey/{apikey}" , method = RequestMethod.GET) + @RequestMapping(value = "/partners/{partnerId}/apikey/{apikey}" , method = RequestMethod.GET) @Operation(summary = "Service to get policy for given API key", description = "Service to get policy for given API key") public ResponseEntity> getPolicyMappedToAPIKey( @PathVariable String partnerId, @@ -205,7 +204,7 @@ public ResponseEntity> ge */ @Deprecated(since = "release-1.3.x") @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersapikey())") - @RequestMapping(value = "/apikey" , method = RequestMethod.GET) + @RequestMapping(value = "/partners/apikey" , method = RequestMethod.GET) @Operation(summary = "Service to get API key requests - deprecated since release-1.3.x.", description = "This endpoint has been deprecated since the release-1.3.x and replaced by the GET /partners/partner-policy-requests endpoint") public ResponseEntity> getAPIKeyRequests(){ @@ -226,7 +225,7 @@ public ResponseEntity> getAPIKeyR * @return response this class contains details related to Partner API key to Policy Mappings */ @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersapikey())") - @RequestMapping(value = "/apikey/{apikey}" , method = RequestMethod.GET) + @RequestMapping(value = "/partners/apikey/{apikey}" , method = RequestMethod.GET) @Operation(summary = "Service to get API key request", description = "Service to get API key request") public ResponseEntity> getAPIKeyRequest( @PathVariable String apikey) { @@ -240,7 +239,7 @@ public ResponseEntity> getAPIKeyRequest( } @PreAuthorize("hasAnyRole(@authorizedRoles.getPutpartnerspolicymapping())") - @RequestMapping(value = "/policy/{mappingkey}", method = RequestMethod.PUT) + @RequestMapping(value = "/partners/policy/{mappingkey}", method = RequestMethod.PUT) @Operation(summary = "Service to approve/reject partner policy mapping", description = "Service to approve/reject partner policy mapping") public ResponseEntity> approveRejectPolicyMappings( @RequestBody @Valid RequestWrapper request, @@ -254,7 +253,7 @@ public ResponseEntity> approveRejectPolicyMappings( } @PreAuthorize("hasAnyRole(@authorizedRoles.getPatchpartnerspolicyapikeystatus())") - @RequestMapping(value = "/{partnerId}/policy/{policyId}/apiKey/status", method = RequestMethod.PATCH) + @RequestMapping(value = "/partners/{partnerId}/policy/{policyId}/apiKey/status", method = RequestMethod.PATCH) @Operation(summary = "Service to activate/de-activate partner API key", description = "Service to activate/de-activate partner API key") public ResponseEntity> activateDeactivatePartnerAPIKey(@PathVariable String partnerId, @PathVariable String policyId, @RequestBody @Valid RequestWrapper request) { @@ -268,7 +267,7 @@ public ResponseEntity> activateDeactivatePartnerAPIKey(@ } @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnerdetails())") - @GetMapping(value = "/{partnerId}/v2") + @GetMapping(value = "/admin-partners/{partnerId}") @Operation(summary = "This endpoint retrieves all the details of the Partner based on Partner Id.", description = "Avaiable since release-1.3.x. It is configured for the role PARTNER_ADMIN.") @ApiResponses(value = { @@ -280,8 +279,8 @@ public ResponseWrapperV2 getPartnerDetails(@PathVariable St return partnerManagementService.getPartnerDetails(partnerId); } - @PreAuthorize("hasAnyRole(@authorizedRoles.getGetallpartners())") - @GetMapping(value = "/v3") + @PreAuthorize("hasAnyRole(@authorizedRoles.getGetadminpartners())") + @GetMapping(value = "/admin-partners") @Operation(summary = "This endpoint retrieves a list of all Partners.", description = "Avaiable since release-1.3.x. This endpoint supports pagination, sorting, and filtering. It is configured for the role PARTNER_ADMIN.") @ApiResponses(value = { @@ -289,7 +288,7 @@ public ResponseWrapperV2 getPartnerDetails(@PathVariable St @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))) }) - public ResponseWrapperV2> getAllPartners( + public ResponseWrapperV2> getAdminPartners( @RequestParam(value = "sortFieldName", required = false) String sortFieldName, @RequestParam(value = "sortType", required = false) String sortType, // e.g., ASC or DESC @RequestParam(value = "pageNo", defaultValue = "0") int pageNo, @@ -330,11 +329,11 @@ public ResponseWrapperV2> getAllPartners( if (isActive != null) { partnerFilterDto.setIsActive(isActive); } - return partnerManagementService.getAllPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto); + return partnerManagementService.getAdminPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto); } @PreAuthorize("hasAnyRole(@authorizedRoles.getGetallpartnerpolicymappingrequests())") - @GetMapping(value = "/partner-policy-requests") + @GetMapping(value = "/partners/partner-policy-requests") @Operation(summary = "This endpoint retrieves a list of all the Policy Requests made by all the Partners.", description = "Avaiable since release-1.3.x. This endpoint supports pagination, sorting, and filtering. It is configured for the role PARTNER_ADMIN.") @ApiResponses(value = { @@ -391,7 +390,7 @@ public ResponseWrapperV2> getA } @PreAuthorize("hasAnyRole(@authorizedRoles.getGetpartnersapikeyrequests())") - @GetMapping(value = "/apikey/search/v2") + @GetMapping(value = "/partners/apikey/search/v2") @Operation(summary = "This endpoint retrieves a list of all the API keys created by all the Auth Partners.", description = "Avaiable since release-1.3.x. This endpoint supports pagination, sorting, and filtering. It is configured for the role PARTNER_ADMIN.") @ApiResponses(value = { @@ -439,16 +438,16 @@ public ResponseWrapperV2> getAllApiKe return partnerManagementService.getAllApiKeyRequests(sortFieldName, sortType, pageNo, pageSize, filterDto); } - @PreAuthorize("hasAnyRole(@authorizedRoles.getGetallcacertificates())") - @GetMapping(value = "/root-certificates") - @Operation(summary = "This endpoint retrieves a list of all the Root Trust Certificates uploaded by the Partner Admin.", + @PreAuthorize("hasAnyRole(@authorizedRoles.getGettrustcertificates())") + @GetMapping(value = "/trust-chain-certificates") + @Operation(summary = "This endpoint retrieves a list of all the Trust Certificates uploaded by the Partner Admin.", description = "Avaiable since release-1.3.x. This endpoint supports pagination, sorting, and filtering. It is configured for the role PARTNER_ADMIN.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))) }) - public ResponseWrapperV2> getCaCertificates( + public ResponseWrapperV2> getTrustCertificates( @RequestParam(value = "sortFieldName", required = false) String sortFieldName, @RequestParam(value = "sortType", required = false) String sortType, // e.g., ASC or DESC @RequestParam(value = "pageNo", defaultValue = "0") int pageNo, @@ -469,8 +468,8 @@ public ResponseWrapperV2> getCaCertif @RequestParam(value = "issuedTo", required = false) String issuedTo, @RequestParam(value = "issuedBy", required = false) String issuedBy ) { - partnerHelper.validateRequestParameters(partnerHelper.caCertificateAliasToColumnMap, sortFieldName, sortType, pageNo, pageSize); - CaCertificateFilterDto filterDto = new CaCertificateFilterDto(); + partnerHelper.validateRequestParameters(partnerHelper.trustCertificateAliasToColumnMap, sortFieldName, sortType, pageNo, pageSize); + TrustCertificateFilterDto filterDto = new TrustCertificateFilterDto(); if (caCertificateType != null) { filterDto.setCaCertificateType(caCertificateType); } @@ -486,11 +485,11 @@ public ResponseWrapperV2> getCaCertif if (issuedBy != null) { filterDto.setIssuedBy(issuedBy); } - return partnerManagementService.getCaCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto); + return partnerManagementService.getTrustCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto); } - @PreAuthorize("hasAnyRole(@authorizedRoles.getGetdownloadrootcertificate())") - @GetMapping(value = "/download-root-certificate/{certificateId}") + @PreAuthorize("hasAnyRole(@authorizedRoles.getGetdownloadtrustcertificates())") + @GetMapping(value = "/trust-chain-certificates/{certificateId}/certificateFile") @Operation(summary = "This endpoint will download p7b file for a CA / Intermediate CA certificate along with the trust chain based on Certificate Id.", description = "Avaiable since release-1.3.x. It is configured for the role PARTNER_ADMIN.") @ApiResponses(value = { @@ -498,8 +497,8 @@ public ResponseWrapperV2> getCaCertif @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))) }) - ResponseWrapperV2 downloadRootCertificate( - @ApiParam("To download root certificate.") @PathVariable("certificateId") @NotNull String certificateId) { - return partnerManagementService.downloadRootCertificate(certificateId); + ResponseWrapperV2 downloadTrustCertificates( + @ApiParam("To download trust certificates.") @PathVariable("certificateId") @NotNull String certificateId) { + return partnerManagementService.downloadTrustCertificates(certificateId); } } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertTypeListRequestDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertTypeListRequestDto.java similarity index 98% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertTypeListRequestDto.java rename to partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertTypeListRequestDto.java index dd866b4fef..5f8db7d55c 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertTypeListRequestDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertTypeListRequestDto.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @ApiModel(description = "Model representing request to get CA/Sub-CA certificates.") -public class CaCertTypeListRequestDto { +public class TrustCertTypeListRequestDto { /** * Certificate Type diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertTypeListResponseDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertTypeListResponseDto.java similarity index 79% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertTypeListResponseDto.java rename to partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertTypeListResponseDto.java index 50c2a94459..102f190a28 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertTypeListResponseDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertTypeListResponseDto.java @@ -11,11 +11,11 @@ @AllArgsConstructor @NoArgsConstructor @ApiModel(description = "Class representing All CA Certificate Data Response") -public class CaCertTypeListResponseDto { +public class TrustCertTypeListResponseDto { private int pageNumber; private int pageSize; private long totalRecords; private int totalPages; - private List allPartnerCertificates; + private List allPartnerCertificates; } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertificateFilterDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateFilterDto.java similarity index 85% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertificateFilterDto.java rename to partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateFilterDto.java index 292f04af1d..7c13f08f89 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertificateFilterDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateFilterDto.java @@ -3,7 +3,7 @@ import lombok.Data; @Data -public class CaCertificateFilterDto { +public class TrustCertificateFilterDto { private String caCertificateType; private String certificateId; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CACertificateResponseDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateResponseDto.java similarity index 89% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CACertificateResponseDto.java rename to partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateResponseDto.java index 1e94efd68c..3929aa792c 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CACertificateResponseDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateResponseDto.java @@ -9,7 +9,7 @@ @Data @AllArgsConstructor @NoArgsConstructor -public class CACertificateResponseDto { +public class TrustCertificateResponseDto { /** * CA Certificate Data diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertificateSummaryDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateSummaryDto.java similarity index 97% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertificateSummaryDto.java rename to partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateSummaryDto.java index 6e2b34617e..9b8c9ac8fd 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/CaCertificateSummaryDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/dto/TrustCertificateSummaryDto.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; @Data -public class CaCertificateSummaryDto { +public class TrustCertificateSummaryDto { @Schema(description = "Type of the CA certificate (e.g., ROOT, INTERMEDIATE)", example = "ROOT") private String caCertificateType; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/PartnerManagerService.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/PartnerManagerService.java index 966b41c011..743d5c6ca6 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/PartnerManagerService.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/PartnerManagerService.java @@ -5,12 +5,12 @@ import io.mosip.pms.common.dto.PageResponseV2Dto; import io.mosip.pms.common.response.dto.ResponseWrapperV2; -import io.mosip.pms.partner.manager.dto.CaCertificateFilterDto; +import io.mosip.pms.partner.manager.dto.TrustCertificateFilterDto; import io.mosip.pms.partner.manager.dto.*; import io.mosip.pms.partner.request.dto.APIKeyGenerateRequestDto; import io.mosip.pms.partner.request.dto.APIkeyStatusUpdateRequestDto; import io.mosip.pms.partner.response.dto.APIKeyGenerateResponseDto; -import io.mosip.pms.partner.manager.dto.CaCertificateSummaryDto; +import io.mosip.pms.partner.manager.dto.TrustCertificateSummaryDto; public interface PartnerManagerService { @@ -94,13 +94,13 @@ public PartnersPolicyMappingResponse activateDeactivateAuthEKYCPartner(String pa public ResponseWrapperV2 getPartnerDetails(String partnerId); - public ResponseWrapperV2> getAllPartners(String sortFieldName, String sortType, int pageNo, int pageSize, PartnerFilterDto partnerFilterDto); + public ResponseWrapperV2> getAdminPartners(String sortFieldName, String sortType, int pageNo, int pageSize, PartnerFilterDto partnerFilterDto); public ResponseWrapperV2> getAllPartnerPolicyRequests(String sortFieldName, String sortType, int pageNo, int pageSize, PartnerPolicyRequestFilterDto filterDto); public ResponseWrapperV2> getAllApiKeyRequests(String sortFieldName, String sortType, int pageNo, int pageSize, ApiKeyFilterDto filterDto); - public ResponseWrapperV2> getCaCertificates(String sortFieldName, String sortType, int pageNo, int pageSize, CaCertificateFilterDto filterDto); + public ResponseWrapperV2> getTrustCertificates(String sortFieldName, String sortType, int pageNo, int pageSize, TrustCertificateFilterDto filterDto); - public ResponseWrapperV2 downloadRootCertificate(String certificateId); + public ResponseWrapperV2 downloadTrustCertificates(String certificateId); } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java index 0b0083df03..8a9d7c0ec4 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java @@ -21,14 +21,14 @@ import io.mosip.pms.common.request.dto.RequestWrapper; import io.mosip.pms.common.response.dto.ResponseWrapperV2; import io.mosip.pms.partner.dto.KeycloakUserDto; -import io.mosip.pms.partner.manager.dto.CaCertificateFilterDto; +import io.mosip.pms.partner.manager.dto.TrustCertificateFilterDto; import io.mosip.pms.partner.exception.PartnerServiceException; import io.mosip.pms.partner.manager.dto.*; import io.mosip.pms.partner.manager.dto.PartnerFilterDto; -import io.mosip.pms.partner.manager.dto.CaCertTypeListRequestDto; +import io.mosip.pms.partner.manager.dto.TrustCertTypeListRequestDto; import io.mosip.pms.partner.request.dto.PartnerCertDownloadRequestDto; -import io.mosip.pms.partner.manager.dto.CaCertTypeListResponseDto; -import io.mosip.pms.partner.manager.dto.CaCertificateSummaryDto; +import io.mosip.pms.partner.manager.dto.TrustCertTypeListResponseDto; +import io.mosip.pms.partner.manager.dto.TrustCertificateSummaryDto; import io.mosip.pms.partner.util.MultiPartnerUtil; import io.mosip.pms.partner.util.PartnerHelper; import org.json.simple.JSONObject; @@ -82,8 +82,8 @@ public class PartnerManagementServiceImpl implements PartnerManagerService { private static final String APPROVED = "approved"; public static final String BLANK_STRING = ""; - @Value("${mosip.pms.api.id.all.partners.get}") - private String getAllPartnersId; + @Value("${mosip.pms.api.id.admin.partners.get}") + private String getAdminPartnersId; @Value("${mosip.pms.api.id.all.partner.policy.mapping.requests.get}") private String getAllPartnerPolicyMappingRequestsId; @@ -91,11 +91,11 @@ public class PartnerManagementServiceImpl implements PartnerManagerService { @Value("${mosip.pms.api.id.all.api.key.requests.get}") private String getAllApiKeyRequestsId; - @Value("${mosip.pms.api.id.all.ca.certificates.get}") - private String getCaCertificatesId; + @Value("${mosip.pms.api.id.trust.certificates.get}") + private String getTrustCertificatesId; - @Value("${mosip.pms.api.id.download.ca.certificate.get}") - private String getDownloadCaCertificateId; + @Value("${mosip.pms.api.id.download.trust.certificates.get}") + private String getDownloadTrustCertificateId; @Autowired PartnerSummaryRepository partnerSummaryRepository; @@ -856,7 +856,7 @@ public ResponseWrapperV2 getPartnerDetails(String partnerId } @Override - public ResponseWrapperV2> getAllPartners(String sortFieldName, String sortType, int pageNo, int pageSize, PartnerFilterDto partnerFilterDto) { + public ResponseWrapperV2> getAdminPartners(String sortFieldName, String sortType, int pageNo, int pageSize, PartnerFilterDto partnerFilterDto) { ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); try { PageResponseV2Dto pageResponseV2Dto = new PageResponseV2Dto<>(); @@ -886,17 +886,17 @@ public ResponseWrapperV2> getAllPartners(St } responseWrapper.setResponse(pageResponseV2Dto); } catch (PartnerServiceException ex) { - LOGGER.info("sessionId", "idType", "id", "In getAllPartners method of PartnerManagementServiceImpl - " + ex.getMessage()); + LOGGER.info("sessionId", "idType", "id", "In getAdminPartners method of PartnerManagementServiceImpl - " + ex.getMessage()); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); } catch (Exception ex) { LOGGER.debug("sessionId", "idType", "id", ex.getStackTrace()); LOGGER.error("sessionId", "idType", "id", - "In getAllPartners method of PartnerManagementServiceImpl - " + ex.getMessage()); + "In getAdminPartners method of PartnerManagementServiceImpl - " + ex.getMessage()); String errorCode = ErrorCode.FETCH_ALL_PARTNER_DETAILS_ERROR.getErrorCode(); String errorMessage = ErrorCode.FETCH_ALL_PARTNER_DETAILS_ERROR.getErrorMessage(); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(errorCode, errorMessage)); } - responseWrapper.setId(getAllPartnersId); + responseWrapper.setId(getAdminPartnersId); responseWrapper.setVersion(VERSION); return responseWrapper; } @@ -990,38 +990,38 @@ public ResponseWrapperV2> getAllApiKe } @Override - public ResponseWrapperV2> getCaCertificates(String sortFieldName, String sortType, int pageNo, int pageSize, CaCertificateFilterDto filterDto) { - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + public ResponseWrapperV2> getTrustCertificates(String sortFieldName, String sortType, int pageNo, int pageSize, TrustCertificateFilterDto filterDto) { + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); try { - PageResponseV2Dto pageResponseV2Dto = new PageResponseV2Dto<>(); - CaCertTypeListRequestDto caCertTypeListRequestDto = new CaCertTypeListRequestDto(); - caCertTypeListRequestDto.setCaCertificateType(filterDto.getCaCertificateType()); - caCertTypeListRequestDto.setExcludeMosipCA(true); - caCertTypeListRequestDto.setPartnerDomain(filterDto.getPartnerDomain()); - caCertTypeListRequestDto.setCertId(filterDto.getCertificateId()); - caCertTypeListRequestDto.setIssuedTo(filterDto.getIssuedTo()); - caCertTypeListRequestDto.setIssuedBy(filterDto.getIssuedBy()); - caCertTypeListRequestDto.setPageNumber(pageNo + 1); - caCertTypeListRequestDto.setPageSize(pageSize); + PageResponseV2Dto pageResponseV2Dto = new PageResponseV2Dto<>(); + TrustCertTypeListRequestDto trustCertTypeListRequestDto = new TrustCertTypeListRequestDto(); + trustCertTypeListRequestDto.setCaCertificateType(filterDto.getCaCertificateType()); + trustCertTypeListRequestDto.setExcludeMosipCA(true); + trustCertTypeListRequestDto.setPartnerDomain(filterDto.getPartnerDomain()); + trustCertTypeListRequestDto.setCertId(filterDto.getCertificateId()); + trustCertTypeListRequestDto.setIssuedTo(filterDto.getIssuedTo()); + trustCertTypeListRequestDto.setIssuedBy(filterDto.getIssuedBy()); + trustCertTypeListRequestDto.setPageNumber(pageNo + 1); + trustCertTypeListRequestDto.setPageSize(pageSize); if (Objects.nonNull(sortFieldName) && Objects.nonNull(sortType)) { - caCertTypeListRequestDto.setSortByFieldName(getSortColumn(partnerHelper.caCertificateAliasToColumnMap, sortFieldName)); - caCertTypeListRequestDto.setSortOrder(sortType); + trustCertTypeListRequestDto.setSortByFieldName(getSortColumn(partnerHelper.trustCertificateAliasToColumnMap, sortFieldName)); + trustCertTypeListRequestDto.setSortOrder(sortType); } - RequestWrapper request = new RequestWrapper<>(); - request.setRequest(caCertTypeListRequestDto); - CaCertTypeListResponseDto responseObject = null; - Map apiResponse = restUtil.postApi(environment.getProperty("pmp.ca.certificates.post.rest.uri"), null, "", "", + RequestWrapper request = new RequestWrapper<>(); + request.setRequest(trustCertTypeListRequestDto); + TrustCertTypeListResponseDto responseObject = null; + Map apiResponse = restUtil.postApi(environment.getProperty("pmp.trust.certificates.post.rest.uri"), null, "", "", MediaType.APPLICATION_JSON, request, Map.class); if (apiResponse.get("response") == null && apiResponse.containsKey(PartnerConstants.ERRORS)) { List> certServiceErrorList = (List>) apiResponse .get(PartnerConstants.ERRORS); if (!certServiceErrorList.isEmpty()) { - LOGGER.error("Error occurred while getting the CA certificates list from keymanager"); + LOGGER.error("Error occurred while getting the trust certificates list from keymanager"); throw new ApiAccessibleException(certServiceErrorList.get(0).get(PartnerConstants.ERRORCODE).toString(), certServiceErrorList.get(0).get(PartnerConstants.ERRORMESSAGE).toString()); } else { - LOGGER.error("Error occurred while getting the CA certificates list from keymanager {}", apiResponse); + LOGGER.error("Error occurred while getting the trust certificates list from keymanager {}", apiResponse); throw new ApiAccessibleException(ApiAccessibleExceptionConstant.UNABLE_TO_PROCESS.getErrorCode(), ApiAccessibleExceptionConstant.UNABLE_TO_PROCESS.getErrorMessage()); } @@ -1030,33 +1030,33 @@ public ResponseWrapperV2> getCaCertif throw new ApiAccessibleException(ApiAccessibleExceptionConstant.API_NULL_RESPONSE_EXCEPTION.getErrorCode(), ApiAccessibleExceptionConstant.API_NULL_RESPONSE_EXCEPTION.getErrorMessage()); } - responseObject = mapper.readValue(mapper.writeValueAsString(apiResponse.get("response")), CaCertTypeListResponseDto.class); + responseObject = mapper.readValue(mapper.writeValueAsString(apiResponse.get("response")), TrustCertTypeListResponseDto.class); pageResponseV2Dto.setPageNo((responseObject.getPageNumber() - 1)); pageResponseV2Dto.setPageSize(responseObject.getPageSize()); pageResponseV2Dto.setTotalResults(responseObject.getTotalRecords()); pageResponseV2Dto.setData(responseObject.getAllPartnerCertificates()); responseWrapper.setResponse(pageResponseV2Dto); } catch (ApiAccessibleException ex) { - LOGGER.info("sessionId", "idType", "id", "In getCaCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); + LOGGER.info("sessionId", "idType", "id", "In getTrustCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); } catch (PartnerServiceException ex) { - LOGGER.info("sessionId", "idType", "id", "In getCaCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); + LOGGER.info("sessionId", "idType", "id", "In getTrustCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); } catch (Exception ex) { LOGGER.debug("sessionId", "idType", "id", ex.getStackTrace()); LOGGER.error("sessionId", "idType", "id", - "In getCaCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); - String errorCode = io.mosip.pms.partner.constant.ErrorCode.CA_CERTIFICATES_FETCH_ERROR.getErrorCode(); - String errorMessage = io.mosip.pms.partner.constant.ErrorCode.CA_CERTIFICATES_FETCH_ERROR.getErrorMessage(); + "In getTrustCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); + String errorCode = io.mosip.pms.partner.constant.ErrorCode.TRUST_CERTIFICATES_FETCH_ERROR.getErrorCode(); + String errorMessage = io.mosip.pms.partner.constant.ErrorCode.TRUST_CERTIFICATES_FETCH_ERROR.getErrorMessage(); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(errorCode, errorMessage)); } - responseWrapper.setId(getCaCertificatesId); + responseWrapper.setId(getTrustCertificatesId); responseWrapper.setVersion(VERSION); return responseWrapper; } - public ResponseWrapperV2 downloadRootCertificate(String certificateId) { - ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); + public ResponseWrapperV2 downloadTrustCertificates(String certificateId) { + ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); try { if (Objects.isNull(certificateId) || certificateId.equals(BLANK_STRING)) { LOGGER.info("sessionId", "idType", "id", "Certificate Id is null or empty -" + certificateId); @@ -1064,19 +1064,19 @@ public ResponseWrapperV2 downloadRootCertificate(Strin io.mosip.pms.partner.constant.ErrorCode.INVALID_CERTIFICATE_ID.getErrorMessage() ); } - CACertificateResponseDto responseObject = null; + TrustCertificateResponseDto responseObject = null; Map pathsegments = new HashMap<>(); pathsegments.put("caCertId", certificateId); - Map apiResponse = restUtil.getApi(environment.getProperty("pmp.download.ca.certificate.get.rest.uri"), pathsegments, Map.class); + Map apiResponse = restUtil.getApi(environment.getProperty("pmp.download.trust.certificates.get.rest.uri"), pathsegments, Map.class); if (apiResponse.get("response") == null && apiResponse.containsKey(PartnerConstants.ERRORS)) { List> certServiceErrorList = (List>) apiResponse .get(PartnerConstants.ERRORS); if (!certServiceErrorList.isEmpty()) { - LOGGER.error("Error occurred while downloading the CA certificate from keymanager"); + LOGGER.error("Error occurred while downloading the trust certificates from keymanager"); throw new ApiAccessibleException(certServiceErrorList.get(0).get(PartnerConstants.ERRORCODE).toString(), certServiceErrorList.get(0).get(PartnerConstants.ERRORMESSAGE).toString()); } else { - LOGGER.error("Error occurred while downloading the CA certificate from keymanager {}", apiResponse); + LOGGER.error("Error occurred while downloading the trust certificates from keymanager {}", apiResponse); throw new ApiAccessibleException(ApiAccessibleExceptionConstant.UNABLE_TO_PROCESS.getErrorCode(), ApiAccessibleExceptionConstant.UNABLE_TO_PROCESS.getErrorMessage()); } @@ -1085,23 +1085,23 @@ public ResponseWrapperV2 downloadRootCertificate(Strin throw new ApiAccessibleException(ApiAccessibleExceptionConstant.API_NULL_RESPONSE_EXCEPTION.getErrorCode(), ApiAccessibleExceptionConstant.API_NULL_RESPONSE_EXCEPTION.getErrorMessage()); } - responseObject = mapper.readValue(mapper.writeValueAsString(apiResponse.get("response")), CACertificateResponseDto.class); + responseObject = mapper.readValue(mapper.writeValueAsString(apiResponse.get("response")), TrustCertificateResponseDto.class); responseWrapper.setResponse(responseObject); } catch (ApiAccessibleException ex) { - LOGGER.info("sessionId", "idType", "id", "In downloadRootCertificate method of PartnerManagementServiceImpl - " + ex.getMessage()); + LOGGER.info("sessionId", "idType", "id", "In downloadTrustCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); } catch (PartnerServiceException ex) { - LOGGER.info("sessionId", "idType", "id", "In downloadRootCertificate method of PartnerManagementServiceImpl - " + ex.getMessage()); + LOGGER.info("sessionId", "idType", "id", "In downloadTrustCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); } catch (Exception ex) { LOGGER.debug("sessionId", "idType", "id", ex.getStackTrace()); LOGGER.error("sessionId", "idType", "id", - "In downloadRootCertificate method of PartnerManagementServiceImpl - " + ex.getMessage()); - String errorCode = io.mosip.pms.partner.constant.ErrorCode.DOWNLOAD_CA_CERTIFICATE_ERROR.getErrorCode(); - String errorMessage = io.mosip.pms.partner.constant.ErrorCode.DOWNLOAD_CA_CERTIFICATE_ERROR.getErrorMessage(); + "In downloadTrustCertificates method of PartnerManagementServiceImpl - " + ex.getMessage()); + String errorCode = io.mosip.pms.partner.constant.ErrorCode.DOWNLOAD_TRUST_CERTIFICATE_ERROR.getErrorCode(); + String errorMessage = io.mosip.pms.partner.constant.ErrorCode.DOWNLOAD_TRUST_CERTIFICATE_ERROR.getErrorMessage(); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(errorCode, errorMessage)); } - responseWrapper.setId(getDownloadCaCertificateId); + responseWrapper.setId(getDownloadTrustCertificateId); responseWrapper.setVersion(VERSION); return responseWrapper; } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java index c8eda04471..12ca2aa733 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java @@ -238,6 +238,6 @@ public interface PartnerService { public ResponseWrapperV2> getAuthPartnerApiKeys(); - ResponseWrapperV2> getPartnersV4(String status, Boolean policyGroupAvailable, String partnerType); + ResponseWrapperV2> getPartnersV3(String status, Boolean policyGroupAvailable, String partnerType); } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java index b2946b435c..37eb12d5a6 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java @@ -258,8 +258,8 @@ public class PartnerServiceImpl implements PartnerService { @Value("${mosip.pms.api.id.auth.partner.api.keys.get}") private String getAuthPartnerApiKeysId; - @Value("${mosip.pms.api.id.partners.v4.get}") - private String getPartnersV4Id; + @Value("${mosip.pms.api.id.partners.v3.get}") + private String getPartnersV3Id; @Autowired AuditUtil auditUtil; @@ -1855,8 +1855,8 @@ public ResponseWrapperV2> getAuthPartnerApiKeys() { } @Override - public ResponseWrapperV2> getPartnersV4(String status, Boolean policyGroupAvailable, String partnerType) { - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + public ResponseWrapperV2> getPartnersV3(String status, Boolean policyGroupAvailable, String partnerType) { + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); try { String userId = getUserId(); List partnerList = partnerRepository.findByUserId(userId); @@ -1865,34 +1865,34 @@ public ResponseWrapperV2> getPartnersV4(String status, Boolea throw new PartnerServiceException(ErrorCode.USER_ID_NOT_EXISTS.getErrorCode(), ErrorCode.USER_ID_NOT_EXISTS.getErrorMessage()); } - List partnerDtoV4List = new ArrayList<>(); + List partnerDtoV3List = new ArrayList<>(); List partners = partnerRepository.findPartnersByUserIdAndStatusAndPartnerTypeAndPolicyGroupAvailable(status, userId, partnerType, policyGroupAvailable); for (Partner partner : partners) { - PartnerDtoV4 partnerDtoV4 = new PartnerDtoV4(); + PartnerDtoV3 partnerDtoV3 = new PartnerDtoV3(); partnerHelper.validatePartnerId(partner, userId); - partnerDtoV4.setPartnerId(partner.getId()); - partnerDtoV4.setPartnerType(partner.getPartnerTypeCode()); + partnerDtoV3.setPartnerId(partner.getId()); + partnerDtoV3.setPartnerType(partner.getPartnerTypeCode()); if (Boolean.TRUE.equals(policyGroupAvailable)) { PolicyGroup policyGroup = partnerHelper.validatePolicyGroup(partner); - partnerDtoV4.setPolicyGroupId(partner.getPolicyGroupId()); - partnerDtoV4.setPolicyGroupName(policyGroup.getName()); - partnerDtoV4.setPolicyGroupDescription(policyGroup.getDesc()); + partnerDtoV3.setPolicyGroupId(partner.getPolicyGroupId()); + partnerDtoV3.setPolicyGroupName(policyGroup.getName()); + partnerDtoV3.setPolicyGroupDescription(policyGroup.getDesc()); } - partnerDtoV4List.add(partnerDtoV4); + partnerDtoV3List.add(partnerDtoV3); } - responseWrapper.setResponse(partnerDtoV4List); + responseWrapper.setResponse(partnerDtoV3List); } catch (PartnerServiceException ex) { - LOGGER.info("sessionId", "idType", "id", "In getPartnersV4 method of PartnerServiceImpl - " + ex.getMessage()); + LOGGER.info("sessionId", "idType", "id", "In getPartnersV3 method of PartnerServiceImpl - " + ex.getMessage()); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); } catch (Exception ex) { LOGGER.debug("sessionId", "idType", "id", ex.getStackTrace()); LOGGER.error("sessionId", "idType", "id", - "In getPartnersV4 method of PartnerServiceImpl - " + ex.getMessage()); + "In getPartnersV3 method of PartnerServiceImpl - " + ex.getMessage()); String errorCode = ErrorCode.PARTNERS_FETCH_ERROR.getErrorCode(); String errorMessage = ErrorCode.PARTNERS_FETCH_ERROR.getErrorMessage(); responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(errorCode, errorMessage)); } - responseWrapper.setId(getPartnersV4Id); + responseWrapper.setId(getPartnersV3Id); responseWrapper.setVersion(VERSION); return responseWrapper; } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java index 6dc1dba51f..ad36e22ef2 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java @@ -139,16 +139,16 @@ public class PartnerHelper { deviceAliasToColumnMap.put("createdDateTime", "crDtimes"); } - public final Map caCertificateAliasToColumnMap = new HashMap<>(); + public final Map trustCertificateAliasToColumnMap = new HashMap<>(); { - caCertificateAliasToColumnMap.put("caCertificateType", "caCertificateType"); - caCertificateAliasToColumnMap.put("certificateId", "certId"); - caCertificateAliasToColumnMap.put("partnerDomain", "partnerDomain"); - caCertificateAliasToColumnMap.put("issuedTo", "certSubject"); - caCertificateAliasToColumnMap.put("issuedBy", "certIssuer"); - caCertificateAliasToColumnMap.put("validFrom", "certNotBefore"); - caCertificateAliasToColumnMap.put("validTill", "certNotAfter"); - caCertificateAliasToColumnMap.put("uploadedDateTime", "createdtimes"); + trustCertificateAliasToColumnMap.put("caCertificateType", "caCertificateType"); + trustCertificateAliasToColumnMap.put("certificateId", "certId"); + trustCertificateAliasToColumnMap.put("partnerDomain", "partnerDomain"); + trustCertificateAliasToColumnMap.put("issuedTo", "certSubject"); + trustCertificateAliasToColumnMap.put("issuedBy", "certIssuer"); + trustCertificateAliasToColumnMap.put("validFrom", "certNotBefore"); + trustCertificateAliasToColumnMap.put("validTill", "certNotAfter"); + trustCertificateAliasToColumnMap.put("uploadedDateTime", "createdtimes"); } @Autowired diff --git a/partner/partner-management-service/src/main/resources/bootstrap.properties b/partner/partner-management-service/src/main/resources/bootstrap.properties index 4c20749e4d..414fac8dc6 100644 --- a/partner/partner-management-service/src/main/resources/bootstrap.properties +++ b/partner/partner-management-service/src/main/resources/bootstrap.properties @@ -69,8 +69,8 @@ auth.allowed.urls=https://${mosip.pmp.host}/,https://${mosip.pmp.reactjs.ui.host mosip.kernel.keymanager.url=https://dev.mosip.net pmp.partner.original.certificate.get.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getPartnerSignedCertificate/{partnerCertId} -pmp.ca.certificates.post.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCaCertificates -pmp.download.ca.certificate.get.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCACertificateTrustPath/{caCertId} +pmp.trust.certificates.post.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCaCertificates +pmp.download.trust.certificates.get.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCACertificateTrustPath/{caCertId} mosip.role.pms.getpartnercertificates=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,DEVICE_PROVIDER,FTM_PROVIDER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER mosip.role.pms.getpolicyrequests=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER @@ -86,16 +86,16 @@ mosip.role.pms.getftmchipdetails=FTM_PROVIDER,PARTNER_ADMIN mosip.role.pms.patchdeactivateftm=FTM_PROVIDER,PARTNER_ADMIN mosip.role.pms.getoriginalftmcertificate=FTM_PROVIDER,PARTNER_ADMIN mosip.role.pms.getpartnerdetails=PARTNER_ADMIN -mosip.role.pms.getallpartners=PARTNER_ADMIN +mosip.role.pms.getadminpartners=PARTNER_ADMIN mosip.role.pms.getallpartnerpolicymappingrequests=PARTNER_ADMIN mosip.role.pms.getoauthpartnersclients=PARTNER_ADMIN mosip.role.pms.getpartnersapikeyrequests=PARTNER_ADMIN mosip.role.pms.getpartnersftmchipdetails=PARTNER_ADMIN mosip.role.pms.getallsbidetails=PARTNER_ADMIN mosip.role.pms.getalldevicedetails=PARTNER_ADMIN -mosip.role.pms.getallcacertificates=PARTNER_ADMIN -mosip.role.pms.getdownloadrootcertificate=PARTNER_ADMIN -mosip.role.pms.getpartnersv4=DEVICE_PROVIDER,FTM_PROVIDER,PARTNER_ADMIN,AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER +mosip.role.pms.gettrustcertificates=PARTNER_ADMIN +mosip.role.pms.getdownloadtrustcertificates=PARTNER_ADMIN +mosip.role.pms.getpartnersv3=DEVICE_PROVIDER,FTM_PROVIDER,PARTNER_ADMIN,AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER #OIDC Client attributes for create and update mosip.pms.oidc.clients.grantTypes=authorization_code @@ -135,14 +135,14 @@ mosip.pms.api.id.approved.ftm.provider.ids.get=mosip.pms.approved.ftm.provider.i mosip.pms.api.id.deactivate.ftm.patch=mosip.pms.deactivate.ftm.patch mosip.pms.api.id.original.ftm.certificate.get=mosip.pms.original.ftm.certificate.get mosip.pms.api.id.partner.details.get=mosip.pms.partner.details.get -mosip.pms.api.id.all.partners.get=mosip.pms.all.partners.get +mosip.pms.api.id.admin.partners.get=mosip.pms.admin.partners.get mosip.pms.api.id.all.partner.policy.mapping.requests.get=mosip.pms.all.partner.policy.mapping.requests.get mosip.pms.api.id.oauth.partners.clients.get=mosip.pms.oauth.partners.clients.get mosip.pms.api.id.all.api.key.requests.get=mosip.pms.all.api.key.requests.get mosip.pms.api.id.partners.ftm.chip.details.get=mosip.pms.partners.ftm.chip.details.get mosip.pms.api.id.all.sbi.details.get=mosip.pms.all.sbi.details.get mosip.pms.api.id.get.all.device.details.get=mosip.pms.get.all.device.details.get -mosip.pms.api.id.all.ca.certificates.get=mosip.pms.all.ca.certificates.get -mosip.pms.api.id.download.ca.certificate.get=mosip.pms.download.ca.certificate.get -mosip.pms.api.id.partners.v4.get=mosip.pms.partners.v4.get +mosip.pms.api.id.trust.certificates.get=mosip.pms.trust.certificates.get +mosip.pms.api.id.download.trust.certificates.get=mosip.pms.download.trust.certificates.get +mosip.pms.api.id.partners.v3.get=mosip.pms.partners.v3.get ##END properties are for PMS Revamp DP1 release diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/controller/DeviceDetailControllerTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/controller/DeviceDetailControllerTest.java index 321678459b..78cd6065d5 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/controller/DeviceDetailControllerTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/controller/DeviceDetailControllerTest.java @@ -489,7 +489,7 @@ public void getAllDeviceDetailsTest() throws Exception { doNothing().when(partnerHelper).validateRequestParameters(any(), eq(sortFieldName), eq(sortType), eq(pageNo), eq(pageSize)); - mockMvc.perform(MockMvcRequestBuilders.get("/devicedetail/search/v2") + mockMvc.perform(MockMvcRequestBuilders.get("/devicedetail/v2") .param("sortFieldName", sortFieldName) .param("sortType", sortType) .param("pageNo", String.valueOf(pageNo)) diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java index c65def1ffa..a15a925e84 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java @@ -6,7 +6,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.lang.reflect.Field; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.ZonedDateTime; @@ -16,12 +15,10 @@ import io.mosip.pms.common.response.dto.ResponseWrapperV2; import io.mosip.pms.partner.manager.controller.PartnerManagementController; import io.mosip.pms.partner.manager.dto.*; -import io.mosip.pms.partner.util.PartnerHelper; import lombok.SneakyThrows; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; @@ -348,7 +345,7 @@ public void getPartnerDetailsTest() throws Exception { Mockito.when(partnerManagementService.getPartnerDetails(anyString())) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/{partnerId}/v2", "samplePartnerId") + mockMvc.perform(MockMvcRequestBuilders.get("/admin-partners/{partnerId}", "samplePartnerId") .contentType(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isOk()); } @@ -370,9 +367,9 @@ public void getAllPartnersTest() throws Exception { partnerFilterDto.setIsActive(false); ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - Mockito.when(partnerManagementService.getAllPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto)) + Mockito.when(partnerManagementService.getAdminPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto)) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/v3?sortFieldName=createdDateTime&sortType=desc&pageSize=8&pageNo=0&" + + mockMvc.perform(MockMvcRequestBuilders.get("/admin-partners?sortFieldName=createdDateTime&sortType=desc&pageSize=8&pageNo=0&" + "partnerId=abc&partnerType=Auth_Partner&orgName=ABC&emailAddress=abc&certificateUploadStatus=not_uploaded&policyGroupName=default&isActive=false")) .andExpect(MockMvcResultMatchers.status().isOk()); } @@ -394,9 +391,9 @@ public void getAllPartners_NoFiltersTest() throws Exception { partnerFilterDto.setIsActive(false); ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - Mockito.when(partnerManagementService.getAllPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto)) + Mockito.when(partnerManagementService.getAdminPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto)) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/v3?sortFieldName=createdDateTime&sortType=desc&pageSize=8&pageNo=0&")) + mockMvc.perform(MockMvcRequestBuilders.get("/admin-partners?sortFieldName=createdDateTime&sortType=desc&pageSize=8&pageNo=0&")) .andExpect(MockMvcResultMatchers.status().isOk()); } @@ -520,12 +517,12 @@ public void getCaCertificatesTest() throws Exception { String sortType = "desc"; int pageNo = 0; int pageSize = 8; - CaCertificateFilterDto filterDto = new CaCertificateFilterDto(); - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + TrustCertificateFilterDto filterDto = new TrustCertificateFilterDto(); + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - Mockito.when(partnerManagementService.getCaCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto)) + Mockito.when(partnerManagementService.getTrustCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto)) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/root-certificates") + mockMvc.perform(MockMvcRequestBuilders.get("/trust-chain-certificates") .param("sortFieldName", sortFieldName) .param("sortType", sortType) .param("pageNo", String.valueOf(pageNo)) @@ -545,12 +542,12 @@ public void getCaCertificates_NoFiltersTest() throws Exception { String sortType = "desc"; int pageNo = 0; int pageSize = 8; - CaCertificateFilterDto filterDto = new CaCertificateFilterDto(); - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + TrustCertificateFilterDto filterDto = new TrustCertificateFilterDto(); + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - Mockito.when(partnerManagementService.getCaCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto)) + Mockito.when(partnerManagementService.getTrustCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto)) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/root-certificates") + mockMvc.perform(MockMvcRequestBuilders.get("/trust-chain-certificates") .param("sortFieldName", sortFieldName) .param("sortType", sortType) .param("pageNo", String.valueOf(pageNo)) @@ -561,9 +558,9 @@ public void getCaCertificates_NoFiltersTest() throws Exception { @Test @WithMockUser(roles = {"PARTNER_ADMIN"}) public void downloadRootCertificateTest() throws Exception { - ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); - Mockito.when(partnerManagementService.downloadRootCertificate(anyString())).thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/download-root-certificate/{certificateId}", "123") + ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); + Mockito.when(partnerManagementService.downloadTrustCertificates(anyString())).thenReturn(responseWrapper); + mockMvc.perform(MockMvcRequestBuilders.get("/trust-chain-certificates/{certificateId}/certificateFile", "123") .contentType(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isOk()); } diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerServiceControllerTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerServiceControllerTest.java index 54465964e9..daa2f988af 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerServiceControllerTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerServiceControllerTest.java @@ -19,7 +19,7 @@ import io.mosip.pms.partner.controller.PartnerServiceController; import io.mosip.pms.partner.dto.CertificateDto; import io.mosip.pms.partner.dto.PolicyDto; -import io.mosip.pms.partner.dto.PartnerDtoV4; +import io.mosip.pms.partner.dto.PartnerDtoV3; import io.mosip.pms.partner.response.dto.*; import org.junit.Before; import org.junit.Test; @@ -51,7 +51,6 @@ import io.mosip.pms.device.util.AuditUtil; import io.mosip.pms.partner.constant.PartnerServiceAuditEnum; import io.mosip.pms.partner.dto.PartnerPolicyMappingResponseDto; -import io.mosip.pms.partner.dto.PartnerDtoV4; import io.mosip.pms.partner.dto.ApiKeyResponseDto; import io.mosip.pms.partner.manager.service.PartnerManagerService; import io.mosip.pms.partner.request.dto.APIKeyGenerateRequestDto; @@ -648,18 +647,18 @@ public void getAuthPartnerApiKeysTest() throws Exception { @Test @WithMockUser(roles = {"PARTNER"}) - public void getPartnersV4Test() throws Exception { - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - PartnerDtoV4 partnerDto = new PartnerDtoV4(); + public void getPartnersV3Test() throws Exception { + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + PartnerDtoV3 partnerDto = new PartnerDtoV3(); - List partnerDtoList = new ArrayList<>(); + List partnerDtoList = new ArrayList<>(); partnerDtoList.add(partnerDto); responseWrapper.setResponse(partnerDtoList); - Mockito.when(partnerService.getPartnersV4(Mockito.anyString(), Mockito.any(), Mockito.any())) + Mockito.when(partnerService.getPartnersV3(Mockito.anyString(), Mockito.any(), Mockito.any())) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/v4") + mockMvc.perform(MockMvcRequestBuilders.get("/partners/v3") .param("status", "approved") .param("policyGroupAvailable", "true") .param("partnerType", "Auth_Partner")) @@ -668,18 +667,18 @@ public void getPartnersV4Test() throws Exception { @Test @WithMockUser(roles = {"PARTNER"}) - public void getPartnersV4Test2() throws Exception { - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - PartnerDtoV4 partnerDto = new PartnerDtoV4(); + public void getPartnersV3Test2() throws Exception { + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + PartnerDtoV3 partnerDto = new PartnerDtoV3(); - List partnerDtoList = new ArrayList<>(); + List partnerDtoList = new ArrayList<>(); partnerDtoList.add(partnerDto); responseWrapper.setResponse(partnerDtoList); - Mockito.when(partnerService.getPartnersV4(Mockito.anyString(), Mockito.any(), Mockito.any())) + Mockito.when(partnerService.getPartnersV3(Mockito.anyString(), Mockito.any(), Mockito.any())) .thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/v4") + mockMvc.perform(MockMvcRequestBuilders.get("/partners/v3") .param("status", "approved") .param("partnerType", "Device_Provider")) .andExpect(status().isOk()); @@ -711,18 +710,18 @@ public void testPartnerRegistration() throws Exception { @Test @WithMockUser(roles = {"AUTH_PARTNER"}) - public void testGetPartnersV4() throws Exception { - List partnerDtoV4List = new ArrayList<>(); - PartnerDtoV4 partnerDto = new PartnerDtoV4(); + public void testGetPartnersV3() throws Exception { + List partnerDtoV3List = new ArrayList<>(); + PartnerDtoV3 partnerDto = new PartnerDtoV3(); partnerDto.setPartnerId("123"); - partnerDtoV4List.add(partnerDto); + partnerDtoV3List.add(partnerDto); - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - responseWrapper.setResponse(partnerDtoV4List); + ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); + responseWrapper.setResponse(partnerDtoV3List); - Mockito.when(partnerService.getPartnersV4("approved", true, "typeA")).thenReturn(responseWrapper); + Mockito.when(partnerService.getPartnersV3("approved", true, "typeA")).thenReturn(responseWrapper); - mockMvc.perform(MockMvcRequestBuilders.get("/partners/v4?status=approved")).andExpect(MockMvcResultMatchers.status().isOk()); + mockMvc.perform(MockMvcRequestBuilders.get("/partners/v3?status=approved")).andExpect(MockMvcResultMatchers.status().isOk()); } diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java index deac4b4b04..77f21ed8a6 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java @@ -1237,7 +1237,7 @@ public void getPartnerDetailsTest1() throws Exception { } @Test - public void getAllPartnersTest() throws Exception { + public void getAdminPartnersTest() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1259,11 +1259,11 @@ public void getAllPartnersTest() throws Exception { ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); Page page = null; when(partnerSummaryRepository.getSummaryOfAllPartners(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any())).thenReturn(page); - partnerManagementImpl.getAllPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto); + partnerManagementImpl.getAdminPartners(sortFieldName, sortType, pageNo, pageSize, partnerFilterDto); } @Test - public void getAllPartnersTestException() throws Exception { + public void getAdminPartnersTestException() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1277,7 +1277,7 @@ public void getAllPartnersTestException() throws Exception { ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); Page page = null; when(partnerSummaryRepository.getSummaryOfAllPartners(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any())).thenReturn(page); - partnerManagementImpl.getAllPartners(sortFieldName, sortType, pageNo, pageSize, null); + partnerManagementImpl.getAdminPartners(sortFieldName, sortType, pageNo, pageSize, null); } @Test @@ -1361,7 +1361,7 @@ public void getAllPartnerPolicyRequestsException() throws Exception { } @Test - public void getCaCertificatesTest() throws Exception { + public void getTrustCertificatesTest() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1372,39 +1372,39 @@ public void getCaCertificatesTest() throws Exception { String sortType = "desc"; int pageNo = 0; int pageSize = 8; - CaCertificateFilterDto filterDto = new CaCertificateFilterDto(); + TrustCertificateFilterDto filterDto = new TrustCertificateFilterDto(); filterDto.setCertificateId("abc"); filterDto.setCaCertificateType("root"); filterDto.setPartnerDomain("Auth"); - CaCertificateSummaryDto caCertificateSummaryDto = new CaCertificateSummaryDto(); - caCertificateSummaryDto.setCaCertificateType("ROOT"); - caCertificateSummaryDto.setCertId("abc"); - caCertificateSummaryDto.setPartnerDomain("AUTH"); - List caCertificateSummaryDtoList = new ArrayList<>(); - caCertificateSummaryDtoList.add(caCertificateSummaryDto); + TrustCertificateSummaryDto trustCertificateSummaryDto = new TrustCertificateSummaryDto(); + trustCertificateSummaryDto.setCaCertificateType("ROOT"); + trustCertificateSummaryDto.setCertId("abc"); + trustCertificateSummaryDto.setPartnerDomain("AUTH"); + List trustCertificateSummaryDtoList = new ArrayList<>(); + trustCertificateSummaryDtoList.add(trustCertificateSummaryDto); - CaCertTypeListResponseDto caCertTypeListResponseDto = new CaCertTypeListResponseDto(); - caCertTypeListResponseDto.setPageNumber(1); - caCertTypeListResponseDto.setPageSize(8); - caCertTypeListResponseDto.setTotalRecords(10); - caCertTypeListResponseDto.setAllPartnerCertificates(caCertificateSummaryDtoList); + TrustCertTypeListResponseDto trustCertTypeListResponseDto = new TrustCertTypeListResponseDto(); + trustCertTypeListResponseDto.setPageNumber(1); + trustCertTypeListResponseDto.setPageSize(8); + trustCertTypeListResponseDto.setTotalRecords(10); + trustCertTypeListResponseDto.setAllPartnerCertificates(trustCertificateSummaryDtoList); Map apiResponse = new HashMap<>(); - apiResponse.put("response", caCertTypeListResponseDto); + apiResponse.put("response", trustCertTypeListResponseDto); when(restUtil.postApi(eq("https://localhost/v1/keymanager/getCaCertificates"), any(), eq(""), eq(""), eq(MediaType.APPLICATION_JSON), any(), eq(Map.class))).thenReturn(apiResponse); - when(mapper.writeValueAsString(any())).thenReturn(new ObjectMapper().writeValueAsString(caCertTypeListResponseDto)); - when(mapper.readValue(anyString(), eq(CaCertTypeListResponseDto.class))).thenReturn(caCertTypeListResponseDto); + when(mapper.writeValueAsString(any())).thenReturn(new ObjectMapper().writeValueAsString(trustCertTypeListResponseDto)); + when(mapper.readValue(anyString(), eq(TrustCertTypeListResponseDto.class))).thenReturn(trustCertTypeListResponseDto); - ResponseWrapperV2> responseWrapper = - partnerManagementImpl.getCaCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto); + ResponseWrapperV2> responseWrapper = + partnerManagementImpl.getTrustCertificates(sortFieldName, sortType, pageNo, pageSize, filterDto); } @Test - public void getCaCertificatesExceptionTest() throws Exception { + public void getTrustCertificatesExceptionTest() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1415,11 +1415,11 @@ public void getCaCertificatesExceptionTest() throws Exception { String sortType = "desc"; int pageNo = 0; int pageSize = 8; - partnerManagementImpl.getCaCertificates(sortFieldName, sortType, pageNo, pageSize, null); + partnerManagementImpl.getTrustCertificates(sortFieldName, sortType, pageNo, pageSize, null); } @Test - public void downloadRootCertificateTest() throws Exception { + public void downloadTrustCertificatesTest() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1462,23 +1462,23 @@ public void downloadRootCertificateTest() throws Exception { "-----END CERTIFICATE-----"); apiResponse.put("response", response); - when(environment.getProperty("pmp.download.ca.certificate.get.rest.uri")).thenReturn("uri"); + when(environment.getProperty("pmp.download.trust.certificates.get.rest.uri")).thenReturn("uri"); when(restUtil.getApi(anyString(), any(), eq(Map.class))).thenReturn(apiResponse); - partnerManagementImpl.downloadRootCertificate("123"); + partnerManagementImpl.downloadTrustCertificates("123"); } @Test - public void downloadRootCertificateExceptionTest1() throws Exception { + public void downloadTrustCertificatesExceptionTest1() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); when(authentication.getPrincipal()).thenReturn(authUserDetails); when(securityContext.getAuthentication()).thenReturn(authentication); - partnerManagementImpl.downloadRootCertificate(""); + partnerManagementImpl.downloadTrustCertificates(""); } @Test - public void downloadRootCertificateExceptionTest2() throws Exception { + public void downloadTrustCertificatesExceptionTest2() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1493,13 +1493,13 @@ public void downloadRootCertificateExceptionTest2() throws Exception { apiResponse.put("response", null); apiResponse.put("errors", errorList); - when(environment.getProperty("pmp.download.ca.certificate.get.rest.uri")).thenReturn("uri"); + when(environment.getProperty("pmp.download.trust.certificates.get.rest.uri")).thenReturn("uri"); when(restUtil.getApi(anyString(), any(), eq(Map.class))).thenReturn(apiResponse); - partnerManagementImpl.downloadRootCertificate("123"); + partnerManagementImpl.downloadTrustCertificates("123"); } @Test - public void downloadRootCertificateExceptionTes3() throws Exception { + public void downloadTrustCertificatesExceptionTes3() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1510,13 +1510,13 @@ public void downloadRootCertificateExceptionTes3() throws Exception { apiResponse.put("response", null); apiResponse.put("errors", errorList); - when(environment.getProperty("pmp.download.ca.certificate.get.rest.uri")).thenReturn("uri"); + when(environment.getProperty("pmp.download.trust.certificates.get.rest.uri")).thenReturn("uri"); when(restUtil.getApi(anyString(), any(), eq(Map.class))).thenReturn(apiResponse); - partnerManagementImpl.downloadRootCertificate("123"); + partnerManagementImpl.downloadTrustCertificates("123"); } @Test - public void downloadRootCertificateExceptionTest5() throws Exception { + public void downloadTrustCertificatesExceptionTest5() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1531,13 +1531,13 @@ public void downloadRootCertificateExceptionTest5() throws Exception { apiResponse.put("response", null); apiResponse.put("errors", errorList); - when(environment.getProperty("pmp.download.ca.certificate.get.rest.uri")).thenReturn("uri"); + when(environment.getProperty("pmp.download.trust.certificates.get.rest.uri")).thenReturn("uri"); when(restUtil.getApi(anyString(), any(), eq(Map.class))).thenReturn(apiResponse); - partnerManagementImpl.downloadRootCertificate("123"); + partnerManagementImpl.downloadTrustCertificates("123"); } @Test - public void downloadRootCertificateExceptionTes4() throws Exception { + public void downloadTrustCertificatesExceptionTes4() throws Exception { MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1546,9 +1546,9 @@ public void downloadRootCertificateExceptionTes4() throws Exception { Map apiResponse = new HashMap<>(); apiResponse.put("response", null); - when(environment.getProperty("pmp.download.ca.certificate.get.rest.uri")).thenReturn("uri"); + when(environment.getProperty("pmp.download.trust.certificates.get.rest.uri")).thenReturn("uri"); when(restUtil.getApi(anyString(), any(), eq(Map.class))).thenReturn(apiResponse); - partnerManagementImpl.downloadRootCertificate("123"); + partnerManagementImpl.downloadTrustCertificates("123"); } private io.mosip.kernel.openid.bridge.model.MosipUserDto getMosipUserDto() { diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java index 2ef8ab5bee..71763f08d3 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java @@ -18,7 +18,7 @@ import io.mosip.pms.partner.dto.DataShareDto; import io.mosip.pms.partner.dto.DataShareResponseDto; import io.mosip.pms.partner.dto.UploadCertificateRequestDto; -import io.mosip.pms.partner.dto.PartnerDtoV4; +import io.mosip.pms.partner.dto.PartnerDtoV3; import io.mosip.pms.partner.request.dto.*; import io.mosip.pms.partner.response.dto.*; import io.mosip.pms.partner.util.PartnerHelper; @@ -1864,7 +1864,7 @@ public void getAuthPartnerApiKeysTestException1() throws Exception { } @Test - public void getPartnersV4Test() throws Exception{ + public void getPartnersV3Test() throws Exception{ io.mosip.kernel.openid.bridge.model.MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1884,12 +1884,12 @@ public void getPartnersV4Test() throws Exception{ PolicyGroup policyGroup = new PolicyGroup(); policyGroup.setName("abc"); when(policyGroupRepository.findPolicyGroupById(any())).thenReturn(policyGroup); - ResponseWrapperV2> responseWrapper = pserviceImpl.getPartnersV4("approved", true, "Auth_Partner"); + ResponseWrapperV2> responseWrapper = pserviceImpl.getPartnersV3("approved", true, "Auth_Partner"); assertNotNull(responseWrapper); } @Test - public void getPartnersV4Test1() throws Exception{ + public void getPartnersV3Test1() throws Exception{ io.mosip.kernel.openid.bridge.model.MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1905,12 +1905,12 @@ public void getPartnersV4Test1() throws Exception{ when(partnerRepository.findByUserId(anyString())).thenReturn(partnerList); when(partnerRepository.findPartnersByUserIdAndStatusAndPartnerTypeAndPolicyGroupAvailable(any(),any(),any(),any())).thenReturn(partnerList); - ResponseWrapperV2> responseWrapper = pserviceImpl.getPartnersV4("approved", null, "FTM_Provider"); + ResponseWrapperV2> responseWrapper = pserviceImpl.getPartnersV3("approved", null, "FTM_Provider"); assertNotNull(responseWrapper); } @Test - public void getPartnersV4TestException() throws Exception{ + public void getPartnersV3TestException() throws Exception{ io.mosip.kernel.openid.bridge.model.MosipUserDto mosipUserDto = getMosipUserDto(); AuthUserDetails authUserDetails = new AuthUserDetails(mosipUserDto, "123"); SecurityContextHolder.setContext(securityContext); @@ -1929,7 +1929,7 @@ public void getPartnersV4TestException() throws Exception{ PolicyGroup policyGroup = new PolicyGroup(); when(policyGroupRepository.findPolicyGroupById(any())).thenReturn(policyGroup); - ResponseWrapperV2> responseWrapper = pserviceImpl.getPartnersV4("approved", true, "Auth_Partner"); + ResponseWrapperV2> responseWrapper = pserviceImpl.getPartnersV3("approved", true, "Auth_Partner"); assertNotNull(responseWrapper); } diff --git a/partner/partner-management-service/src/test/resources/application.properties b/partner/partner-management-service/src/test/resources/application.properties index 5f02c06ed6..55504ac984 100644 --- a/partner/partner-management-service/src/test/resources/application.properties +++ b/partner/partner-management-service/src/test/resources/application.properties @@ -123,8 +123,8 @@ pmp.partner.certificaticate.upload.rest.uri=https://localhost/v1/keymanager/uplo pmp.partner.certificaticate.get.rest.uri=https://localhost/v1/keymanager/getPartnerCertificate pmp.partner.original.certificate.get.rest.uri=https://localhost/v1/keymanager/getPartnerSignedCertificate/{partnerCertId} pmp-keymanager.upload.other.domain.cert.rest.uri=http://kernel-keymanager-service/v1/keymanager/uploadOtherDomainCertificate -pmp.ca.certificates.post.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCaCertificates -pmp.download.ca.certificate.get.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCACertificateTrustPath/{caCertId} +pmp.trust.certificates.post.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCaCertificates +pmp.download.trust.certificates.get.rest.uri=${mosip.kernel.keymanager.url}/v1/keymanager/getCACertificateTrustPath/{caCertId} application.id=PARTNER ###############Keycloak configuration ########################## mosip.iam.base-url=https://localhost/keycloak @@ -321,16 +321,16 @@ mosip.role.pms.getftmchipdetails=FTM_PROVIDER,PARTNER_ADMIN mosip.role.pms.patchdeactivateftm=FTM_PROVIDER,PARTNER_ADMIN mosip.role.pms.getoriginalftmcertificate=FTM_PROVIDER,PARTNER_ADMIN mosip.role.pms.getpartnerdetails=PARTNER_ADMIN -mosip.role.pms.getallpartners=PARTNER_ADMIN +mosip.role.pms.getadminpartners=PARTNER_ADMIN mosip.role.pms.getallpartnerpolicymappingrequests=PARTNER_ADMIN mosip.role.pms.getoauthpartnersclients=PARTNER_ADMIN mosip.role.pms.getpartnersapikeyrequests=PARTNER_ADMIN mosip.role.pms.getpartnersftmchipdetails=PARTNER_ADMIN mosip.role.pms.getallsbidetails=PARTNER_ADMIN mosip.role.pms.getalldevicedetails=PARTNER_ADMIN -mosip.role.pms.getallcacertificates=PARTNER_ADMIN -mosip.role.pms.getdownloadrootcertificate=PARTNER_ADMIN -mosip.role.pms.getpartnersv4=DEVICE_PROVIDER,FTM_PROVIDER,PARTNER_ADMIN,AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER +mosip.role.pms.gettrustcertificates=PARTNER_ADMIN +mosip.role.pms.getdownloadtrustcertificates=PARTNER_ADMIN +mosip.role.pms.getpartnersv3=DEVICE_PROVIDER,FTM_PROVIDER,PARTNER_ADMIN,AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER #id for the API mosip.pms.api.id.oauth.clients.get=mosip.pms.oauth.clients.get @@ -355,13 +355,13 @@ mosip.pms.api.id.approved.ftm.provider.ids.get=mosip.pms.approved.ftm.provider.i mosip.pms.api.id.deactivate.ftm.patch=mosip.pms.deactivate.ftm.patch mosip.pms.api.id.original.ftm.certificate.get=mosip.pms.original.ftm.certificate.get mosip.pms.api.id.partner.details.get=mosip.pms.partner.details.get -mosip.pms.api.id.all.partners.get=mosip.pms.all.partners.get +mosip.pms.api.id.admin.partners.get=mosip.pms.admin.partners.get mosip.pms.api.id.all.partner.policy.mapping.requests.get=mosip.pms.all.partner.policy.mapping.requests.get mosip.pms.api.id.oauth.partners.clients.get=mosip.pms.oauth.partners.clients.get mosip.pms.api.id.all.api.key.requests.get=mosip.pms.all.api.key.requests.get mosip.pms.api.id.partners.ftm.chip.details.get=mosip.pms.partners.ftm.chip.details.get mosip.pms.api.id.all.sbi.details.get=mosip.pms.all.sbi.details.get mosip.pms.api.id.get.all.device.details.get=mosip.pms.get.all.device.details.get -mosip.pms.api.id.all.ca.certificates.get=mosip.pms.all.ca.certificates.get -mosip.pms.api.id.download.ca.certificate.get=mosip.pms.download.ca.certificate.get -mosip.pms.api.id.partners.v4.get=mosip.pms.partners.v4.get \ No newline at end of file +mosip.pms.api.id.trust.certificates.get=mosip.pms.trust.certificates.get +mosip.pms.api.id.download.trust.certificates.get=mosip.pms.download.trust.certificates.get +mosip.pms.api.id.partners.v3.get=mosip.pms.partners.v3.get \ No newline at end of file diff --git a/partner/pms-common/src/main/java/io/mosip/pms/common/constant/ValidationErrorCode.java b/partner/pms-common/src/main/java/io/mosip/pms/common/constant/ValidationErrorCode.java index 19d5771c7b..f06bf5b75a 100644 --- a/partner/pms-common/src/main/java/io/mosip/pms/common/constant/ValidationErrorCode.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/constant/ValidationErrorCode.java @@ -12,7 +12,13 @@ public enum ValidationErrorCode { FILTER_COLUMN_NOT_SUPPORTED("PMS-MSD-324", "Received Filter Type not supported"), COLUMN_DOESNT_EXIST_FILTER("PMS-MSD-348", "Received column does not support filter"), CONSTRAINT_VIOLATION("PMS-MSD-xxx", "Contraint Violation-"), - INVALID_COLUMN_NAME("PMS-MSD-325", "Invalid Column Name passed"); + INVALID_COLUMN_NAME("PMS-MSD-325", "Invalid Column Name passed"), + INVALID_REQUEST_PARAM("PMS_REQUEST_ERROR_001", "Invalid request."), + INVALID_REQUEST_ID("PMS_REQUEST_ERROR_002", "Invalid Request Id"), + INVALID_REQUEST_VERSION("PMS_REQUEST_ERROR_003", "Request version is invalid"), + INVALID_REQUEST_DATETIME("PMS_REQUEST_ERROR_004", "Invalid request time"), + INVALID_REQUEST_BODY("PMS_REQUEST_ERROR_005", "Request body is invalid"), + INVALID_REQUEST_DATETIME_NOT_CURRENT_DATE("PMS_REQUEST_ERROR_006", "Request date should be current date"); /** * Error Code diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/RequestValidator.java b/partner/pms-common/src/main/java/io/mosip/pms/common/util/RequestValidator.java similarity index 54% rename from partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/RequestValidator.java rename to partner/pms-common/src/main/java/io/mosip/pms/common/util/RequestValidator.java index 5c5b32acff..17fe011f51 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/RequestValidator.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/util/RequestValidator.java @@ -1,20 +1,18 @@ -package io.mosip.pms.partner.util; +package io.mosip.pms.common.util; import io.micrometer.core.lang.NonNull; import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.pms.common.constant.ValidationErrorCode; +import io.mosip.pms.common.exception.RequestException; +import io.mosip.pms.common.request.dto.ErrorResponse; import io.mosip.pms.common.request.dto.RequestWrapperV2; import io.mosip.pms.common.response.dto.ResponseWrapperV2; -import io.mosip.pms.common.util.PMSLogger; -import io.mosip.pms.partner.constant.ErrorCode; -import io.mosip.pms.partner.exception.PartnerServiceException; import org.springframework.stereotype.Component; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.Date; -import java.util.Objects; -import java.util.Optional; +import java.util.*; @Component public class RequestValidator { @@ -27,13 +25,13 @@ public void validateId(String operation, String requestId) { if (Objects.nonNull(requestId)) { if (!requestId.equals(operation)) { LOGGER.error("", "", "validateId", "\n" + "Id is not correct"); - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_ID.getErrorCode(), - ErrorCode.INVALID_REQUEST_ID.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_ID.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_ID.getErrorMessage()); } } else { LOGGER.error("", "", "validateId", "\n" + "Id is null"); - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_ID.getErrorCode(), - ErrorCode.INVALID_REQUEST_ID.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_ID.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_ID.getErrorMessage()); } } @@ -43,11 +41,11 @@ public Optional> validate(@NonNull String operation, Re validateReqTime(requestWrapper.getRequestTime()); validateVersion(requestWrapper.getVersion()); validateRequest(requestWrapper.getRequest()); - } catch (PartnerServiceException ex) { + } catch (RequestException ex) { ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); responseWrapper.setId(operation); responseWrapper.setVersion(VERSION); - responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); + responseWrapper.setErrors(setErrorResponse(ex.getErrors().get(0).getErrorCode(), ex.getErrors().get(0).getMessage())); return Optional.of(responseWrapper); } return Optional.empty(); @@ -56,13 +54,14 @@ public Optional> validate(@NonNull String operation, Re protected void validateReqTime(LocalDateTime reqTime) { if (Objects.isNull(reqTime)) { LOGGER.error("", "", "validateReqTime", "requesttime is null"); - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_DATETIME.getErrorCode(), ErrorCode.INVALID_REQUEST_DATETIME.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_DATETIME.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_DATETIME.getErrorMessage()); } else { LocalDate localDate = reqTime.toLocalDate(); LocalDate serverDate = new Date().toInstant().atZone(ZoneId.of("UTC")).toLocalDate(); if (localDate.isBefore(serverDate) || localDate.isAfter(serverDate)) { - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_DATETIME_NOT_CURRENT_DATE.getErrorCode(), - ErrorCode.INVALID_REQUEST_DATETIME_NOT_CURRENT_DATE.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_DATETIME_NOT_CURRENT_DATE.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_DATETIME_NOT_CURRENT_DATE.getErrorMessage()); } } } @@ -70,20 +69,29 @@ protected void validateReqTime(LocalDateTime reqTime) { protected void validateVersion(String ver) { if (Objects.isNull(ver)) { LOGGER.error("", "", "validateVersion", "version is null"); - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_VERSION.getErrorCode(), - ErrorCode.INVALID_REQUEST_VERSION.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_VERSION.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_VERSION.getErrorMessage()); } else if (!VERSION.equalsIgnoreCase(ver)) { LOGGER.error("", "", "validateVersion", "version is not correct"); - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_VERSION.getErrorCode(), - ErrorCode.INVALID_REQUEST_VERSION.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_VERSION.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_VERSION.getErrorMessage()); } } protected void validateRequest(Object request) { if (Objects.isNull(request)) { LOGGER.error("", "", "validateRequest", "\n" + "request is null"); - throw new PartnerServiceException(ErrorCode.INVALID_REQUEST_BODY.getErrorCode(), - ErrorCode.INVALID_REQUEST_BODY.getErrorMessage()); + throw new RequestException(ValidationErrorCode.INVALID_REQUEST_BODY.getErrorCode(), + ValidationErrorCode.INVALID_REQUEST_BODY.getErrorMessage()); } } + + public static List setErrorResponse(String errorCode, String errorMessage) { + List errorResponseList = new ArrayList<>(); + ErrorResponse errorResponse = new ErrorResponse(); + errorResponse.setErrorCode(errorCode); + errorResponse.setMessage(errorMessage); + errorResponseList.add(errorResponse); + return errorResponseList; + } } diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/controller/PolicyManagementController.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/controller/PolicyManagementController.java index 5a80e9cfab..b422840c7b 100644 --- a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/controller/PolicyManagementController.java +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/controller/PolicyManagementController.java @@ -3,10 +3,14 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; +import java.util.Optional; import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import io.mosip.pms.common.request.dto.RequestWrapperV2; import io.mosip.pms.common.response.dto.ResponseWrapperV2; +import io.mosip.pms.common.util.RequestValidator; import io.mosip.pms.policy.util.PolicyUtil; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -16,6 +20,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import org.json.simple.parser.ParseException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -61,6 +66,7 @@ import io.mosip.pms.policy.dto.PolicyFilterDto; import io.mosip.pms.policy.dto.DeactivatePolicyResponseDto; import io.mosip.pms.policy.dto.DeactivatePolicyGroupResponseDto; +import io.mosip.pms.policy.dto.DeactivateRequestDto; import io.mosip.pms.policy.service.PolicyManagementService; import io.mosip.pms.policy.util.AuditUtil; import io.swagger.annotations.Api; @@ -74,12 +80,21 @@ public class PolicyManagementController { private static final Logger logger = PMSLogger.getLogger(PolicyManagementController.class); + @Value("${mosip.pms.api.id.deactivate.policy.patch}") + private String patchDeactivatePolicy; + + @Value("${mosip.pms.api.id.deactivate.policy.group.patch}") + private String patchDeactivatePolicyGroupId; + @Autowired private PolicyManagementService policyManagementService; @Autowired AuditUtil auditUtil; + @Autowired + RequestValidator requestValidator; + @PreAuthorize("hasAnyRole(@authorizedRoles.getPostpoliciesgroupnew())") @PostMapping(value = "/group/new") @Operation(summary = "Service to create a new policy group", description = "Service to craete a new policy group") @@ -312,7 +327,7 @@ public ResponseWrapperV2> getPolicyGroups() throws JsonPars } @PreAuthorize("hasAnyRole(@authorizedRoles.getGetallpolicies())") - @GetMapping(value = "/search/v2") + @GetMapping(value = "/v2") @Operation(summary = "This endpoint retrieves the list of all Policies", description = "Available since release-1.3.x. It is configured for both the POLICYMANAGER and PARTNER_ADMIN roles.") @ApiResponses(value = { @@ -368,8 +383,13 @@ public ResponseWrapperV2> getAllPolicies( @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))) }) - public ResponseWrapperV2 deactivatePolicy(@PathVariable String policyId) { - return policyManagementService.deactivatePolicy(policyId); + public ResponseWrapperV2 deactivatePolicy(@PathVariable("policyId") @NotBlank String policyId, @RequestBody @Valid RequestWrapperV2 + requestWrapper) { + Optional> validationResponse = requestValidator.validate(patchDeactivatePolicy, requestWrapper); + if (validationResponse.isPresent()) { + return validationResponse.get(); + } + return policyManagementService.deactivatePolicy(policyId, requestWrapper.getRequest()); } @PreAuthorize("hasAnyRole(@authorizedRoles.getPatchdeactivatepolicygroup())") @@ -381,7 +401,12 @@ public ResponseWrapperV2 deactivatePolicy(@PathVari @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))) }) - public ResponseWrapperV2 deactivatePolicyGroup(@PathVariable String policyGroupId) { - return policyManagementService.deactivatePolicyGroup(policyGroupId); + public ResponseWrapperV2 deactivatePolicyGroup(@PathVariable("policyGroupId") @NotBlank String policyGroupId, @RequestBody @Valid RequestWrapperV2 + requestWrapper) { + Optional> validationResponse = requestValidator.validate(patchDeactivatePolicyGroupId, requestWrapper); + if (validationResponse.isPresent()) { + return validationResponse.get(); + } + return policyManagementService.deactivatePolicyGroup(policyGroupId, requestWrapper.getRequest()); } } diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/dto/DeactivateRequestDto.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/dto/DeactivateRequestDto.java new file mode 100644 index 0000000000..d6068e2190 --- /dev/null +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/dto/DeactivateRequestDto.java @@ -0,0 +1,11 @@ +package io.mosip.pms.policy.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class DeactivateRequestDto { + + @Schema(description = "Status for deactivate policy", example = "De-Activate") + private String status; +} diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/errorMessages/ErrorMessages.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/errorMessages/ErrorMessages.java index 61af64717b..6d9c70de54 100644 --- a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/errorMessages/ErrorMessages.java +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/errorMessages/ErrorMessages.java @@ -62,7 +62,8 @@ public enum ErrorMessages { ACTIVE_AND_DRAFT_POLICIES_EXISTS_UNDER_POLICY_GROUP( "PMS_POL_069", "Active or draft policies are associated with the policy group"), DRAFT_POLICIES_EXISTS_UNDER_POLICY_GROUP("PMS_POL_070","Draft policies exists under the policy group."), POLICY_GROUP_DEACTIVATION_ERROR("PMS_POL_071", "Error while deactivating policy group"), - POLICY_NOT_APPROVED("PMS_POL_072", "The selected policy is not in activated status"); + POLICY_NOT_APPROVED("PMS_POL_072", "The selected policy is not in activated status"), + DEACTIVATE_STATUS_CODE("PMS_POL_073", "Request status should be De-Activate"); private final String errorCode; private final String errorMessage; diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java index 53651aa5f7..c92f1f562d 100644 --- a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java @@ -96,6 +96,7 @@ import io.mosip.pms.policy.dto.PolicyFilterDto; import io.mosip.pms.policy.dto.DeactivatePolicyResponseDto; import io.mosip.pms.policy.dto.DeactivatePolicyGroupResponseDto; +import io.mosip.pms.policy.dto.DeactivateRequestDto; import io.mosip.pms.policy.errorMessages.ErrorMessages; import io.mosip.pms.policy.errorMessages.PolicyManagementServiceException; import io.mosip.pms.policy.util.AuditUtil; @@ -126,6 +127,8 @@ public class PolicyManagementService { private static final Logger logger = PMSLogger.getLogger(PolicyManagementService.class); + private static final String DEACTIVATE = "De-Activate"; + @Autowired private AuthPolicyRepository authPolicyRepository; @@ -1181,7 +1184,7 @@ public String getSortColumn(String alias) { return PolicyUtil.aliasToColumnMap.getOrDefault(alias, alias); // Return alias if no match found } - public ResponseWrapperV2 deactivatePolicy(String policyId) { + public ResponseWrapperV2 deactivatePolicy(String policyId, DeactivateRequestDto requestDto) { ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); try { if (Objects.isNull(policyId) || policyId.isBlank()){ @@ -1189,6 +1192,12 @@ public ResponseWrapperV2 deactivatePolicy(String po throw new PolicyManagementServiceException(ErrorMessages.INVALID_INPUT_PARAMETER.getErrorCode(), ErrorMessages.INVALID_INPUT_PARAMETER.getErrorMessage()); } + String status = requestDto.getStatus(); + if (Objects.isNull(status) || status.isBlank() || !status.equals(DEACTIVATE)) { + logger.info(status + " : is Invalid Input Parameter, it should be (De-Activate)"); + throw new PolicyManagementServiceException(ErrorMessages.DEACTIVATE_STATUS_CODE.getErrorCode(), + ErrorMessages.DEACTIVATE_STATUS_CODE.getErrorMessage()); + } Optional policy = authPolicyRepository.findById(policyId); if (policy.isEmpty()){ logger.error("The policy does not exits for policy Id:", policyId); @@ -1246,7 +1255,7 @@ public ResponseWrapperV2 deactivatePolicy(String po return responseWrapper; } - public ResponseWrapperV2 deactivatePolicyGroup(String policyGroupId) { + public ResponseWrapperV2 deactivatePolicyGroup(String policyGroupId, DeactivateRequestDto requestDto) { ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); try { if (Objects.isNull(policyGroupId) || policyGroupId.isBlank()){ @@ -1254,6 +1263,12 @@ public ResponseWrapperV2 deactivatePolicyGroup throw new PolicyManagementServiceException(ErrorMessages.INVALID_INPUT_PARAMETER.getErrorCode(), ErrorMessages.INVALID_INPUT_PARAMETER.getErrorMessage()); } + String status = requestDto.getStatus(); + if (Objects.isNull(status) || status.isBlank() || !status.equals(DEACTIVATE)) { + logger.info(status + " : is Invalid Input Parameter, it should be (De-Activate)"); + throw new PolicyManagementServiceException(ErrorMessages.DEACTIVATE_STATUS_CODE.getErrorCode(), + ErrorMessages.DEACTIVATE_STATUS_CODE.getErrorMessage()); + } Optional policyGroupFromDb = policyGroupRepository.findById(policyGroupId); if (policyGroupFromDb.isEmpty()){ logger.error("The policy group does not exits for policy group Id:", policyGroupId); diff --git a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/controller/PolicyManagementControllerTest.java b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/controller/PolicyManagementControllerTest.java index c3e25774d9..2d985da414 100644 --- a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/controller/PolicyManagementControllerTest.java +++ b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/controller/PolicyManagementControllerTest.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import io.mosip.pms.common.dto.*; +import io.mosip.pms.common.request.dto.RequestWrapperV2; import io.mosip.pms.common.response.dto.ResponseWrapperV2; import io.mosip.pms.policy.controller.PolicyManagementController; import io.mosip.pms.policy.dto.*; @@ -824,20 +825,36 @@ public void getAllPoliciesTest() throws Exception { @Test public void deactivatePolicyTest() throws Exception { + RequestWrapperV2 requestWrapper = new RequestWrapperV2<>(); + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + requestWrapper.setRequest(requestDto); + ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); + DeactivatePolicyResponseDto deactivatePolicyResponseDto = new DeactivatePolicyResponseDto(); + responseWrapper.setResponse(deactivatePolicyResponseDto); - Mockito.when(policyManagementService.deactivatePolicy(anyString())) + Mockito.when(policyManagementService.deactivatePolicy(anyString(), any())) .thenReturn(responseWrapper); - policyManagementController.deactivatePolicy("policy123"); + mockMvc.perform(MockMvcRequestBuilders.patch("/policies/12345").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(objectMapper.writeValueAsString(requestWrapper))).andExpect(status().isOk()); } @Test public void deactivatePolicyGroupTest() throws Exception { - String policyGroupId = "test-policy-group-id"; + RequestWrapperV2 requestWrapper = new RequestWrapperV2<>(); + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + requestWrapper.setRequest(requestDto); + ResponseWrapperV2 responseWrapper = new ResponseWrapperV2<>(); - when(policyManagementService.deactivatePolicyGroup(policyGroupId)).thenReturn(responseWrapper); + DeactivatePolicyGroupResponseDto deactivatePolicyGroupResponseDto = new DeactivatePolicyGroupResponseDto(); + responseWrapper.setResponse(deactivatePolicyGroupResponseDto); + + Mockito.when(policyManagementService.deactivatePolicyGroup(anyString(), any())).thenReturn(responseWrapper); - policyManagementController.deactivatePolicyGroup(policyGroupId); + mockMvc.perform(MockMvcRequestBuilders.patch("/policies/group/12345").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(objectMapper.writeValueAsString(requestWrapper))).andExpect(status().isOk()); } } diff --git a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java index 7632a5acf8..4a9ed6bb79 100644 --- a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java +++ b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java @@ -1278,6 +1278,9 @@ public void getAllPoliciesTestException() throws Exception { @Test public void deactivatePolicyTest() throws Exception { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + AuthPolicy authPolicy = new AuthPolicy(); authPolicy.setIsActive(true); when(authPolicyRepository.findById(anyString())).thenReturn(Optional.of(authPolicy)); @@ -1285,24 +1288,32 @@ public void deactivatePolicyTest() throws Exception { authPolicy.setIsActive(false); when(authPolicyRepository.save(any())).thenReturn(authPolicy); - service.deactivatePolicy("policy123"); + service.deactivatePolicy("policy123", requestDto); } @Test public void deactivatePolicyExceptionTest0() throws Exception { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + AuthPolicy authPolicy = new AuthPolicy(); authPolicy.setIsActive(true); when(authPolicyRepository.findById(anyString())).thenReturn(Optional.empty()); - service.deactivatePolicy("policy123"); + service.deactivatePolicy("policy123", requestDto); } @Test public void deactivatePolicyExceptionTest1() throws Exception { - service.deactivatePolicy(""); + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + service.deactivatePolicy("", requestDto); } @Test public void deactivatePolicyExceptionTest2() throws Exception { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + AuthPolicy authPolicy = new AuthPolicy(); authPolicy.setIsActive(true); when(authPolicyRepository.findById(anyString())).thenReturn(Optional.of(authPolicy)); @@ -1315,11 +1326,14 @@ public void deactivatePolicyExceptionTest2() throws Exception { authPolicy.setIsActive(false); when(authPolicyRepository.save(any())).thenReturn(authPolicy); - service.deactivatePolicy("policy123"); + service.deactivatePolicy("policy123", requestDto); } @Test public void deactivatePolicyGroupTestSuccess() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + String policyGroupId = "group123"; PolicyGroup mockPolicyGroup = new PolicyGroup(); mockPolicyGroup.setId(policyGroupId); @@ -1334,7 +1348,7 @@ public void deactivatePolicyGroupTestSuccess() { when(policyGroupRepository.save(any(PolicyGroup.class))).thenReturn(mockPolicyGroup); ResponseWrapperV2 response = - service.deactivatePolicyGroup(policyGroupId); + service.deactivatePolicyGroup(policyGroupId, requestDto); assertNotNull(response); assertNotNull(response.getResponse()); @@ -1346,8 +1360,11 @@ public void deactivatePolicyGroupTestSuccess() { @Test public void deactivatePolicyGroupTestNullPolicyGroupId() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + ResponseWrapperV2 response = - service.deactivatePolicyGroup(null); + service.deactivatePolicyGroup(null, requestDto); // Assert assertNotNull(response); @@ -1358,8 +1375,11 @@ public void deactivatePolicyGroupTestNullPolicyGroupId() { @Test public void deactivatePolicyGroupTestEmptyPolicyGroupId() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + ResponseWrapperV2 response = - service.deactivatePolicyGroup(""); + service.deactivatePolicyGroup("", requestDto); // Assert assertNotNull(response); @@ -1370,11 +1390,14 @@ public void deactivatePolicyGroupTestEmptyPolicyGroupId() { @Test public void deactivatePolicyGroupTestInvalidPolicyGroup() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + String policyGroupId = "group123"; when(policyGroupRepository.findById(policyGroupId)).thenReturn(Optional.empty()); ResponseWrapperV2 response = - service.deactivatePolicyGroup(policyGroupId); + service.deactivatePolicyGroup(policyGroupId, requestDto); // Assert assertNotNull(response); @@ -1385,6 +1408,9 @@ public void deactivatePolicyGroupTestInvalidPolicyGroup() { @Test public void deactivatePolicyGroupTest_AlreadyDeactivated() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + String policyGroupId = "group123"; PolicyGroup mockPolicyGroup = new PolicyGroup(); mockPolicyGroup.setId(policyGroupId); @@ -1393,7 +1419,7 @@ public void deactivatePolicyGroupTest_AlreadyDeactivated() { when(policyGroupRepository.findById(policyGroupId)).thenReturn(Optional.of(mockPolicyGroup)); ResponseWrapperV2 response = - service.deactivatePolicyGroup(policyGroupId); + service.deactivatePolicyGroup(policyGroupId, requestDto); // Assert assertNotNull(response); @@ -1404,6 +1430,9 @@ public void deactivatePolicyGroupTest_AlreadyDeactivated() { @Test public void deactivatePolicyGroupTest_ActivePoliciesExist() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + String policyGroupId = "group123"; PolicyGroup mockPolicyGroup = new PolicyGroup(); mockPolicyGroup.setId(policyGroupId); @@ -1417,7 +1446,7 @@ public void deactivatePolicyGroupTest_ActivePoliciesExist() { when(authPolicyRepository.findPolicyCountsByPolicyGroupId(policyGroupId)).thenReturn(mockPolicyCountDto); ResponseWrapperV2 response = - service.deactivatePolicyGroup(policyGroupId); + service.deactivatePolicyGroup(policyGroupId, requestDto); // Assert assertNotNull(response); @@ -1428,6 +1457,8 @@ public void deactivatePolicyGroupTest_ActivePoliciesExist() { @Test public void deactivatePolicyGroupTest_DraftPoliciesExist() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); // Arrange String policyGroupId = "group123"; PolicyGroup mockPolicyGroup = new PolicyGroup(); @@ -1442,7 +1473,7 @@ public void deactivatePolicyGroupTest_DraftPoliciesExist() { when(authPolicyRepository.findPolicyCountsByPolicyGroupId(policyGroupId)).thenReturn(mockPolicyCountDto); ResponseWrapperV2 response = - service.deactivatePolicyGroup(policyGroupId); + service.deactivatePolicyGroup(policyGroupId, requestDto); // Assert assertNotNull(response); @@ -1453,6 +1484,9 @@ public void deactivatePolicyGroupTest_DraftPoliciesExist() { @Test public void deactivatePolicyGroupTest_ActiveAndDraftPoliciesExist() { + DeactivateRequestDto requestDto = new DeactivateRequestDto(); + requestDto.setStatus("De-Activate"); + String policyGroupId = "group123"; PolicyGroup mockPolicyGroup = new PolicyGroup(); mockPolicyGroup.setId(policyGroupId); @@ -1466,7 +1500,7 @@ public void deactivatePolicyGroupTest_ActiveAndDraftPoliciesExist() { when(authPolicyRepository.findPolicyCountsByPolicyGroupId(policyGroupId)).thenReturn(mockPolicyCountDto); ResponseWrapperV2 response = - service.deactivatePolicyGroup(policyGroupId); + service.deactivatePolicyGroup(policyGroupId, requestDto); // Assert assertNotNull(response);