Skip to content

Commit

Permalink
Merge pull request #1409 from mohanachandran-s/release-1.3.x
Browse files Browse the repository at this point in the history
MOSIP-39220 - Synced release branch with develop branch
  • Loading branch information
ckm007 authored Jan 28, 2025
2 parents 0d0a520 + 27658d5 commit ce287f9
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 87 deletions.
8 changes: 4 additions & 4 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.3.0-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.3.0-SNAPSHOT-jar-with-dependencies</fileName>
</properties>

<dependencies>
<dependency>
<groupId>io.mosip.testrig.apirig.apitest.commons</groupId>
<groupId>io.mosip.testrig.apitest.commons</groupId>
<artifactId>apitest-commons</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>1.3.1-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 Expand Up @@ -190,34 +191,13 @@ public static void startTestRunner() {
homeDir = new File(dir.getParent() + "/mosip/testNgXmlFiles");
LOGGER.info("ELSE :" + homeDir);
}
// List and sort the files
File[] files = homeDir.listFiles();
if (files != null) {
Arrays.sort(files, (f1, f2) -> {
// Customize the comparison based on file names
if (f1.getName().toLowerCase().contains("prerequisite")) {
return -1; // f1 should come before f2
} else if (f2.getName().toLowerCase().contains("prerequisite")) {
return 1; // f2 comes before f1
}
return f1.getName().compareTo(f2.getName()); // default alphabetical order
});

for (File file : files) {
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<>();

if (file.getName().toLowerCase().contains("auth")) {
if (file.getName().toLowerCase().contains("prerequisite")) {
BaseTestCase.setReportName("auth-prerequisite");
} else {
// Check if prerequisite suite failed or skipped
if (EmailableReport.getFailedCount() > 0 || EmailableReport.getSkippedCount() > 0) {
// skipAll = true;
}

BaseTestCase.setReportName("auth");
}
if (file.getName().toLowerCase().contains("mastertestsuite")) {
BaseTestCase.setReportName(GlobalConstants.AUTH);
suitefiles.add(file.getAbsolutePath());
runner.setTestSuites(suitefiles);
System.getProperties().setProperty("testng.outpur.dir", "testng-report");
Expand All @@ -228,7 +208,6 @@ public static void startTestRunner() {
} else {
LOGGER.error("No files found in directory: " + homeDir);
}

}

public static String getGlobalResourcePath() {
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 @@ -23,6 +23,7 @@
import io.mosip.testrig.apirig.auth.utils.IdAuthenticationUtil;
import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
Expand Down Expand Up @@ -113,7 +114,16 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
identityRequestEncUrl = identityReqJson.getString("identityRequestEncUrl");
identityReqJson.remove("identityRequestEncUrl");
identityRequest = getJsonFromTemplate(identityReqJson.toString(), identityRequestTemplate);

logger.info(identityRequest);
if (identityRequest.contains("baseurl")) {
String domainUrl = BaseTestCase.ApplnURI;
identityRequest = identityRequest.replace("baseurl", domainUrl);
}
if (identityRequest.contains("$DOMAINURI$")) {
String domainUrl = BaseTestCase.ApplnURI;
identityRequest = identityRequest.replace("$DOMAINURI$", domainUrl);
}
logger.info(identityRequest);
String encryptedIdentityReq = null;
try {
encryptedIdentityReq = bioDataUtil.constractBioIdentityRequest(identityRequest,
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 @@ -24,6 +24,7 @@
import io.mosip.testrig.apirig.auth.utils.IdAuthenticationUtil;
import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.JsonPrecondtion;
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
Expand Down Expand Up @@ -171,6 +172,16 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
otpChannel = inputJsonKeyWordHandeler(otpChannel, testCaseName);
String identyEnryptRequest = updateTimestampOtp(identityRequest, otpChannel, testCaseName);
//String identyEnryptRequest = updateTimestampOtp(identityRequest);
logger.info(identyEnryptRequest);
if (identyEnryptRequest.contains("baseurl")) {
String domainUrl = BaseTestCase.ApplnURI;
identyEnryptRequest = identyEnryptRequest.replace("baseurl", domainUrl);
}
if (identyEnryptRequest.contains("$DOMAINURI$")) {
String domainUrl = BaseTestCase.ApplnURI;
identyEnryptRequest = identyEnryptRequest.replace("$DOMAINURI$", domainUrl);
}
logger.info(identyEnryptRequest);
String encryptedIdentityReq=null;
try {
encryptedIdentityReq = bioDataUtil.constractBioIdentityRequest(identyEnryptRequest, getResourcePath()+props.getProperty("bioValueEncryptionTemplate"), testCaseName, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,9 @@ public void test(TestCaseDTO testCaseDTO)
// dev - t f
}
}
testCaseName = isTestCaseValidForExecution(testCaseDTO);

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

if (inputJson.contains("$PHONENUMBERFROMREGEXFORSIGNUP$")) {
String phoneNumber = getPhoneNumber();
if (phoneNumber != null && !phoneNumber.isEmpty()) {
inputJson = replaceKeywordWithValue(inputJson, "$PHONENUMBERFROMREGEXFORSIGNUP$", phoneNumber);
req = new JSONObject(inputJson);
writeAutoGeneratedId(testCaseDTO.getTestCaseName(), "PHONE", phoneNumber);
}
}

auditLogCheck = testCaseDTO.isAuditLogCheck();
String otpRequest = null;
String sendOtpReqTemplate = null;
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 All @@ -106,36 +105,6 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
inputJson = inputJson.replace("&quot;", "\"");
}

if (inputJson.contains("$PHONENUMBERFROMREGEXFORSIGNUP$")) {
String phoneNumber = getPhoneNumber();
if (phoneNumber != null && !phoneNumber.isEmpty()) {
inputJson = replaceKeywordWithValue(inputJson, "$PHONENUMBERFROMREGEXFORSIGNUP$", phoneNumber);
writeAutoGeneratedId(testCaseDTO.getTestCaseName(), "PHONE", phoneNumber);
}
}

if (inputJson.contains("$FULLNAMETOREGISTERUSER$")) {
String jsonString = generateFullNameToRegisterUser(inputJson, testCaseDTO.getTestCaseName());
if (!jsonString.isBlank())
inputJson = jsonString;
}

if (inputJson.contains("$PASSWORDTOREGISTERUSER$")) {
// String password = getPasswordPattern();
String password = PASSWORD_FOR_ADDIDENTITY_AND_REGISTRATION;
if (password != null && !password.isEmpty()) {
inputJson = replaceKeywordWithValue(inputJson, "$PASSWORDTOREGISTERUSER$", password);
// writeAutoGeneratedId(testCaseDTO.getTestCaseName(), "PASSWORD", password);
}
}

if (inputJson.contains("$PASSWORDTORESET$")) {
String passwordToReset = PASSWORD_TO_RESET;
if (passwordToReset != null && !passwordToReset.isEmpty()) {
inputJson = replaceKeywordWithValue(inputJson, "$PASSWORDTORESET$", passwordToReset);
}
}

if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) {
ArrayList<JSONObject> inputtestCases = AdminTestUtil.getInputTestCase(testCaseDTO);
ArrayList<JSONObject> outputtestcase = AdminTestUtil.getOutputTestCase(testCaseDTO);
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
12 changes: 12 additions & 0 deletions api-test/testNgXmlFiles/authMasterTestSuite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Authentication API Test Rig Master Suite">
<listeners>
<listener class-name="io.mosip.testrig.apirig.report.EmailableReport" />
</listeners>
<suite-files>
<suite-file path="authPrerequisiteSuite.xml" />
<suite-file path="authSuite.xml" />
</suite-files>
</suite>
2 changes: 1 addition & 1 deletion api-test/testNgXmlFiles/authPrerequisiteSuite.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Authentication Prerequisite Test Suite">
<suite name="Authentication Pre-requisite API Test">
<!-- Passing Group as parmeter unsing "testType" Possible Groups are: smoke
regression smokeAndRegression -->
<listeners>
Expand Down
2 changes: 1 addition & 1 deletion api-test/testNgXmlFiles/authSuite.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="AuthenticationTest Suite">
<suite name="Authentication API Test">
<!-- Passing Group as parmeter unsing "testType" Possible Groups are: smoke
regression smokeAndRegression -->
<listeners>
Expand Down

0 comments on commit ce287f9

Please sign in to comment.