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 Dec 2, 2024
1 parent 5dba2c4 commit a3d2f00
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 20 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-auth</name>
<description>Parent project of MOSIP Id Authentication apitests</description>
<url>https://github.com/mosip/id-authentication</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-auth-1.2.1-SNAPSHOT-jar-with-dependencies</fileName>
<fileName>apitest-auth-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 @@ -96,6 +96,7 @@ public static void main(String[] arg) {
KeycloakUserManager.removeUser();
KeycloakUserManager.createUsers();
KeycloakUserManager.closeKeycloakInstance();
AdminTestUtil.getRequiredField();

List<String> localLanguageList = new ArrayList<>(BaseTestCase.getLanguageList());
AdminTestUtil.getLocationData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,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 @@ -100,7 +100,6 @@ public void test(TestCaseDTO testCaseDTO)
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
IdAuthenticationUtil.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 = IdAuthenticationUtil.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 @@ -119,8 +119,6 @@ public void test(TestCaseDTO testCaseDTO)
// dev - t f
}
}
testCaseName = isTestCaseValidForExecution(testCaseDTO);

String inputJson = testCaseDTO.getInput().toString();
JSONObject req = new JSONObject(testCaseDTO.getInput());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
}
}

testCaseName = isTestCaseValidForExecution(testCaseDTO);
auditLogCheck = testCaseDTO.isAuditLogCheck();
JSONObject req = new JSONObject(testCaseDTO.getInput());
String otpRequest = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public Object[] getTestCaseList(ITestContext context) {
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = isTestCaseValidForExecution(testCaseDTO);
testCaseName = IdAuthenticationUtil.isTestCaseValidForExecution(testCaseDTO);
String[] templateFields = testCaseDTO.getTemplateFields();
if (HealthChecker.signalTerminateExecution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = IdAuthenticationUtil.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 @@ -109,9 +109,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
Expand Up @@ -163,7 +163,7 @@ public void updateIdentity(TestCaseDTO testCaseDTO) throws AuthenticationTestExc
inputJson = inputJson.replace("$RID$", genRid);

if ((testCaseName.startsWith("IdRepository_") || testCaseName.startsWith("Auth_"))
&& inputJson.contains("dateOfBirth") && (!isElementPresent(new JSONArray(schemaRequiredField), dob))) {
&& inputJson.contains("dateOfBirth") && (!isElementPresent(globalRequiredFields, dob))) {
JSONObject reqJson = new JSONObject(inputJson);
reqJson.getJSONObject("request").getJSONObject("identity").remove("dateOfBirth");
inputJson = reqJson.toString();
Expand All @@ -173,7 +173,7 @@ public void updateIdentity(TestCaseDTO testCaseDTO) throws AuthenticationTestExc

if ((testCaseName.startsWith("IdRepository_") || testCaseName.startsWith("Auth_"))
&& inputJson.contains("email")
&& (!isElementPresent(new JSONArray(schemaRequiredField), emailResult))) {
&& (!isElementPresent(globalRequiredFields, emailResult))) {
JSONObject reqJson = new JSONObject(inputJson);
reqJson.getJSONObject("request").getJSONObject("identity").remove(emailResult);
if (reqJson.getJSONObject("request").getJSONObject("identity").has(result)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package io.mosip.testrig.apirig.auth.utils;

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

import io.mosip.testrig.apirig.auth.testrunner.MosipTestRunner;
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 @@ -16,13 +19,48 @@ public class IdAuthenticationUtil 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 (MosipTestRunner.skipAll == true) {
throw new SkipException(GlobalConstants.PRE_REQUISITE_FAILED_MESSAGE);
}

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

JSONArray individualBiometricsArray = new JSONArray(
getValueFromAuthActuator("json-property", "individualBiometrics"));

String individualBiometrics = individualBiometricsArray.getString(0);

if (testCaseName.startsWith("auth_")
&& (testCaseName.contains("_BioAuth_") || testCaseName.contains("_EkycBio_")
|| testCaseName.contains("_MultiFactorAuth_") || testCaseName.contains("_DemoAuth")
|| testCaseName.contains("_EkycDemo_"))
&& (!isElementPresent(globalRequiredFields, individualBiometrics))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
} else if (testCaseName.startsWith("auth_")
&& ((testCaseName.contains("_DeactivateUINs_")) || (testCaseName.contains("PublishDraft_")))
&& (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid"))) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
} else if (testCaseName.startsWith("auth_")
&& (testCaseName.contains("_AuthLock_") || testCaseName.contains("_AuthUnLock_"))
&& (ConfigManager.isInServiceNotDeployedList(GlobalConstants.RESIDENT))) {
throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE);
} else if (testCaseName.startsWith("auth_")
&& (testCaseName.contains("_BlockHotlistAPI_") || testCaseName.contains("_HotlistAPI_")
|| testCaseName.contains("_BlockPartnerId_")
|| testCaseName.contains("_OTP_Auth_With_blocked_misp_Pos")
|| testCaseName.contains("_OTP_Auth_With_blocked_partnerid_Pos"))
&& (ConfigManager.isInServiceNotDeployedList(GlobalConstants.HOTLIST))) {
throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE);
}

return testCaseName;
}

Expand Down

0 comments on commit a3d2f00

Please sign in to comment.