Skip to content

Commit

Permalink
Merge pull request #1224 from pvsaidurga/ES-877
Browse files Browse the repository at this point in the history
[ES-877]added catch block to handle VCIExchangeException
  • Loading branch information
ckm007 authored Apr 18, 2024
2 parents 3f53935 + 306d8aa commit 6432f4f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public VCResult<JsonLDObject> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand All @@ -34,10 +35,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;

Expand Down Expand Up @@ -204,6 +202,32 @@ 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"});
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("IDA-VCI-003", e.getErrorCode());
}
}

@Test
public void getVerifiableCredentialWithLinkedDataProof_withInVlidResponse_thenFail() throws Exception {

Expand Down

0 comments on commit 6432f4f

Please sign in to comment.