diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java b/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java index cff4087b03..f2b405a9cb 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java @@ -14,6 +14,7 @@ import java.util.Map; import java.util.Properties; +import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.bouncycastle.openssl.jcajce.JcaPEMWriter; import org.testng.TestNG; @@ -24,10 +25,8 @@ import io.mosip.testrig.apirig.dataprovider.BiometricDataProvider; import io.mosip.testrig.apirig.dbaccess.DBManager; import io.mosip.testrig.apirig.utils.AdminTestUtil; -import io.mosip.testrig.apirig.utils.CertificateGenerationUtil; +import io.mosip.testrig.apirig.utils.AuthTestsUtil; import io.mosip.testrig.apirig.utils.CertsUtil; -import io.mosip.testrig.apirig.utils.ConfigManager; -import io.mosip.testrig.apirig.utils.EncryptionDecrptionUtil; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.JWKKeyUtil; import io.mosip.testrig.apirig.utils.KeyCloakUserAndAPIKeyGeneration; @@ -66,7 +65,7 @@ public static void main(String[] arg) { LOGGER.info(String.format("ENV %s = %s%n", envName, envMap.get(envName))); } BaseTestCase.setRunContext(getRunType(), jarUrl); - + ExtractResource.removeOldMosipTestTestResource(); if (getRunType().equalsIgnoreCase("JAR")) { ExtractResource.extractCommonResourceFromJar(); @@ -75,7 +74,7 @@ public static void main(String[] arg) { } AdminTestUtil.init(); ResidentConfigManager.init(); - BaseTestCase.suiteSetup(getRunType()); + suiteSetup(getRunType()); SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt"); setLogLevels(); @@ -92,7 +91,7 @@ public static void main(String[] arg) { List localLanguageList = new ArrayList<>(BaseTestCase.getLanguageList()); AdminTestUtil.getLocationData(); - + // Generate device certificates to be consumed by Mock-MDS PartnerRegistration.deleteCertificates(); AdminTestUtil.createAndPublishPolicy(); @@ -114,6 +113,34 @@ public static void main(String[] arg) { System.exit(0); } + + public static void suiteSetup(String runType) { + if (ResidentConfigManager.IsDebugEnabled()) + LOGGER.setLevel(Level.ALL); + else + LOGGER.info("Test Framework for Mosip api Initialized"); + BaseTestCase.initialize(); + LOGGER.info("Done with BeforeSuite and test case setup! su TEST EXECUTION!\n\n"); + + if (!runType.equalsIgnoreCase("JAR")) { + AuthTestsUtil.removeOldMosipTempTestResource(); + } + BaseTestCase.currentModule = GlobalConstants.RESIDENT; + BaseTestCase.certsForModule = GlobalConstants.RESIDENT; + DBManager.executeDBQueries(ResidentConfigManager.getKMDbUrl(), ResidentConfigManager.getKMDbUser(), + ResidentConfigManager.getKMDbPass(), ResidentConfigManager.getKMDbSchema(), + getGlobalResourcePath() + "/" + "config/keyManagerDataDeleteQueriesForEsignet.txt"); + DBManager.executeDBQueries(ResidentConfigManager.getIdaDbUrl(), ResidentConfigManager.getIdaDbUser(), + ResidentConfigManager.getPMSDbPass(), ResidentConfigManager.getIdaDbSchema(), + getGlobalResourcePath() + "/" + "config/idaDeleteQueriesForEsignet.txt"); + DBManager.executeDBQueries(ResidentConfigManager.getMASTERDbUrl(), ResidentConfigManager.getMasterDbUser(), + ResidentConfigManager.getMasterDbPass(), ResidentConfigManager.getMasterDbSchema(), + getGlobalResourcePath() + "/" + "config/masterDataDeleteQueriesForEsignet.txt"); + BaseTestCase.setReportName(GlobalConstants.RESIDENT); + AdminTestUtil.copyResidentTestResource(); + BaseTestCase.otpListener = new OTPListener(); + BaseTestCase.otpListener.run(); + } private static void setLogLevels() { AdminTestUtil.setLogLevel(); @@ -134,7 +161,6 @@ public static void startTestRunner() { File homeDir = null; TestNG runner = new TestNG(); List suitefiles = new ArrayList<>(); - List modulesToRun = BaseTestCase.listOfModules; String os = System.getProperty("os.name"); LOGGER.info(os); if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) { @@ -146,12 +172,8 @@ public static void startTestRunner() { LOGGER.info("ELSE :" + homeDir); } for (File file : homeDir.listFiles()) { - for (String fileName : modulesToRun) { - if (file.getName().toLowerCase().contains(fileName)) { - suitefiles.add(file.getAbsolutePath()); - } else if (fileName.equals("all") && file.getName().toLowerCase().contains("testng")) { - suitefiles.add(file.getAbsolutePath()); - } + if (file.getName().toLowerCase().contains(GlobalConstants.RESIDENT)) { + suitefiles.add(file.getAbsolutePath()); } } runner.setTestSuites(suitefiles);