From 91dbc428b4133081288f78e0a01eeb5bf6c63737 Mon Sep 17 00:00:00 2001 From: Venkata Saidurga Polamraju Date: Mon, 25 Mar 2024 20:33:16 +0530 Subject: [PATCH 1/3] [ES-877] Signed-off-by: Venkata Saidurga Polamraju --- .../esignet/integration/service/IdaVCIssuancePluginImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java index cfcdb655385..0055bb1a91c 100644 --- a/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java +++ b/authentication/esignet-integration-impl/src/main/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImpl.java @@ -143,7 +143,7 @@ public VCResult getVerifiableCredentialWithLinkedDataProof(VCReque ErrorConstants.DATA_EXCHANGE_FAILED : responseWrapper.getErrors().get(0).getErrorCode()); } log.error("Error response received from IDA (VCI-exchange) with status : {}", responseEntity.getStatusCode()); - } catch (Exception e) { + } catch (VCIExchangeException e) { throw e; } catch (Exception e) { log.error("IDA Vci-exchange failed ", e); } throw new VCIExchangeException(); From 2ba252894661facb95b2845b1a6f42bfac3d48d4 Mon Sep 17 00:00:00 2001 From: Venkata Saidurga Polamraju Date: Mon, 1 Apr 2024 16:08:57 +0530 Subject: [PATCH 2/3] [ES-877] Signed-off-by: Venkata Saidurga Polamraju --- .../service/IdaVCIssuancePluginImplTest.java | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java b/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java index fe3bb52f8c6..8ff5ee1a20e 100644 --- a/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java +++ b/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java @@ -2,12 +2,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; import foundation.identity.jsonld.JsonLDObject; +import io.mosip.authentication.esignet.integration.dto.IdaError; import io.mosip.authentication.esignet.integration.dto.IdaResponseWrapper; import io.mosip.authentication.esignet.integration.dto.IdaVcExchangeRequest; import io.mosip.authentication.esignet.integration.dto.IdaVcExchangeResponse; import io.mosip.authentication.esignet.integration.helper.VCITransactionHelper; import io.mosip.esignet.api.dto.VCRequestDto; import io.mosip.esignet.api.dto.VCResult; +import io.mosip.esignet.api.exception.VCIExchangeException; import io.mosip.esignet.core.constants.ErrorConstants; import io.mosip.esignet.core.dto.OIDCTransaction; import io.mosip.esignet.core.exception.EsignetException; @@ -34,10 +36,7 @@ import java.nio.charset.StandardCharsets; import java.security.Key; import java.time.LocalDateTime; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static io.mosip.kernel.keymanagerservice.constant.KeymanagerConstant.CURRENTKEYALIAS; @@ -204,6 +203,38 @@ public void getVerifiableCredentialWithLinkedDataProof_withInValidIndividualId_t } } + @Test + public void getVerifiableCredentialWithLinkedDataProof_withInValidDetails_thenFail() throws Exception { + + ReflectionTestUtils.setField(idaVCIssuancePlugin,"vciExchangeUrl","http://example.com"); + + VCRequestDto vcRequestDto = new VCRequestDto(); + vcRequestDto.setFormat("ldp_vc"); + vcRequestDto.setContext(Arrays.asList("context1","context2")); + vcRequestDto.setType(Arrays.asList("VerifiableCredential")); + vcRequestDto.setCredentialSubject(Map.of("subject1","subject1","subject2","subject2")); + + OIDCTransaction oidcTransaction = new OIDCTransaction(); + oidcTransaction.setIndividualId("individualId"); + oidcTransaction.setKycToken("kycToken"); + oidcTransaction.setAuthTransactionId("authTransactionId"); + oidcTransaction.setRelyingPartyId("relyingPartyId"); + oidcTransaction.setClaimsLocales(new String[]{"en-US", "en", "en-CA", "fr-FR", "fr-CA"}); + + IdaResponseWrapper> mockResponseWrapper = new IdaResponseWrapper<>(); + mockResponseWrapper.setErrors(Collections.singletonList(new IdaError())); + ParameterizedTypeReference>> responseType = + new ParameterizedTypeReference>>() { + }; + + try { + idaVCIssuancePlugin.getVerifiableCredentialWithLinkedDataProof(vcRequestDto, "holderId", Map.of("accessTokenHash", "ACCESS_TOKEN_HASH", "client_id", "CLIENT_ID")); + Assert.fail(); + } catch (VCIExchangeException e) { + Assert.assertEquals("vci_exchange_failed", e.getErrorCode()); + } + } + @Test public void getVerifiableCredentialWithLinkedDataProof_withInVlidResponse_thenFail() throws Exception { From 306d8aa428ecf481362a4befec78cf390d92570a Mon Sep 17 00:00:00 2001 From: Venkata Saidurga Polamraju Date: Fri, 12 Apr 2024 20:35:06 +0530 Subject: [PATCH 3/3] code fix Signed-off-by: Venkata Saidurga Polamraju --- .../service/IdaVCIssuancePluginImplTest.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java b/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java index 8ff5ee1a20e..c0a665157b2 100644 --- a/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java +++ b/authentication/esignet-integration-impl/src/test/java/io/mosip/authentication/esignet/integration/service/IdaVCIssuancePluginImplTest.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import foundation.identity.jsonld.JsonLDObject; -import io.mosip.authentication.esignet.integration.dto.IdaError; import io.mosip.authentication.esignet.integration.dto.IdaResponseWrapper; import io.mosip.authentication.esignet.integration.dto.IdaVcExchangeRequest; import io.mosip.authentication.esignet.integration.dto.IdaVcExchangeResponse; @@ -220,18 +219,12 @@ public void getVerifiableCredentialWithLinkedDataProof_withInValidDetails_thenFa oidcTransaction.setAuthTransactionId("authTransactionId"); oidcTransaction.setRelyingPartyId("relyingPartyId"); oidcTransaction.setClaimsLocales(new String[]{"en-US", "en", "en-CA", "fr-FR", "fr-CA"}); - - IdaResponseWrapper> mockResponseWrapper = new IdaResponseWrapper<>(); - mockResponseWrapper.setErrors(Collections.singletonList(new IdaError())); - ParameterizedTypeReference>> responseType = - new ParameterizedTypeReference>>() { - }; - + Mockito.when(vciTransactionHelper.getOAuthTransaction(Mockito.any())).thenThrow(new VCIExchangeException("IDA-VCI-003")); try { idaVCIssuancePlugin.getVerifiableCredentialWithLinkedDataProof(vcRequestDto, "holderId", Map.of("accessTokenHash", "ACCESS_TOKEN_HASH", "client_id", "CLIENT_ID")); Assert.fail(); } catch (VCIExchangeException e) { - Assert.assertEquals("vci_exchange_failed", e.getErrorCode()); + Assert.assertEquals("IDA-VCI-003", e.getErrorCode()); } }