Skip to content

Commit

Permalink
[ES-1966] modified test cases for build failure issue (#66)
Browse files Browse the repository at this point in the history
* [MODIFIED] test cases issue resolved

Signed-off-by: Zeeshan Mehboob <[email protected]>

* [RENAMED] KBA to KBI, and error msg to challenge_format

Signed-off-by: Zeeshan Mehboob <[email protected]>

---------

Signed-off-by: Zeeshan Mehboob <[email protected]>
Signed-off-by: Zeeshan Mehboob <[email protected]>
  • Loading branch information
zesu22 authored Dec 3, 2024
1 parent cc591b7 commit 634669f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 414 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,156 +50,6 @@ public class MockAuthenticationServiceTest {
@Mock
ObjectMapper objectMapper;

/*@Test
public void doVerifiedKycExchange_withValidDetails_thenPass() throws KycExchangeException {
ReflectionTestUtils.setField(mockAuthenticationService, "kycExchangeUrl", "http://localhost:8080/kyc/exchange");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
ReflectionTestUtils.setField(mockAuthenticationService, "objectMapper", objectMapper);
VerifiedKycExchangeDto verifiedKycExchangeDto = new VerifiedKycExchangeDto();
verifiedKycExchangeDto.setKycToken("kycToken");
verifiedKycExchangeDto.setAcceptedClaims(Arrays.asList("name", "gender"));
verifiedKycExchangeDto.setClaimsLocales(new String[]{"eng", "hin"});
Map<String, VerificationFilter> acceptedVerifiedClaims=new HashMap<>();
VerificationFilter verificationFilterForName= new VerificationFilter();
FilterCriteria trustFrameWorkCriteria = new FilterCriteria();
trustFrameWorkCriteria.setValues(List.of("PWD", "Income-tax"));
FilterDateTime filterDateTime = new FilterDateTime();
filterDateTime.setMax_age(1000);
verificationFilterForName.setTime(filterDateTime);
verificationFilterForName.setTrust_framework(trustFrameWorkCriteria);
VerificationFilter verificationFilterForEmail= new VerificationFilter();
FilterCriteria trustFrameworkForEmail = new FilterCriteria();
trustFrameworkForEmail.setValues(List.of("PWD"));
filterDateTime.setMax_age(500);
verificationFilterForEmail.setTime(filterDateTime);
verificationFilterForEmail.setTrust_framework(trustFrameworkForEmail);
acceptedVerifiedClaims.put("name", verificationFilterForName);
acceptedVerifiedClaims.put("email", verificationFilterForEmail);
verifiedKycExchangeDto.setAcceptedVerifiedClaims(acceptedVerifiedClaims);
KycExchangeResponseDto kycExchangeResponseDto = new KycExchangeResponseDto();
kycExchangeResponseDto.setKyc("responseKyc");
ResponseWrapper responseWrapper = new ResponseWrapper();
responseWrapper.setResponse(kycExchangeResponseDto);
ResponseEntity<ResponseWrapper<KycExchangeResponseDto>> responseEntity = new ResponseEntity(responseWrapper, HttpStatus.OK);
Mockito.when(restTemplate.exchange(
Mockito.any(RequestEntity.class),
Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<KycExchangeResponseDto>>() {
})
)).thenReturn(responseEntity);
KycExchangeResult kycExchangeResult = mockAuthenticationService.doVerifiedKycExchange("RP", "CL", verifiedKycExchangeDto);
Assert.assertEquals(kycExchangeResponseDto.getKyc(), kycExchangeResult.getEncryptedKyc());
}
@Test
public void doVerifiedKycExchange_withEmptyResponse_thenFail() {
ReflectionTestUtils.setField(mockAuthenticationService, "kycExchangeUrl", "http://localhost:8080/kyc/exchange");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
ReflectionTestUtils.setField(mockAuthenticationService, "objectMapper", objectMapper);
VerifiedKycExchangeDto verifiedKycExchangeDto = new VerifiedKycExchangeDto();
verifiedKycExchangeDto.setKycToken("kycToken");
verifiedKycExchangeDto.setAcceptedClaims(Arrays.asList("name", "gender"));
verifiedKycExchangeDto.setClaimsLocales(new String[]{"eng", "hin"});
Map<String, VerificationFilter> acceptedVerifiedClaims=new HashMap<>();
VerificationFilter verificationFilterForName= new VerificationFilter();
FilterCriteria trustFrameWorkCriteria = new FilterCriteria();
trustFrameWorkCriteria.setValues(List.of("PWD", "Income-tax"));
FilterDateTime filterDateTime = new FilterDateTime();
filterDateTime.setMax_age(1000);
verificationFilterForName.setTime(filterDateTime);
verificationFilterForName.setTrust_framework(trustFrameWorkCriteria);
VerificationFilter verificationFilterForEmail= new VerificationFilter();
FilterCriteria trustFrameworkForEmail = new FilterCriteria();
trustFrameworkForEmail.setValues(List.of("PWD"));
filterDateTime.setMax_age(500);
verificationFilterForEmail.setTime(filterDateTime);
verificationFilterForEmail.setTrust_framework(trustFrameworkForEmail);
acceptedVerifiedClaims.put("name", verificationFilterForName);
acceptedVerifiedClaims.put("email", verificationFilterForEmail);
verifiedKycExchangeDto.setAcceptedVerifiedClaims(acceptedVerifiedClaims);
ResponseWrapper responseWrapper = new ResponseWrapper();
responseWrapper.setResponse(null);
ResponseEntity<ResponseWrapper<KycExchangeResponseDto>> responseEntity = new ResponseEntity(responseWrapper, HttpStatus.OK);
Mockito.when(restTemplate.exchange(
Mockito.any(RequestEntity.class),
Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<KycExchangeResponseDto>>() {
})
)).thenReturn(responseEntity);
try {
mockAuthenticationService.doVerifiedKycExchange("RP", "CL", verifiedKycExchangeDto);
Assert.fail();
} catch (KycExchangeException e) {
Assert.assertEquals(e.getErrorCode(), ErrorConstants.DATA_EXCHANGE_FAILED);
}
}
@Test
public void doVerifiedKycExchange_withInvalidDetails_thenFail() {
ReflectionTestUtils.setField(mockAuthenticationService, "kycExchangeUrl", "http://localhost:8080/kyc/exchange");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
ReflectionTestUtils.setField(mockAuthenticationService, "objectMapper", objectMapper);
VerifiedKycExchangeDto verifiedKycExchangeDto = new VerifiedKycExchangeDto();
verifiedKycExchangeDto.setKycToken("kycToken");
verifiedKycExchangeDto.setAcceptedClaims(Arrays.asList("name", "gender"));
verifiedKycExchangeDto.setClaimsLocales(new String[]{"eng", "hin"});
Map<String, VerificationFilter> acceptedVerifiedClaims=new HashMap<>();
VerificationFilter verificationFilterForName= new VerificationFilter();
FilterCriteria trustFrameWorkCriteria = new FilterCriteria();
trustFrameWorkCriteria.setValues(List.of("PWD", "Income-tax"));
FilterDateTime filterDateTime = new FilterDateTime();
filterDateTime.setMax_age(1000);
verificationFilterForName.setTime(filterDateTime);
verificationFilterForName.setTrust_framework(trustFrameWorkCriteria);
VerificationFilter verificationFilterForEmail= new VerificationFilter();
FilterCriteria trustFrameworkForEmail = new FilterCriteria();
trustFrameworkForEmail.setValues(List.of("PWD"));
filterDateTime.setMax_age(500);
verificationFilterForEmail.setTime(filterDateTime);
verificationFilterForEmail.setTrust_framework(trustFrameworkForEmail);
acceptedVerifiedClaims.put("name", verificationFilterForName);
acceptedVerifiedClaims.put("email", verificationFilterForEmail);
verifiedKycExchangeDto.setAcceptedVerifiedClaims(acceptedVerifiedClaims);
try {
mockAuthenticationService.doVerifiedKycExchange("RP", "CL", verifiedKycExchangeDto);
Assert.fail();
} catch (KycExchangeException e) {
Assert.assertEquals(e.getErrorCode(),"mock-ida-005");
}
}*/

@Test
public void doKycExchange_withValidDetails_thenPass() throws KycExchangeException {
ReflectionTestUtils.setField(mockAuthenticationService, "kycExchangeUrl", "http://localhost:8080/kyc/exchange");
Expand Down
Loading

0 comments on commit 634669f

Please sign in to comment.