From d4623be576994265594b83cc03e108419dda7edb Mon Sep 17 00:00:00 2001 From: Md Humair Kankudti <163233654+Md-Humair-KK@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:58:37 +0530 Subject: [PATCH] Feature ES-1100 Integration with API - v2 kyc-auth endpoint to give out claim verification details (#49) * ES-1100 API integration kyc-auth v2 Signed-off-by: Md-Humair-KK * cherry-pick Signed-off-by: Md-Humair-KK * addressed review comments Signed-off-by: Md-Humair-KK * removed commented code Signed-off-by: Md-Humair-KK * fixed test case Signed-off-by: Md-Humair-KK * addressed review comments Signed-off-by: Md-Humair-KK --------- Signed-off-by: Md-Humair-KK --- .../plugin/mosipid/dto/IdaKycAuthRequest.java | 3 + .../mosipid/dto/IdaKycAuthResponse.java | 5 + .../mosipid/service/IdaAuthenticatorImpl.java | 143 +++++++++++------- .../src/main/resources/application.properties | 1 + .../service/IdaAuthenticatorImplTest.java | 116 +++++++++----- 5 files changed, 177 insertions(+), 91 deletions(-) diff --git a/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthRequest.java b/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthRequest.java index 1c78de2..9821db6 100644 --- a/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthRequest.java +++ b/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthRequest.java @@ -8,9 +8,11 @@ import java.util.List; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; @Data +@JsonInclude(JsonInclude.Include.NON_NULL) public class IdaKycAuthRequest { private String id; @@ -29,6 +31,7 @@ public class IdaKycAuthRequest { private String requestSessionKey; private Map metadata; private List allowedKycAttributes; + private Boolean claimMetadataRequired; @Data public static class AuthRequest { diff --git a/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthResponse.java b/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthResponse.java index ed009e5..e2ae557 100644 --- a/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthResponse.java +++ b/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/dto/IdaKycAuthResponse.java @@ -5,12 +5,17 @@ */ package io.mosip.esignet.plugin.mosipid.dto; +import com.fasterxml.jackson.databind.JsonNode; import lombok.Data; +import java.util.List; +import java.util.Map; + @Data public class IdaKycAuthResponse { private String kycToken; private String authToken; private boolean kycStatus; + private Map> verifiedClaims; } diff --git a/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImpl.java b/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImpl.java index 7ff92e9..48a3fe8 100644 --- a/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImpl.java +++ b/mosip-identity-plugin/src/main/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImpl.java @@ -8,9 +8,9 @@ import java.util.*; import io.mosip.esignet.api.dto.*; -import io.mosip.esignet.plugin.mosipid.dto.GetAllCertificatesResponse; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycAuthResponse; +import io.mosip.esignet.plugin.mosipid.dto.*; import io.mosip.esignet.plugin.mosipid.helper.AuthTransactionHelper; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -26,11 +26,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycAuthRequest; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycExchangeRequest; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycExchangeResponse; -import io.mosip.esignet.plugin.mosipid.dto.IdaResponseWrapper; -import io.mosip.esignet.plugin.mosipid.dto.IdaSendOtpRequest; import io.mosip.esignet.api.exception.KycAuthException; import io.mosip.esignet.api.exception.KycExchangeException; import io.mosip.esignet.api.exception.KycSigningCertificateException; @@ -67,7 +62,10 @@ public class IdaAuthenticatorImpl implements Authenticator { @Value("${mosip.esignet.authenticator.ida.kyc-auth-url}") private String kycAuthUrl; - + + @Value("${mosip.esignet.authenticator.ida.kyc-auth-url-v2}") + private String kycAuthUrlV2; + @Value("${mosip.esignet.authenticator.ida.kyc-exchange-url}") private String kycExchangeUrl; @@ -101,49 +99,7 @@ public class IdaAuthenticatorImpl implements Authenticator { @Override public KycAuthResult doKycAuth(String relyingPartyId, String clientId, KycAuthDto kycAuthDto) throws KycAuthException { - log.info("Started to build kyc-auth request with transactionId : {} && clientId : {}", - kycAuthDto.getTransactionId(), clientId); - try { - IdaKycAuthRequest idaKycAuthRequest = new IdaKycAuthRequest(); - idaKycAuthRequest.setId(kycAuthId); - idaKycAuthRequest.setVersion(idaVersion); - idaKycAuthRequest.setRequestTime(HelperService.getUTCDateTime()); - idaKycAuthRequest.setDomainUri(idaDomainUri); - idaKycAuthRequest.setEnv(idaEnv); - idaKycAuthRequest.setConsentObtained(true); - idaKycAuthRequest.setIndividualId(kycAuthDto.getIndividualId()); - idaKycAuthRequest.setTransactionID(kycAuthDto.getTransactionId()); - helperService.setAuthRequest(kycAuthDto.getChallengeList(), idaKycAuthRequest); - - //set signature header, body and invoke kyc auth endpoint - String requestBody = objectMapper.writeValueAsString(idaKycAuthRequest); - RequestEntity requestEntity = RequestEntity - .post(UriComponentsBuilder.fromUriString(kycAuthUrl).pathSegment(relyingPartyId, clientId).build().toUri()) - .contentType(MediaType.APPLICATION_JSON_UTF8) - .header(SIGNATURE_HEADER_NAME, helperService.getRequestSignature(requestBody)) - .header(AUTHORIZATION_HEADER_NAME, AUTHORIZATION_HEADER_NAME) - .body(requestBody); - ResponseEntity> responseEntity = restTemplate.exchange(requestEntity, - new ParameterizedTypeReference>() {}); - - if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { - IdaResponseWrapper responseWrapper = responseEntity.getBody(); - if(responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && responseWrapper.getResponse().getKycToken() != null) { - return new KycAuthResult(responseEntity.getBody().getResponse().getKycToken(), - responseEntity.getBody().getResponse().getAuthToken()); - } - log.error("Error response received from IDA KycStatus : {} && Errors: {}", - responseWrapper.getResponse().isKycStatus(), responseWrapper.getErrors()); - throw new KycAuthException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ? - ErrorConstants.AUTH_FAILED : responseWrapper.getErrors().get(0).getErrorCode()); - } - - log.error("Error response received from IDA (Kyc-auth) with status : {}", responseEntity.getStatusCode()); - } catch (KycAuthException e) { throw e; } catch (Exception e) { - log.error("KYC-auth failed with transactionId : {} && clientId : {}", kycAuthDto.getTransactionId(), - clientId, e); - } - throw new KycAuthException(ErrorConstants.AUTH_FAILED); + return doKycAuthentication(relyingPartyId, clientId, kycAuthDto, false); } @Override @@ -251,10 +207,91 @@ public List getAllKycSigningCertificates() throws Kyc } @Override - public KycAuthResult doKycAuth(String relyingPartyId, String clientId, boolean claimsMetadataRequired, KycAuthDto kycAuthDto) throws KycAuthException { - return doKycAuth(relyingPartyId, clientId, kycAuthDto); //TODO + public KycAuthResult doKycAuth(String relyingPartyId, String clientId, boolean claimsMetadataRequired, + KycAuthDto kycAuthDto) throws KycAuthException { + return doKycAuthentication(relyingPartyId, clientId, kycAuthDto, claimsMetadataRequired); + } + + /** + * Method for kyc authentication based on claimsMetadataRequired flag this will authenticate in accordance with + * v2 or existing flow. + * @param relyingPartyId relyingPartyId required for the request + * @param clientId clientId required for the request + * @param kycAuthDto {@link KycAuthDto} required for the request with authorization details + * @param claimsMetadataRequired boolean flag to recognize v2 or existing flow + * @return {@link KycAuthResult} + * @throws KycAuthException throws this exception when fail to get the response + */ + private KycAuthResult doKycAuthentication(String relyingPartyId, String clientId, KycAuthDto kycAuthDto, + boolean claimsMetadataRequired) throws KycAuthException { + log.info("Started to build kyc-auth request with transactionId : {} && clientId : {}", + kycAuthDto.getTransactionId(), clientId); + try { + IdaKycAuthRequest idaKycAuthRequest = getIdaKycAuthRequest(kycAuthDto, claimsMetadataRequired); + helperService.setAuthRequest(kycAuthDto.getChallengeList(), idaKycAuthRequest); + + //set signature header, body and invoke kyc auth endpoint + String requestBody = objectMapper.writeValueAsString(idaKycAuthRequest); + RequestEntity requestEntity = RequestEntity + .post(UriComponentsBuilder.fromUriString(claimsMetadataRequired ? kycAuthUrlV2 : kycAuthUrl) + .pathSegment(relyingPartyId, clientId).build().toUri()) + .contentType(MediaType.APPLICATION_JSON_UTF8) + .header(SIGNATURE_HEADER_NAME, helperService.getRequestSignature(requestBody)) + .header(AUTHORIZATION_HEADER_NAME, AUTHORIZATION_HEADER_NAME) + .body(requestBody); + ResponseEntity> responseEntity = restTemplate.exchange(requestEntity, + new ParameterizedTypeReference<>() { + }); + + if(responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) { + IdaResponseWrapper responseWrapper = responseEntity.getBody(); + if(responseWrapper.getResponse() != null && responseWrapper.getResponse().isKycStatus() && + responseWrapper.getResponse().getKycToken() != null) { + return claimsMetadataRequired ? (new KycAuthResult(responseEntity.getBody().getResponse().getKycToken(), + responseEntity.getBody().getResponse().getAuthToken(), + responseEntity.getBody().getResponse().getVerifiedClaims())) + : (new KycAuthResult(responseEntity.getBody().getResponse().getKycToken(), + responseEntity.getBody().getResponse().getAuthToken())); + } + assert responseWrapper.getResponse() != null; + log.error("Error response received from IDA KycStatus : {} && Errors: {}", + responseWrapper.getResponse().isKycStatus(), responseWrapper.getErrors()); + throw new KycAuthException(CollectionUtils.isEmpty(responseWrapper.getErrors()) ? + ErrorConstants.AUTH_FAILED : responseWrapper.getErrors().get(0).getErrorCode()); + } + + log.error("Error response received from IDA (Kyc-auth) with status : {}", responseEntity.getStatusCode()); + } catch (KycAuthException e) { throw e; } catch (Exception e) { + log.error("KYC-auth failed with transactionId : {} && clientId : {}", kycAuthDto.getTransactionId(), + clientId, e); + } + throw new KycAuthException(ErrorConstants.AUTH_FAILED); } + /** + * Method to create {@link IdaKycAuthRequest} object required in the kyc-auth flow + * @param kycAuthDto {@link KycAuthDto} + * @param claimsMetadataRequired boolean flag to recognize v2 or existing flow + * @return {@link IdaKycAuthRequest} + */ + @NotNull + private IdaKycAuthRequest getIdaKycAuthRequest(KycAuthDto kycAuthDto, boolean claimsMetadataRequired) { + IdaKycAuthRequest idaKycAuthRequest = new IdaKycAuthRequest(); + idaKycAuthRequest.setId(kycAuthId); + idaKycAuthRequest.setVersion(idaVersion); + idaKycAuthRequest.setRequestTime(HelperService.getUTCDateTime()); + idaKycAuthRequest.setDomainUri(idaDomainUri); + idaKycAuthRequest.setEnv(idaEnv); + idaKycAuthRequest.setConsentObtained(true); + idaKycAuthRequest.setIndividualId(kycAuthDto.getIndividualId()); + idaKycAuthRequest.setTransactionID(kycAuthDto.getTransactionId()); + if(claimsMetadataRequired){ + idaKycAuthRequest.setClaimMetadataRequired(true); + } + return idaKycAuthRequest; + } + + @Override public KycExchangeResult doVerifiedKycExchange(String relyingPartyId, String clientId, VerifiedKycExchangeDto kycExchangeDto) throws KycExchangeException { return doKycExchange(relyingPartyId, clientId, kycExchangeDto); //TODO diff --git a/mosip-identity-plugin/src/main/resources/application.properties b/mosip-identity-plugin/src/main/resources/application.properties index c591395..2e089be 100644 --- a/mosip-identity-plugin/src/main/resources/application.properties +++ b/mosip-identity-plugin/src/main/resources/application.properties @@ -14,6 +14,7 @@ mosip.esignet.authenticator.ida.misp-license-key=${mosip.esignet.misp.key} mosip.esignet.authenticator.ida-domainUri=${mosip.esignet.domain.url} mosip.esignet.authenticator.ida.cert-url=http://mosip-file-server.mosip-file-server/mosip-certs/ida-partner.cer mosip.esignet.authenticator.ida.kyc-auth-url=http://ida-auth.ida/idauthentication/v1/kyc-auth/delegated/${mosip.esignet.authenticator.ida.misp-license-key}/ +mosip.esignet.authenticator.ida.kyc-auth-url-v2=http://ida-auth.ida/idauthentication/v2/kyc-auth/delegated/${mosip.esignet.authenticator.ida.misp-license-key}/ mosip.esignet.authenticator.ida.kyc-exchange-url=http://ida-auth.ida/idauthentication/v1/kyc-exchange/delegated/${mosip.esignet.authenticator.ida.misp-license-key}/ mosip.esignet.authenticator.ida.send-otp-url=http://ida-otp.ida/idauthentication/v1/otp/${mosip.esignet.authenticator.ida.misp-license-key}/ mosip.esignet.binder.ida.key-binding-url=http://ida-auth.ida/idauthentication/v1/identity-key-binding/delegated/${mosip.esignet.authenticator.ida.misp-license-key}/ diff --git a/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java b/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java index b60bbff..bcada97 100644 --- a/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java +++ b/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java @@ -5,19 +5,19 @@ */ package io.mosip.esignet.plugin.mosipid.service; -import static org.mockito.ArgumentMatchers.any; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import io.mosip.esignet.api.dto.*; +import io.mosip.esignet.api.exception.KycAuthException; +import io.mosip.esignet.api.exception.KycExchangeException; +import io.mosip.esignet.api.exception.KycSigningCertificateException; +import io.mosip.esignet.api.exception.SendOtpException; import io.mosip.esignet.api.util.ErrorConstants; -import io.mosip.esignet.plugin.mosipid.dto.GetAllCertificatesResponse; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycAuthRequest; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycAuthResponse; -import io.mosip.esignet.plugin.mosipid.dto.IdaKycExchangeResponse; -import io.mosip.esignet.plugin.mosipid.dto.IdaResponseWrapper; +import io.mosip.esignet.plugin.mosipid.dto.*; import io.mosip.esignet.plugin.mosipid.helper.AuthTransactionHelper; +import io.mosip.kernel.core.exception.ServiceError; +import io.mosip.kernel.core.http.ResponseWrapper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -35,22 +35,9 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.RestTemplate; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.*; -import io.mosip.esignet.api.dto.AuthChallenge; -import io.mosip.esignet.api.dto.KycAuthDto; -import io.mosip.esignet.api.dto.KycAuthResult; -import io.mosip.esignet.api.dto.KycExchangeDto; -import io.mosip.esignet.api.dto.KycExchangeResult; -import io.mosip.esignet.api.dto.KycSigningCertificateData; -import io.mosip.esignet.api.dto.SendOtpDto; -import io.mosip.esignet.api.dto.SendOtpResult; -import io.mosip.esignet.api.exception.KycAuthException; -import io.mosip.esignet.api.exception.KycExchangeException; -import io.mosip.esignet.api.exception.KycSigningCertificateException; -import io.mosip.esignet.api.exception.SendOtpException; -import io.mosip.kernel.core.exception.ServiceError; -import io.mosip.kernel.core.http.ResponseWrapper; +import static org.mockito.ArgumentMatchers.any; @SpringBootTest @RunWith(MockitoJUnitRunner.class) @@ -59,8 +46,8 @@ public class IdaAuthenticatorImplTest { @InjectMocks IdaAuthenticatorImpl idaAuthenticatorImpl; - @Mock - ObjectMapper mapper; + + ObjectMapper mapper = new ObjectMapper();; @Mock RestTemplate restTemplate; @@ -86,6 +73,8 @@ public void setUp() { ReflectionTestUtils.setField(idaAuthenticatorImpl, "kycAuthUrl", "https://testkycAuthUrl"); ReflectionTestUtils.setField(idaAuthenticatorImpl, "getCertsUrl", "https://testGetCertsUrl"); ReflectionTestUtils.setField(idaAuthenticatorImpl, "otpChannels", Arrays.asList("otp", "pin", "bio")); + ReflectionTestUtils.setField(idaAuthenticatorImpl, "objectMapper", mapper); + ReflectionTestUtils.setField(idaAuthenticatorImpl, "kycAuthUrlV2", "https://testkycAuthUrl"); } @Test @@ -100,7 +89,6 @@ public void doKycAuth_withInvalidDetails_throwsException() throws Exception { authChallengeList.add(authChallenge); kycAuthDto.setChallengeList(authChallengeList); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); Mockito.when(restTemplate.exchange(Mockito.>any(), Mockito.>>any())).thenReturn(null); @@ -108,6 +96,26 @@ public void doKycAuth_withInvalidDetails_throwsException() throws Exception { () -> idaAuthenticatorImpl.doKycAuth("relyingId", "clientId", kycAuthDto)); } + @Test + public void doKycAuthV2_withInvalidDetails_throwsException() throws Exception { + KycAuthDto kycAuthDto = new KycAuthDto(); + kycAuthDto.setIndividualId("IND1234"); + kycAuthDto.setTransactionId("TRAN1234"); + AuthChallenge authChallenge = new AuthChallenge(); + authChallenge.setAuthFactorType("PIN"); + authChallenge.setChallenge("111111"); + List authChallengeList = new ArrayList<>(); + authChallengeList.add(authChallenge); + kycAuthDto.setChallengeList(authChallengeList); + + Mockito.when(restTemplate.exchange(Mockito.>any(), + Mockito.>>any())).thenReturn(null); + + Assert.assertThrows(KycAuthException.class, + () -> idaAuthenticatorImpl.doKycAuth("relyingId", "clientId", true, kycAuthDto)); + } + + @Test public void doKycAuth_withValidDetails_thenPass() throws Exception { KycAuthDto kycAuthDto = new KycAuthDto(); @@ -120,7 +128,6 @@ public void doKycAuth_withValidDetails_thenPass() throws Exception { authChallengeList.add(authChallenge); kycAuthDto.setChallengeList(authChallengeList); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); IdaKycAuthResponse idaKycAuthResponse = new IdaKycAuthResponse(); idaKycAuthResponse.setAuthToken("authToken1234"); @@ -144,8 +151,9 @@ public void doKycAuth_withValidDetails_thenPass() throws Exception { Assert.assertEquals(kycAuthResult.getKycToken(), kycAuthResult.getKycToken()); } + @Test - public void doKycAuth_withInValidResponseDetails_thenFail() throws Exception { + public void doKycAuthV2_withValidDetails_thenPass() throws Exception { KycAuthDto kycAuthDto = new KycAuthDto(); kycAuthDto.setIndividualId("IND1234"); kycAuthDto.setTransactionId("TRAN1234"); @@ -156,9 +164,21 @@ public void doKycAuth_withInValidResponseDetails_thenFail() throws Exception { authChallengeList.add(authChallenge); kycAuthDto.setChallengeList(authChallengeList); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); + + IdaKycAuthResponse idaKycAuthResponse = new IdaKycAuthResponse(); + idaKycAuthResponse.setAuthToken("authToken1234"); + idaKycAuthResponse.setKycToken("kycToken1234"); + idaKycAuthResponse.setKycStatus(true); + Map> verified = new HashMap<>(); + + ObjectNode jNode = mapper.createObjectNode(); + jNode.put("street", "xyz"); + jNode.put("street_no", "123"); + verified.put("address", List.of(jNode)); + idaKycAuthResponse.setVerifiedClaims(verified); IdaResponseWrapper idaResponseWrapper = new IdaResponseWrapper<>(); + idaResponseWrapper.setResponse(idaKycAuthResponse); idaResponseWrapper.setTransactionID("TRAN123"); idaResponseWrapper.setVersion("VER1"); @@ -168,6 +188,32 @@ public void doKycAuth_withInValidResponseDetails_thenFail() throws Exception { Mockito.when(restTemplate.exchange(Mockito.>any(), Mockito.>>any())) .thenReturn(responseEntity); + + KycAuthResult kycAuthResult = idaAuthenticatorImpl.doKycAuth("relyingId", "clientId",true, kycAuthDto); + + Assert.assertEquals(kycAuthResult.getKycToken(), kycAuthResult.getKycToken()); + } + + @Test + public void doKycAuth_withInValidResponseDetails_thenFail() { + KycAuthDto kycAuthDto = new KycAuthDto(); + kycAuthDto.setIndividualId("IND1234"); + kycAuthDto.setTransactionId("TRAN1234"); + AuthChallenge authChallenge = new AuthChallenge(); + authChallenge.setAuthFactorType("OTP"); + authChallenge.setChallenge("111111"); + List authChallengeList = new ArrayList<>(); + authChallengeList.add(authChallenge); + kycAuthDto.setChallengeList(authChallengeList); + + + IdaResponseWrapper idaResponseWrapper = new IdaResponseWrapper<>(); + idaResponseWrapper.setTransactionID("TRAN123"); + idaResponseWrapper.setVersion("VER1"); + + ResponseEntity> responseEntity = new ResponseEntity>( + idaResponseWrapper, HttpStatus.OK); + try{ idaAuthenticatorImpl.doKycAuth("relyingId", "clientId", kycAuthDto); }catch (KycAuthException e){ @@ -187,7 +233,6 @@ public void doKycAuth_withInvalidRequest_thenFail() throws Exception { authChallengeList.add(authChallenge); kycAuthDto.setChallengeList(authChallengeList); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); IdaResponseWrapper idaResponseWrapper = new IdaResponseWrapper<>(); idaResponseWrapper.setTransactionID("TRAN123"); @@ -254,7 +299,6 @@ public void doKycAuth_withBIOAuthChallenge_thenPass() throws Exception { b.setThumbprint("Thumbprint"); List bioList = new ArrayList<>(); bioList.add(b); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); IdaKycAuthResponse idaKycAuthResponse = new IdaKycAuthResponse(); idaKycAuthResponse.setAuthToken("authToken1234"); idaKycAuthResponse.setKycToken("kycToken1234"); @@ -289,7 +333,6 @@ public void doKycExchange_withValidDetails_thenPass() throws Exception { String[] claimsLacales = new String[] { "claims", "locales" }; kycExchangeDto.setClaimsLocales(claimsLacales); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); IdaKycExchangeResponse idaKycExchangeResponse = new IdaKycExchangeResponse(); idaKycExchangeResponse.setEncryptedKyc("ENCRKYC123"); @@ -324,7 +367,6 @@ public void doKycExchange_withValidDetailsEmptyAcceptedClaims_thenPass() throws String[] claimsLacales = new String[] { "claims", "locales" }; kycExchangeDto.setClaimsLocales(claimsLacales); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); IdaKycExchangeResponse idaKycExchangeResponse = new IdaKycExchangeResponse(); idaKycExchangeResponse.setEncryptedKyc("ENCRKYC123"); @@ -359,7 +401,6 @@ public void doKycExchange_withInvalidDetails_thenFail() throws Exception { String[] claimsLacales = new String[] { "claims", "locales" }; kycExchangeDto.setClaimsLocales(claimsLacales); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); IdaKycExchangeResponse idaKycExchangeResponse = new IdaKycExchangeResponse(); idaKycExchangeResponse.setEncryptedKyc("ENCRKYC123"); @@ -392,7 +433,6 @@ public void doKycExchange_withInvalidIndividualId_throwsException() throws Exce String[] claimsLacales = new String[] { "claims", "locales" }; kycExchangeDto.setClaimsLocales(claimsLacales); - Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value"); Mockito.when(restTemplate.exchange(Mockito.>any(), Mockito.>>any())) .thenReturn(null);