From 2ba252894661facb95b2845b1a6f42bfac3d48d4 Mon Sep 17 00:00:00 2001 From: Venkata Saidurga Polamraju Date: Mon, 1 Apr 2024 16:08:57 +0530 Subject: [PATCH] [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 {