Skip to content

Commit

Permalink
Merge pull request #103 from nandhu-kumar/develop
Browse files Browse the repository at this point in the history
MOSIP-35404 | Move component specific test code from common to component api test rigs
  • Loading branch information
ckm007 authored Oct 3, 2024
2 parents 4e96387 + 3af3448 commit 8a36837
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 338 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import io.mosip.testrig.apirig.dataprovider.BiometricDataProvider;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.CertsUtil;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.JWKKeyUtil;
import io.mosip.testrig.apirig.utils.KeyCloakUserAndAPIKeyGeneration;
import io.mosip.testrig.apirig.utils.KeycloakUserManager;
Expand Down Expand Up @@ -61,14 +61,16 @@ public static void main(String[] arg) {
for (String envName : envMap.keySet()) {
LOGGER.info(String.format("ENV %s = %s%n", envName, envMap.get(envName)));
}

BaseTestCase.setRunContext(getRunType(), jarUrl);
ExtractResource.removeOldMosipTestTestResource();
if (checkRunType().equalsIgnoreCase("JAR")) {
if (getRunType().equalsIgnoreCase("JAR")) {
ExtractResource.extractCommonResourceFromJar();
} else {
ExtractResource.copyCommonResources();
}
ConfigManager.init();
BaseTestCase.suiteSetup();
InjiCertifyConfigManager.init();
BaseTestCase.suiteSetup(getRunType());
SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt");
setLogLevels();

Expand Down Expand Up @@ -98,7 +100,7 @@ public static void main(String[] arg) {
LOGGER.error("Exception " + e.getMessage());
}

MockSMTPListener.bTerminate = true;
OTPListener.bTerminate = true;

if (BaseTestCase.isTargetEnvLTS())
HealthChecker.bTerminate = true;
Expand Down Expand Up @@ -129,7 +131,7 @@ public static void startTestRunner() {
List<String> modulesToRun = BaseTestCase.listOfModules;
String os = System.getProperty("os.name");
LOGGER.info(os);
if (checkRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
homeDir = new File(System.getProperty("user.dir") + "/testNgXmlFiles");
LOGGER.info("IDE :" + homeDir);
} else {
Expand Down Expand Up @@ -165,9 +167,9 @@ public static String getGlobalResourcePath() {
}

String path = null;
if (checkRunType().equalsIgnoreCase("JAR")) {
if (getRunType().equalsIgnoreCase("JAR")) {
path = new File(jarUrl).getParentFile().getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource";
} else if (checkRunType().equalsIgnoreCase("IDE")) {
} else if (getRunType().equalsIgnoreCase("IDE")) {
path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath()
+ "/MosipTestResource/MosipTemporaryTestResource";
if (path.contains(GlobalConstants.TESTCLASSES))
Expand Down Expand Up @@ -277,7 +279,7 @@ public static Properties getproperty(String path) {
*
* @return
*/
public static String checkRunType() {
public static String getRunType() {
if (MosipTestRunner.class.getResource("MosipTestRunner.class").getPath().contains(".jar"))
return "JAR";
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.KernelAuthentication;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
Expand All @@ -56,7 +56,7 @@ public String getTestName() {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
Expand All @@ -43,7 +43,7 @@ public class PostWithAutogenIdWithOtpGenerate extends AdminTestUtil implements I

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -99,7 +99,7 @@ public void test(TestCaseDTO testCaseDTO)
}

if (BaseTestCase.isTargetEnvLTS()) {
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.RESIDENT)
if (InjiCertifyConfigManager.isInServiceNotDeployedList(GlobalConstants.RESIDENT)
&& (BaseTestCase.currentModule.equals("esignet")
&& testCaseName.startsWith("ESignetRes_Generate"))) {
throw new SkipException("Generating VID using IdRepo API. Hence skipping this test case");
Expand Down Expand Up @@ -132,10 +132,10 @@ public void test(TestCaseDTO testCaseDTO)
int currLoopCount = 0;
while (currLoopCount < maxLoopCount) {
if (testCaseName.contains(GlobalConstants.ESIGNET_)) {
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
if (InjiCertifyConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
throw new SkipException("esignet is not deployed hence skipping the testcase");
}
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = InjiCertifyConfigManager.getEsignetBaseUrl();
String endPointKeyWord = "";
if (sendOtpEndPoint.contains("BASEURL$")) {
tempUrl = InjiCertifyUtil.getTempURL(testCaseDTO);
Expand Down Expand Up @@ -204,10 +204,10 @@ public void test(TestCaseDTO testCaseDTO)
reqJson = InjiCertifyUtil.smtpOtpHandler(reqJson, testCaseDTO);

if (testCaseName.contains(GlobalConstants.ESIGNET_)) {
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
if (InjiCertifyConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
throw new SkipException("esignet is not deployed hence skipping the testcase");
}
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = InjiCertifyConfigManager.getEsignetBaseUrl();
String endPointKeyWord = "";
if (testCaseDTO.getEndPoint().contains("BASEURL$")) {
tempUrl = InjiCertifyUtil.getTempURL(testCaseDTO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package io.mosip.testrig.apirig.testscripts;

import java.io.IOException;
import java.lang.reflect.Field;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableEntryException;
import java.security.cert.CertificateException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -33,8 +28,8 @@
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.PartnerTypes;
Expand All @@ -50,7 +45,7 @@ public class PostWithBodyAndQueryParamsForAutoGenId extends AdminTestUtil implem

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
Expand All @@ -43,7 +43,7 @@ public class PostWithOnlyPathParam extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
Expand All @@ -43,7 +43,7 @@ public class PutWithPathParamsAndBody extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -119,7 +119,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad

else {
if (testCaseName.contains("ESignet_")) {
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = InjiCertifyConfigManager.getEsignetBaseUrl();
response = putWithPathParamsBodyAndBearerToken(tempUrl + testCaseDTO.getEndPoint(), inputJson,
COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), pathParams);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
Expand All @@ -44,7 +44,7 @@ public class SimplePost extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -121,7 +121,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
}

else {
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = InjiCertifyConfigManager.getEsignetBaseUrl();
if (testCaseName.contains("ESignet_") || testCaseName.contains("InjiCertify")) {

String endPointKeyWord = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
Expand All @@ -46,7 +46,7 @@ public class SimplePostForAutoGenId extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -101,7 +101,7 @@ public void test(TestCaseDTO testCaseDTO)
}

if (BaseTestCase.isTargetEnvLTS()) {
if (!ConfigManager.isInServiceNotDeployedList(GlobalConstants.RESIDENT)) {
if (!InjiCertifyConfigManager.isInServiceNotDeployedList(GlobalConstants.RESIDENT)) {
if ((BaseTestCase.currentModule.equals("esignet") && testCaseName.startsWith("ESignetIdR_Generate"))) {
throw new SkipException(
GlobalConstants.VID_GENERATED_USING_RESIDENT_API_SO_FEATURE_NOT_SUPPORTED_OR_NEEDED_MESSAGE);
Expand Down Expand Up @@ -143,10 +143,10 @@ public void test(TestCaseDTO testCaseDTO)
}
} else {
if (testCaseName.contains("ESignet_")) {
if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
if (InjiCertifyConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
throw new SkipException("esignet is not deployed hence skipping the testcase");
}
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = InjiCertifyConfigManager.getEsignetBaseUrl();
String endPointKeyWord = "";

if (testCaseDTO.getEndPoint().contains("BASEURL$")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.InjiCertifyConfigManager;
import io.mosip.testrig.apirig.utils.InjiCertifyUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
Expand All @@ -43,7 +43,7 @@ public class SimplePostForAutoGenIdForUrlEncoded extends AdminTestUtil implement

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (InjiCertifyConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -91,7 +91,7 @@ public void test(TestCaseDTO testCaseDTO)
}

if (testCaseDTO.getEndPoint().startsWith("$ESIGNETMOCKBASEURL$") && testCaseName.contains("SunBirdRC")) {
if (ConfigManager.isInServiceNotDeployedList("sunbirdrc"))
if (InjiCertifyConfigManager.isInServiceNotDeployedList("sunbirdrc"))
throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE);
}

Expand All @@ -102,7 +102,7 @@ public void test(TestCaseDTO testCaseDTO)
}
}

if (ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
if (InjiCertifyConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) {
throw new SkipException("esignet is not deployed hence skipping the testcase");
}
testCaseName = isTestCaseValidForExecution(testCaseDTO);
Expand Down Expand Up @@ -139,7 +139,7 @@ public void test(TestCaseDTO testCaseDTO)
jsonInput = InjiCertifyUtil.reqJsonKeyWordHandeler(jsonInput, testCaseName);

if (testCaseName.contains("ESignet_")) {
String tempUrl = ConfigManager.getEsignetBaseUrl();
String tempUrl = InjiCertifyConfigManager.getEsignetBaseUrl();
String endPointKeyWord = "";

if (testCaseDTO.getEndPoint().contains("BASEURL$")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.mosip.testrig.apirig.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.apache.log4j.Logger;

import io.mosip.testrig.apirig.testrunner.MosipTestRunner;

public class InjiCertifyConfigManager extends ConfigManager{
private static final Logger LOGGER = Logger.getLogger(InjiCertifyConfigManager.class);

public static void init() {
Map<String, Object> moduleSpecificPropertiesMap = new HashMap<>();
// Load scope specific properties
try {
String path = MosipTestRunner.getGlobalResourcePath() + "/config/injiCertify.properties";
Properties props = getproperties(path);
// Convert Properties to Map and add to moduleSpecificPropertiesMap
for (String key : props.stringPropertyNames()) {
moduleSpecificPropertiesMap.put(key, props.getProperty(key));
}
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
// Add module specific properties as well.
init(moduleSpecificPropertiesMap);
}



}
Loading

0 comments on commit 8a36837

Please sign in to comment.