From fd1b3c48cc0399da350ca831f9374e245ac6161a Mon Sep 17 00:00:00 2001 From: pvsaidurga <132046494+pvsaidurga@users.noreply.github.com> Date: Tue, 7 Nov 2023 13:08:23 +0530 Subject: [PATCH] [ES-417] (#1126) Signed-off-by: Venkata Saidurga Polamraju --- .../integration/dto/IdaKycAuthRequest.java | 1 + .../integration/service/HelperService.java | 2 ++ .../service/HelperServiceTest.java | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/dto/IdaKycAuthRequest.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/dto/IdaKycAuthRequest.java index 086d71af66e..1465bb7129b 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/dto/IdaKycAuthRequest.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/dto/IdaKycAuthRequest.java @@ -37,6 +37,7 @@ public static class AuthRequest { private String timestamp; private List biometrics; private List keyBindedTokens; + private String password; } @Data diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java index 203c80d38f9..5a95185da93 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/HelperService.java @@ -259,6 +259,8 @@ private void buildAuthRequest(AuthChallenge authChallenge, IdaKycAuthRequest.Aut list.add(keyBindedToken); authRequest.setKeyBindedTokens(list); break; + case "PWD" : authRequest.setPassword(authChallenge.getChallenge()); + break; default: throw new NotImplementedException("KYC auth not implemented"); } diff --git a/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/HelperServiceTest.java b/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/HelperServiceTest.java index 8528d4b3d91..7e66a33a45e 100644 --- a/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/HelperServiceTest.java +++ b/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/HelperServiceTest.java @@ -170,6 +170,27 @@ public void setAuthRequest_withOTPChallengeType_thenPass() throws Exception { Assert.assertNotNull(idaKycAuthRequest.getThumbprint()); } + @Test + public void setAuthRequest_withPWDChallengeType_thenPass() throws Exception { + List challengeList = new ArrayList<>(); + AuthChallenge authChallenge = new AuthChallenge(); + authChallenge.setChallenge("password"); + authChallenge.setAuthFactorType("pwd"); + authChallenge.setFormat("numeric"); + challengeList.add(authChallenge); + + Mockito.when(restTemplate.getForObject("https://test/test", String.class)).thenReturn("test-certificate"); + Mockito.when(keymanagerUtil.convertToCertificate(Mockito.any(String.class))).thenReturn(TestUtil.getCertificate()); + Mockito.when(cryptoCore.asymmetricEncrypt(Mockito.any(), Mockito.any())).thenReturn("test".getBytes()); + + IdaKycAuthRequest idaKycAuthRequest = new IdaKycAuthRequest(); + helperService.setAuthRequest(challengeList, idaKycAuthRequest); + Assert.assertNotNull(idaKycAuthRequest.getRequest()); + Assert.assertNotNull(idaKycAuthRequest.getRequestSessionKey()); + Assert.assertNotNull(idaKycAuthRequest.getRequestHMAC()); + Assert.assertNotNull(idaKycAuthRequest.getThumbprint()); + } + @Test public void setAuthRequest_withPINChallengeType_thenPass() throws Exception { List challengeList = new ArrayList<>();