Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-25539] made corrections in API body 5 #671

Merged
merged 46 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4fad21b
[MOSIP-24670] Updated API correction id and version
aihamh Nov 28, 2022
95025ef
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Nov 29, 2022
5c38170
[MOSIP-24670] Updated API body correction
aihamh Nov 29, 2022
fa09a84
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 1, 2022
da5b52e
[MOSIP-22640] Fixed Sonar Bugs
aihamh Dec 2, 2022
3729e67
updated PR
aihamh Dec 2, 2022
924d5e9
updated PR
aihamh Dec 2, 2022
0a58d82
updated review code
aihamh Dec 2, 2022
d6e7379
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 5, 2022
dbea954
[MOSIP-22640] Fixed sonar bugs
aihamh Dec 5, 2022
7fe46bd
updated PR
aihamh Dec 5, 2022
d4aa199
updated PR
aihamh Dec 5, 2022
96f375e
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 6, 2022
5689396
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 7, 2022
d5e7a0d
[MOSIP-22639] Resolved security hotspots in code
aihamh Dec 7, 2022
6206c82
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 12, 2022
97e7f06
[MOSIP-24630] Fixed Security Vulnerability in code
aihamh Dec 12, 2022
a8f6c5b
added error for isValidUrl method
aihamh Dec 13, 2022
eca676b
renamed vaildateURL method
aihamh Dec 13, 2022
054d6fd
updated PR
aihamh Dec 13, 2022
c3a7398
updated PR
aihamh Dec 13, 2022
579e5f8
[MOSIP-24670] Made corrections in id and version
aihamh Dec 21, 2022
38c38de
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 21, 2022
debe14b
resolved conflicts
aihamh Dec 21, 2022
ffdbeb1
updated PR
aihamh Dec 21, 2022
67cf9ad
updated PR
aihamh Dec 21, 2022
374ce63
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 22, 2022
3cc97ed
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 23, 2022
ebfd5d1
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Dec 26, 2022
0957e1b
[MOSIP-24670] Made corrections n API body, response code
aihamh Dec 28, 2022
defa915
updated PR
aihamh Dec 30, 2022
5cd32c5
updated PR
aihamh Dec 30, 2022
efc6f3e
updated dateTime
aihamh Jan 2, 2023
660242e
updated PR
aihamh Jan 2, 2023
f9fc826
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Jan 2, 2023
7396725
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Jan 5, 2023
a4f26f0
[MOSIP-25539] Made corrections in API body, response code
aihamh Jan 5, 2023
0887331
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Jan 6, 2023
e15c891
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Jan 10, 2023
be6421e
[MOSIP-25539] made corrections in API body
aihamh Jan 12, 2023
65b1d7c
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Jan 12, 2023
a3ec456
updated error message
aihamh Jan 12, 2023
83446e0
updated error code
aihamh Jan 12, 2023
ceed0c9
updated trasactionid dto change
aihamh Jan 12, 2023
3bb523b
Merge branch 'develop' of https://github.com/mosip/resident-services …
aihamh Jan 12, 2023
26eb59c
added equals
aihamh Jan 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public enum TransactionStage {
this.name = name;
this.listOfName = listOfName;
}

public String getName() {
return name;
}

public static String getTypeCode(String transactionTypeCode){
for (TransactionStage transactionStage : values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ public ResponseEntity<Object> requestVidCard(@PathVariable("VID") String vid) th
.body(tupleResponse.getT1());
}

@GetMapping("/status/individualId/{individualId}")
public ResponseEntity<Object> getStatus(@PathVariable("individualId") String individualId) throws BaseCheckedException, IOException {
ResponseWrapper<CheckStatusResponseDTO> responseWrapper = downloadCardService.getIndividualIdStatus(individualId);
@GetMapping("/aid-stage/{aid}")
public ResponseEntity<Object> getStatus(@PathVariable("aid") String aid) throws BaseCheckedException, IOException {
ResponseWrapper<CheckStatusResponseDTO> responseWrapper = downloadCardService.getIndividualIdStatus(aid);
return ResponseEntity.ok()
.body(responseWrapper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public class ResidentController {

@Value("${resident.download.card.eventid.version}")
private String downloadCardEventidVersion;

@Value("${resident.vid.version.new}")
private String newVersion;

@Value("${resident.checkstatus.id}")
private String checkStatusId;

private static final Logger logger = LoggerConfiguration.logConfig(ResidentController.class);

Expand Down Expand Up @@ -471,7 +477,7 @@ private String getIdType(String id) {
}

@ResponseFilter
@PostMapping("/aid/get-individual-id")
@PostMapping("/aid/status")
@Operation(summary = "checkAidStatus", description = "Get AID Status", tags = { "resident-controller" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "201", description = "Created", content = @Content(schema = @Schema(hidden = true))),
Expand All @@ -488,6 +494,8 @@ public ResponseWrapper<AidStatusResponseDTO> checkAidStatus(@RequestBody Request
logger.debug("ResidentController::getAidStatus()::exit");
ResponseWrapper<AidStatusResponseDTO> responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(resp);
responseWrapper.setId(checkStatusId);
responseWrapper.setVersion(newVersion);
return responseWrapper;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import java.security.NoSuchAlgorithmException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.dto.AidOtpRequestDTO;
import io.mosip.resident.dto.IndividualIdOtpRequestDTO;
import io.mosip.resident.dto.OtpRequestDTO;
import io.mosip.resident.dto.OtpResponseDTO;
import io.mosip.resident.exception.ApisResourceAccessException;
Expand All @@ -32,6 +33,12 @@ public class ResidentOtpController {

@Autowired
private AuditUtil audit;

@Value("${mosip.resident.api.id.otp.request}")
private String otpRequestId;

@Value("${resident.version.new}")
private String otpRequestVersion;

@PostMapping(value = "/req/otp")
@Operation(summary = "reqOtp", description = "reqOtp", tags = { "resident-otp-controller" })
Expand All @@ -49,20 +56,22 @@ public OtpResponseDTO reqOtp(@RequestBody OtpRequestDTO otpRequestDto) throws Re
}

@PostMapping(value = "/req/individualId/otp")
@Operation(summary = "reqAidOtp", description = "reqAidOtp", tags = { "resident-otp-controller" })
@Operation(summary = "reqIndividualIdOtp", description = "reqIndividualIdOtp", tags = { "resident-otp-controller" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))})
public OtpResponseDTO reqOtpForAid(@RequestBody AidOtpRequestDTO otpRequestDto) throws ResidentServiceCheckedException, NoSuchAlgorithmException, ApisResourceAccessException {
audit.setAuditRequestDto(EventEnum.OTP_AID_GEN);
if(otpRequestDto.getAid() == null) {
throw new ResidentServiceCheckedException(ResidentErrorCode.INVALID_INPUT.getErrorCode(), ResidentErrorCode.INVALID_INPUT.getErrorMessage() + "aid");
public OtpResponseDTO reqOtpForIndividualId(@RequestBody IndividualIdOtpRequestDTO otpRequestDto) throws ResidentServiceCheckedException, NoSuchAlgorithmException, ApisResourceAccessException {
audit.setAuditRequestDto(EventEnum.OTP_INDIVIDUALID_GEN);
if(otpRequestDto.getIndividualId() == null) {
throw new ResidentServiceCheckedException(ResidentErrorCode.INVALID_INPUT.getErrorCode(), ResidentErrorCode.INVALID_INPUT.getErrorMessage() + "individualId");
}
OtpResponseDTO otpResponseDTO = residentOtpService.generateOtpForAid(otpRequestDto);
audit.setAuditRequestDto(EventEnum.OTP_AID_GEN_SUCCESS);
OtpResponseDTO otpResponseDTO = residentOtpService.generateOtpForIndividualId(otpRequestDto);
audit.setAuditRequestDto(EventEnum.OTP_INDIVIDUALID_GEN_SUCCESS);
otpResponseDTO.setId(otpRequestId);
otpResponseDTO.setVersion(otpRequestVersion);
return otpResponseDTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class AidStatusRequestDTO {

private String aid;
private String otp;
private String transactionID;
private String transactionId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
public class AidStatusResponseDTO {

private String individualId;
private String individualIdType;
private String transactionID;
private String transactionId;
private String aidStatus;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
/**
* This class is used to provide request for OTP generation.
*
* @author Dinesh Karuppiah
* @author Aiham Hasan
*
*/

@Data
@EqualsAndHashCode(callSuper=true)
public class AidOtpRequestDTO extends OtpRequestDTO{
public class IndividualIdOtpRequestDTO extends OtpRequestDTO{

/** Variable to hold individualID */
private String aid;
private String individualId;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.mosip.resident.service;

import io.mosip.resident.dto.AidOtpRequestDTO;
import io.mosip.resident.dto.IndividualIdOtpRequestDTO;
import io.mosip.resident.dto.OtpRequestDTO;
import io.mosip.resident.dto.OtpResponseDTO;
import io.mosip.resident.exception.ApisResourceAccessException;
Expand All @@ -23,6 +23,6 @@ public interface ResidentOtpService {

public void insertData(OtpRequestDTO otpRequestDTO) throws ResidentServiceCheckedException, NoSuchAlgorithmException, ApisResourceAccessException;

public OtpResponseDTO generateOtpForAid(AidOtpRequestDTO otpRequestDto) throws NoSuchAlgorithmException, ResidentServiceCheckedException, ApisResourceAccessException;
public OtpResponseDTO generateOtpForIndividualId(IndividualIdOtpRequestDTO otpRequestDto) throws NoSuchAlgorithmException, ResidentServiceCheckedException, ApisResourceAccessException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.mosip.resident.constant.RequestType;
import io.mosip.resident.constant.ResidentConstants;
import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.constant.TransactionStage;
import io.mosip.resident.dto.CheckStatusResponseDTO;
import io.mosip.resident.dto.CredentialReqestDto;
import io.mosip.resident.dto.DownloadCardRequestDTO;
Expand Down Expand Up @@ -124,7 +125,15 @@ public Tuple2<byte[], String> getDownloadCardPDF(MainRequestDTO<DownloadCardRequ
String idType = identityService.getIndividualIdType(individualId);
if (idType.equalsIgnoreCase(AID)) {
rid = individualId;
pdfBytes = residentService.getUINCard(rid);
HashMap<String, String> ridStatus = utilities.getPacketStatus(rid);
String transactionTypeCode = ridStatus.get(ResidentConstants.TRANSACTION_TYPE_CODE);
String aidStatus = ridStatus.get(ResidentConstants.AID_STATUS);
if (transactionTypeCode.equalsIgnoreCase(TransactionStage.CARD_READY_TO_DOWNLOAD.getName()) && aidStatus.equalsIgnoreCase(EventStatus.SUCCESS.name())) {
pdfBytes = residentService.getUINCard(rid);
} else {
throw new ResidentServiceException(ResidentErrorCode.CARD_NOT_READY.getErrorCode(),
ResidentErrorCode.CARD_NOT_READY.getErrorMessage());
}
} else if (idType.equalsIgnoreCase(VID)) {
ResidentTransactionEntity residentTransactionEntity = residentTransactionRepository.findTopByAidOrderByCrDtimesDesc(individualId);
if(residentTransactionEntity !=null ){
Expand Down Expand Up @@ -382,8 +391,8 @@ public Tuple2<ResponseWrapper<VidDownloadCardResponseDto>, String> getVidCardEve
}

@Override
public ResponseWrapper<CheckStatusResponseDTO> getIndividualIdStatus(String individualId) throws ApisResourceAccessException, IOException {
HashMap<String, String> packetStatusMap = utilities.getPacketStatus(individualId);
public ResponseWrapper<CheckStatusResponseDTO> getIndividualIdStatus(String aid) throws ApisResourceAccessException, IOException {
HashMap<String, String> packetStatusMap = utilities.getPacketStatus(aid);
return getCheckStatusResponse(packetStatusMap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.mosip.resident.constant.ResidentConstants;
import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.constant.ServiceType;
import io.mosip.resident.dto.AidOtpRequestDTO;
import io.mosip.resident.dto.IndividualIdOtpRequestDTO;
import io.mosip.resident.dto.OtpRequestDTO;
import io.mosip.resident.dto.OtpResponseDTO;
import io.mosip.resident.entity.ResidentTransactionEntity;
Expand Down Expand Up @@ -124,11 +124,11 @@ private String getRefIdHash(String individualId) throws NoSuchAlgorithmException
}

@Override
public OtpResponseDTO generateOtpForAid(AidOtpRequestDTO otpRequestDto)
public OtpResponseDTO generateOtpForIndividualId(IndividualIdOtpRequestDTO otpRequestDto)
throws NoSuchAlgorithmException, ResidentServiceCheckedException, ApisResourceAccessException {
String individualId;
try {
individualId = identityServiceImpl.getIndividualIdForAid(otpRequestDto.getAid());
individualId = identityServiceImpl.getIndividualIdForAid(otpRequestDto.getIndividualId());
otpRequestDto.setIndividualId(individualId);
return generateOtp(otpRequestDto);
} catch (ResidentServiceCheckedException | ApisResourceAccessException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1940,13 +1940,13 @@ public AidStatusResponseDTO getAidStatus(AidStatusRequestDTO reqDto, boolean per
String individualId = identityServiceImpl.getIndividualIdForAid(reqDto.getAid());
boolean validStatus = individualId != null;
if (performOtpValidation) {
validStatus = idAuthServiceImpl.validateOtp(reqDto.getTransactionID(), individualId, reqDto.getOtp());
validStatus = idAuthServiceImpl.validateOtp(reqDto.getTransactionId(), individualId, reqDto.getOtp());
}
if (validStatus) {
AidStatusResponseDTO aidStatusResponseDTO = new AidStatusResponseDTO();
aidStatusResponseDTO.setIndividualId(individualId);
aidStatusResponseDTO.setAidStatus(PROCESSED);
aidStatusResponseDTO.setTransactionID(reqDto.getTransactionID());
aidStatusResponseDTO.setTransactionId(reqDto.getTransactionId());
return aidStatusResponseDTO;
}
throw new ResidentServiceCheckedException(ResidentErrorCode.AID_STATUS_IS_NOT_READY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ public enum EventEnum {
"Residence service", "NO_ID", "NO_ID_TYPE", RegistrationConstants.APPLICATIONID,
RegistrationConstants.APPLICATIONNAME),

OTP_AID_GEN("RES-SER-194", RegistrationConstants.SYSTEM, "generating otp for aid", "Request for generating otp for aid", "RES-SER",
OTP_INDIVIDUALID_GEN("RES-SER-194", RegistrationConstants.SYSTEM, "generating otp for Individual ID", "Request for generating otp for Individual ID", "RES-SER",
"Residence service", "NO_ID", "NO_ID_TYPE", RegistrationConstants.APPLICATIONID,
RegistrationConstants.APPLICATIONNAME),
OTP_AID_GEN_SUCCESS("RES-SER-195", RegistrationConstants.SYSTEM, "generating otp for aid success", "otp generation for aid is success",
OTP_INDIVIDUALID_GEN_SUCCESS("RES-SER-195", RegistrationConstants.SYSTEM, "generating otp for Individual ID success", "otp generation for Individual ID is success",
"RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE", RegistrationConstants.APPLICATIONID,
RegistrationConstants.APPLICATIONNAME),
OTP_AID_GEN_EXCEPTION("RES-SER-196", RegistrationConstants.SYSTEM, "generating otp for aid failure", "otp generation for aid is failed",
Expand All @@ -480,12 +480,18 @@ public enum EventEnum {
AID_STATUS("RES-SER-210", RegistrationConstants.SYSTEM, "Checking AID status", "Request for checking AID status",
"RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE", RegistrationConstants.APPLICATIONID,
RegistrationConstants.APPLICATIONNAME),
INDIVIDUALID_STATUS("RES-SER-210", RegistrationConstants.SYSTEM, "Checking Individual ID status", "Request for checking Individual ID status",
"RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE", RegistrationConstants.APPLICATIONID,
RegistrationConstants.APPLICATIONNAME),
AID_STATUS_RESPONSE("RES-SER-211", RegistrationConstants.SYSTEM, "Checking AID status Response", "AID status is %s",
"RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE", RegistrationConstants.APPLICATIONID,
RegistrationConstants.APPLICATIONNAME),
AID_STATUS_SUCCESS("RES-SER-212", RegistrationConstants.SYSTEM, "Checking AID status Success",
"Request for checking AID status is success", "RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE",
RegistrationConstants.APPLICATIONID, RegistrationConstants.APPLICATIONNAME),
INDIVIDUALID_STATUS_SUCCESS("RES-SER-212", RegistrationConstants.SYSTEM, "Checking Individual ID status Success",
"Request for checking Individual ID status is success", "RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE",
RegistrationConstants.APPLICATIONID, RegistrationConstants.APPLICATIONNAME),
REQ_AUTH_TYPE_LOCK("RES-SER-213", RegistrationConstants.SYSTEM, "Request auth type lock",
"Requesting auth type lock is success", "RES-SER", "Residence service", "NO_ID", "NO_ID_TYPE",
RegistrationConstants.APPLICATIONID, RegistrationConstants.APPLICATIONNAME),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,25 @@ public boolean validateRequest(RequestWrapper<?> request, RequestIdType requestI
return true;

}

public boolean validateAidStatusRequest(RequestWrapper<?> request, RequestIdType requestIdType) {
if (StringUtils.isEmpty(request.getId()) || !request.getId().equals(map.get(requestIdType)))
throw new InvalidInputException("id");
try {
DateUtils.parseToLocalDateTime(request.getRequesttime());
} catch (Exception e) {
throw new InvalidInputException("requesttime");
}
if (StringUtils.isEmpty(request.getVersion()) || !request.getVersion().equals(newVersion))
throw new InvalidInputException("version");

if (request.getRequest() == null) {
audit.setAuditRequestDto(EventEnum.INPUT_DOESNT_EXISTS);
throw new InvalidInputException("request");
}
return true;

}

public static boolean isNumeric(String strNum) {
return !strNum.matches(("[0-9]+"));
Expand Down Expand Up @@ -840,10 +859,10 @@ private boolean validateIndividualIdvIdWithoutIdType(String individualId) {
}

public void validateAidStatusRequestDto(RequestWrapper<AidStatusRequestDTO> reqDto) throws ResidentServiceCheckedException {
validateRequest(reqDto, RequestIdType.CHECK_STATUS);
validateAidStatusRequest(reqDto, RequestIdType.CHECK_STATUS);

if(reqDto.getRequest().getAid() == null) {
throw new InvalidInputException("aid");
throw new InvalidInputException("individualId");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ resident.event.ack.download.id=mosip.resident.event.ack.download
resident.event.ack.download.version=1.0
resident.download.card.eventid.id =mosip.resident.download.card.eventid
resident.download.card.eventid.version=1.0
resident.vid.version.new=1.0
mosip.resident.checkstatus.individualid.id=mosip.resident.check-stage-status
resident.version.new=1.0
mosip.resident.api.id.otp.request=mosip.identity.otp.internal
#-----------------------------RID Properties---------------------------------------
# length of the rid
mosip.kernel.rid.length=29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;

import io.mosip.resident.dto.AidOtpRequestDTO;
import io.mosip.resident.dto.AuthError;
import io.mosip.resident.dto.IdentityDTO;
import io.mosip.resident.dto.IndividualIdOtpRequestDTO;
import io.mosip.resident.dto.MaskedResponseDTO;
import io.mosip.resident.dto.OtpRequestDTO;
import io.mosip.resident.dto.OtpResponseDTO;
Expand Down Expand Up @@ -92,18 +92,18 @@ public void generateOtpPhoneTest() throws Exception {
}

@Test
public void generateOtpForAid() throws Exception {
AidOtpRequestDTO aidOtpRequestDTO = getAidOtpRequestDTO();
public void generateOtpForIndividualId() throws Exception {
IndividualIdOtpRequestDTO aidOtpRequestDTO = getAidOtpRequestDTO();
OtpRequestDTO otpRequestDTO = getOtpRequestDTO();
aidOtpRequestDTO.setOtpChannel(List.of("EMAIL", "PHONE"));
Mockito.when(identityServiceImpl.getIndividualIdForAid(any())).thenReturn(otpRequestDTO.getIndividualId());
assertNotNull(residentOtpServiceImpl.generateOtpForAid(aidOtpRequestDTO));
assertNotNull(residentOtpServiceImpl.generateOtpForIndividualId(aidOtpRequestDTO));
}

@Ignore
@Test(expected = ResidentServiceCheckedException.class)
public void generateOtpFailureTest() throws Exception {
AidOtpRequestDTO aidOtpRequestDTO = getAidOtpRequestDTO();
IndividualIdOtpRequestDTO aidOtpRequestDTO = getAidOtpRequestDTO();
OtpRequestDTO otpRequestDTO = getOtpRequestDTO();
IdentityDTO identityDTO = getIdentityDTO();
identityDTO.setEmail(null);
Expand All @@ -115,12 +115,11 @@ public void generateOtpFailureTest() throws Exception {
when(identityServiceImpl.getIndividualIdForAid(any())).thenReturn(otpRequestDTO.getIndividualId());
Mockito.when(residentOtpServiceImpl.generateOtp(any())).thenThrow(new ResidentServiceCheckedException());
Mockito.when(residentServiceRestClient.postApi(any(), any(), any(), any())).thenReturn(otpResponseDTO);
assertNotNull(residentOtpServiceImpl.generateOtpForAid(aidOtpRequestDTO));
assertNotNull(residentOtpServiceImpl.generateOtpForIndividualId(aidOtpRequestDTO));
}

private AidOtpRequestDTO getAidOtpRequestDTO() {
AidOtpRequestDTO aidOtpRequestDTO = new AidOtpRequestDTO();
aidOtpRequestDTO.setAid("aid");
private IndividualIdOtpRequestDTO getAidOtpRequestDTO() {
IndividualIdOtpRequestDTO aidOtpRequestDTO = new IndividualIdOtpRequestDTO();
aidOtpRequestDTO.setIndividualId("individualId");
return aidOtpRequestDTO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void testGetStatus() throws Exception {
responseWrapper.setResponse(checkStatusResponseDTO);
Mockito.when(downloadCardService.getIndividualIdStatus(Mockito.any()))
.thenReturn(responseWrapper);
mockMvc.perform(MockMvcRequestBuilders.get("/status/individualId/12345")).andExpect(status().isOk());
mockMvc.perform(MockMvcRequestBuilders.get("/aid-stage/12345")).andExpect(status().isOk());
}

}
Loading