Skip to content

Commit

Permalink
MOSIP:36283-Partner is able to reupload the Certificate for Deactivat…
Browse files Browse the repository at this point in the history
…ed FTM. (#925)

* MOSIP:36283-Partner is able to reupload the Certificate for Deactivated FTM.

Signed-off-by: sudeep <[email protected]>

* MOSIP:36283-Partner is able to reupload the Certificate for Deactivated FTM.

Signed-off-by: sudeep <[email protected]>

---------

Signed-off-by: sudeep <[email protected]>
  • Loading branch information
Sudeep7353 authored Oct 10, 2024
1 parent 0a8e961 commit 08a783b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ public FtpCertificateResponseDto uploadCertificate(FtpChipCertificateRequestDto
FoundationalTrustProviderErrorMessages.FTP_CHIP_ID_PROVIDER_ID_NOT_MATCHED.getErrorMessage());

}
if (!chipDetail.get().getApprovalStatus().equals(APPROVED) && !chipDetail.get().getApprovalStatus().equals(CommonConstant.PENDING_CERT_UPLOAD)){
throw new RequestException(FoundationalTrustProviderErrorMessages.INVALID_FTP_CHIP_STATUS.getErrorCode(),
FoundationalTrustProviderErrorMessages.INVALID_FTP_CHIP_STATUS.getErrorMessage());
}
if (chipDetail.get().getApprovalStatus().equals(APPROVED) && !chipDetail.get().isActive()){
throw new RequestException(FoundationalTrustProviderErrorMessages.FTP_CHIP_DEACTIVATED.getErrorCode(),
FoundationalTrustProviderErrorMessages.FTP_CHIP_DEACTIVATED.getErrorMessage());
}
FtpCertificateRequestDto certRequest = new FtpCertificateRequestDto();
certRequest.setCertificateData(ftpChipCertRequestDto.getCertificateData());
certRequest.setOrganizationName(ftpChipCertRequestDto.getOrganizationName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ public enum FoundationalTrustProviderErrorMessages {
FTP_PROVIDER_MAKE_MODEL_EXISTS("PMP_AUT_032","FTM Chip details already exists for the same make and model"),
FTP_CERT_NOT_UPLOADED("PMP_AUT_033","Certificate is not uploaded."),
FTP_CHIP_ID_PROVIDER_ID_NOT_MATCHED("PMP_AUT_034","Ftp chip detail id and ftp provider id not mappped. "),
FTP_PROVIDER_DETAILS_EXISTS("PMP_AUT_037","Given ftp chip details already registered.");
FTP_PROVIDER_DETAILS_EXISTS("PMP_AUT_037","Given ftp chip details already registered."),
INVALID_FTP_CHIP_STATUS("PMP_AUT_038","The certificate can only be uploaded for FTM that is either pending certificate upload or has an approved status."),
FTP_CHIP_DEACTIVATED("PMP_AUT_039","FTM chip is deactivated.");

private final String errorCode;
private final String errorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,23 +696,7 @@ public void testUploadCertificate4() throws IOException {
doNothing().when(auditUtil)
.auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any());
when(environment.getProperty((String) any())).thenReturn("Property");
FTPChipDetail ftpChipDetail = mock(FTPChipDetail.class);
when(ftpChipDetail.getFtpChipDetailId()).thenReturn("ChipId");
when(ftpChipDetail.getFtpProviderId()).thenReturn("ProviderId");
doNothing().when(ftpChipDetail).setActive(anyBoolean());
doNothing().when(ftpChipDetail).setApprovalStatus((String) any());
doNothing().when(ftpChipDetail).setCertificateAlias((String) any());
doNothing().when(ftpChipDetail).setCrBy((String) any());
doNothing().when(ftpChipDetail).setCrDtimes((LocalDateTime) any());
doNothing().when(ftpChipDetail).setDelDtimes((LocalDateTime) any());
doNothing().when(ftpChipDetail).setDeleted(anyBoolean());
doNothing().when(ftpChipDetail).setFtpChipDetailId((String) any());
doNothing().when(ftpChipDetail).setFtpProviderId((String) any());
doNothing().when(ftpChipDetail).setMake((String) any());
doNothing().when(ftpChipDetail).setModel((String) any());
doNothing().when(ftpChipDetail).setPartnerOrganizationName((String) any());
doNothing().when(ftpChipDetail).setUpdBy((String) any());
doNothing().when(ftpChipDetail).setUpdDtimes((LocalDateTime) any());
FTPChipDetail ftpChipDetail = new FTPChipDetail();
ftpChipDetail.setActive(true);
ftpChipDetail.setApprovalStatus("Approval Status");
ftpChipDetail.setCertificateAlias("Certificate Alias");
Expand All @@ -727,8 +711,7 @@ public void testUploadCertificate4() throws IOException {
ftpChipDetail.setPartnerOrganizationName("Partner Organization Name");
ftpChipDetail.setUpdBy("Upd By");
ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1));
Optional<FTPChipDetail> ofResult = Optional.of(ftpChipDetail);
when(ftpChipDetailRepository.findById((String) any())).thenReturn(ofResult);
when(ftpChipDetailRepository.findById((String) any())).thenReturn(Optional.of(ftpChipDetail));

Partner partner = new Partner();
partner.setAdditionalInfo("Additional Info");
Expand Down

0 comments on commit 08a783b

Please sign in to comment.