From 433fe1d100127be99d2fcdf86b3b5be561323c81 Mon Sep 17 00:00:00 2001 From: Mohanachandran S <165888272+mohanachandran-s@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:27:22 +0530 Subject: [PATCH] MOSIP-36093 - updated apitest in release branch (#741) * MOSIP-36093 - Pushing apitestrig to release branch Signed-off-by: Mohanachandran S * MOSIP-36093 - updated apitest in release branch Signed-off-by: Mohanachandran S * MOSIP-36093 - updated apitest in release branch Signed-off-by: Mohanachandran S --------- Signed-off-by: Mohanachandran S --- api-test/pom.xml | 2 +- .../apirig/testrunner/MosipTestRunner.java | 82 +++--- .../apirig/testscripts/BookAppoinment.java | 4 +- .../testscripts/BookAppoinmentByPrid.java | 4 +- .../apirig/testscripts/CreatePreReg.java | 19 +- .../apirig/testscripts/DeleteWithParam.java | 3 +- .../apirig/testscripts/GetWithParam.java | 3 +- .../testscripts/GetWithParamForAutoGenId.java | 3 +- ...WithFormDataAndFileForNotificationAPI.java | 3 +- .../PostWithFormPathParamAndFile.java | 3 +- .../PostWithPathParamsAndBody.java | 3 +- .../testscripts/PreregAuditValidator.java | 3 +- .../apirig/testscripts/PutWithPathParam.java | 3 +- .../apirig/testscripts/SimplePost.java | 3 +- .../apirig/testscripts/UpdatePrereg.java | 3 +- .../apirig/utils/PreRegConfigManager.java | 33 +++ .../main/resources/config/prereg.properties | 0 .../GetAllApplications/GetAllApplications.yml | 2 +- .../GetApplicationStatusByApplicationID.yml | 2 +- .../preReg/ValidateOtp/ValidateOtp.yml | 251 +++++++++--------- .../preReg/createPrereg/createPrereg.yml | 11 +- 21 files changed, 243 insertions(+), 197 deletions(-) create mode 100644 api-test/src/main/java/io/mosip/testrig/apirig/utils/PreRegConfigManager.java create mode 100644 api-test/src/main/resources/config/prereg.properties diff --git a/api-test/pom.xml b/api-test/pom.xml index f3efb15c30a..4ac0500da36 100644 --- a/api-test/pom.xml +++ b/api-test/pom.xml @@ -265,4 +265,4 @@ - + \ No newline at end of file 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 c0d679e5699..1e412e9494c 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; @@ -21,12 +22,10 @@ import com.nimbusds.jose.jwk.KeyUse; import com.nimbusds.jose.jwk.RSAKey; -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; @@ -34,6 +33,7 @@ import io.mosip.testrig.apirig.utils.MispPartnerAndLicenseKeyGeneration; import io.mosip.testrig.apirig.utils.OutputValidationUtil; import io.mosip.testrig.apirig.utils.PartnerRegistration; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.SkipTestCaseHandler; /** @@ -63,14 +63,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(); + AdminTestUtil.init(); + PreRegConfigManager.init(); + suiteSetup(getRunType()); SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt"); setLogLevels(); @@ -88,12 +90,14 @@ public static void main(String[] arg) { //List localDocCatCode =new ArrayList<>(BaseTestCase.getDocCatCode()); + // List localDocCatCode =new ArrayList<>(BaseTestCase.getDocCatCode()); + startTestRunner(); } catch (Exception e) { LOGGER.error("Exception " + e.getMessage()); } - MockSMTPListener.bTerminate = true; + OTPListener.bTerminate = true; if (BaseTestCase.isTargetEnvLTS()) HealthChecker.bTerminate = true; @@ -101,6 +105,25 @@ public static void main(String[] arg) { System.exit(0); } + + public static void suiteSetup(String runType) { + if (ConfigManager.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.PREREG; + BaseTestCase.setReportName(GlobalConstants.PREREG); + AdminTestUtil.copyPreregTestResource(); + BaseTestCase.otpListener = new OTPListener(); + BaseTestCase.otpListener.run(); + } private static void setLogLevels() { AdminTestUtil.setLogLevel(); @@ -121,10 +144,9 @@ 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 (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 { @@ -133,12 +155,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.PREREG)) { + suitefiles.add(file.getAbsolutePath()); } } runner.setTestSuites(suitefiles); @@ -147,34 +165,15 @@ public static void startTestRunner() { runner.run(); } - /** - * The method to return class loader resource path - * - * @return String - * @throws IOException - */ - /* - * public static String getGlobalResourcePath() { if - * (checkRunType().equalsIgnoreCase("JAR")) { return new - * File(jarUrl).getParentFile().getAbsolutePath() + - * "/MosipTestResource/MosipTemporaryTestResource"; } else if - * (checkRunType().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; } 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)) @@ -191,15 +190,6 @@ public static String getGlobalResourcePath() { public static String getResourcePath() { return getGlobalResourcePath(); -// if (checkRunType().equalsIgnoreCase("JAR")) { -// return new File(jarUrl).getParentFile().getAbsolutePath(); -// } else if (checkRunType().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() { @@ -293,7 +283,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 diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinment.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinment.java index de683690b81..f6a488a51bb 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinment.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinment.java @@ -28,10 +28,10 @@ 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.KernelAuthentication; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.mosip.testrig.apirig.utils.RestClient; @@ -44,7 +44,7 @@ public class BookAppoinment extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinmentByPrid.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinmentByPrid.java index 8271c390535..ed8cea4972a 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinmentByPrid.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/BookAppoinmentByPrid.java @@ -27,10 +27,10 @@ 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.KernelAuthentication; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.mosip.testrig.apirig.utils.RestClient; @@ -43,7 +43,7 @@ public class BookAppoinmentByPrid extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/CreatePreReg.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/CreatePreReg.java index 7eee5435097..c21814194f9 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/CreatePreReg.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/CreatePreReg.java @@ -3,6 +3,7 @@ import java.lang.reflect.Field; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,9 +29,9 @@ 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.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -43,7 +44,7 @@ public class CreatePreReg extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); @@ -119,8 +120,18 @@ public void test(TestCaseDTO testCaseDTO) } else { response = postWithBodyAndCookieForAutoGeneratedId(ApplnURI + testCaseDTO.getEndPoint(), inputJson, COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), idKeyName); - Map> ouputValid = OutputValidationUtil - .doJsonOutputValidation(response.asString(), outputJson, testCaseDTO, response.getStatusCode()); + Map> ouputValid = null; + if (testCaseName.contains("_StatusCode")) { + + OutputValidationDto customResponse = customStatusCodeResponse(String.valueOf(response.getStatusCode()), + testCaseDTO.getOutput()); + + ouputValid = new HashMap<>(); + ouputValid.put(GlobalConstants.EXPECTED_VS_ACTUAL, List.of(customResponse)); + } else { + ouputValid = OutputValidationUtil + .doJsonOutputValidation(response.asString(), outputJson, testCaseDTO, response.getStatusCode()); + } Reporter.log(ReportUtil.getOutputValidationReport(ouputValid)); if (!OutputValidationUtil.publishOutputResult(ouputValid)) throw new AdminTestException("Failed at output validation"); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/DeleteWithParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/DeleteWithParam.java index ff975a331fd..ef87e0c0543 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/DeleteWithParam.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/DeleteWithParam.java @@ -29,6 +29,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -40,7 +41,7 @@ public class DeleteWithParam extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParam.java index d04e3d735ed..65757bb2d63 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParam.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParam.java @@ -29,6 +29,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -41,7 +42,7 @@ public class GetWithParam extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParamForAutoGenId.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParamForAutoGenId.java index cff83158b7c..378ea411905 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParamForAutoGenId.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/GetWithParamForAutoGenId.java @@ -29,6 +29,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -42,7 +43,7 @@ public class GetWithParamForAutoGenId extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormDataAndFileForNotificationAPI.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormDataAndFileForNotificationAPI.java index 3b5907a2e44..6a6c485bcab 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormDataAndFileForNotificationAPI.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormDataAndFileForNotificationAPI.java @@ -27,6 +27,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -39,7 +40,7 @@ public class PostWithFormDataAndFileForNotificationAPI extends AdminTestUtil imp @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormPathParamAndFile.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormPathParamAndFile.java index 783291485b2..f3fc0b6439d 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormPathParamAndFile.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithFormPathParamAndFile.java @@ -27,6 +27,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -39,7 +40,7 @@ public class PostWithFormPathParamAndFile extends AdminTestUtil implements ITest @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithPathParamsAndBody.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithPathParamsAndBody.java index d7bdf2e6186..5d59bbdf843 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithPathParamsAndBody.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PostWithPathParamsAndBody.java @@ -27,6 +27,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -38,7 +39,7 @@ public class PostWithPathParamsAndBody extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PreregAuditValidator.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PreregAuditValidator.java index 6a9b380990b..f7be19fa190 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PreregAuditValidator.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PreregAuditValidator.java @@ -32,6 +32,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.restassured.response.Response; @@ -51,7 +52,7 @@ public String getTestName() { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PutWithPathParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PutWithPathParam.java index 7c3039f8cba..5930fecebd8 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PutWithPathParam.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/PutWithPathParam.java @@ -29,6 +29,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -40,7 +41,7 @@ public class PutWithPathParam extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/SimplePost.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/SimplePost.java index 8e17639d083..ea0480aec30 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/SimplePost.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/SimplePost.java @@ -29,6 +29,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -41,7 +42,7 @@ public class SimplePost extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/UpdatePrereg.java b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/UpdatePrereg.java index 94e63c03227..8546d4a6257 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/UpdatePrereg.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/testscripts/UpdatePrereg.java @@ -29,6 +29,7 @@ import io.mosip.testrig.apirig.utils.ConfigManager; import io.mosip.testrig.apirig.utils.GlobalConstants; import io.mosip.testrig.apirig.utils.OutputValidationUtil; +import io.mosip.testrig.apirig.utils.PreRegConfigManager; import io.mosip.testrig.apirig.utils.PreRegUtil; import io.mosip.testrig.apirig.utils.ReportUtil; import io.restassured.response.Response; @@ -41,7 +42,7 @@ public class UpdatePrereg extends AdminTestUtil implements ITest { @BeforeClass public static void setLogLevel() { - if (ConfigManager.IsDebugEnabled()) + if (PreRegConfigManager.IsDebugEnabled()) logger.setLevel(Level.ALL); else logger.setLevel(Level.ERROR); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/utils/PreRegConfigManager.java b/api-test/src/main/java/io/mosip/testrig/apirig/utils/PreRegConfigManager.java new file mode 100644 index 00000000000..2821c6e0c2d --- /dev/null +++ b/api-test/src/main/java/io/mosip/testrig/apirig/utils/PreRegConfigManager.java @@ -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 PreRegConfigManager extends ConfigManager{ + private static final Logger LOGGER = Logger.getLogger(PreRegConfigManager.class); + + public static void init() { + Map moduleSpecificPropertiesMap = new HashMap<>(); + // Load scope specific properties + try { + String path = MosipTestRunner.getGlobalResourcePath() + "/config/prereg.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); + } + + + +} \ No newline at end of file diff --git a/api-test/src/main/resources/config/prereg.properties b/api-test/src/main/resources/config/prereg.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/api-test/src/main/resources/preReg/GetAllApplications/GetAllApplications.yml b/api-test/src/main/resources/preReg/GetAllApplications/GetAllApplications.yml index dafbf32c58b..acdecaa2318 100644 --- a/api-test/src/main/resources/preReg/GetAllApplications/GetAllApplications.yml +++ b/api-test/src/main/resources/preReg/GetAllApplications/GetAllApplications.yml @@ -13,7 +13,7 @@ GetAllApplications: output: '{ }' Prereg_GetAllApplications_InValid: - endPoint: /preregistration/v1/applications + endPoint: /preregistration/v1/applications?type={type} description: Retrieve all applications with invalid data role: batch checkErrorsOnlyInResponse: true diff --git a/api-test/src/main/resources/preReg/GetApplicationStatusByApplicationID/GetApplicationStatusByApplicationID.yml b/api-test/src/main/resources/preReg/GetApplicationStatusByApplicationID/GetApplicationStatusByApplicationID.yml index 699c47f3038..97a4af3955b 100644 --- a/api-test/src/main/resources/preReg/GetApplicationStatusByApplicationID/GetApplicationStatusByApplicationID.yml +++ b/api-test/src/main/resources/preReg/GetApplicationStatusByApplicationID/GetApplicationStatusByApplicationID.yml @@ -8,7 +8,7 @@ GetApplicationStatusByApplicationID: inputTemplate: preReg/GetApplicationStatusByApplicationID/getApplicationStatusByApplicationID outputTemplate: preReg/GetApplicationStatusByApplicationID/getApplicationStatusByApplicationIDResult input: '{ - "applicationId": "52917592714578" + "applicationId": "$ID:CreatePrereg_All_Valid_Smoke_sid_preRegistrationId$" }' output: '{ "response": "Cancelled" diff --git a/api-test/src/main/resources/preReg/ValidateOtp/ValidateOtp.yml b/api-test/src/main/resources/preReg/ValidateOtp/ValidateOtp.yml index 09b4fe1136d..da01ddcc396 100644 --- a/api-test/src/main/resources/preReg/ValidateOtp/ValidateOtp.yml +++ b/api-test/src/main/resources/preReg/ValidateOtp/ValidateOtp.yml @@ -1,124 +1,131 @@ ValidateOtp: - Prereg_ValidateOtp_All_Valid_Smoke_email_sid: - endPoint: /preregistration/v1/login/validateOtp - description: Validating OTP with a valid phone number - role: batch - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: preReg/ValidateOtp/validateOtp - outputTemplate: preReg/ValidateOtp/validateOtpResult - input: '{ - "version": "1.0", - "requesttime": "$TIMESTAMP$", - "userId": "john.doe@mailinator.com", - "otp": "DYNAMICOTP", - "id": "mosip.pre-registration.login.useridotp" -}' - output: '{ -}' - Prereg_ValidateOtp_All_Valid_Smoke_Phone_sid: - endPoint: /preregistration/v1/login/validateOtp - description: Validating OTP with an invalid phone number - role: batch - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: preReg/ValidateOtp/validateOtp - outputTemplate: preReg/ValidateOtp/validateOtpResult - input: '{ - "version": "1.0", - "requesttime": "$TIMESTAMP$", - "userId": "9090872300", - "otp": "DYNAMICOTP", - "id": "mosip.pre-registration.login.useridotp" -}' - output: '{ -}' + Prereg_ValidateOtp_All_Valid_Smoke_email_sid: + endPoint: /preregistration/v1/login/validateOtp + description: Validating OTP with a valid phone number + role: batch + checkErrorsOnlyInResponse: true + restMethod: post + inputTemplate: preReg/ValidateOtp/validateOtp + outputTemplate: preReg/ValidateOtp/validateOtpResult + input: '{ + "version": "1.0", + "requesttime": "$TIMESTAMP$", + "userId": "john.doe@mailinator.com", + "otp": "DYNAMICOTP", + "id": "mosip.pre-registration.login.useridotp" + }' + output: '{}' - Prereg_ValidateOtp_Invalid_Phone_Neg_INVALIDOTP: - endPoint: /preregistration/v1/login/validateOtp - description: Validating OTP with a phone number containing special characters - role: batch - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: preReg/ValidateOtp/validateOtp - outputTemplate: preReg/error - input: '{ - "version": "1.0", - "requesttime": "$TIMESTAMP$", - "userId": "909", - "otp": "DYNAMICOTP", - "id": "mosip.pre-registration.login.useridotp" -}' - output: '{ - "errors": [ - { - "errorCode": "PRG_PAM_LGN_013" - } - ] -}' - Prereg_ValidateOtp_SpacialCharacters_Phone_Neg_INVALIDOTP: - endPoint: /preregistration/v1/login/validateOtp - description: validating OPT with valid email address - role: batch - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: preReg/ValidateOtp/validateOtp - outputTemplate: preReg/error - input: '{ - "version": "1.0", - "requesttime": "$TIMESTAMP$", - "userId": "$!(", - "otp": "DYNAMICOTP", - "id": "mosip.pre-registration.login.useridotp" -}' - output: '{ - "errors": [ - { - "errorCode": "PRG_PAM_LGN_013" - } - ] -}' - Prereg_ValidateOtp_SpacialCharacters_Email_Neg_INVALIDOTP: - endPoint: /preregistration/v1/login/validateOtp - description: Validating OTP with an email address containing special characters - role: batch - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: preReg/ValidateOtp/validateOtp - outputTemplate: preReg/error - input: '{ - "version": "1.0", - "requesttime": "$TIMESTAMP$", - "userId": "john.doe@mail$!inator.com", - "otp": "DYNAMICOTP", - "id": "mosip.pre-registration.login.useridotp" -}' - output: '{ - "errors": [ - { - "errorCode": "PRG_PAM_LGN_013" - } - ] -}' - Prereg_ValidateOtp_Invalid_Email_Neg_INVALIDOTP: - endPoint: /preregistration/v1/login/validateOtp - description: Validating OTP with an invalid email address - role: batch - checkErrorsOnlyInResponse: true - restMethod: post - inputTemplate: preReg/ValidateOtp/validateOtp - outputTemplate: preReg/error - input: '{ - "version": "1.0", - "requesttime": "$TIMESTAMP$", - "userId": "joh23", - "otp": "DYNAMICOTP", - "id": "mosip.pre-registration.login.useridotp" -}' - output: '{ - "errors": [ - { - "errorCode": "PRG_PAM_LGN_013" - } - ] -}' \ No newline at end of file + Prereg_ValidateOtp_All_Valid_Smoke_Phone_sid: + endPoint: /preregistration/v1/login/validateOtp + description: Validating OTP with an invalid phone number + role: batch + restMethod: post + inputTemplate: preReg/ValidateOtp/validateOtp + outputTemplate: preReg/error + input: '{ + "version": "1.0", + "requesttime": "$TIMESTAMP$", + "userId": "9090872300", + "otp": "DYNAMICOTP", + "id": "mosip.pre-registration.login.useridotp" + }' + output: '{ + "errors": [ + { + "errorCode": "KER-OTV-005" + } + ] + }' + + Prereg_ValidateOtp_Invalid_Phone_Neg_INVALIDOTP: + endPoint: /preregistration/v1/login/validateOtp + description: Validating OTP with a phone number containing special characters + role: batch + checkErrorsOnlyInResponse: true + restMethod: post + inputTemplate: preReg/ValidateOtp/validateOtp + outputTemplate: preReg/error + input: '{ + "version": "1.0", + "requesttime": "$TIMESTAMP$", + "userId": "909", + "otp": "DYNAMICOTP", + "id": "mosip.pre-registration.login.useridotp" + }' + output: '{ + "errors": [ + { + "errorCode": "KER-OTV-005" + } + ] + }' + + Prereg_ValidateOtp_SpacialCharacters_Phone_Neg_INVALIDOTP: + endPoint: /preregistration/v1/login/validateOtp + description: Validating OTP with a valid email address + role: batch + checkErrorsOnlyInResponse: true + restMethod: post + inputTemplate: preReg/ValidateOtp/validateOtp + outputTemplate: preReg/error + input: '{ + "version": "1.0", + "requesttime": "$TIMESTAMP$", + "userId": "$!(", + "otp": "DYNAMICOTP", + "id": "mosip.pre-registration.login.useridotp" + }' + output: '{ + "errors": [ + { + "errorCode": "KER-OTV-005" + } + ] + }' + + Prereg_ValidateOtp_SpacialCharacters_Email_Neg_INVALIDOTP: + endPoint: /preregistration/v1/login/validateOtp + description: Validating OTP with an email address containing special characters + role: batch + checkErrorsOnlyInResponse: true + restMethod: post + inputTemplate: preReg/ValidateOtp/validateOtp + outputTemplate: preReg/error + input: '{ + "version": "1.0", + "requesttime": "$TIMESTAMP$", + "userId": "john.doe@mail$!inator.com", + "otp": "DYNAMICOTP", + "id": "mosip.pre-registration.login.useridotp" + }' + output: '{ + "errors": [ + { + "errorCode": "KER-OTV-005" + } + ] + }' + + Prereg_ValidateOtp_Invalid_Email_Neg_INVALIDOTP: + endPoint: /preregistration/v1/login/validateOtp + description: Validating OTP with an invalid email address + role: batch + checkErrorsOnlyInResponse: true + restMethod: post + inputTemplate: preReg/ValidateOtp/validateOtp + outputTemplate: preReg/error + input: '{ + "version": "1.0", + "requesttime": "$TIMESTAMP$", + "userId": "joh23", + "otp": "DYNAMICOTP", + "id": "mosip.pre-registration.login.useridotp" + }' + output: '{ + "errors": [ + { + "errorCode": "KER-OTV-005" + } + ] + }' \ No newline at end of file diff --git a/api-test/src/main/resources/preReg/createPrereg/createPrereg.yml b/api-test/src/main/resources/preReg/createPrereg/createPrereg.yml index aee7974e46c..854ca8b9403 100644 --- a/api-test/src/main/resources/preReg/createPrereg/createPrereg.yml +++ b/api-test/src/main/resources/preReg/createPrereg/createPrereg.yml @@ -537,7 +537,7 @@ CreatePrereg: } ] }' - Prereg_CreatePrereg_Invalid_OTP_Neg: + Prereg_CreatePrereg_Invalid_OTP_Neg_StatusCode: endPoint: /preregistration/v1/applications/prereg description: Creating preregistration with an invalid OTP role: invalidBatch @@ -557,13 +557,8 @@ CreatePrereg: "requesttime": "$TIMESTAMP$", "id": "mosip.pre-registration.demographic.create" }' - output: '{ - "errors": [ - { - "errorCode": "KER-IOV-004" - } - ] -}' + output: "500" + Prereg_CreatePrereg_All_Valid_Smoke_date_verification_sid: endPoint: /preregistration/v1/applications/prereg description: Creating preregistration with an invalid OTP