From be5baf05e0b48d9cb34748cc0521a6d643a63e19 Mon Sep 17 00:00:00 2001
From: Kaif Siddique <74772315+kaifk468@users.noreply.github.com>
Date: Fri, 4 Oct 2024 12:36:38 +0530
Subject: [PATCH 1/2] [ES-1613] added test case for coverage (#27)

* added test case for coverage

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* remvoed null pointer bug

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* removed bug

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* review comment changes

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* review changes

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* review changes

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* review changes

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

* reivew changes

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>

---------

Signed-off-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>
Co-authored-by: Mohd Kaif Siddique <mohdkaif.siddique@ad.infosys.com>
Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>
---
 .../MockProfileRegistryPluginImpl.java        |   4 +-
 .../MockIdentityVerifierPluginImplTest.java   | 126 +++++
 .../MockProfileRegistryPluginImplTest.java    | 304 ++++++++++
 .../service/IdaAuthenticatorImplTest.java     |  69 ++-
 .../IdrepoProfileRegistryPluginImplTest.java  | 528 ++++++++++++++++++
 5 files changed, 1026 insertions(+), 5 deletions(-)
 create mode 100644 mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockIdentityVerifierPluginImplTest.java
 create mode 100644 mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImplTest.java
 create mode 100644 mosip-identity-plugin/src/test/java/io/mosip/signup/plugin/mosipid/service/IdrepoProfileRegistryPluginImplTest.java

diff --git a/mock-plugin/src/main/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImpl.java b/mock-plugin/src/main/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImpl.java
index c5a5935..ef36a7b 100644
--- a/mock-plugin/src/main/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImpl.java
+++ b/mock-plugin/src/main/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImpl.java
@@ -70,7 +70,7 @@ public class MockProfileRegistryPluginImpl implements ProfileRegistryPlugin {
 
     @Value("${mosip.signup.mock.add-verified-claims.endpoint}")
     private String addVerifiedClaimsEndpoint;
-    
+
     @Autowired
     @Qualifier("selfTokenRestTemplate")
     private RestTemplate restTemplate;
@@ -194,7 +194,7 @@ private <T> ResponseWrapper<T> request(String url, HttpMethod method, Object req
 				throw new ProfileException(SERVER_UNREACHABLE);
 		}
 	}
-    
+
     private MockIdentityResponse addIdentity(JsonNode identityRequest) throws ProfileException{
         RequestWrapper<JsonNode> restRequest = new RequestWrapper<>();
         restRequest.setRequestTime(getUTCDateTime());
diff --git a/mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockIdentityVerifierPluginImplTest.java b/mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockIdentityVerifierPluginImplTest.java
new file mode 100644
index 0000000..1d74e1c
--- /dev/null
+++ b/mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockIdentityVerifierPluginImplTest.java
@@ -0,0 +1,126 @@
+package io.mosip.signup.plugin.mock.service;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.mosip.signup.api.dto.FrameDetail;
+import io.mosip.signup.api.dto.IdentityVerificationDto;
+import io.mosip.signup.api.dto.IdentityVerificationResult;
+import io.mosip.signup.api.dto.VerificationResult;
+import io.mosip.signup.api.exception.IdentityVerifierException;
+import io.mosip.signup.api.util.VerificationStatus;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class MockIdentityVerifierPluginImplTest {
+
+    @InjectMocks
+    private MockIdentityVerifierPluginImpl mockIdentityVerifierPlugin;
+
+    @Mock
+    ResourceLoader resourceLoader;
+
+
+    ObjectMapper objectMapper;
+
+    @Before
+    public void before(){
+        objectMapper = new ObjectMapper();
+        ReflectionTestUtils.setField(mockIdentityVerifierPlugin, "objectMapper",objectMapper);
+    }
+
+
+    @Test
+    public void verify_withValidIdentityVerificationDto_thenPass() throws IdentityVerifierException, IOException {
+
+        String transactionId = "transactionId123";
+        IdentityVerificationDto identityVerificationDto = new IdentityVerificationDto();
+        identityVerificationDto.setStepCode("START");
+        List<FrameDetail> frameDetails= new ArrayList<>();
+        FrameDetail frameDetail = new FrameDetail();
+        frameDetail.setFrame("frame");
+        frameDetail.setOrder(0);
+        frameDetails.add(frameDetail);
+        identityVerificationDto.setFrames(frameDetails);
+
+        String jsonContent = "{\"scenes\":[{\"frameNumber\":0,\"stepCode\":\"START\",\"step\":{\"code\":\"liveness_check\",\"framesPerSecond\":3,\"durationInSeconds\":100,\"startupDelayInSeconds\":2,\"retryOnTimeout\":false,\"retryableErrorCodes\":[]},\"feedback\":null}],\"verificationResult\":{\"status\":\"COMPLETED\",\"verifiedClaims\":{\"fullName\":{\"trust_framework\":\"XYZ TF\",\"verification_process\":\"EKYC\",\"assurance_level\":\"Gold\",\"time\":\"34232432\"}},\"errorCode\":null}}";
+        Resource resource = Mockito.mock(Resource.class);
+        Mockito.when(resourceLoader.getResource(Mockito.anyString())).thenReturn(resource);
+        Mockito.when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(jsonContent.getBytes()));
+
+        KafkaTemplate<String, IdentityVerificationResult> kafkaTemplate = Mockito.mock(KafkaTemplate.class);
+        ReflectionTestUtils.setField(mockIdentityVerifierPlugin, "kafkaTemplate", kafkaTemplate);
+
+
+        mockIdentityVerifierPlugin.verify(transactionId, identityVerificationDto);
+
+        Mockito.verify(resourceLoader).getResource(Mockito.anyString());
+        ArgumentCaptor<IdentityVerificationResult> resultCaptor = ArgumentCaptor.forClass(IdentityVerificationResult.class);
+        Mockito.verify(kafkaTemplate, Mockito.times(2)).send(
+                Mockito.eq("ANALYZE_FRAMES_RESULT"),
+                resultCaptor.capture()
+        );
+    }
+
+
+    @Test
+    public void getVerifiedResult_withValidTransactionId_thenPass() throws IdentityVerifierException, IOException {
+
+        String transactionId = "transactionId123";
+        VerificationResult verifiedResult = new VerificationResult();
+        Map<String,String> fullNameMap = new HashMap<>();
+        fullNameMap.put("trust_framework","XYZ TF");
+        fullNameMap.put("verification_process","EKYC");
+        fullNameMap.put("assurance_level","Gold");
+        fullNameMap.put("time","34232432");
+
+        Map<String,JsonNode> verifiedClaims = new HashMap<>();
+        verifiedClaims.put("fullName",objectMapper.convertValue(fullNameMap,JsonNode.class));
+        verifiedResult.setVerifiedClaims(verifiedClaims);
+        verifiedResult.setStatus(VerificationStatus.COMPLETED);
+
+        String jsonContent = "{\"scenes\":[{\"frameNumber\":0,\"stepCode\":\"START\",\"step\":{\"code\":\"liveness_check\",\"framesPerSecond\":3,\"durationInSeconds\":100,\"startupDelayInSeconds\":2,\"retryOnTimeout\":false,\"retryableErrorCodes\":[]},\"feedback\":null}],\"verificationResult\":{\"status\":\"COMPLETED\",\"verifiedClaims\":{\"fullName\":{\"trust_framework\":\"XYZ TF\",\"verification_process\":\"EKYC\",\"assurance_level\":\"Gold\",\"time\":\"34232432\"}},\"errorCode\":null}}";
+        Resource resource = Mockito.mock(Resource.class);
+
+        Mockito.when(resourceLoader.getResource(Mockito.anyString())).thenReturn(resource);
+        Mockito.when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(jsonContent.getBytes()));
+        VerificationResult actualVerifiedResult = mockIdentityVerifierPlugin.getVerificationResult(transactionId);
+
+        Assert.assertEquals(verifiedResult.getStatus(), actualVerifiedResult.getStatus());
+        Assert.assertEquals(verifiedResult.getVerifiedClaims(), actualVerifiedResult.getVerifiedClaims());
+    }
+
+
+    @Test
+    public void getVerifiedResult_withValidTransactionId_thenFail() throws IdentityVerifierException, IOException {
+
+        String transactionId = "transactionId123";
+        String jsonContent = "{}";
+        Resource resource = Mockito.mock(Resource.class);
+        Mockito.when(resourceLoader.getResource(Mockito.anyString())).thenReturn(resource);
+        Mockito.when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(jsonContent.getBytes()));
+        VerificationResult verificationResult = mockIdentityVerifierPlugin.getVerificationResult(transactionId);
+        Assert.assertEquals(verificationResult.getErrorCode(),"mock_verification_failed");
+        Assert.assertEquals(verificationResult.getStatus(),VerificationStatus.FAILED);
+    }
+}
diff --git a/mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImplTest.java b/mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImplTest.java
new file mode 100644
index 0000000..c254020
--- /dev/null
+++ b/mock-plugin/src/test/java/io/mosip/signup/plugin/mock/service/MockProfileRegistryPluginImplTest.java
@@ -0,0 +1,304 @@
+package io.mosip.signup.plugin.mock.service;
+
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import io.mosip.esignet.core.dto.Error;
+import io.mosip.esignet.core.dto.ResponseWrapper;
+import io.mosip.signup.api.dto.ProfileDto;
+import io.mosip.signup.api.dto.ProfileResult;
+import io.mosip.signup.api.exception.ProfileException;
+import io.mosip.signup.api.util.ProfileCreateUpdateStatus;
+import io.mosip.signup.plugin.mock.dto.MockIdentityResponse;
+import io.mosip.signup.plugin.mock.util.ErrorConstants;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RunWith(SpringRunner.class)
+public class MockProfileRegistryPluginImplTest {
+
+
+    @InjectMocks
+    private MockProfileRegistryPluginImpl mockProfileRegistryPlugin;
+
+    @Mock
+    RestTemplate restTemplate;
+
+    ObjectMapper objectMapper=new ObjectMapper();
+
+    @Before
+    public void init(){
+        objectMapper.registerModule(new JavaTimeModule());
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "objectMapper",objectMapper);
+    }
+
+
+    @Test
+    public void validate_withValidActionAndProfileDto_thenPass() throws JsonProcessingException {
+
+        List<String> requiredField=new ArrayList<>();
+        requiredField.add("phone");
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "requiredFieldsOnCreate", requiredField);
+        String action = "CREATE";
+
+        String phone="{ \"value\": \"7408001310\", \"essential\":true }";
+        String verifiedClaims="[{\"verification\":{\"trust_framework\":{\"value\":\"income-tax\"}},\"claims\":{\"name\":null,\"email\":{\"essential\":0}}},{\"verification\":{\"trust_framework\":{\"value\":\"pwd\"}},\"claims\":{\"birthdate\":{\"essential\":true},\"address\":null}},{\"verification\":{\"trust_framework\":{\"value\":\"cbi\"}},\"claims\":{\"gender\":{\"essential\":true},\"email\":{\"essential\":true}}}]";
+        JsonNode addressNode = objectMapper.readValue(phone, JsonNode.class);
+        JsonNode verifiedClaimNode = objectMapper.readValue(verifiedClaims, JsonNode.class);
+
+        Map<String, JsonNode> userinfoMap = new HashMap<>();
+        userinfoMap.put("phone", addressNode);
+        userinfoMap.put("verified_claims", verifiedClaimNode);
+        JsonNode mockIdentity=objectMapper.valueToTree(userinfoMap);
+
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId("individualId");
+        profileDto.setIdentity(mockIdentity);
+
+        mockProfileRegistryPlugin.validate(action, profileDto);
+    }
+
+    @Test
+    public void createProfile_withValidRequestAndProfileDto_thenPass() throws ProfileException {
+        // Arrange
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "identityEndpoint","http://localhost:8080/");
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "usernameField","individualId");
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("individualId","1234567890");
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId("1234567890");
+        profileDto.setIdentity(mockIdentity);
+
+        MockIdentityResponse mockIdentityResponse=new MockIdentityResponse();
+        mockIdentityResponse.setStatus("CREATED");
+        ResponseWrapper<MockIdentityResponse> responseWrapper = new ResponseWrapper<>();
+        responseWrapper.setResponse(mockIdentityResponse);
+        ResponseEntity<ResponseWrapper<MockIdentityResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<MockIdentityResponse>>() {
+                }))).thenReturn(responseEntity);
+
+        ProfileResult result = mockProfileRegistryPlugin.createProfile("requestId", profileDto);
+        Assert.assertNotNull(result);
+        Assert.assertEquals(result.getStatus(), "CREATED");
+    }
+
+
+    @Test
+    public void createProfile_withInValidRequestAndProfileDto_thenFail() throws ProfileException {
+        // Arrange
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "usernameField","individualId");
+        Map<String,String> identityData=new HashMap<>();
+        identityData.put("individualId","1234567890");
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId("123456789");
+        profileDto.setIdentity(mockIdentity);
+        try{
+            mockProfileRegistryPlugin.createProfile("requestId", profileDto);
+        }catch (ProfileException e){
+            Assert.assertEquals(ErrorConstants.IDENTIFIER_MISMATCH,e.getMessage());
+        }
+    }
+
+
+    @Test
+    public void getProfileCreateUpdateStatus_withValidRequestId_thenPass() throws ProfileException {
+        String requestId = "requestId123";
+
+        ProfileCreateUpdateStatus status = mockProfileRegistryPlugin.getProfileCreateUpdateStatus(requestId);
+
+        Assert.assertEquals(status,ProfileCreateUpdateStatus.COMPLETED);
+    }
+
+    @Test
+    public void getProfile_withValidIndividualId_thenPass() throws ProfileException {
+        String individualId = "1234567890";
+       ReflectionTestUtils.setField(mockProfileRegistryPlugin, "getIdentityEndpoint","http://localhost:8080/");
+
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+        identityData.put("UIN","1234567890");
+        identityData.put("individualId",individualId);
+
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ResponseWrapper<JsonNode> responseWrapper = new ResponseWrapper<>();
+        responseWrapper.setResponse(mockIdentity);
+        ResponseEntity<ResponseWrapper<JsonNode>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/"+individualId,
+                HttpMethod.GET,
+                null,
+                new ParameterizedTypeReference<ResponseWrapper<JsonNode>>() {
+                })).thenReturn(responseEntity);
+        ProfileDto profileDto= mockProfileRegistryPlugin.getProfile(individualId);
+        Assert.assertNotNull(profileDto);
+        Assert.assertTrue(profileDto.isActive());
+    }
+
+    @Test
+    public void getProfile_withInValidIndividualId_thenFail() throws ProfileException {
+        String individualId = "1234567890";
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "getIdentityEndpoint","http://localhost:8080/");
+
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+        identityData.put("UIN","1234567890");
+        identityData.put("individualId",individualId);
+
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ResponseWrapper<JsonNode> responseWrapper = new ResponseWrapper<>();
+        responseWrapper.setResponse(mockIdentity);
+        Error error = new Error();
+        error.setErrorCode("invalid_individual_id");
+        responseWrapper.setErrors(List.of(error));
+        ResponseEntity<ResponseWrapper<JsonNode>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/"+individualId,
+                HttpMethod.GET,
+                null,
+                new ParameterizedTypeReference<ResponseWrapper<JsonNode>>() {
+                })).thenReturn(responseEntity);
+
+        ProfileDto profileDto= mockProfileRegistryPlugin.getProfile(individualId);
+        Assert.assertNotNull(profileDto);
+        Assert.assertFalse(profileDto.isActive());
+        Assert.assertEquals(profileDto.getIndividualId(),individualId);
+    }
+
+
+    @Test
+    public void updateProfile_withVerifiedClaim_thenPass()  {
+
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "addVerifiedClaimsEndpoint","http://localhost:8080/");
+        String requestId = "req-123";
+        String individualId = "ind-456";
+
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+
+        Map<String,Object> verifiedClaim=new HashMap<>();
+        verifiedClaim.put("verified_claims",identityData);
+
+        JsonNode mockIdentity = objectMapper.valueToTree(verifiedClaim);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+
+        MockIdentityResponse mockIdentityResponse=new MockIdentityResponse();
+        mockIdentityResponse.setStatus("UPDATED");
+        ResponseWrapper<MockIdentityResponse> responseWrapper = new ResponseWrapper<>();
+        responseWrapper.setResponse(mockIdentityResponse);
+        ResponseEntity<ResponseWrapper<MockIdentityResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<MockIdentityResponse>>() {
+                }))).thenReturn(responseEntity);
+
+
+        ProfileResult profileResult = mockProfileRegistryPlugin.updateProfile(requestId, profileDto);
+        Assert.assertNotNull(profileResult);
+        Assert.assertEquals(profileResult.getStatus(),"UPDATED");
+    }
+
+    @Test
+    public void updateProfile_withOutVerifiedClaim_thenPass()  {
+
+
+        ReflectionTestUtils.setField(mockProfileRegistryPlugin, "identityEndpoint","http://localhost:8080/");
+        String requestId = "req-123";
+        String individualId = "ind-456";
+
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+
+        MockIdentityResponse mockIdentityResponse=new MockIdentityResponse();
+        mockIdentityResponse.setStatus("UPDATED");
+        ResponseWrapper<MockIdentityResponse> responseWrapper = new ResponseWrapper<>();
+        responseWrapper.setResponse(mockIdentityResponse);
+        ResponseEntity<ResponseWrapper<MockIdentityResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<MockIdentityResponse>>() {
+                }))).thenReturn(responseEntity);
+
+
+        ProfileResult profileResult = mockProfileRegistryPlugin.updateProfile(requestId, profileDto);
+        Assert.assertNotNull(profileResult);
+        Assert.assertEquals(profileResult.getStatus(),"UPDATED");
+    }
+
+    @Test
+    public void isMatch_withValidInputChallenge_thenPass() {
+
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+        identityData.put("UIN","1234567890");
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        JsonNode challengeIdentity=objectMapper.valueToTree(identityData);
+
+        boolean isMatch = mockProfileRegistryPlugin.isMatch(mockIdentity, challengeIdentity);
+        Assert.assertTrue(isMatch);
+    }
+
+    @Test
+    public void isMatch_withInValidInputChallenge_thenFail() {
+
+        Map<String, Object> identityDataMap = new HashMap<>();
+        identityDataMap.put("email","123@email.com");
+        identityDataMap.put("password","123456");
+        identityDataMap.put("UIN","1234567890");
+        JsonNode mockIdentity = objectMapper.valueToTree(identityDataMap);
+
+        Map<String, Object> challengeIdentityMap = new HashMap<>();
+        challengeIdentityMap.put("email","1234@email.com");
+        challengeIdentityMap.put("password","123456");
+        challengeIdentityMap.put("UIN","1234567890");
+        JsonNode challengeIdentity=objectMapper.valueToTree(challengeIdentityMap);
+
+        boolean isMatch = mockProfileRegistryPlugin.isMatch(mockIdentity, challengeIdentity);
+        Assert.assertFalse(isMatch);
+    }
+}
diff --git a/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java b/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java
index 896976a..b60bbff 100644
--- a/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java
+++ b/mosip-identity-plugin/src/test/java/io/mosip/esignet/plugin/mosipid/service/IdaAuthenticatorImplTest.java
@@ -11,6 +11,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import io.mosip.esignet.api.util.ErrorConstants;
 import io.mosip.esignet.plugin.mosipid.dto.GetAllCertificatesResponse;
 import io.mosip.esignet.plugin.mosipid.dto.IdaKycAuthRequest;
 import io.mosip.esignet.plugin.mosipid.dto.IdaKycAuthResponse;
@@ -144,7 +145,69 @@ public void doKycAuth_withValidDetails_thenPass() throws Exception {
 	}
 
 	@Test
-	public void doKycAuth_withAuthChallengeNull_thenFail() throws Exception {
+	public void doKycAuth_withInValidResponseDetails_thenFail() throws Exception {
+		KycAuthDto kycAuthDto = new KycAuthDto();
+		kycAuthDto.setIndividualId("IND1234");
+		kycAuthDto.setTransactionId("TRAN1234");
+		AuthChallenge authChallenge = new AuthChallenge();
+		authChallenge.setAuthFactorType("OTP");
+		authChallenge.setChallenge("111111");
+		List<AuthChallenge> authChallengeList = new ArrayList<>();
+		authChallengeList.add(authChallenge);
+		kycAuthDto.setChallengeList(authChallengeList);
+
+		Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value");
+
+		IdaResponseWrapper<IdaKycAuthResponse> idaResponseWrapper = new IdaResponseWrapper<>();
+		idaResponseWrapper.setTransactionID("TRAN123");
+		idaResponseWrapper.setVersion("VER1");
+
+		ResponseEntity<IdaResponseWrapper<IdaKycAuthResponse>> responseEntity = new ResponseEntity<IdaResponseWrapper<IdaKycAuthResponse>>(
+				idaResponseWrapper, HttpStatus.OK);
+
+		Mockito.when(restTemplate.exchange(Mockito.<RequestEntity<Void>>any(),
+						Mockito.<ParameterizedTypeReference<IdaResponseWrapper<IdaKycAuthResponse>>>any()))
+				.thenReturn(responseEntity);
+		try{
+			idaAuthenticatorImpl.doKycAuth("relyingId", "clientId", kycAuthDto);
+		}catch (KycAuthException e){
+			Assert.assertEquals(e.getErrorCode(), ErrorConstants.AUTH_FAILED);
+		}
+	}
+
+	@Test
+	public void doKycAuth_withInvalidRequest_thenFail() throws Exception {
+		KycAuthDto kycAuthDto = new KycAuthDto();
+		kycAuthDto.setIndividualId("IND1234");
+		kycAuthDto.setTransactionId("TRAN1234");
+		AuthChallenge authChallenge = new AuthChallenge();
+		authChallenge.setAuthFactorType("OTP");
+		authChallenge.setChallenge("111111");
+		List<AuthChallenge> authChallengeList = new ArrayList<>();
+		authChallengeList.add(authChallenge);
+		kycAuthDto.setChallengeList(authChallengeList);
+
+		Mockito.when(mapper.writeValueAsString(Mockito.any())).thenReturn("value");
+
+		IdaResponseWrapper<IdaKycAuthResponse> idaResponseWrapper = new IdaResponseWrapper<>();
+		idaResponseWrapper.setTransactionID("TRAN123");
+		idaResponseWrapper.setVersion("VER1");
+
+		ResponseEntity<IdaResponseWrapper<IdaKycAuthResponse>> responseEntity = new ResponseEntity<IdaResponseWrapper<IdaKycAuthResponse>>(
+				idaResponseWrapper, HttpStatus.BAD_REQUEST);
+
+		Mockito.when(restTemplate.exchange(Mockito.<RequestEntity<Void>>any(),
+						Mockito.<ParameterizedTypeReference<IdaResponseWrapper<IdaKycAuthResponse>>>any()))
+				.thenReturn(responseEntity);
+		try{
+			idaAuthenticatorImpl.doKycAuth("relyingId", "clientId", kycAuthDto);
+		}catch (KycAuthException e){
+			Assert.assertEquals(e.getErrorCode(), ErrorConstants.AUTH_FAILED);
+		}
+	}
+
+	@Test
+	public void doKycAuth_withAuthChallengeNull_thenFail()  {
 		KycAuthDto kycAuthDto = new KycAuthDto();
 		kycAuthDto.setIndividualId("IND1234");
 		kycAuthDto.setTransactionId("TRAN1234");
@@ -155,7 +218,7 @@ public void doKycAuth_withAuthChallengeNull_thenFail() throws Exception {
 	}
 
 	@Test
-	public void doKycAuth_withInvalidAuthChallenge_thenFail() throws Exception {
+	public void doKycAuth_withInvalidAuthChallenge_thenFail()  {
 		KycAuthDto kycAuthDto = new KycAuthDto();
 		kycAuthDto.setIndividualId("IND1234");
 		kycAuthDto.setTransactionId("TRAN1234");
@@ -318,7 +381,7 @@ public void doKycExchange_withInvalidDetails_thenFail() throws Exception {
 	}
 
 	@Test
-	public void doKycExchange_withInvalidIndividualId_throwsException() throws KycExchangeException, Exception {
+	public void doKycExchange_withInvalidIndividualId_throwsException() throws  Exception {
 		KycExchangeDto kycExchangeDto = new KycExchangeDto();
 		kycExchangeDto.setIndividualId("IND1234");
 		kycExchangeDto.setKycToken("KYCT123");
diff --git a/mosip-identity-plugin/src/test/java/io/mosip/signup/plugin/mosipid/service/IdrepoProfileRegistryPluginImplTest.java b/mosip-identity-plugin/src/test/java/io/mosip/signup/plugin/mosipid/service/IdrepoProfileRegistryPluginImplTest.java
new file mode 100644
index 0000000..57634e0
--- /dev/null
+++ b/mosip-identity-plugin/src/test/java/io/mosip/signup/plugin/mosipid/service/IdrepoProfileRegistryPluginImplTest.java
@@ -0,0 +1,528 @@
+package io.mosip.signup.plugin.mosipid.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import io.mosip.signup.api.dto.ProfileDto;
+import io.mosip.signup.api.dto.ProfileResult;
+import io.mosip.signup.api.exception.InvalidProfileException;
+import io.mosip.signup.api.exception.ProfileException;
+import io.mosip.signup.api.util.ProfileCreateUpdateStatus;
+import io.mosip.signup.plugin.mosipid.dto.*;
+import io.mosip.signup.plugin.mosipid.dto.Error;
+import io.mosip.signup.plugin.mosipid.util.ProfileCacheService;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.*;
+import org.springframework.test.util.ReflectionTestUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class IdrepoProfileRegistryPluginImplTest {
+
+    @InjectMocks
+    private IdrepoProfileRegistryPluginImpl idrepoProfileRegistryPlugin;
+
+    @Mock
+    private ProfileCacheService profileCacheService;
+
+    @Mock
+    private RestTemplate restTemplate;
+
+    private  ObjectMapper objectMapper;
+
+    private static final String schemaSchemaJson="{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"description\":\"Identity schema for sign up\",\"additionalProperties\":false,\"title\":\"signup identity\",\"type\":\"object\",\"definitions\":{\"simpleType\":{\"uniqueItems\":true,\"additionalItems\":false,\"type\":\"array\",\"items\":{\"additionalProperties\":false,\"type\":\"object\",\"required\":[\"language\",\"value\"],\"properties\":{\"language\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"}}}},\"documentType\":{\"additionalProperties\":false,\"type\":\"object\",\"properties\":{\"format\":{\"type\":\"string\"},\"type\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"}}},\"biometricsType\":{\"additionalProperties\":false,\"type\":\"object\",\"properties\":{\"format\":{\"type\":\"string\"},\"version\":{\"type\":\"number\",\"minimum\":0},\"value\":{\"type\":\"string\"}}},\"hashType\":{\"additionalProperties\":false,\"type\":\"object\",\"properties\":{\"hash\":{\"type\":\"string\"},\"salt\":{\"type\":\"string\"}}}},\"properties\":{\"identity\":{\"additionalProperties\":false,\"type\":\"object\",\"required\":[\"IDSchemaVersion\",\"phone\"],\"properties\":{\"UIN\":{\"bioAttributes\":[],\"fieldCategory\":\"none\",\"format\":\"none\",\"type\":\"string\",\"fieldType\":\"default\"},\"IDSchemaVersion\":{\"bioAttributes\":[],\"fieldCategory\":\"none\",\"format\":\"none\",\"type\":\"number\",\"fieldType\":\"default\",\"minimum\":0},\"selectedHandles\":{\"fieldCategory\":\"none\",\"format\":\"none\",\"type\":\"array\",\"items\":{\"type\":\"string\"},\"fieldType\":\"default\"},\"fullName\":{\"bioAttributes\":[],\"validators\":[{\"validator\":\"^(.{3,50})$\",\"arguments\":[],\"type\":\"regex\"}],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"fieldType\":\"default\",\"$ref\":\"#/definitions/simpleType\"},\"phone\":{\"bioAttributes\":[],\"validators\":[{\"validator\":\"^[+]91([0-9]{8,9})$\",\"arguments\":[],\"type\":\"regex\"}],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"type\":\"string\",\"fieldType\":\"default\",\"requiredOn\":\"\",\"handle\":true},\"password\":{\"bioAttributes\":[],\"validators\":[],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"fieldType\":\"default\",\"$ref\":\"#/definitions/hashType\"},\"preferredLang\":{\"bioAttributes\":[],\"validators\":[{\"validator\":\"(^eng$)\",\"arguments\":[],\"type\":\"regex\"}],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"fieldType\":\"default\",\"type\":\"string\"},\"registrationType\":{\"bioAttributes\":[],\"validators\":[{\"validator\":\"^L[1-2]{1}$\",\"arguments\":[],\"type\":\"regex\"}],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"fieldType\":\"default\",\"type\":\"string\"},\"phoneVerified\":{\"bioAttributes\":[],\"validators\":[],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"fieldType\":\"default\",\"type\":\"boolean\"},\"updatedAt\":{\"bioAttributes\":[],\"validators\":[],\"fieldCategory\":\"pvt\",\"format\":\"none\",\"fieldType\":\"default\",\"type\":\"number\"}}}}}";
+
+
+    @Before
+    public void beforeEach(){
+
+        objectMapper=new ObjectMapper();
+        objectMapper.registerModule(new JavaTimeModule());
+        List<String> defaultSelectedHandles = new ArrayList<>();
+        defaultSelectedHandles.add("email");
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "defaultSelectedHandles",defaultSelectedHandles);
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "objectMapper",objectMapper);
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "getUinEndpoint","http://localhost:8080/identity/v1/uin");
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "schemaUrl","http://localhost:8080/identity/v1/schema/");
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "identityEndpoint","http://localhost:8080/identity/v1/identity/");
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "generateHashEndpoint","http://localhost:8080/identity/v1/identity/genereateHash/");
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "getIdentityEndpoint","http://localhost:8080/identity/v1/identity/");
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "mandatoryLanguages",List.of("eng"));
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "getStatusEndpoint","http://localhost:8080/identity/v1/identity/");
+    }
+
+    @Test
+    public void validate_withValidProfile_thenPass()  {
+
+        String individualId = "ind-456";
+
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("phone","+91841987567");
+
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+        ResponseWrapper<SchemaResponse> responseWrapper = new ResponseWrapper<>();
+        SchemaResponse schemaResponse = new SchemaResponse();
+        schemaResponse.setIdVersion(0.0);
+        schemaResponse.setSchemaJson(schemaSchemaJson);
+        responseWrapper.setResponse(schemaResponse);
+        ResponseEntity<ResponseWrapper<SchemaResponse>> responseEntity2=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/schema/"+0.0,  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<SchemaResponse>>() {}
+        )).thenReturn(responseEntity2);
+        idrepoProfileRegistryPlugin.validate("CREATE", profileDto);
+
+    }
+
+    @Test
+    public void validate_withValidProfileContainingArrayDataType_thenPass()  {
+        String individualId = "ind-456";
+
+        Map<String, Object> identityData = new HashMap<>();
+        SimpleType [] simpleTypesArray=new SimpleType[1];
+        SimpleType simpleType=new SimpleType();
+        simpleType.setLanguage("eng");
+        simpleType.setValue("John Doe");
+        simpleTypesArray[0]=simpleType;
+        identityData.put("phone","+91841987567");
+        identityData.put("fullName",simpleTypesArray);
+
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+        ResponseWrapper<SchemaResponse> responseWrapper = new ResponseWrapper<>();
+        SchemaResponse schemaResponse = new SchemaResponse();
+        schemaResponse.setIdVersion(0.0);
+        schemaResponse.setSchemaJson(schemaSchemaJson);
+        responseWrapper.setResponse(schemaResponse);
+        ResponseEntity<ResponseWrapper<SchemaResponse>> responseEntity2=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/schema/"+0.0,  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<SchemaResponse>>() {}
+        )).thenReturn(responseEntity2);
+        idrepoProfileRegistryPlugin.validate("CREATE", profileDto);
+    }
+
+    @Test
+    public void validate_withInvalidProfile_thenFail()  {
+
+        String individualId = "ind-456";
+
+        Map<String, Object> identityData = new HashMap<>();
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+        ResponseWrapper<SchemaResponse> responseWrapper = new ResponseWrapper<>();
+        SchemaResponse schemaResponse = new SchemaResponse();
+        schemaResponse.setIdVersion(0.0);
+        schemaResponse.setSchemaJson(schemaSchemaJson);
+        responseWrapper.setResponse(schemaResponse);
+        ResponseEntity<ResponseWrapper<SchemaResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/schema/"+0.0,  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<SchemaResponse>>() {}
+        )).thenReturn(responseEntity);
+        try{
+            idrepoProfileRegistryPlugin.validate("CREATE", profileDto);
+        }catch (InvalidProfileException e){
+            Assert.assertEquals(e.getErrorCode(),"invalid_phone");
+        }
+    }
+
+    @Test
+    public void createProfile_withValidProfileDetails_thenPass()  {
+        String requestId = "req-123";
+        String individualId = "ind-456";
+
+        JsonNode mockIdentity = createIdentity();
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+        ResponseWrapper<UINResponse> responseWrapper = new ResponseWrapper<>();
+        UINResponse uinResponse = new UINResponse();
+        uinResponse.setUIN("1234567890");
+        responseWrapper.setResponse(uinResponse);
+        ResponseEntity<ResponseWrapper<UINResponse>> responseEntity = new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(profileCacheService.setHandleRequestIds(Mockito.anyString(),Mockito.anyList())).thenReturn(null);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/uin",
+                HttpMethod.GET,
+                null,
+                new ParameterizedTypeReference<ResponseWrapper<UINResponse>>() {}
+        )).thenReturn(responseEntity);
+
+        ResponseWrapper<SchemaResponse> responseWrapper2 = new ResponseWrapper<>();
+        SchemaResponse schemaResponse = new SchemaResponse();
+        schemaResponse.setIdVersion(0.0);
+        schemaResponse.setSchemaJson(schemaSchemaJson);
+        responseWrapper2.setResponse(schemaResponse);
+        ResponseEntity<ResponseWrapper<SchemaResponse>> responseEntity2=new ResponseEntity<>(responseWrapper2, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/schema/"+0.0,  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<SchemaResponse>>() {}
+        )).thenReturn(responseEntity2);
+
+        ResponseWrapper<IdentityResponse> responseWrapper3 = new ResponseWrapper<>();
+        IdentityResponse identityResponse = new IdentityResponse();
+        identityResponse.setStatus("SUCCESS");
+        identityResponse.setDocuments(List.of("Document1"));
+        responseWrapper3.setResponse(identityResponse);
+        ResponseEntity<ResponseWrapper<IdentityResponse>> responseEntity3=new ResponseEntity<>(responseWrapper3, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(HttpEntity.class),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<IdentityResponse>>() {
+                }))).thenReturn(responseEntity3);
+
+        ProfileResult profileResult = idrepoProfileRegistryPlugin.createProfile(requestId, profileDto);
+        Assert.assertNotNull(profileResult);
+        Assert.assertEquals(profileResult.getStatus(),"SUCCESS");
+    }
+
+    @Test
+    public void createProfile_withInValidProfileDetails_thenFail()  {
+        String requestId = "req-123";
+        String individualId = "ind-456";
+
+        JsonNode mockIdentity = createIdentity();
+        ProfileDto profileDto = new ProfileDto();
+        profileDto.setIndividualId(individualId);
+        profileDto.setIdentity(mockIdentity);
+
+        ResponseWrapper<UINResponse> responseWrapper = new ResponseWrapper<>();
+        UINResponse uinResponse = new UINResponse();
+        uinResponse.setUIN("1234567890");
+        responseWrapper.setResponse(uinResponse);
+        ResponseEntity<ResponseWrapper<UINResponse>> responseEntity = new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(profileCacheService.setHandleRequestIds(Mockito.anyString(),Mockito.anyList())).thenReturn(null);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/uin",
+                HttpMethod.GET,
+                null,
+                new ParameterizedTypeReference<ResponseWrapper<UINResponse>>() {}
+        )).thenReturn(responseEntity);
+
+        ResponseWrapper<SchemaResponse> responseWrapper2 = new ResponseWrapper<>();
+        SchemaResponse schemaResponse = new SchemaResponse();
+        schemaResponse.setIdVersion(0.0);
+        schemaResponse.setSchemaJson(schemaSchemaJson);
+        responseWrapper2.setResponse(schemaResponse);
+        ResponseEntity<ResponseWrapper<SchemaResponse>> responseEntity2=new ResponseEntity<>(responseWrapper2, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/schema/"+0.0,  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<SchemaResponse>>() {}
+        )).thenReturn(responseEntity2);
+
+        ResponseWrapper<IdentityResponse> responseWrapper3 = new ResponseWrapper<>();
+        IdentityResponse identityResponse = new IdentityResponse();
+        identityResponse.setStatus("SUCCESS");
+        identityResponse.setDocuments(List.of("Document1"));
+        responseWrapper3.setResponse(identityResponse);
+        ResponseEntity<ResponseWrapper<IdentityResponse>> responseEntity3=new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
+
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(HttpEntity.class),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<IdentityResponse>>() {
+                }))).thenReturn(responseEntity3);
+
+        try{
+            idrepoProfileRegistryPlugin.createProfile(requestId, profileDto);
+            Assert.fail();
+        }catch (ProfileException e){
+            Assert.assertEquals(e.getErrorCode(),"request_failed");
+        }
+    }
+
+    @Test
+    public void updateProfile_withValidProfileDetails_thenPass()  {
+
+            String requestId = "req-123";
+            String individualId = "ind-456";
+            Map<String, Object> identityData = new HashMap<>();
+            identityData.put("email","123@email.com");
+            identityData.put("password","123456");
+
+            JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+            ProfileDto profileDto = new ProfileDto();
+            profileDto.setIndividualId(individualId);
+            profileDto.setIdentity(mockIdentity);
+
+            Mockito.when(profileCacheService.setHandleRequestIds(Mockito.anyString(),Mockito.anyList())).thenReturn(null);
+
+            ResponseWrapper<SchemaResponse> responseWrapper= new ResponseWrapper<>();
+            SchemaResponse schemaResponse = new SchemaResponse();
+            schemaResponse.setIdVersion(0.0);
+            schemaResponse.setSchemaJson(schemaSchemaJson);
+            responseWrapper.setResponse(schemaResponse);
+            ResponseEntity<ResponseWrapper<SchemaResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+            Mockito.when(restTemplate.exchange(
+                    "http://localhost:8080/identity/v1/schema/"+0.0,  // Matches any URL string
+                    HttpMethod.GET,  // Matches any HTTP method
+                    null,  // Matches any HttpEntity
+                    new ParameterizedTypeReference<ResponseWrapper<SchemaResponse>>() {}
+            )).thenReturn(responseEntity);
+
+        //Mocking Password Hash
+        ResponseWrapper<Password.PasswordHash> responseWrapper4 = new ResponseWrapper<>();
+        Password.PasswordHash passwordHash = new Password.PasswordHash();
+        passwordHash.setHashValue("123456");
+        passwordHash.setSalt("123456");
+        responseWrapper4.setResponse(passwordHash);
+        ResponseEntity<ResponseWrapper<Password.PasswordHash>> responseEntity2=new ResponseEntity<>(responseWrapper4, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(HttpEntity.class),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<Password.PasswordHash>>() {
+                }))).thenReturn(responseEntity2);
+
+            ResponseWrapper<IdentityResponse> responseWrapper3 = new ResponseWrapper<>();
+            IdentityResponse identityResponse = new IdentityResponse();
+            identityResponse.setStatus("SUCCESS");
+            identityResponse.setDocuments(List.of("Document1"));
+            responseWrapper3.setResponse(identityResponse);
+            ResponseEntity<ResponseWrapper<IdentityResponse>> responseEntity3=new ResponseEntity<>(responseWrapper3, HttpStatus.OK);
+
+            Mockito.when(restTemplate.exchange(
+                    Mockito.anyString(),
+                    Mockito.any(HttpMethod.class),
+                    Mockito.any(HttpEntity.class),
+                    Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<IdentityResponse>>() {
+                    }))).thenReturn(responseEntity3);
+
+            ProfileResult profileResult = idrepoProfileRegistryPlugin.updateProfile(requestId, profileDto);
+            Assert.assertNotNull(profileResult);
+            Assert.assertEquals(profileResult.getStatus(),"SUCCESS");
+    }
+
+    @Test
+    public void getProfile_withValidDetails_thenPass()  {
+        String individualId = "1234567890";
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+        identityData.put("UIN","1234567890");
+
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+
+        ResponseWrapper<IdentityResponse> responseWrapper = new ResponseWrapper<>();
+        IdentityResponse identityResponse = new IdentityResponse();
+        identityResponse.setStatus("SUCCESS");
+        identityResponse.setDocuments(List.of("Document1"));
+        identityResponse.setIdentity(mockIdentity);
+
+        responseWrapper.setResponse(identityResponse);
+        ResponseEntity<ResponseWrapper<IdentityResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(HttpEntity.class),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<IdentityResponse>>() {
+                }))).thenReturn(responseEntity);
+        ProfileDto profileDto= idrepoProfileRegistryPlugin.getProfile(individualId);
+        Assert.assertNotNull(profileDto);
+        Assert.assertEquals(profileDto.getIndividualId(),"1234567890");
+    }
+
+    @Test
+    public void getProfile_withErrorCodeAsIdentityFail_thenFail()  {
+        String individualId = "1234567890";
+        JsonNode mockIdentity = createIdentity();
+
+        ResponseWrapper<IdentityResponse> responseWrapper = new ResponseWrapper<>();
+        IdentityResponse identityResponse = new IdentityResponse();
+        identityResponse.setStatus("SUCCESS");
+        identityResponse.setDocuments(List.of("Document1"));
+        identityResponse.setIdentity(mockIdentity);
+
+        responseWrapper.setResponse(null);
+        Error error = new Error();
+        error.setErrorCode("IDR-IDC-007");
+        responseWrapper.setErrors(List.of(error));
+        ResponseEntity<ResponseWrapper<IdentityResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                Mockito.anyString(),
+                Mockito.any(HttpMethod.class),
+                Mockito.any(HttpEntity.class),
+                Mockito.eq(new ParameterizedTypeReference<ResponseWrapper<IdentityResponse>>() {
+                }))).thenReturn(responseEntity);
+        ProfileDto profileDto= idrepoProfileRegistryPlugin.getProfile(individualId);
+        Assert.assertNotNull(profileDto);
+        Assert.assertEquals(profileDto.getIndividualId(),"1234567890");
+    }
+
+    @Test
+    public void getProfileCreateUpdate_withStatusAsProcessing_thenPass(){
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "getStatusEndpoint","http://localhost:8080/identity/v1/identity/");
+
+        Mockito.when(profileCacheService.getHandleRequestIds(ArgumentMatchers.anyString())).thenReturn(null);
+
+        ResponseWrapper<IdentityStatusResponse> responseWrapper = new ResponseWrapper<>();
+        IdentityStatusResponse identityStatusResponse = new IdentityStatusResponse();
+        identityStatusResponse.setStatusCode("PROCESSING");
+
+        responseWrapper.setResponse(identityStatusResponse);
+        ResponseEntity<ResponseWrapper<IdentityStatusResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/identity/requestId",  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<IdentityStatusResponse>>() {}
+        )).thenReturn(responseEntity);
+        ProfileCreateUpdateStatus profileCreateUpdateStatus = idrepoProfileRegistryPlugin.getProfileCreateUpdateStatus("requestId");
+        Assert.assertNotNull(profileCreateUpdateStatus);
+        Assert.assertEquals(profileCreateUpdateStatus,ProfileCreateUpdateStatus.PENDING);
+    }
+
+    @Test
+    public void getProfileCreateUpdateStatus_withStatusAsFailed_thenPass(){
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "getStatusEndpoint","http://localhost:8080/identity/v1/identity/");
+
+        Mockito.when(profileCacheService.getHandleRequestIds(ArgumentMatchers.anyString())).thenReturn(null);
+
+        ResponseWrapper<IdentityStatusResponse> responseWrapper = new ResponseWrapper<>();
+        IdentityStatusResponse identityStatusResponse = new IdentityStatusResponse();
+        identityStatusResponse.setStatusCode("FAILED");
+
+
+        responseWrapper.setResponse(identityStatusResponse);
+        ResponseEntity<ResponseWrapper<IdentityStatusResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/identity/requestId",  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<IdentityStatusResponse>>() {}
+        )).thenReturn(responseEntity);
+        ProfileCreateUpdateStatus profileCreateUpdateStatus = idrepoProfileRegistryPlugin.getProfileCreateUpdateStatus("requestId");
+        Assert.assertNotNull(profileCreateUpdateStatus);
+        Assert.assertEquals(profileCreateUpdateStatus,ProfileCreateUpdateStatus.FAILED);
+    }
+
+    @Test
+    public void getProfileCreateUpdateStatus_withStatusAsStored_thenPass(){
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "getStatusEndpoint","http://localhost:8080/identity/v1/identity/");
+
+        Mockito.when(profileCacheService.getHandleRequestIds(ArgumentMatchers.anyString())).thenReturn(List.of("requestId"));
+
+        ResponseWrapper<IdentityStatusResponse> responseWrapper = new ResponseWrapper<>();
+        IdentityStatusResponse identityStatusResponse = new IdentityStatusResponse();
+        identityStatusResponse.setStatusCode("STORED");
+
+        responseWrapper.setResponse(identityStatusResponse);
+        ResponseEntity<ResponseWrapper<IdentityStatusResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/identity/requestId",  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<IdentityStatusResponse>>() {}
+        )).thenReturn(responseEntity);
+        ProfileCreateUpdateStatus profileCreateUpdateStatus = idrepoProfileRegistryPlugin.getProfileCreateUpdateStatus("requestId");
+        Assert.assertNotNull(profileCreateUpdateStatus);
+        Assert.assertEquals(profileCreateUpdateStatus,ProfileCreateUpdateStatus.COMPLETED);
+    }
+
+    @Test
+    public void getProfileCreateUpdateStatus_withInvalidStatusCode_thenFail(){
+        Mockito.when(profileCacheService.getHandleRequestIds(ArgumentMatchers.anyString())).thenReturn(List.of("requestId"));
+
+        ResponseWrapper<IdentityStatusResponse> responseWrapper = new ResponseWrapper<>();
+        IdentityStatusResponse identityStatusResponse = new IdentityStatusResponse();
+        identityStatusResponse.setStatusCode("STORED");
+        responseWrapper.setResponse(new IdentityStatusResponse());
+        ResponseEntity<ResponseWrapper<IdentityStatusResponse>> responseEntity=new ResponseEntity<>(responseWrapper, HttpStatus.OK);
+        Mockito.when(restTemplate.exchange(
+                "http://localhost:8080/identity/v1/identity/requestId",  // Matches any URL string
+                HttpMethod.GET,  // Matches any HTTP method
+                null,  // Matches any HttpEntity
+                new ParameterizedTypeReference<ResponseWrapper<IdentityStatusResponse>>() {}
+        )).thenReturn(responseEntity);
+        try{
+            idrepoProfileRegistryPlugin.getProfileCreateUpdateStatus("requestId");
+            Assert.fail();
+        }catch (ProfileException e){
+            Assert.assertEquals(e.getErrorCode(),"request_failed");
+        }
+    }
+
+    @Test
+    public void isMatch_withValidDetails_thenPass(){
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "objectMapper",objectMapper);
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("password","123456");
+        identityData.put("UIN","1234567890");
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+        boolean matched=idrepoProfileRegistryPlugin.isMatch(mockIdentity, mockIdentity);
+        Assert.assertTrue(matched);
+    }
+
+    @Test
+    public void isMatch_withInValidDetails_thenFail(){
+
+        ReflectionTestUtils.setField(idrepoProfileRegistryPlugin, "objectMapper",objectMapper);
+        Map<String, Object> identityData = new LinkedHashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("UIN","1234567890");
+        identityData.put("channel",List.of("email"));
+        JsonNode mockIdentity = objectMapper.valueToTree(identityData);
+
+
+        Map<String, Object> inputChallengeMap = new LinkedHashMap<>();
+        inputChallengeMap.put("channel",List.of("email"));
+        inputChallengeMap.put("email","123@email.com");
+        inputChallengeMap.put("password","1234456");
+        inputChallengeMap.put("UIN","1234567890");
+        JsonNode inputChallenge = objectMapper.valueToTree(inputChallengeMap);
+
+        boolean matched=idrepoProfileRegistryPlugin.isMatch(mockIdentity, inputChallenge);
+        Assert.assertFalse(matched);
+    }
+
+    private JsonNode createIdentity() {
+        Map<String, Object> identityData = new HashMap<>();
+        identityData.put("email","123@email.com");
+        identityData.put("phone","+91841987567");
+        return objectMapper.valueToTree(identityData);
+    }
+}

From 457c057526d2bdd898ced1aba33c4b128810ab5c Mon Sep 17 00:00:00 2001
From: ase-101 <sunkadaeanusha@gmail.com>
Date: Fri, 4 Oct 2024 12:37:58 +0530
Subject: [PATCH 2/2] Updated readme and updated version

Signed-off-by: ase-101 <sunkadaeanusha@gmail.com>
---
 README.md                       |  3 +++
 mock-plugin/README.md           |  5 +++--
 mock-plugin/pom.xml             | 10 +++-------
 mosip-identity-plugin/README.md | 19 +++++++++++++++++++
 mosip-identity-plugin/pom.xml   |  5 +++--
 5 files changed, 31 insertions(+), 11 deletions(-)
 create mode 100644 mosip-identity-plugin/README.md

diff --git a/README.md b/README.md
index 7e19628..15718bf 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,5 @@
 # esignet-plugins
 Repository hosting source code for esignet and esignet-signup java runtime dependencies plugins.
+
+## License
+This project is licensed under the terms of [Mozilla Public License 2.0](LICENSE).
diff --git a/mock-plugin/README.md b/mock-plugin/README.md
index 39455f8..865e319 100644
--- a/mock-plugin/README.md
+++ b/mock-plugin/README.md
@@ -2,10 +2,11 @@
 
 ## About
 
-Implementation for all the interfaces defined in esignet-integration-api.
+Implementation for all the interfaces defined in esignet-integration-api. Mock plugin is built to use eSignet with [Mock IDA system](https://github.com/mosip/esignet-mock-services/tree/master/mock-identity-system)
 
 This library should be added as a runtime dependency to [esignet-service](https://github.com/mosip/esignet) for development purpose only.
-Note: This is not production use implementation.
+
+**Note**: This is not production use implementation.
 
 ## Configurations
 
diff --git a/mock-plugin/pom.xml b/mock-plugin/pom.xml
index c99e1ca..c294668 100644
--- a/mock-plugin/pom.xml
+++ b/mock-plugin/pom.xml
@@ -87,6 +87,7 @@
 
 		<kernel-keymanager-service.version>1.2.1.0</kernel-keymanager-service.version>
 		<esignet.version>1.5.0-SNAPSHOT</esignet.version>
+		<esignet-signup.version>1.1.0-SNAPSHOT</esignet-signup.version>
 
 		<sonar.exclusions>**/dto/**,**/entity/**,**/exception/**,**/spi/**,**/advice/**,**/config/**</sonar.exclusions>
 		<sonar.cpd.exclusions>**/dto/**,**/entity/**,**/config/**</sonar.cpd.exclusions>
@@ -127,12 +128,6 @@
 			<scope>provided</scope>
 		</dependency>
 
-		<dependency>
-			<groupId>io.mosip.signup</groupId>
-			<artifactId>signup-integration-api</artifactId>
-			<version>1.1.0-SNAPSHOT</version>
-		</dependency>
-
 		<dependency>
 			<groupId>io.mosip.kernel</groupId>
 			<artifactId>kernel-keymanager-service</artifactId>
@@ -156,10 +151,11 @@
 			<version>1.7.30</version>
 			<scope>provided</scope>
 		</dependency>
+
 		<dependency>
 			<groupId>io.mosip.signup</groupId>
 			<artifactId>signup-integration-api</artifactId>
-			<version>1.1.0-SNAPSHOT</version>
+			<version>${esignet-signup.version}</version>
 			<scope>provided</scope>
 		</dependency>
 	</dependencies>
diff --git a/mosip-identity-plugin/README.md b/mosip-identity-plugin/README.md
new file mode 100644
index 0000000..42bc8a9
--- /dev/null
+++ b/mosip-identity-plugin/README.md
@@ -0,0 +1,19 @@
+# MOSIP Identity plugin
+
+## About
+
+Implementation for all the interfaces defined in esignet-integration-api. This plugin is built to use eSignet with [MOSIP IDA system](https://github.com/mosip/id-authentication)
+
+This library should be added as a runtime dependency to [esignet-service](https://github.com/mosip/esignet).
+
+## Prerequisites
+
+1. Onboard esignet-service as a MISP(MOSIP Infra Service Provider) partner in MOSIP's Partner management portal. 
+2. Update the MISP license key in `mosip.esignet.misp.key` property.
+
+## Configurations
+
+Refer [application.properties](src/main/resources/application.properties) for all the configurations required to use this plugin implementation.
+
+## License
+This project is licensed under the terms of [Mozilla Public License 2.0](LICENSE).
diff --git a/mosip-identity-plugin/pom.xml b/mosip-identity-plugin/pom.xml
index 36e86e4..5bebc21 100644
--- a/mosip-identity-plugin/pom.xml
+++ b/mosip-identity-plugin/pom.xml
@@ -85,8 +85,9 @@
 		<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
 		<spring.boot.version>2.3.6.RELEASE</spring.boot.version>
 
-		<kernel-keymanager-service.version>1.2.0.1</kernel-keymanager-service.version>
+		<kernel-keymanager-service.version>1.2.1.0</kernel-keymanager-service.version>
 		<esignet.version>1.5.0-SNAPSHOT</esignet.version>
+		<esignet-signup.version>1.1.0-SNAPSHOT</esignet-signup.version>
 
 		<sonar.exclusions>**/dto/**,**/entity/**,**/exception/**,**/spi/**,**/advice/**,**/config/**</sonar.exclusions>
 		<sonar.cpd.exclusions>**/dto/**,**/entity/**,**/config/**</sonar.cpd.exclusions>
@@ -142,7 +143,7 @@
 		<dependency>
 			<groupId>io.mosip.signup</groupId>
 			<artifactId>signup-integration-api</artifactId>
-			<version>1.1.0-SNAPSHOT</version>
+			<version>${esignet-signup.version}</version>
 			<scope>provided</scope>
 		</dependency>