From 9260a7a14fd03781e434eca4126cb0fede9381a9 Mon Sep 17 00:00:00 2001 From: Piyush7034 Date: Thu, 3 Jul 2025 17:17:22 +0530 Subject: [PATCH 1/5] [INJICERT-1007] Add changes from develop to release (#116) * [INJICERT-1007] Certify version upgrade (#114) Signed-off-by: Piyush7034 * [MOSIP-41674] central sonatype migration changes (#115) Signed-off-by: Piyush7034 --------- Signed-off-by: Piyush7034 Co-authored-by: Praful Rakhade --- .github/workflows/push-trigger.yml | 10 +- mock-certify-plugin/pom.xml | 38 ++-- .../service/MDocMockVCIssuancePlugin.java | 5 +- .../service/MDocMockVCIssuancePluginTest.java | 173 ++++++++++++++++++ mosip-identity-certify-plugin/pom.xml | 38 ++-- .../service/IdaAuditPluginImplTest.java | 67 +++++++ .../service/IdaVCIssuancePluginImplTest.java | 159 +++++++++++++++- postgres-dataprovider-plugin/pom.xml | 38 ++-- .../PostgresDataProviderPluginTest.java | 3 +- sunbird-rc-certify-integration-impl/pom.xml | 56 +++--- .../SunbirdRCVCIssuancePluginTest.java | 2 - sunbird-rc-esignet-integration-impl/pom.xml | 41 ++--- 12 files changed, 490 insertions(+), 140 deletions(-) create mode 100644 mock-certify-plugin/src/test/java/io/mosip/certify/mock/integration/service/MDocMockVCIssuancePluginTest.java diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index e773309f..7606b056 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -44,7 +44,7 @@ jobs: secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_URL: ${{ secrets.OSSRH_CENTRAL_URL }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} @@ -85,7 +85,7 @@ jobs: secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_URL: ${{ secrets.OSSRH_CENTRAL_URL }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} @@ -126,7 +126,7 @@ jobs: secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_URL: ${{ secrets.OSSRH_CENTRAL_URL }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} @@ -167,7 +167,7 @@ jobs: secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_URL: ${{ secrets.OSSRH_CENTRAL_URL }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} @@ -208,7 +208,7 @@ jobs: secrets: OSSRH_USER: ${{ secrets.OSSRH_USER }} OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_URL: ${{ secrets.OSSRH_CENTRAL_URL }} OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/mock-certify-plugin/pom.xml b/mock-certify-plugin/pom.xml index 7c97c7aa..3c96d5bd 100644 --- a/mock-certify-plugin/pom.xml +++ b/mock-certify-plugin/pom.xml @@ -10,7 +10,7 @@ io.mosip.certify mock-certify-plugin - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT jar mock-certify-integration-impl @@ -48,7 +48,7 @@ 3.2.5 1.5 2.2.1 - 6.1.0 + 0.7.0 3.0.1 0.8.11 3.6.3 @@ -65,7 +65,7 @@ io.mosip.certify certify-core - 0.11.0-SNAPSHOT + 0.12.0-SNAPSHOT provided @@ -170,9 +170,9 @@ - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots + ossrh-central + MavenCentralRepository + https://central.sonatype.com/repository/maven-snapshots default true @@ -200,14 +200,13 @@ ossrh - https://oss.sonatype.org/content/repositories/snapshots + https://central.sonatype.com/repository/maven-snapshots/ ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + https://central.sonatype.com/api/v1/publisher - @@ -262,26 +261,15 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.14 + org.sonatype.central + central-publishing-maven-plugin + ${central.publishing.maven.plugin.version} true - - - default-deploy - deploy - - deploy - - - - ossrh - https://oss.sonatype.org/ - false + ossrh + false - org.apache.maven.plugins maven-source-plugin diff --git a/mock-certify-plugin/src/main/java/io.mosip.certify.mock.integration/service/MDocMockVCIssuancePlugin.java b/mock-certify-plugin/src/main/java/io.mosip.certify.mock.integration/service/MDocMockVCIssuancePlugin.java index d5542f9b..035a2ecd 100644 --- a/mock-certify-plugin/src/main/java/io.mosip.certify.mock.integration/service/MDocMockVCIssuancePlugin.java +++ b/mock-certify-plugin/src/main/java/io.mosip.certify.mock.integration/service/MDocMockVCIssuancePlugin.java @@ -44,6 +44,9 @@ public class MDocMockVCIssuancePlugin implements VCIssuancePlugin { @Autowired private KeymanagerDBHelper dbHelper; + @Autowired + private MdocGenerator mdocGenerator; + @Value("${mosip.certify.cache.security.secretkey.reference-id}") private String cacheSecretKeyRefId; @@ -84,7 +87,7 @@ public VCResult getVerifiableCredential(VCRequestDto vcRequestDto, Strin VCResult vcResult = new VCResult<>(); String mdocVc; try { - mdocVc = new MdocGenerator().generate(mockDataForMsoMdoc(documentNumber),holderId, issuerKeyAndCertificate); + mdocVc = mdocGenerator.generate(mockDataForMsoMdoc(documentNumber),holderId, issuerKeyAndCertificate); } catch (Exception e) { log.error("Exception on mdoc creation", e); throw new VCIExchangeException(ErrorConstants.VCI_EXCHANGE_FAILED); diff --git a/mock-certify-plugin/src/test/java/io/mosip/certify/mock/integration/service/MDocMockVCIssuancePluginTest.java b/mock-certify-plugin/src/test/java/io/mosip/certify/mock/integration/service/MDocMockVCIssuancePluginTest.java new file mode 100644 index 00000000..31f29d5a --- /dev/null +++ b/mock-certify-plugin/src/test/java/io/mosip/certify/mock/integration/service/MDocMockVCIssuancePluginTest.java @@ -0,0 +1,173 @@ +package io.mosip.certify.mock.integration.service; + +import io.mosip.certify.api.dto.VCRequestDto; +import io.mosip.certify.api.dto.VCResult; +import io.mosip.certify.api.exception.VCIExchangeException; +import io.mosip.certify.constants.VCFormats; +import io.mosip.certify.core.exception.CertifyException; +import io.mosip.certify.mock.integration.mocks.MdocGenerator; +import io.mosip.esignet.core.dto.OIDCTransaction; +import io.mosip.kernel.core.keymanager.spi.KeyStore; +import io.mosip.kernel.keymanagerservice.entity.KeyAlias; +import io.mosip.kernel.keymanagerservice.helper.KeymanagerDBHelper; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.*; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.test.util.ReflectionTestUtils; + +import java.security.Key; +import java.time.LocalDateTime; +import java.util.*; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +@RunWith(org.mockito.junit.MockitoJUnitRunner.class) +public class MDocMockVCIssuancePluginTest { + + @InjectMocks + private MDocMockVCIssuancePlugin plugin; + + @Mock + private CacheManager cacheManager; + @Mock + private KeyStore keyStore; + @Mock + private KeymanagerDBHelper dbHelper; + @Mock + private Cache cache; + @Mock + private Key key; + @Mock + private MdocGenerator mdocGenerator; + + @Before + public void setUp() { + ReflectionTestUtils.setField(plugin, "issuerKeyAndCertificate", "empty"); + ReflectionTestUtils.setField(plugin, "cacheSecretKeyRefId", "refId"); + ReflectionTestUtils.setField(plugin, "aesECBTransformation", "AES/ECB/PKCS5Padding"); + ReflectionTestUtils.setField(plugin, "storeIndividualId", true); + ReflectionTestUtils.setField(plugin, "secureIndividualId", false); + } + + @Test + public void testGetVerifiableCredential_Success() throws Exception { + VCRequestDto dto = mock(VCRequestDto.class); + when(dto.getFormat()).thenReturn(VCFormats.MSO_MDOC); + + Map identityDetails = new HashMap<>(); + identityDetails.put("accessTokenHash", "tokenHash"); + + OIDCTransaction transaction = mock(OIDCTransaction.class); + when(transaction.getIndividualId()).thenReturn("docNum"); + + when(cacheManager.getCache(anyString())).thenReturn(cache); + when(cache.get(anyString(), eq(OIDCTransaction.class))).thenReturn(transaction); + + when(mdocGenerator.generate(anyMap(), anyString(), anyString())).thenReturn("mockedMdoc"); + + VCResult result = plugin.getVerifiableCredential(dto, "holderId", identityDetails); + + assertNotNull(result); + assertEquals(VCFormats.MSO_MDOC, result.getFormat()); + assertEquals("mockedMdoc", result.getCredential()); + } + + @Test(expected = VCIExchangeException.class) + public void testGetVerifiableCredential_NotImplemented() throws Exception { + VCRequestDto dto = mock(VCRequestDto.class); + + Map identityDetails = new HashMap<>(); + identityDetails.put("accessTokenHash", "tokenHash"); + + plugin.getVerifiableCredential(dto, "holderId", identityDetails); + } + + @Test(expected = VCIExchangeException.class) + public void testGetVerifiableCredentialWithLinkedDataProof_NotImplemented() throws Exception { + VCRequestDto dto = mock(VCRequestDto.class); + plugin.getVerifiableCredentialWithLinkedDataProof(dto, "holderId", new HashMap<>()); + } + + @Test + public void testGetIndividualId_SecureFalse() { + OIDCTransaction transaction = mock(OIDCTransaction.class); + when(transaction.getIndividualId()).thenReturn("docNum"); + ReflectionTestUtils.setField(plugin, "secureIndividualId", false); + ReflectionTestUtils.setField(plugin, "storeIndividualId", true); + String result = (String) ReflectionTestUtils.invokeMethod(plugin, "getIndividualId", transaction); + assertEquals("docNum", result); + } + + @Test + public void testGetIndividualId_StoreFalse() { + OIDCTransaction transaction = mock(OIDCTransaction.class); + ReflectionTestUtils.setField(plugin, "storeIndividualId", false); + String result = (String) ReflectionTestUtils.invokeMethod(plugin, "getIndividualId", transaction); + assertNull(result); + } + + @Test(expected = CertifyException.class) + public void testDecryptIndividualId_Exception() { + ReflectionTestUtils.setField(plugin, "aesECBTransformation", "invalid"); + ReflectionTestUtils.invokeMethod(plugin, "decryptIndividualId", "invalid"); + } + + @Test(expected = CertifyException.class) + public void testGetSecretKeyFromHSM_NoAlias() { + when(dbHelper.getKeyAliases(anyString(), anyString(), any(LocalDateTime.class))) + .thenReturn(Collections.singletonMap("currentKeyAlias", new ArrayList<>())); + ReflectionTestUtils.invokeMethod(plugin, "getSecretKeyFromHSM"); + } + + @Test + public void testGetKeyAlias_Success() { + KeyAlias alias = mock(KeyAlias.class); + when(alias.getAlias()).thenReturn("alias"); + List aliases = Collections.singletonList(alias); + Map> map = new HashMap<>(); + map.put("currentKeyAlias", aliases); + when(dbHelper.getKeyAliases(anyString(), anyString(), any(LocalDateTime.class))).thenReturn(map); + String result = (String) ReflectionTestUtils.invokeMethod(plugin, "getKeyAlias", "appId", "refId"); + assertEquals("alias", result); + } + + @Test(expected = CertifyException.class) + public void testGetKeyAlias_NotUnique() { + List aliases = Arrays.asList(mock(KeyAlias.class), mock(KeyAlias.class)); + Map> map = new HashMap<>(); + map.put("currentKeyAlias", aliases); + when(dbHelper.getKeyAliases(anyString(), anyString(), any(LocalDateTime.class))).thenReturn(map); + ReflectionTestUtils.invokeMethod(plugin, "getKeyAlias", "appId", "refId"); + } + + @Test + public void testMockDataForMsoMdoc() { + String docNum = "12345"; + @SuppressWarnings("unchecked") + Map data = (Map) ReflectionTestUtils.invokeMethod(plugin, "mockDataForMsoMdoc", docNum); + assertNotNull(data); + assertEquals("Agatha", data.get("family_name")); + assertEquals("Joseph", data.get("given_name")); + assertEquals("1994-11-06", data.get("birth_date")); + assertEquals("IN", data.get("issuing_country")); + assertEquals(docNum, data.get("document_number")); + assertTrue(data.get("driving_privileges") instanceof Map); + assertEquals("A", ((Map) data.get("driving_privileges")).get("vehicle_category_code")); + } + + @Test + public void testGetUserInfoTransaction() { + String accessTokenHash = "tokenHash"; + OIDCTransaction transaction = mock(OIDCTransaction.class); + when(cacheManager.getCache(anyString())).thenReturn(cache); + when(cache.get(eq(accessTokenHash), eq(OIDCTransaction.class))).thenReturn(transaction); + + OIDCTransaction result = (OIDCTransaction) ReflectionTestUtils.invokeMethod(plugin, "getUserInfoTransaction", accessTokenHash); + assertNotNull(result); + assertEquals(transaction, result); + } +} \ No newline at end of file diff --git a/mosip-identity-certify-plugin/pom.xml b/mosip-identity-certify-plugin/pom.xml index 8bb0b39d..bd6a0a81 100644 --- a/mosip-identity-certify-plugin/pom.xml +++ b/mosip-identity-certify-plugin/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.mosip.certify mosip-identity-certify-plugin - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT jar mosipid-certify-integration-impl @@ -38,9 +38,9 @@ - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots + ossrh-central + MavenCentralRepository + https://central.sonatype.com/repository/maven-snapshots default true @@ -64,14 +64,13 @@ ossrh - https://oss.sonatype.org/content/repositories/snapshots + https://central.sonatype.com/repository/maven-snapshots/ ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + https://central.sonatype.com/api/v1/publisher - 21 21 @@ -85,6 +84,7 @@ 3.6.3 1.3.0-beta.1 2.12.1 + 0.7.0 @@ -98,13 +98,13 @@ io.mosip.certify certify-core - 0.11.0-SNAPSHOT + 0.12.0-SNAPSHOT provided io.mosip.certify certify-integration-api - 0.11.0-SNAPSHOT + 0.12.0-SNAPSHOT provided @@ -221,23 +221,13 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.14 + org.sonatype.central + central-publishing-maven-plugin + ${central.publishing.maven.plugin.version} true - - - default-deploy - deploy - - deploy - - - - ossrh - https://oss.sonatype.org/ - false + ossrh + false diff --git a/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaAuditPluginImplTest.java b/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaAuditPluginImplTest.java index 9f91eb76..0d498083 100644 --- a/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaAuditPluginImplTest.java +++ b/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaAuditPluginImplTest.java @@ -19,6 +19,10 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.RestTemplate; +import java.time.LocalDateTime; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) @@ -144,4 +148,67 @@ public void getAuditDescription_shouldReturnValidJson() throws Exception { assert obj.getString("transactionId").equals("txn123"); assert obj.getString("idType").equals("UIN"); } + + // Add inside IdaAuditPluginImplTest + + @Test + public void auditRequest_gettersSetters_allArgsConstructor() { + LocalDateTime localDateTime = LocalDateTime.now(); + io.mosip.certify.mosipid.integration.dto.AuditRequest req1 = new io.mosip.certify.mosipid.integration.dto.AuditRequest( + "eventId", "eventName", "eventType", localDateTime, "hostName", "hostIp", + "appId", "appName", "sessionUserId", "sessionUserName", "id", "idType", + "createdBy", "moduleName", "moduleId", "desc" + ); + assertEquals("eventId", req1.getEventId()); + assertEquals("eventName", req1.getEventName()); + assertEquals("eventType", req1.getEventType()); + assertEquals(localDateTime, req1.getActionTimeStamp()); + assertEquals("hostName", req1.getHostName()); + assertEquals("hostIp", req1.getHostIp()); + assertEquals("appId", req1.getApplicationId()); + assertEquals("appName", req1.getApplicationName()); + assertEquals("sessionUserId", req1.getSessionUserId()); + assertEquals("sessionUserName", req1.getSessionUserName()); + assertEquals("idType", req1.getIdType()); + assertEquals("createdBy", req1.getCreatedBy()); + assertEquals("moduleName", req1.getModuleName()); + assertEquals("moduleId", req1.getModuleId()); + assertEquals("desc", req1.getDescription()); + assertEquals("id", req1.getId()); + + io.mosip.certify.mosipid.integration.dto.AuditRequest req2 = new io.mosip.certify.mosipid.integration.dto.AuditRequest(); + req2.setEventId("eventId"); + req2.setEventName("eventName"); + req2.setEventType("eventType"); + req2.setActionTimeStamp(localDateTime); + req2.setHostName("hostName"); + req2.setHostIp("hostIp"); + req2.setApplicationId("appId"); + req2.setApplicationName("appName"); + req2.setSessionUserId("sessionUserId"); + req2.setSessionUserName("sessionUserName"); + req2.setIdType("idType"); + req2.setCreatedBy("createdBy"); + req2.setModuleName("moduleName"); + req2.setModuleId("moduleId"); + req2.setDescription("desc"); + req2.setId("id"); + + assertEquals(req1, req2); + assertEquals(req1.hashCode(), req2.hashCode()); + assertTrue(req1.toString().contains("eventId")); + } + + @Test + public void auditResponse_gettersSetters_allArgsConstructor() { + AuditResponse resp1 = new AuditResponse(); + resp1.setStatus(true); + + AuditResponse resp2 = new AuditResponse(); + resp2.setStatus(true); + + assertEquals(resp1, resp2); + assertEquals(resp1.hashCode(), resp2.hashCode()); + assertEquals(resp1.toString(), resp2.toString()); + } } diff --git a/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaVCIssuancePluginImplTest.java b/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaVCIssuancePluginImplTest.java index d1d558a6..f94861c4 100644 --- a/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaVCIssuancePluginImplTest.java +++ b/mosip-identity-certify-plugin/src/test/java/io/mosip/certify/mosipid/integration/service/IdaVCIssuancePluginImplTest.java @@ -13,9 +13,7 @@ import io.mosip.certify.api.exception.VCIExchangeException; import io.mosip.certify.api.util.ErrorConstants; import io.mosip.certify.core.exception.CertifyException; -import io.mosip.certify.mosipid.integration.dto.IdaResponseWrapper; -import io.mosip.certify.mosipid.integration.dto.IdaVcExchangeRequest; -import io.mosip.certify.mosipid.integration.dto.IdaVcExchangeResponse; +import io.mosip.certify.mosipid.integration.dto.*; import io.mosip.certify.mosipid.integration.helper.VCITransactionHelper; import io.mosip.esignet.core.dto.OIDCTransaction; import io.mosip.kernel.core.keymanager.spi.KeyStore; @@ -44,6 +42,8 @@ import java.util.*; import static io.mosip.kernel.keymanagerservice.constant.KeymanagerConstant.CURRENTKEYALIAS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; @RunWith(MockitoJUnitRunner.class) public class IdaVCIssuancePluginImplTest { @@ -386,4 +386,157 @@ public void getIndividualId_whenSecureIndividualIdFalse_shouldReturnOriginalValu String result = idaVCIssuancePlugin.getIndividualId(expected); Assert.assertEquals(expected, result); } + + @Test + public void testIdaVcExchangeRequest() { + IdaVcExchangeRequest req1 = new IdaVcExchangeRequest(); + req1.setVcAuthToken("token"); + req1.setCredSubjectId("subjectId"); + req1.setVcFormat("format"); + req1.setLocales(List.of("en", "fr")); + req1.setMetadata(Map.of("key", "value")); + req1.setId("id"); + req1.setVersion("v1"); + req1.setIndividualId("indivId"); + req1.setTransactionID("txnId"); + req1.setRequestTime("now"); + CredentialDefinitionDTO credDef = new CredentialDefinitionDTO(); + req1.setCredentialsDefinition(credDef); + + assertEquals("token", req1.getVcAuthToken()); + assertEquals("subjectId", req1.getCredSubjectId()); + assertEquals("format", req1.getVcFormat()); + assertEquals(List.of("en", "fr"), req1.getLocales()); + assertEquals(Map.of("key", "value"), req1.getMetadata()); + assertEquals("id", req1.getId()); + assertEquals("v1", req1.getVersion()); + assertEquals("indivId", req1.getIndividualId()); + assertEquals("txnId", req1.getTransactionID()); + assertEquals("now", req1.getRequestTime()); + assertEquals(credDef, req1.getCredentialsDefinition()); + + IdaVcExchangeRequest req2 = new IdaVcExchangeRequest(); + req2.setVcAuthToken("token"); + req2.setCredSubjectId("subjectId"); + req2.setVcFormat("format"); + req2.setLocales(List.of("en", "fr")); + req2.setMetadata(Map.of("key", "value")); + req2.setId("id"); + req2.setVersion("v1"); + req2.setIndividualId("indivId"); + req2.setTransactionID("txnId"); + req2.setRequestTime("now"); + req2.setCredentialsDefinition(credDef); + + assertEquals(req1, req2); + assertEquals(req1.hashCode(), req2.hashCode()); + assertTrue(req1.toString().contains("token")); + } + + @Test + public void testIdaVcExchangeResponse() { + IdaVcExchangeResponse resp1 = new IdaVcExchangeResponse<>(); + resp1.setVerifiableCredentials("vc"); + assertEquals("vc", resp1.getVerifiableCredentials()); + + IdaVcExchangeResponse resp2 = new IdaVcExchangeResponse<>(); + resp2.setVerifiableCredentials("vc"); + + assertEquals(resp1, resp2); + assertEquals(resp1.hashCode(), resp2.hashCode()); + assertTrue(resp1.toString().contains("vc")); + } + + @Test + public void testIdaError() { + IdaError err1 = new IdaError(); + err1.setActionMessage("action"); + err1.setErrorCode("code"); + err1.setErrorMessage("msg"); + + assertEquals("action", err1.getActionMessage()); + assertEquals("code", err1.getErrorCode()); + assertEquals("msg", err1.getErrorMessage()); + + IdaError err2 = new IdaError(); + err2.setActionMessage("action"); + err2.setErrorCode("code"); + err2.setErrorMessage("msg"); + + assertEquals(err1, err2); + assertEquals(err1.hashCode(), err2.hashCode()); + assertTrue(err1.toString().contains("action")); + } + + @Test + public void testCredentialDefinitionDTO() { + CredentialDefinitionDTO dto1 = new CredentialDefinitionDTO(); + dto1.setCredentialSubject(Map.of("key", "value")); + dto1.setType(List.of("type1", "type2")); + dto1.setContext(List.of("context1", "context2")); + + assertEquals(Map.of("key", "value"), dto1.getCredentialSubject()); + assertEquals(List.of("type1", "type2"), dto1.getType()); + assertEquals(List.of("context1", "context2"), dto1.getContext()); + + CredentialDefinitionDTO dto2 = new CredentialDefinitionDTO(); + dto2.setCredentialSubject(Map.of("key", "value")); + dto2.setType(List.of("type1", "type2")); + dto2.setContext(List.of("context1", "context2")); + + assertEquals(dto1, dto2); + assertEquals(dto1.hashCode(), dto2.hashCode()); + assertTrue(dto1.toString().contains("key")); + } + + @Test + public void testClientIdSecretKeyRequest() { + // All-args constructor + ClientIdSecretKeyRequest req1 = new ClientIdSecretKeyRequest("client", "secret", "app"); + assertEquals("client", req1.getClientId()); + assertEquals("secret", req1.getSecretKey()); + assertEquals("app", req1.getAppId()); + + // No-args constructor and setters + ClientIdSecretKeyRequest req2 = new ClientIdSecretKeyRequest(); + req2.setClientId("client"); + req2.setSecretKey("secret"); + req2.setAppId("app"); + + assertEquals(req1, req2); + assertEquals(req1.hashCode(), req2.hashCode()); + assertTrue(req1.toString().contains("client")); + } + + @Test + public void testIdaResponseWrapper() { + IdaResponseWrapper wrapper1 = new IdaResponseWrapper<>(); + wrapper1.setId("id1"); + wrapper1.setVersion("v1"); + wrapper1.setTransactionID("txn1"); + wrapper1.setResponseTime("now"); + wrapper1.setResponse("response"); + IdaError error = new IdaError(); + error.setErrorCode("E1"); + wrapper1.setErrors(List.of(error)); + + assertEquals("id1", wrapper1.getId()); + assertEquals("v1", wrapper1.getVersion()); + assertEquals("txn1", wrapper1.getTransactionID()); + assertEquals("now", wrapper1.getResponseTime()); + assertEquals("response", wrapper1.getResponse()); + assertEquals(List.of(error), wrapper1.getErrors()); + + IdaResponseWrapper wrapper2 = new IdaResponseWrapper<>(); + wrapper2.setId("id1"); + wrapper2.setVersion("v1"); + wrapper2.setTransactionID("txn1"); + wrapper2.setResponseTime("now"); + wrapper2.setResponse("response"); + wrapper2.setErrors(List.of(error)); + + assertEquals(wrapper1, wrapper2); + assertEquals(wrapper1.hashCode(), wrapper2.hashCode()); + assertTrue(wrapper1.toString().contains("id1")); + } } diff --git a/postgres-dataprovider-plugin/pom.xml b/postgres-dataprovider-plugin/pom.xml index 71423c2c..83c3249f 100644 --- a/postgres-dataprovider-plugin/pom.xml +++ b/postgres-dataprovider-plugin/pom.xml @@ -4,7 +4,7 @@ io.mosip.certify postgres-dataprovider-plugin - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT jar postgres-dataprovider-plugin @@ -42,7 +42,7 @@ 3.2.5 1.5 2.2.1 - 6.1.0 + 0.7.0 3.0.1 0.8.11 3.6.3 @@ -58,7 +58,7 @@ io.mosip.certify certify-core - 0.11.0-SNAPSHOT + 0.12.0-SNAPSHOT provided @@ -92,9 +92,9 @@ - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots + ossrh-central + MavenCentralRepository + https://central.sonatype.com/repository/maven-snapshots default true @@ -114,14 +114,13 @@ ossrh - https://oss.sonatype.org/content/repositories/snapshots + https://central.sonatype.com/repository/maven-snapshots/ ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + https://central.sonatype.com/api/v1/publisher - @@ -176,26 +175,15 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.14 + org.sonatype.central + central-publishing-maven-plugin + ${central.publishing.maven.plugin.version} true - - - default-deploy - deploy - - deploy - - - - ossrh - https://oss.sonatype.org/ - false + ossrh + false - org.apache.maven.plugins maven-source-plugin diff --git a/postgres-dataprovider-plugin/src/test/java/io/mosip/certify/postgresdataprovider/integration/service/PostgresDataProviderPluginTest.java b/postgres-dataprovider-plugin/src/test/java/io/mosip/certify/postgresdataprovider/integration/service/PostgresDataProviderPluginTest.java index 5041c394..bf1a40e9 100644 --- a/postgres-dataprovider-plugin/src/test/java/io/mosip/certify/postgresdataprovider/integration/service/PostgresDataProviderPluginTest.java +++ b/postgres-dataprovider-plugin/src/test/java/io/mosip/certify/postgresdataprovider/integration/service/PostgresDataProviderPluginTest.java @@ -12,6 +12,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; +import org.mockito.exceptions.base.MockitoException; import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; @@ -84,7 +85,7 @@ public void fetchJsonDataWithMissingSub_thenFail() throws DataProviderExchangeEx @Test(expected = DataProviderExchangeException.class) public void fetchJsonDataWithNullQueryResult_thenFail() throws DataProviderExchangeException { Mockito.when(dataProviderRepository.fetchQueryResult("1234567", "test_query")) - .thenReturn(null); + .thenThrow(new MockitoException("Query execution failed")); postgresDataProviderPlugin.fetchData(Map.of("sub", "1234567", "client_id", "CLIENT_ID", "scope", "test_vc_ldp")); } diff --git a/sunbird-rc-certify-integration-impl/pom.xml b/sunbird-rc-certify-integration-impl/pom.xml index 0e28380e..cbe458de 100644 --- a/sunbird-rc-certify-integration-impl/pom.xml +++ b/sunbird-rc-certify-integration-impl/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.mosip.certify.sunbirdrc sunbird-rc-certify-integration-impl - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT jar sunbird-rc-certify-integration-impl @@ -45,7 +45,7 @@ 3.2.5 1.5 2.2.1 - 6.1.0 + 0.7.0 3.0.1 0.8.11 3.6.3 @@ -54,7 +54,7 @@ io.mosip.certify certify-integration-api - 0.11.0-SNAPSHOT + 0.12.0-SNAPSHOT provided @@ -77,11 +77,16 @@ 3.4.3 test + + + + + + - org.springframework.boot - spring-boot-starter-test - 3.2.3 - test + org.springframework + spring-test + 6.1.4 @@ -99,12 +104,18 @@ + + junit + junit + 4.13.2 + test + - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots + ossrh-central + MavenCentralRepository + https://central.sonatype.com/repository/maven-snapshots default true @@ -132,11 +143,11 @@ ossrh - https://oss.sonatype.org/content/repositories/snapshots + https://central.sonatype.com/repository/maven-snapshots/ ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + https://central.sonatype.com/api/v1/publisher @@ -193,26 +204,15 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.14 + org.sonatype.central + central-publishing-maven-plugin + ${central.publishing.maven.plugin.version} true - - - default-deploy - deploy - - deploy - - - - ossrh - https://oss.sonatype.org/ - false + ossrh + false - org.apache.maven.plugins maven-source-plugin diff --git a/sunbird-rc-certify-integration-impl/src/test/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePluginTest.java b/sunbird-rc-certify-integration-impl/src/test/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePluginTest.java index 50b02d63..0da5b685 100644 --- a/sunbird-rc-certify-integration-impl/src/test/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePluginTest.java +++ b/sunbird-rc-certify-integration-impl/src/test/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePluginTest.java @@ -18,7 +18,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.env.Environment; import org.springframework.http.HttpStatus; @@ -34,7 +33,6 @@ import java.util.Map; @RunWith(MockitoJUnitRunner.class) -@SpringBootTest public class SunbirdRCVCIssuancePluginTest { @Mock diff --git a/sunbird-rc-esignet-integration-impl/pom.xml b/sunbird-rc-esignet-integration-impl/pom.xml index 80d81722..dc5c2673 100644 --- a/sunbird-rc-esignet-integration-impl/pom.xml +++ b/sunbird-rc-esignet-integration-impl/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.mosip.esignet.sunbirdrc sunbird-rc-esignet-integration-impl - 0.4.0-SNAPSHOT + 0.5.0-SNAPSHOT jar sunbird-rc-esignet-integration-impl @@ -43,7 +43,7 @@ 2.22.0 1.5 2.2.1 - 1.6.7 + 0.7.0 3.0.1 0.8.5 3.3.1 @@ -149,14 +149,14 @@ - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + ossrh + https://central.sonatype.com/repository/maven-snapshots/ + + + ossrh + https://central.sonatype.com/api/v1/publisher + + @@ -211,26 +211,15 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 + org.sonatype.central + central-publishing-maven-plugin + ${central.publishing.maven.plugin.version} true - - - default-deploy - deploy - - deploy - - - - ossrh - https://oss.sonatype.org/ - false + ossrh + false - org.apache.maven.plugins maven-source-plugin From f9387532a951f313c7d504cdd4355c9e341afeaf Mon Sep 17 00:00:00 2001 From: Piyush7034 Date: Fri, 18 Jul 2025 19:15:56 +0530 Subject: [PATCH 2/5] [INJICERT-1145] Fix mdoc failure issue (#118) Signed-off-by: Piyush7034 --- .../io/mosip/certify/mock/integration/mocks/MdocGenerator.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mock-certify-plugin/src/main/java/io/mosip/certify/mock/integration/mocks/MdocGenerator.java b/mock-certify-plugin/src/main/java/io/mosip/certify/mock/integration/mocks/MdocGenerator.java index 3e285931..565344cb 100644 --- a/mock-certify-plugin/src/main/java/io/mosip/certify/mock/integration/mocks/MdocGenerator.java +++ b/mock-certify-plugin/src/main/java/io/mosip/certify/mock/integration/mocks/MdocGenerator.java @@ -10,6 +10,7 @@ import com.android.identity.mdoc.util.MdocUtil; import com.android.identity.util.Timestamp; import io.mosip.certify.util.*; +import org.springframework.stereotype.Component; import java.io.ByteArrayOutputStream; import java.security.KeyPair; @@ -20,6 +21,7 @@ import java.time.temporal.ChronoUnit; import java.util.*; +@Component public class MdocGenerator { public static final String NAMESPACE = "org.iso.18013.5.1"; From 35166d8a4a5b5e9f4caef2ad32980de46c4a4a87 Mon Sep 17 00:00:00 2001 From: Piyush7034 Date: Thu, 24 Jul 2025 17:58:21 +0530 Subject: [PATCH 3/5] [INJICERT-1145] Remove VerifiableCredentia as first type condition Signed-off-by: Piyush7034 --- .../integration/service/SunbirdRCVCIssuancePlugin.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sunbird-rc-certify-integration-impl/src/main/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePlugin.java b/sunbird-rc-certify-integration-impl/src/main/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePlugin.java index 68b51df5..dda880e9 100644 --- a/sunbird-rc-certify-integration-impl/src/main/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePlugin.java +++ b/sunbird-rc-certify-integration-impl/src/main/java/io/mosip/certify/sunbirdrc/integration/service/SunbirdRCVCIssuancePlugin.java @@ -131,11 +131,11 @@ public VCResult getVerifiableCredentialWithLinkedDataProof(VCReque throw new VCIExchangeException(ErrorConstants.VCI_EXCHANGE_FAILED); } List types = vcRequestDto.getType(); - if (types.isEmpty() || !types.get(0).equals("VerifiableCredential")) { - log.error("Invalid request: first item in type is not VerifiableCredential"); + if (types.isEmpty() || !types.contains("VerifiableCredential")) { + log.error("Invalid request: VerifiableCredential not present in types"); throw new VCIExchangeException(ErrorConstants.VCI_EXCHANGE_FAILED); } - types.remove(0); + types.remove("VerifiableCredential"); String requestedCredentialType = String.join("-", types); //Check if the key is in the supported-credential-types if (!supportedCredentialTypes.contains(requestedCredentialType)) { From 168e553b673fbf1546bc1c9491cc194c464165d6 Mon Sep 17 00:00:00 2001 From: Praful Rakhade Date: Wed, 6 Aug 2025 14:30:23 +0530 Subject: [PATCH 4/5] [MOSIP-42464] [MOSIP-41674] central sonatype migration changes (#121) * [MOSIP-42464] [MOSIP-41674] central sonatype migration changes Signed-off-by: Prafulrakhade * [MOSIP-42464] [MOSIP-41674] central sonatype migration changes Signed-off-by: Praful Rakhade --------- Signed-off-by: Prafulrakhade Signed-off-by: Praful Rakhade Co-authored-by: Prafulrakhade --- sunbird-rc-esignet-integration-impl/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sunbird-rc-esignet-integration-impl/pom.xml b/sunbird-rc-esignet-integration-impl/pom.xml index dc5c2673..433118bb 100644 --- a/sunbird-rc-esignet-integration-impl/pom.xml +++ b/sunbird-rc-esignet-integration-impl/pom.xml @@ -120,9 +120,9 @@ - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots + ossrh-central + MavenCentralRepository + https://central.sonatype.com/repository/maven-snapshots default true From 931e2c69ac1d61bc120e6913a382a2713795b5c6 Mon Sep 17 00:00:00 2001 From: Praful Rakhade Date: Tue, 26 Aug 2025 11:33:15 +0530 Subject: [PATCH 5/5] [DSD-8775] inji-certify 0.12.0 release (#122) Signed-off-by: Prafulrakhade --- mock-certify-plugin/pom.xml | 4 ++-- mosip-identity-certify-plugin/pom.xml | 6 +++--- postgres-dataprovider-plugin/pom.xml | 4 ++-- sunbird-rc-certify-integration-impl/pom.xml | 4 ++-- sunbird-rc-esignet-integration-impl/pom.xml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mock-certify-plugin/pom.xml b/mock-certify-plugin/pom.xml index 3c96d5bd..e36aa14b 100644 --- a/mock-certify-plugin/pom.xml +++ b/mock-certify-plugin/pom.xml @@ -10,7 +10,7 @@ io.mosip.certify mock-certify-plugin - 0.5.0-SNAPSHOT + 0.5.0 jar mock-certify-integration-impl @@ -65,7 +65,7 @@ io.mosip.certify certify-core - 0.12.0-SNAPSHOT + 0.12.0 provided diff --git a/mosip-identity-certify-plugin/pom.xml b/mosip-identity-certify-plugin/pom.xml index bd6a0a81..a61b2070 100644 --- a/mosip-identity-certify-plugin/pom.xml +++ b/mosip-identity-certify-plugin/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.mosip.certify mosip-identity-certify-plugin - 0.5.0-SNAPSHOT + 0.5.0 jar mosipid-certify-integration-impl @@ -98,13 +98,13 @@ io.mosip.certify certify-core - 0.12.0-SNAPSHOT + 0.12.0 provided io.mosip.certify certify-integration-api - 0.12.0-SNAPSHOT + 0.12.0 provided diff --git a/postgres-dataprovider-plugin/pom.xml b/postgres-dataprovider-plugin/pom.xml index 83c3249f..c03c8ada 100644 --- a/postgres-dataprovider-plugin/pom.xml +++ b/postgres-dataprovider-plugin/pom.xml @@ -4,7 +4,7 @@ io.mosip.certify postgres-dataprovider-plugin - 0.5.0-SNAPSHOT + 0.5.0 jar postgres-dataprovider-plugin @@ -58,7 +58,7 @@ io.mosip.certify certify-core - 0.12.0-SNAPSHOT + 0.12.0 provided diff --git a/sunbird-rc-certify-integration-impl/pom.xml b/sunbird-rc-certify-integration-impl/pom.xml index cbe458de..f3cb1679 100644 --- a/sunbird-rc-certify-integration-impl/pom.xml +++ b/sunbird-rc-certify-integration-impl/pom.xml @@ -8,7 +8,7 @@ 4.0.0 io.mosip.certify.sunbirdrc sunbird-rc-certify-integration-impl - 0.5.0-SNAPSHOT + 0.5.0 jar sunbird-rc-certify-integration-impl @@ -54,7 +54,7 @@ io.mosip.certify certify-integration-api - 0.12.0-SNAPSHOT + 0.12.0 provided diff --git a/sunbird-rc-esignet-integration-impl/pom.xml b/sunbird-rc-esignet-integration-impl/pom.xml index 433118bb..e6120d13 100644 --- a/sunbird-rc-esignet-integration-impl/pom.xml +++ b/sunbird-rc-esignet-integration-impl/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.mosip.esignet.sunbirdrc sunbird-rc-esignet-integration-impl - 0.5.0-SNAPSHOT + 0.5.0 jar sunbird-rc-esignet-integration-impl