Skip to content

Commit

Permalink
MOSIP-35404
Browse files Browse the repository at this point in the history
Signed-off-by: Nandhukumar <[email protected]>
  • Loading branch information
nandhu-kumar committed Nov 29, 2024
1 parent 01efa80 commit 53bba96
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 12 deletions.
6 changes: 3 additions & 3 deletions api-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<name>apitest-idrepo</name>
<description>Parent project of MOSIP Id Repository apitests</description>
<url>https://github.com/mosip/id-repository</url>
<version>1.2.1-SNAPSHOT</version>
<version>1.2.1-cleanup-SNAPSHOT</version>

<licenses>
<license>
Expand Down Expand Up @@ -49,14 +49,14 @@
<maven.source.plugin.version>2.2.1</maven.source.plugin.version>

<git.commit.id.plugin.version>3.0.1</git.commit.id.plugin.version>
<fileName>apitest-idrepo-1.2.1-SNAPSHOT-jar-with-dependencies</fileName>
<fileName>apitest-idrepo-1.2.1-cleanup-SNAPSHOT-jar-with-dependencies</fileName>
</properties>

<dependencies>
<dependency>
<groupId>io.mosip.testrig.apirig.apitest.commons</groupId>
<artifactId>apitest-commons</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>1.2.2-cleanup-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
new KernelAuthentication().getTokenByRole(testCaseDTO.getRole())).asString(),
"response.uin");

testCaseName = isTestCaseValidForExecution(testCaseDTO);

DateFormat dateFormatter = new SimpleDateFormat("yyyyMMddHHmmss");
Calendar cal = Calendar.getInstance();
String timestampValue = dateFormatter.format(cal.getTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = IdRepoUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = IdRepoUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = IdRepoUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = IdRepoUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
String[] templateFields = testCaseDTO.getTemplateFields();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = IdRepoUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
auditLogCheck = testCaseDTO.isAuditLogCheck();
String[] templateFields = testCaseDTO.getTemplateFields();
if (HealthChecker.signalTerminateExecution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public void test(TestCaseDTO testCaseDTO)
}
}

testCaseName = isTestCaseValidForExecution(testCaseDTO);
String[] templateFields = testCaseDTO.getTemplateFields();
String inputJson = "";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.mosip.testrig.apirig.idrepo.utils;

import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.testng.SkipException;

import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.SkipTestCaseHandler;

Expand All @@ -14,10 +17,55 @@ public class IdRepoUtil extends AdminTestUtil {

public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {
String testCaseName = testCaseDTO.getTestCaseName();


int indexof = testCaseName.indexOf("_");
String modifiedTestCaseName = testCaseName.substring(indexof + 1);

addTestCaseDetailsToMap(modifiedTestCaseName, testCaseDTO.getUniqueIdentifier());

if (SkipTestCaseHandler.isTestCaseInSkippedList(testCaseName)) {
throw new SkipException(GlobalConstants.KNOWN_ISSUES);
}

JSONArray dobArray = new JSONArray(getValueFromAuthActuator("json-property", "dob"));
String dob = dobArray.getString(0);
JSONArray emailArray = new JSONArray(getValueFromAuthActuator("json-property", "emailId"));
String email = emailArray.getString(0);
JSONArray phoneArray = new JSONArray(getValueFromAuthActuator("json-property", "phone_number"));

if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("DOB")
&& (!isElementPresent(new JSONArray(schemaRequiredField), dob))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("_handle")
&& foundHandlesInIdSchema == false) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

if (testCaseName.startsWith("IdRepository_")
&& (testCaseName.contains("_withInvalidEmail") || testCaseName.contains("_with_invalid_Email")
|| testCaseName.contains("_with_Missing_Email") || testCaseName.contains("_with_Empty_Email")
|| testCaseName.contains("_with_SpaceVal_Email"))
&& (globalRequiredFields != null && !globalRequiredFields.toList().contains(emailArray))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("_with_Missing_phone")
&& (globalRequiredFields != null && !globalRequiredFields.toList().contains(phoneArray))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Email")
&& (!isElementPresent(new JSONArray(schemaRequiredField), email))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Invalid_BioVal")
&& (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ADMIN))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

return testCaseName;
}

Expand Down

0 comments on commit 53bba96

Please sign in to comment.