From 74ad779d7e1bace70941d0e080fb732e3e77785c Mon Sep 17 00:00:00 2001 From: ase-101 Date: Wed, 3 Jul 2024 15:54:01 +0530 Subject: [PATCH] ES-842 Signed-off-by: ase-101 --- .../esignet/core/dto/OIDCTransaction.java | 3 + .../api/dto/VerifiedKycExchangeDto.java | 4 +- .../api/dto/claim/VerificationDetail.java | 4 +- .../esignet/TestAuthenticationService.java | 4 +- .../services/AuthorizationHelperService.java | 11 ++- .../services/AuthorizationServiceImpl.java | 93 +++++++++++++++++-- .../esignet/services/OAuthServiceImpl.java | 20 +++- .../AuthorizationHelperServiceTest.java | 24 +++-- .../services/AuthorizationServiceTest.java | 11 +-- .../LinkedAuthorizationServiceTest.java | 7 +- 10 files changed, 143 insertions(+), 38 deletions(-) diff --git a/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java b/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java index b036152c1..a3fdc1cbf 100644 --- a/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java +++ b/esignet-core/src/main/java/io/mosip/esignet/core/dto/OIDCTransaction.java @@ -6,12 +6,14 @@ package io.mosip.esignet.core.dto; import io.mosip.esignet.api.dto.claim.Claims; +import io.mosip.esignet.api.dto.claim.VerificationDetail; import io.mosip.esignet.api.util.ConsentAction; import io.mosip.esignet.core.util.LinkCodeQueue; import lombok.Data; import java.util.List; import java.io.Serializable; +import java.util.Map; import java.util.Set; @Data @@ -62,4 +64,5 @@ public class OIDCTransaction implements Serializable { List requestedCredentialScopes; boolean isInternalAuthSuccess; + Map> claimMetadata; } diff --git a/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/VerifiedKycExchangeDto.java b/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/VerifiedKycExchangeDto.java index eed3d7718..e062dd642 100644 --- a/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/VerifiedKycExchangeDto.java +++ b/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/VerifiedKycExchangeDto.java @@ -7,12 +7,10 @@ import io.mosip.esignet.api.dto.claim.VerificationFilter; import lombok.Data; - -import java.util.List; import java.util.Map; @Data public class VerifiedKycExchangeDto extends KycExchangeDto { - private Map> acceptedVerifiedClaims; + private Map acceptedVerifiedClaims; } diff --git a/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/claim/VerificationDetail.java b/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/claim/VerificationDetail.java index 65eb2aa0d..fe0dd8195 100644 --- a/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/claim/VerificationDetail.java +++ b/esignet-integration-api/src/main/java/io/mosip/esignet/api/dto/claim/VerificationDetail.java @@ -6,10 +6,12 @@ package io.mosip.esignet.api.dto.claim; import lombok.Data; + +import java.io.Serializable; import java.util.List; @Data -public class VerificationDetail { +public class VerificationDetail implements Serializable { private String trust_framework; private String time; diff --git a/esignet-service/src/test/java/io/mosip/esignet/TestAuthenticationService.java b/esignet-service/src/test/java/io/mosip/esignet/TestAuthenticationService.java index 1caa9cae6..ffd606f34 100644 --- a/esignet-service/src/test/java/io/mosip/esignet/TestAuthenticationService.java +++ b/esignet-service/src/test/java/io/mosip/esignet/TestAuthenticationService.java @@ -317,12 +317,12 @@ public List getAllKycSigningCertificates() { @Override public KycAuthResult doKycAuth(String relyingPartyId, String clientId, boolean claimsMetadataRequired, KycAuthDto kycAuthDto) throws KycAuthException { - return null; + return doKycAuth(relyingPartyId, clientId, kycAuthDto); } @Override public KycExchangeResult doVerifiedKycExchange(String relyingPartyId, String clientId, VerifiedKycExchangeDto kycExchangeDto) throws KycExchangeException { - return null; + return doKycExchange(relyingPartyId, clientId, kycExchangeDto); } private boolean authenticateUser(String transactionId, String individualId, AuthChallenge authChallenge) { diff --git a/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationHelperService.java b/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationHelperService.java index 397c7fb4f..1502a24b5 100644 --- a/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationHelperService.java +++ b/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationHelperService.java @@ -209,8 +209,9 @@ protected KycAuthResult delegateAuthenticateRequest(String transactionId, String KycAuthResult kycAuthResult; try { + KycAuthDto kycAuthDto = new KycAuthDto(transaction.getAuthTransactionId(), individualId, challengeList); kycAuthResult = authenticationWrapper.doKycAuth(transaction.getRelyingPartyId(), transaction.getClientId(), - new KycAuthDto(transaction.getAuthTransactionId(), individualId, challengeList)); + isVerifiedClaimRequested(transaction), kycAuthDto); } catch (KycAuthException e) { log.error("KYC auth failed for transaction : {}", transactionId, e); throw new EsignetException(e.getErrorCode()); @@ -439,4 +440,12 @@ private String getKeyAlias(String keyAppId, String keyRefId) { log.error("CurrentKeyAlias is not unique. KeyAlias count: {}", currentKeyAliases.size()); throw new EsignetException(NO_UNIQUE_ALIAS); } + + private boolean isVerifiedClaimRequested(OIDCTransaction transaction) { + return transaction.getRequestedClaims().getUserinfo() != null && + transaction.getRequestedClaims().getUserinfo() + .entrySet() + .stream() + .anyMatch( entry -> entry.getValue() != null && entry.getValue().getVerification() != null); + } } diff --git a/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java b/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java index 7328784ad..bc04ec12e 100644 --- a/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java +++ b/oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java @@ -8,11 +8,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.esignet.api.dto.claim.ClaimDetail; -import io.mosip.esignet.api.dto.claim.Claims; +import io.mosip.esignet.api.dto.claim.*; import io.mosip.esignet.api.dto.KycAuthResult; import io.mosip.esignet.api.dto.SendOtpResult; -import io.mosip.esignet.api.dto.claim.ClaimsV2; import io.mosip.esignet.api.spi.AuditPlugin; import io.mosip.esignet.api.spi.Authenticator; import io.mosip.esignet.api.util.Action; @@ -39,6 +37,10 @@ import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.*; import java.util.stream.Collectors; @@ -58,6 +60,8 @@ public class AuthorizationServiceImpl implements AuthorizationService { private static final String VERIFIED_CLAIMS = "verified_claims"; + private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); @Autowired private ClientManagementService clientManagementService; @@ -272,12 +276,8 @@ public ClaimDetailResponse getClaimDetails(String transactionId) { claimDetailResponse.setTransactionId(transactionId); List list = new ArrayList<>(); - //TODO need to compute this - for(String claim : transaction.getEssentialClaims()) { - list.add(new ClaimStatus(claim, false, (claim.equals("name") || claim.equals("phone_number")) )); - } - for(String claim : transaction.getVoluntaryClaims()) { - list.add(new ClaimStatus(claim, false, (claim.equals("name") || claim.equals("phone_number")) )); + for(Map.Entry entry : transaction.getRequestedClaims().getUserinfo().entrySet()) { + list.add(getClaimStatus(entry.getKey(), entry.getValue(), transaction.getClaimMetadata())); } //Profile update is mandated only if any essential verified claim is requested @@ -339,6 +339,7 @@ private OIDCTransaction authenticate(AuthRequest authRequest, boolean checkConse transaction.setPartnerSpecificUserToken(kycAuthResult.getPartnerSpecificUserToken()); transaction.setKycToken(kycAuthResult.getKycToken()); transaction.setAuthTimeInSeconds(IdentityProviderUtil.getEpochSeconds()); + transaction.setClaimMetadata(kycAuthResult.getClaimsMetadata()); transaction.setProvidedAuthFactors(providedAuthFactors.stream().map(acrFactors -> acrFactors.stream() .map(AuthenticationFactor::getType) .collect(Collectors.toList())).collect(Collectors.toSet())); @@ -450,6 +451,7 @@ private Claims getRequestedClaims(OAuthDetailRequest oauthDetailRequest, ClientD else if(claimBasedOnScope.contains(claimName)) resolvedClaims.getUserinfo().put(claimName, null); + //Verified claim request takes priority if(verifiedClaimsMap.containsKey(claimName)) resolvedClaims.getUserinfo().put(claimName, verifiedClaimsMap.get(claimName)); }); @@ -570,4 +572,77 @@ private String getSubject(String idTokenHint) { } throw new EsignetException(ErrorConstants.INVALID_ID_TOKEN_HINT); } + + private ClaimStatus getClaimStatus(String claim, ClaimDetail claimDetail, Map> storedVerificationData) { + if(storedVerificationData == null || storedVerificationData.isEmpty()) + return new ClaimStatus(claim, false, false); + + if(claimDetail == null || claimDetail.getVerification() == null || !CollectionUtils.isEmpty(storedVerificationData.get(claim))) + return new ClaimStatus(claim, false, storedVerificationData.containsKey(claim)); + + List verificationDetails = storedVerificationData.get(claim); + + //check trust_framework + Optional result = verificationDetails.stream() + .filter( vd -> doMatch(claimDetail.getVerification().getTrust_framework(), vd.getTrust_framework())) + .findFirst(); + + if(result.isEmpty()) + return new ClaimStatus(claim, false, true); + + //check verification datetime + result = verificationDetails.stream() + .filter( vd -> doMatch(claimDetail.getVerification().getTime(), vd.getTime(), dateTimeFormat)) + .findFirst(); + + if(result.isEmpty()) + return new ClaimStatus(claim, false, true); + + //check verification_process + result = verificationDetails.stream() + .filter( vd -> doMatch(claimDetail.getVerification().getVerification_process(), vd.getVerification_process())) + .findFirst(); + + if(result.isEmpty()) + return new ClaimStatus(claim, false, true); + + //check assuranceLevel + result = verificationDetails.stream() + .filter( vd -> doMatch(claimDetail.getVerification().getAssurance_level(), vd.getAssurance_level())) + .findFirst(); + + if(result.isEmpty()) + return new ClaimStatus(claim, false, true); + + return new ClaimStatus(claim, true, true); + } + + private boolean doMatch(FilterCriteria filterCriteria, String value) { + if(filterCriteria == null) + return true; + if(filterCriteria.getValue() != null) + return filterCriteria.getValue().equals(value); + if(filterCriteria.getValues() != null) + return filterCriteria.getValues().contains(value); + return false; + } + + private boolean doMatch(FilterDateTime filterDateTime, String value, SimpleDateFormat format) { + if(filterDateTime == null) + return true; + + if(value == null || value.isEmpty()) + return false; + + try { + format.setTimeZone(TimeZone.getTimeZone("UTC")); + Date date = format.parse(value); + return ((System.currentTimeMillis() - date.getTime())/1000) < filterDateTime.getMax_age(); + } catch (ParseException e) { + log.error("Failed to parse the given date-time : {}", value, e); + } + return false; + } + } diff --git a/oidc-service-impl/src/main/java/io/mosip/esignet/services/OAuthServiceImpl.java b/oidc-service-impl/src/main/java/io/mosip/esignet/services/OAuthServiceImpl.java index 4a1744458..0206da7c9 100644 --- a/oidc-service-impl/src/main/java/io/mosip/esignet/services/OAuthServiceImpl.java +++ b/oidc-service-impl/src/main/java/io/mosip/esignet/services/OAuthServiceImpl.java @@ -10,6 +10,8 @@ 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.VerifiedKycExchangeDto; +import io.mosip.esignet.api.dto.claim.ClaimDetail; import io.mosip.esignet.api.exception.KycExchangeException; import io.mosip.esignet.api.exception.KycSigningCertificateException; import io.mosip.esignet.api.spi.AuditPlugin; @@ -30,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.nio.charset.StandardCharsets; @@ -245,18 +248,31 @@ private TokenResponse getTokenResponse(OIDCTransaction transaction, boolean isTr private KycExchangeResult doKycExchange(OIDCTransaction transaction) { KycExchangeResult kycExchangeResult; try { - KycExchangeDto kycExchangeDto = new KycExchangeDto(); + VerifiedKycExchangeDto kycExchangeDto = new VerifiedKycExchangeDto(); kycExchangeDto.setTransactionId(transaction.getAuthTransactionId()); kycExchangeDto.setKycToken(transaction.getKycToken()); kycExchangeDto.setAcceptedClaims(transaction.getAcceptedClaims()); kycExchangeDto.setClaimsLocales(transaction.getClaimsLocales()); kycExchangeDto.setIndividualId(authorizationHelperService.getIndividualId(transaction)); + kycExchangeDto.setAcceptedVerifiedClaims(new HashMap<>()); + + if(!CollectionUtils.isEmpty(transaction.getAcceptedClaims()) && transaction.getRequestedClaims().getUserinfo() != null) { + for(String claim : transaction.getAcceptedClaims()) { + ClaimDetail claimDetail = transaction.getRequestedClaims().getUserinfo().get(claim); + if(claimDetail != null) { + kycExchangeDto.getAcceptedVerifiedClaims().put(claim, claimDetail.getVerification()); + } + } + } if(transaction.isInternalAuthSuccess()) { log.info("Internal kyc exchange is invoked as the transaction is marked as internal auth success"); kycExchangeResult = doInternalKycExchange(kycExchangeDto); } else { - kycExchangeResult = authenticationWrapper.doKycExchange(transaction.getRelyingPartyId(), + kycExchangeResult = kycExchangeDto.getAcceptedVerifiedClaims().isEmpty() ? + authenticationWrapper.doKycExchange(transaction.getRelyingPartyId(), + transaction.getClientId(), kycExchangeDto) : + authenticationWrapper.doVerifiedKycExchange(transaction.getRelyingPartyId(), transaction.getClientId(), kycExchangeDto); } diff --git a/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationHelperServiceTest.java b/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationHelperServiceTest.java index e3222cd9e..5943e95df 100644 --- a/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationHelperServiceTest.java +++ b/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationHelperServiceTest.java @@ -43,6 +43,8 @@ import static io.mosip.esignet.core.constants.ErrorConstants.*; import static io.mosip.esignet.core.spi.TokenService.ACR; import static io.mosip.kernel.keymanagerservice.constant.KeymanagerConstant.CURRENTKEYALIAS; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; @RunWith(MockitoJUnitRunner.class) public class AuthorizationHelperServiceTest { @@ -215,10 +217,11 @@ public void delegateAuthenticateRequest_withValidDetails_thenPass() throws KycAu oidcTransaction.setRelyingPartyId("rp-id"); oidcTransaction.setClientId("client-id"); oidcTransaction.setAuthTransactionId("auth-transaction-id"); + oidcTransaction.setRequestedClaims(new Claims()); KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("kyc-token"); kycAuthResult.setPartnerSpecificUserToken("psut"); - Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), Mockito.any(KycAuthDto.class))).thenReturn(kycAuthResult); + Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), anyBoolean(), any(KycAuthDto.class))).thenReturn(kycAuthResult); KycAuthResult result = authorizationHelperService.delegateAuthenticateRequest(transactionId, individualId, challengeList, oidcTransaction); Assert.assertNotNull(result); Assert.assertEquals(kycAuthResult.getKycToken(), result.getKycToken()); @@ -234,8 +237,9 @@ public void delegateAuthenticateRequest_withInvalidResult_thenFail() throws KycA oidcTransaction.setRelyingPartyId("rp-id"); oidcTransaction.setClientId("client-id"); oidcTransaction.setAuthTransactionId("auth-transaction-id"); + oidcTransaction.setRequestedClaims(new Claims()); - Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), Mockito.any(KycAuthDto.class))).thenReturn(null); + Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), anyBoolean(), any(KycAuthDto.class))).thenReturn(null); try { authorizationHelperService.delegateAuthenticateRequest(transactionId, individualId, challengeList, oidcTransaction); Assert.fail(); @@ -244,7 +248,7 @@ public void delegateAuthenticateRequest_withInvalidResult_thenFail() throws KycA } KycAuthResult result = new KycAuthResult(); - Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), Mockito.any(KycAuthDto.class))).thenReturn(result); + Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), anyBoolean(), any(KycAuthDto.class))).thenReturn(result); try { authorizationHelperService.delegateAuthenticateRequest(transactionId, individualId, challengeList, oidcTransaction); Assert.fail(); @@ -254,7 +258,7 @@ public void delegateAuthenticateRequest_withInvalidResult_thenFail() throws KycA result.setPartnerSpecificUserToken("PSUT"); result.setKycToken(null); - Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), Mockito.any(KycAuthDto.class))).thenReturn(result); + Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), anyBoolean(), any(KycAuthDto.class))).thenReturn(result); try { authorizationHelperService.delegateAuthenticateRequest(transactionId, individualId, challengeList, oidcTransaction); Assert.fail(); @@ -264,7 +268,7 @@ public void delegateAuthenticateRequest_withInvalidResult_thenFail() throws KycA result.setPartnerSpecificUserToken(null); result.setKycToken("kyctoken"); - Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), Mockito.any(KycAuthDto.class))).thenReturn(result); + Mockito.when(authenticationWrapper.doKycAuth(Mockito.anyString(), Mockito.anyString(), anyBoolean(), any(KycAuthDto.class))).thenReturn(result); try { authorizationHelperService.delegateAuthenticateRequest(transactionId, individualId, challengeList, oidcTransaction); Assert.fail(); @@ -435,7 +439,7 @@ public void delegateSendOtpRequest_withValidRequest_thenPass() throws SendOtpExc oidcTransaction.setRelyingPartyId("rpid"); oidcTransaction.setClientId("client-id"); SendOtpResult sendOtpResult = new SendOtpResult(oidcTransaction.getAuthTransactionId(), "masked-email", "masked-mobile"); - Mockito.when(authenticationWrapper.sendOtp(Mockito.anyString(), Mockito.anyString(), Mockito.any(SendOtpDto.class))).thenReturn(sendOtpResult); + Mockito.when(authenticationWrapper.sendOtp(Mockito.anyString(), Mockito.anyString(), any(SendOtpDto.class))).thenReturn(sendOtpResult); SendOtpResult result = authorizationHelperService.delegateSendOtpRequest(otpRequest, oidcTransaction); Assert.assertEquals(sendOtpResult.getMaskedMobile(), result.getMaskedMobile()); Assert.assertEquals(sendOtpResult.getMaskedEmail(), result.getMaskedEmail()); @@ -451,7 +455,7 @@ public void delegateSendOtpRequest_withInvalidTransactionId_thenFail() throws Se oidcTransaction.setRelyingPartyId("rpid"); oidcTransaction.setClientId("client-id"); SendOtpResult sendOtpResult = new SendOtpResult("temp-id", "masked-email", "masked-mobile"); - Mockito.when(authenticationWrapper.sendOtp(Mockito.anyString(), Mockito.anyString(), Mockito.any(SendOtpDto.class))).thenReturn(sendOtpResult); + Mockito.when(authenticationWrapper.sendOtp(Mockito.anyString(), Mockito.anyString(), any(SendOtpDto.class))).thenReturn(sendOtpResult); try { authorizationHelperService.delegateSendOtpRequest(otpRequest, oidcTransaction); @@ -483,7 +487,7 @@ public void getProvidedAuthFactors_withValidInput_thenPass() { AuthenticationFactor pinAuthFactor = new AuthenticationFactor(); pinAuthFactor.setType("PIN"); list.add(Arrays.asList(pinAuthFactor)); - Mockito.when(authenticationContextClassRefUtil.getAuthFactors(Mockito.any(String[].class))).thenReturn(list); + Mockito.when(authenticationContextClassRefUtil.getAuthFactors(any(String[].class))).thenReturn(list); Set> result = authorizationHelperService.getProvidedAuthFactors(oidcTransaction, challengeList); Assert.assertTrue(result.size() == 1); @@ -512,7 +516,7 @@ public void getProvidedAuthFactors_withAuthFactorMismatch_thenFail() { AuthenticationFactor pinAuthFactor = new AuthenticationFactor(); pinAuthFactor.setType("PIN"); list.add(Arrays.asList(pinAuthFactor)); - Mockito.when(authenticationContextClassRefUtil.getAuthFactors(Mockito.any(String[].class))).thenReturn(list); + Mockito.when(authenticationContextClassRefUtil.getAuthFactors(any(String[].class))).thenReturn(list); try { authorizationHelperService.getProvidedAuthFactors(oidcTransaction, challengeList); @@ -533,7 +537,7 @@ public void setGetIndividualId_test() throws Exception { KeyAlias keyAlias = new KeyAlias(); keyAlias.setAlias("test"); keyaliasesMap.put(CURRENTKEYALIAS, Arrays.asList(keyAlias)); - Mockito.when(dbHelper.getKeyAliases(Mockito.anyString(), Mockito.anyString(), Mockito.any(LocalDateTime.class))).thenReturn(keyaliasesMap); + Mockito.when(dbHelper.getKeyAliases(Mockito.anyString(), Mockito.anyString(), any(LocalDateTime.class))).thenReturn(keyaliasesMap); KeyGenerator generator = KeyGenerator.getInstance("AES"); generator.init(256); SecretKey key = generator.generateKey(); diff --git a/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java b/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java index b40ac59fe..dabafb79a 100644 --- a/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java +++ b/oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java @@ -46,8 +46,7 @@ import javax.servlet.http.HttpServletResponse; import static io.mosip.esignet.core.spi.TokenService.ACR; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -821,7 +820,7 @@ public void authenticate_multipleRegisteredAcrsWithSingleFactor_thenPass() throw KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("test-kyc-token"); kycAuthResult.setPartnerSpecificUserToken("test-psut"); - when(authenticationWrapper.doKycAuth(anyString(), anyString(), any())).thenReturn(kycAuthResult); + when(authenticationWrapper.doKycAuth(anyString(), anyString(), anyBoolean(), any())).thenReturn(kycAuthResult); AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); @@ -877,7 +876,7 @@ public void authenticate_multipleRegisteredAcrsWithMultiFactor_thenPass() throws KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("test-kyc-token"); kycAuthResult.setPartnerSpecificUserToken("test-psut"); - when(authenticationWrapper.doKycAuth(anyString(), anyString(), any())).thenReturn(kycAuthResult); + when(authenticationWrapper.doKycAuth(anyString(), anyString(), anyBoolean(), any())).thenReturn(kycAuthResult); AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); @@ -950,7 +949,7 @@ public void authenticateV2_multipleRegisteredAcrsWithSingleFactor_thenPass() thr KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("test-kyc-token"); kycAuthResult.setPartnerSpecificUserToken("test-psut"); - when(authenticationWrapper.doKycAuth(anyString(), anyString(), any())).thenReturn(kycAuthResult); + when(authenticationWrapper.doKycAuth(anyString(), anyString(), anyBoolean(), any())).thenReturn(kycAuthResult); AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); @@ -1007,7 +1006,7 @@ public void authenticateV2_multipleRegisteredAcrsWithMultiFactor_thenPass() thro KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("test-kyc-token"); kycAuthResult.setPartnerSpecificUserToken("test-psut"); - when(authenticationWrapper.doKycAuth(anyString(), anyString(), any())).thenReturn(kycAuthResult); + when(authenticationWrapper.doKycAuth(anyString(), anyString(), anyBoolean(), any())).thenReturn(kycAuthResult); AuthRequest authRequest = new AuthRequest(); authRequest.setTransactionId(transactionId); diff --git a/oidc-service-impl/src/test/java/io/mosip/esignet/services/LinkedAuthorizationServiceTest.java b/oidc-service-impl/src/test/java/io/mosip/esignet/services/LinkedAuthorizationServiceTest.java index 1562b38de..3d94eaf72 100644 --- a/oidc-service-impl/src/test/java/io/mosip/esignet/services/LinkedAuthorizationServiceTest.java +++ b/oidc-service-impl/src/test/java/io/mosip/esignet/services/LinkedAuthorizationServiceTest.java @@ -45,8 +45,7 @@ import java.util.stream.Collectors; import static io.mosip.esignet.core.spi.TokenService.ACR; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) @@ -381,7 +380,7 @@ public void authenticateUser_withValidInput_thenPass() throws KycAuthException { KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("test-kyc-token"); kycAuthResult.setPartnerSpecificUserToken("test-psut"); - when(authenticationWrapper.doKycAuth(anyString(), anyString(), any())).thenReturn(kycAuthResult); + when(authenticationWrapper.doKycAuth(anyString(), anyString(), anyBoolean(), any())).thenReturn(kycAuthResult); linkedKycAuthRequest.setIndividualId("23423434234"); List authChallenges = new ArrayList<>(); @@ -425,7 +424,7 @@ public void authenticateUserV2_withValidInput_thenPass() throws KycAuthException KycAuthResult kycAuthResult = new KycAuthResult(); kycAuthResult.setKycToken("test-kyc-token"); kycAuthResult.setPartnerSpecificUserToken("test-psut"); - when(authenticationWrapper.doKycAuth(anyString(), anyString(), any())).thenReturn(kycAuthResult); + when(authenticationWrapper.doKycAuth(anyString(), anyString(), anyBoolean(), any())).thenReturn(kycAuthResult); linkedKycAuthRequest.setIndividualId("23423434234"); List authChallenges = new ArrayList<>();