From 6d0c859406874384047f9bbf338d89c4a8f162ae Mon Sep 17 00:00:00 2001 From: Nandhukumar Date: Mon, 7 Oct 2024 18:57:52 +0530 Subject: [PATCH] MOSIP-35404 Signed-off-by: Nandhukumar --- .../apirig/testrunner/MosipTestRunner.java | 75 +++++++++---------- 1 file changed, 36 insertions(+), 39 deletions(-) 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 a5f768fc72..d5110b467e 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,12 +25,11 @@ 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.AuthTestsUtil; import io.mosip.testrig.apirig.utils.CertificateGenerationUtil; 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.GlobalMethods; import io.mosip.testrig.apirig.utils.IdAuthConfigManager; import io.mosip.testrig.apirig.utils.JWKKeyUtil; import io.mosip.testrig.apirig.utils.KeyCloakUserAndAPIKeyGeneration; @@ -74,8 +74,7 @@ public static void main(String[] arg) { ExtractResource.copyCommonResources(); } IdAuthConfigManager.init(); - - BaseTestCase.suiteSetup(getRunType()); + suiteSetup(getRunType()); SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt"); setLogLevels(); @@ -125,6 +124,37 @@ public static void main(String[] arg) { System.exit(0); } + + public static void suiteSetup(String runType) { + if (IdAuthConfigManager.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.setReportName("auth"); + BaseTestCase.currentModule = "auth"; + BaseTestCase.certsForModule = "IDA"; + DBManager.executeDBQueries(ConfigManager.getKMDbUrl(), ConfigManager.getKMDbUser(), ConfigManager.getKMDbPass(), + ConfigManager.getKMDbSchema(), + getGlobalResourcePath() + "/" + "config/keyManagerDataDeleteQueriesForEsignet.txt"); + DBManager.executeDBQueries(ConfigManager.getIdaDbUrl(), ConfigManager.getIdaDbUser(), + ConfigManager.getPMSDbPass(), ConfigManager.getIdaDbSchema(), + getGlobalResourcePath() + "/" + "config/idaDeleteQueriesForEsignet.txt"); + + DBManager.executeDBQueries(ConfigManager.getMASTERDbUrl(), ConfigManager.getMasterDbUser(), + ConfigManager.getMasterDbPass(), ConfigManager.getMasterDbSchema(), + getGlobalResourcePath() + "/" + "config/masterDataDeleteQueriesForEsignet.txt"); + AuthTestsUtil.initiateAuthTest(); + BaseTestCase.otpListener = new OTPListener(); + BaseTestCase.otpListener.run(); + } + + private static void setLogLevels() { AdminTestUtil.setLogLevel(); @@ -145,7 +175,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")) { @@ -157,12 +186,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("auth")) { + suitefiles.add(file.getAbsolutePath()); } } runner.setTestSuites(suitefiles); @@ -171,25 +196,6 @@ public static void startTestRunner() { runner.run(); } - /** - * The method to return class loader resource path - * - * @return String - * @throws IOException - */ - /* - * public static String getGlobalResourcePath() { if - * (getRunType().equalsIgnoreCase("JAR")) { return new - * File(jarUrl).getParentFile().getAbsolutePath() + - * "/MosipTestResource/MosipTemporaryTestResource"; } else if - * (getRunType().equalsIgnoreCase("IDE")) { String path = new - * File(MosipTestRunner.class.getClassLoader().getResource("").getPath()). - * getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource"; if - * (path.contains(GlobalConstants.TESTCLASSES)) path = - * path.replace(GlobalConstants.TESTCLASSES, "classes"); return path; } return - * "Global Resource File Path Not Found"; } - */ - public static String getGlobalResourcePath() { if (cachedPath != null) { return cachedPath; @@ -215,15 +221,6 @@ public static String getGlobalResourcePath() { public static String getResourcePath() { return getGlobalResourcePath(); -// if (getRunType().equalsIgnoreCase("JAR")) { -// return new File(jarUrl).getParentFile().getAbsolutePath(); -// } else if (getRunType().equalsIgnoreCase("IDE")) { -// String path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath(); -// if (path.contains(GlobalConstants.TESTCLASSES)) -// path = path.replace(GlobalConstants.TESTCLASSES, "classes"); -// return path; -// } -// return "Global Resource File Path Not Found"; } public static String generatePulicKey() {