diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testrunner/MosipTestRunner.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testrunner/MosipTestRunner.java index 1129e6ea..983c00a8 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testrunner/MosipTestRunner.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testrunner/MosipTestRunner.java @@ -117,6 +117,8 @@ public static void main(String[] arg) { BiometricDataProvider.generateBiometricTestData("Registration"); startTestRunner(); } else { + BaseTestCase.isTargetEnvLatest = true; + SignupUtil.getSupportedLanguage(); startTestRunner(); } diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/AddIdentity.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/AddIdentity.java index a96fb113..77a9b985 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/AddIdentity.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/AddIdentity.java @@ -150,8 +150,6 @@ public void test(TestCaseDTO testCaseDTO) throws Exception { 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()); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/DeleteWithParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/DeleteWithParam.java deleted file mode 100644 index e1afeaec..00000000 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/DeleteWithParam.java +++ /dev/null @@ -1,167 +0,0 @@ -package io.mosip.testrig.apirig.signup.testscripts; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.json.JSONObject; -import org.testng.ITest; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.Reporter; -import org.testng.SkipException; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.internal.BaseTestMethod; -import org.testng.internal.TestResult; - -import io.mosip.testrig.apirig.dto.OutputValidationDto; -import io.mosip.testrig.apirig.dto.TestCaseDTO; -import io.mosip.testrig.apirig.signup.utils.SignupConfigManager; -import io.mosip.testrig.apirig.signup.utils.SignupUtil; -import io.mosip.testrig.apirig.testrunner.HealthChecker; -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.GlobalConstants; -import io.mosip.testrig.apirig.utils.OutputValidationUtil; -import io.mosip.testrig.apirig.utils.ReportUtil; -import io.restassured.response.Response; - -public class DeleteWithParam extends AdminTestUtil implements ITest { - private static final Logger logger = Logger.getLogger(DeleteWithParam.class); - protected String testCaseName = ""; - public Response response = null; - - @BeforeClass - public static void setLogLevel() { - if (SignupConfigManager.IsDebugEnabled()) - logger.setLevel(Level.ALL); - else - logger.setLevel(Level.ERROR); - } - - /** - * get current testcaseName - */ - @Override - public String getTestName() { - return testCaseName; - } - - /** - * Data provider class provides test case list - * - * @return object of data provider - */ - @DataProvider(name = "testcaselist") - public Object[] getTestCaseList(ITestContext context) { - String ymlFile = context.getCurrentXmlTest().getLocalParameters().get("ymlFile"); - logger.info("Started executing yml: " + ymlFile); - return getYmlTestData(ymlFile); - } - - /** - * Test method for OTP Generation execution - * - * @param objTestParameters - * @param testScenario - * @param testcaseName - * @throws AuthenticationTestException - * @throws AdminTestException - */ - @Test(dataProvider = "testcaselist") - public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException { - testCaseName = testCaseDTO.getTestCaseName(); - testCaseName = SignupUtil.isTestCaseValidForExecution(testCaseDTO); - testCaseName = isTestCaseValidForExecution(testCaseDTO); - if (HealthChecker.signalTerminateExecution) { - throw new SkipException( - GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS); - } - String[] templateFields = testCaseDTO.getTemplateFields(); - - if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) { - ArrayList inputtestCases = AdminTestUtil.getInputTestCase(testCaseDTO); - ArrayList outputtestcase = AdminTestUtil.getOutputTestCase(testCaseDTO); - - for (int i = 0; i < languageList.size(); i++) { - response = deleteWithPathParamAndCookie(ApplnURI + testCaseDTO.getEndPoint(), - getJsonFromTemplate(inputtestCases.get(i).toString(), testCaseDTO.getInputTemplate()), - COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - - Map> ouputValid = OutputValidationUtil.doJsonOutputValidation( - response.asString(), - getJsonFromTemplate(outputtestcase.get(i).toString(), testCaseDTO.getOutputTemplate()), - testCaseDTO, response.getStatusCode()); - Reporter.log(ReportUtil.getOutputValidationReport(ouputValid)); - - if (!OutputValidationUtil.publishOutputResult(ouputValid)) - throw new AdminTestException("Failed at output validation"); - } - } - - else { - - if (testCaseName.contains("ESignet_")) { - if (SignupConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) { - throw new SkipException("esignet is not deployed hence skipping the testcase"); - } - - String tempUrl = ApplnURI; - - if (testCaseDTO.getEndPoint().startsWith("$SUNBIRDBASEURL$") && testCaseName.contains("SunBirdR")) { - - if (SignupConfigManager.isInServiceNotDeployedList("sunbirdrc")) - throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE); - - if (SignupConfigManager.getSunBirdBaseURL() != null && !SignupConfigManager.getSunBirdBaseURL().isBlank()) - tempUrl = SignupConfigManager.getSunBirdBaseURL(); - //Once sunbird registry is pointing to specific env, remove the above line and uncomment below line - //tempUrl = ApplnURI.replace(GlobalConstants.API_INTERNAL, ConfigManager.getSunBirdBaseURL()); - testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$SUNBIRDBASEURL$", "")); - } - - response = deleteWithPathParamAndCookie(tempUrl + testCaseDTO.getEndPoint(), - getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate()), COOKIENAME, - testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - - } else { - response = deleteWithPathParamAndCookie(ApplnURI + testCaseDTO.getEndPoint(), - getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate()), COOKIENAME, - testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - } - Map> ouputValid = OutputValidationUtil.doJsonOutputValidation( - response.asString(), getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate()), - testCaseDTO, response.getStatusCode()); - Reporter.log(ReportUtil.getOutputValidationReport(ouputValid)); - if (!OutputValidationUtil.publishOutputResult(ouputValid)) - throw new AdminTestException("Failed at output validation"); - } - } - - /** - * The method ser current test name to result - * - * @param result - */ - @AfterMethod(alwaysRun = true) - public void setResultTestName(ITestResult result) { - try { - Field method = TestResult.class.getDeclaredField("m_method"); - method.setAccessible(true); - method.set(result, result.getMethod().clone()); - BaseTestMethod baseTestMethod = (BaseTestMethod) result.getMethod(); - Field f = baseTestMethod.getClass().getSuperclass().getDeclaredField("m_methodName"); - f.setAccessible(true); - f.set(baseTestMethod, testCaseName); - } catch (Exception e) { - Reporter.log("Exception : " + e.getMessage()); - } - } -} \ No newline at end of file diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/EsignetBioAuth.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/EsignetBioAuth.java deleted file mode 100644 index 0b242c69..00000000 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/EsignetBioAuth.java +++ /dev/null @@ -1,228 +0,0 @@ -package io.mosip.testrig.apirig.signup.testscripts; - -import java.lang.reflect.Field; -import java.util.Base64; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.json.JSONArray; -import org.json.JSONObject; -import org.testng.ITest; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.Reporter; -import org.testng.SkipException; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.internal.BaseTestMethod; -import org.testng.internal.TestResult; - -import io.mosip.testrig.apirig.dto.OutputValidationDto; -import io.mosip.testrig.apirig.dto.TestCaseDTO; -import io.mosip.testrig.apirig.signup.utils.SignupConfigManager; -import io.mosip.testrig.apirig.signup.utils.SignupUtil; -import io.mosip.testrig.apirig.testrunner.BaseTestCase; -import io.mosip.testrig.apirig.testrunner.HealthChecker; -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.BioDataUtility; -import io.mosip.testrig.apirig.utils.GlobalConstants; -import io.mosip.testrig.apirig.utils.OutputValidationUtil; -import io.mosip.testrig.apirig.utils.ReportUtil; -import io.restassured.response.Response; - -public class EsignetBioAuth extends AdminTestUtil implements ITest { - private static final Logger logger = Logger.getLogger(EsignetBioAuth.class); - protected String testCaseName = ""; - public Response response = null; - public boolean isInternal = false; - - private BioDataUtility bioDataUtil = new BioDataUtility(); - - @BeforeClass - public static void setLogLevel() { - if (SignupConfigManager.IsDebugEnabled()) - logger.setLevel(Level.ALL); - else - logger.setLevel(Level.ERROR); - } - - /** - * get current testcaseName - */ - @Override - public String getTestName() { - return testCaseName; - } - - /** - * Data provider class provides test case list - * - * @return object of data provider - */ - @DataProvider(name = "testcaselist") - public Object[] getTestCaseList(ITestContext context) { - String ymlFile = context.getCurrentXmlTest().getLocalParameters().get("ymlFile"); - isInternal = Boolean.parseBoolean(context.getCurrentXmlTest().getLocalParameters().get("isInternal")); - logger.info("Started executing yml: " + ymlFile); - return getYmlTestData(ymlFile); - } - - /** - * Test method for OTP Generation execution - * - * @param objTestParameters - * @param testScenario - * @param testcaseName - * @throws AuthenticationTestException - * @throws AdminTestException - */ - @Test(dataProvider = "testcaselist") - public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException { - testCaseName = testCaseDTO.getTestCaseName(); - testCaseName = SignupUtil.isTestCaseValidForExecution(testCaseDTO); - testCaseName = isTestCaseValidForExecution(testCaseDTO); - if (HealthChecker.signalTerminateExecution) { - throw new SkipException( - GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS); - } - - if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) { - if (!BaseTestCase.getSupportedIdTypesValue().contains("UIN") - && !BaseTestCase.getSupportedIdTypesValue().contains("uin")) { - throw new SkipException(GlobalConstants.UIN_FEATURE_NOT_SUPPORTED); - } - } - - if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) { - if (!BaseTestCase.getSupportedIdTypesValue().contains("VID") - && !BaseTestCase.getSupportedIdTypesValue().contains("vid")) { - throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED); - } - } - testCaseName = isTestCaseValidForExecution(testCaseDTO); - - JSONObject request = new JSONObject(testCaseDTO.getInput()); - String identityRequest = null; - String identityRequestTemplate = null; - String identityRequestEncUrl = null; - if (request.has(GlobalConstants.IDENTITYREQUEST)) { - identityRequest = request.get(GlobalConstants.IDENTITYREQUEST).toString(); - request.remove(GlobalConstants.IDENTITYREQUEST); - } - identityRequest = buildIdentityRequest(identityRequest); - identityRequest = inputJsonKeyWordHandeler(identityRequest, testCaseName); - - JSONObject identityReqJson = new JSONObject(identityRequest); - identityRequestTemplate = identityReqJson.getString("identityRequestTemplate"); - identityReqJson.remove("identityRequestTemplate"); - identityRequestEncUrl = identityReqJson.getString("identityRequestEncUrl"); - identityReqJson.remove("identityRequestEncUrl"); - - if (identityReqJson.has("transactionId")) { - String oidcTransactionId = AdminTestUtil.getAuthTransactionId(identityReqJson.getString("transactionId")); - if (oidcTransactionId != null && !oidcTransactionId.isBlank()) - identityReqJson.put("transactionId", oidcTransactionId); - } - - identityRequest = getJsonFromTemplate(identityReqJson.toString(), identityRequestTemplate); - if (identityRequest.contains("$DOMAINURI$")) { - String domainUrl = ApplnURI.replace("api-internal", GlobalConstants.ESIGNET); - identityRequest = identityRequest.replace("$DOMAINURI$", domainUrl); - } - String encryptedIdentityReq = null; - try { - encryptedIdentityReq = bioDataUtil.constractBioIdentityRequest(identityRequest, - getResourcePath() + properties.getProperty("bioValueEncryptionTemplate"), testCaseName, isInternal); - - if (encryptedIdentityReq == null) - throw new AdminTestException("bioDataUtil.constractBioIdentityRequest is null"); - - JSONObject encryptedIdentityReqObject = new JSONObject(encryptedIdentityReq); - - logger.info(encryptedIdentityReqObject); - JSONArray arrayBiometrics = encryptedIdentityReqObject.getJSONArray(GlobalConstants.BIOMETRICS); - - String bioData = arrayBiometrics.toString(); - logger.info(bioData); - - byte[] byteBioData = bioData.getBytes(); - - String challengeValue = Base64.getUrlEncoder().encodeToString(byteBioData); - logger.info(challengeValue); - - String authRequest = getJsonFromTemplate(request.toString(), testCaseDTO.getInputTemplate()); - - if (authRequest.contains("$CHALLENGE$")) { - authRequest = authRequest.replace("$CHALLENGE$", challengeValue); - } - if (testCaseName.contains("ESignet_")) { - String tempUrl = SignupConfigManager.getEsignetBaseUrl(); - response = postRequestWithCookieAuthHeaderAndXsrfToken(tempUrl + testCaseDTO.getEndPoint(), authRequest, - COOKIENAME, testCaseDTO.getTestCaseName()); - - } else { - response = postWithBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(), authRequest, COOKIENAME, - testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - } - String ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate()); - - if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) { - if (BaseTestCase.getSupportedIdTypesValue().contains("UIN") - || BaseTestCase.getSupportedIdTypesValue().contains("uin")) { - ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate()); - } else { - ActualOPJson = AdminTestUtil.getRequestJson("config/errorUINIdp.json").toString(); - } - } else { - if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) { - if (BaseTestCase.getSupportedIdTypesValue().contains("VID") - || BaseTestCase.getSupportedIdTypesValue().contains("vid")) { - ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate()); - } else { - ActualOPJson = AdminTestUtil.getRequestJson("config/errorUINIdp.json").toString(); - } - } - } - - Map> ouputValid = OutputValidationUtil - .doJsonOutputValidation(response.asString(), ActualOPJson, testCaseDTO, response.getStatusCode()); - Reporter.log(ReportUtil.getOutputValidationReport(ouputValid)); - - if (!OutputValidationUtil.publishOutputResult(ouputValid)) - throw new AdminTestException("Failed at output validation"); - } catch (SkipException e) { - throw new SkipException(e.getMessage()); - } catch (Exception e) { - throw new AdminTestException(e.getMessage()); - } - - } - - /** - * The method ser current test name to result - * - * @param result - */ - @AfterMethod(alwaysRun = true) - public void setResultTestName(ITestResult result) { - try { - Field method = TestResult.class.getDeclaredField("m_method"); - method.setAccessible(true); - method.set(result, result.getMethod().clone()); - BaseTestMethod baseTestMethod = (BaseTestMethod) result.getMethod(); - Field f = baseTestMethod.getClass().getSuperclass().getDeclaredField("m_methodName"); - f.setAccessible(true); - f.set(baseTestMethod, testCaseName); - } catch (Exception e) { - Reporter.log("Exception : " + e.getMessage()); - } - - } - -} diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithParam.java index d47ce4ca..bc286519 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithParam.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithParam.java @@ -84,7 +84,6 @@ public Object[] getTestCaseList(ITestContext context) { public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException { testCaseName = testCaseDTO.getTestCaseName(); testCaseName = SignupUtil.isTestCaseValidForExecution(testCaseDTO); - testCaseName = isTestCaseValidForExecution(testCaseDTO); if (HealthChecker.signalTerminateExecution) { throw new SkipException( GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithQueryParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithQueryParam.java deleted file mode 100644 index 346ae93b..00000000 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/GetWithQueryParam.java +++ /dev/null @@ -1,170 +0,0 @@ -package io.mosip.testrig.apirig.signup.testscripts; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.json.JSONObject; -import org.testng.ITest; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.Reporter; -import org.testng.SkipException; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.testng.internal.BaseTestMethod; -import org.testng.internal.TestResult; - -import io.mosip.testrig.apirig.dto.OutputValidationDto; -import io.mosip.testrig.apirig.dto.TestCaseDTO; -import io.mosip.testrig.apirig.signup.utils.SignupConfigManager; -import io.mosip.testrig.apirig.signup.utils.SignupUtil; -import io.mosip.testrig.apirig.testrunner.BaseTestCase; -import io.mosip.testrig.apirig.testrunner.HealthChecker; -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.GlobalConstants; -import io.mosip.testrig.apirig.utils.OutputValidationUtil; -import io.mosip.testrig.apirig.utils.ReportUtil; -import io.restassured.response.Response; - -public class GetWithQueryParam extends AdminTestUtil implements ITest { - private static final Logger logger = Logger.getLogger(GetWithQueryParam.class); - protected String testCaseName = ""; - public Response response = null; - - @BeforeClass - public static void setLogLevel() { - if (SignupConfigManager.IsDebugEnabled()) - logger.setLevel(Level.ALL); - else - logger.setLevel(Level.ERROR); - } - - /** - * get current testcaseName - */ - @Override - public String getTestName() { - return testCaseName; - } - - /** - * Data provider class provides test case list - * - * @return object of data provider - */ - @DataProvider(name = "testcaselist") - public Object[] getTestCaseList(ITestContext context) { - String ymlFile = context.getCurrentXmlTest().getLocalParameters().get("ymlFile"); - logger.info("Started executing yml: " + ymlFile); - return getYmlTestData(ymlFile); - } - - /** - * Test method for OTP Generation execution - * - * @param objTestParameters - * @param testScenario - * @param testcaseName - * @throws AuthenticationTestException - * @throws AdminTestException - */ - @Test(dataProvider = "testcaselist") - public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException { - testCaseName = testCaseDTO.getTestCaseName(); - testCaseName = SignupUtil.isTestCaseValidForExecution(testCaseDTO); - if (HealthChecker.signalTerminateExecution) { - throw new SkipException( - GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS); - } - if (SignupConfigManager.isInServiceNotDeployedList(GlobalConstants.ADMIN) && testCaseName.contains("BulkUpload_")) { - throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE); - } - - if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) { - if (!BaseTestCase.getSupportedIdTypesValue().contains("VID") - && !BaseTestCase.getSupportedIdTypesValue().contains("vid")) { - throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED); - } - } - - String[] templateFields = testCaseDTO.getTemplateFields(); - - if (testCaseDTO.getTemplateFields() != null && templateFields.length > 0) { - ArrayList inputtestCases = AdminTestUtil.getInputTestCase(testCaseDTO); - ArrayList outputtestcase = AdminTestUtil.getOutputTestCase(testCaseDTO); - for (int i = 0; i < languageList.size(); i++) { - response = getWithQueryParamAndCookie(ApplnURI + testCaseDTO.getEndPoint(), - getJsonFromTemplate(inputtestCases.get(i).toString(), testCaseDTO.getInputTemplate()), - COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - - Map> ouputValid = OutputValidationUtil.doJsonOutputValidation( - response.asString(), - getJsonFromTemplate(outputtestcase.get(i).toString(), testCaseDTO.getOutputTemplate()), - testCaseDTO, response.getStatusCode()); - Reporter.log(ReportUtil.getOutputValidationReport(ouputValid)); - - if (!OutputValidationUtil.publishOutputResult(ouputValid)) - throw new AdminTestException("Failed at output validation"); - } - } - - else { - if (testCaseName.contains("ESignet_")) { - String tempUrl = SignupConfigManager.getEsignetBaseUrl(); - response = getWithQueryParamAndCookie(tempUrl + testCaseDTO.getEndPoint(), - getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate()), COOKIENAME, - testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - } else { - response = getWithQueryParamAndCookie(ApplnURI + testCaseDTO.getEndPoint(), - getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate()), COOKIENAME, - testCaseDTO.getRole(), testCaseDTO.getTestCaseName()); - } - 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(), - getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate()), testCaseDTO, - response.getStatusCode()); - } - - Reporter.log(ReportUtil.getOutputValidationReport(ouputValid)); - if (!OutputValidationUtil.publishOutputResult(ouputValid)) - throw new AdminTestException("Failed at output validation"); - } - } - - /** - * The method ser current test name to result - * - * @param result - */ - @AfterMethod(alwaysRun = true) - public void setResultTestName(ITestResult result) { - try { - Field method = TestResult.class.getDeclaredField("m_method"); - method.setAccessible(true); - method.set(result, result.getMethod().clone()); - BaseTestMethod baseTestMethod = (BaseTestMethod) result.getMethod(); - Field f = baseTestMethod.getClass().getSuperclass().getDeclaredField("m_methodName"); - f.setAccessible(true); - f.set(baseTestMethod, testCaseName); - } catch (Exception e) { - Reporter.log("Exception : " + e.getMessage()); - } - } -} diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithAutogenIdWithOtpGenerate.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithAutogenIdWithOtpGenerate.java index ef71d5ff..3cf429f5 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithAutogenIdWithOtpGenerate.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithAutogenIdWithOtpGenerate.java @@ -103,8 +103,6 @@ public void test(TestCaseDTO testCaseDTO) throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED); } } - testCaseName = isTestCaseValidForExecution(testCaseDTO); - String inputJson = testCaseDTO.getInput().toString(); JSONObject req = new JSONObject(testCaseDTO.getInput()); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithBodyWithOtpGenerate.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithBodyWithOtpGenerate.java index 4cc5a201..d88b0316 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithBodyWithOtpGenerate.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithBodyWithOtpGenerate.java @@ -93,7 +93,6 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad } } - testCaseName = isTestCaseValidForExecution(testCaseDTO); auditLogCheck = testCaseDTO.isAuditLogCheck(); String tempUrl = SignupConfigManager.getEsignetBaseUrl(); JSONObject req = new JSONObject(testCaseDTO.getInput()); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithOnlyPathParam.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithOnlyPathParam.java index f6791999..d1f403b8 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithOnlyPathParam.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/PostWithOnlyPathParam.java @@ -83,7 +83,6 @@ public Object[] getTestCaseList(ITestContext context) { public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException { testCaseName = testCaseDTO.getTestCaseName(); testCaseName = SignupUtil.isTestCaseValidForExecution(testCaseDTO); - testCaseName = isTestCaseValidForExecution(testCaseDTO); String[] templateFields = testCaseDTO.getTemplateFields(); if (HealthChecker.signalTerminateExecution) { throw new SkipException( diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePost.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePost.java index 51c13850..a387c8f2 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePost.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePost.java @@ -84,7 +84,6 @@ public Object[] getTestCaseList(ITestContext context) { public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException { testCaseName = testCaseDTO.getTestCaseName(); testCaseName = SignupUtil.isTestCaseValidForExecution(testCaseDTO); - testCaseName = isTestCaseValidForExecution(testCaseDTO); auditLogCheck = testCaseDTO.isAuditLogCheck(); String[] templateFields = testCaseDTO.getTemplateFields(); if (HealthChecker.signalTerminateExecution) { diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenId.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenId.java index f045a246..b73578d2 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenId.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenId.java @@ -99,8 +99,6 @@ public void test(TestCaseDTO testCaseDTO) throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED); } } - - testCaseName = isTestCaseValidForExecution(testCaseDTO); String[] templateFields = testCaseDTO.getTemplateFields(); String inputJson = ""; diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenIdForUrlEncoded.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenIdForUrlEncoded.java index bd620bb7..1160d033 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenIdForUrlEncoded.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/testscripts/SimplePostForAutoGenIdForUrlEncoded.java @@ -111,7 +111,6 @@ public void test(TestCaseDTO testCaseDTO) if (SignupConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET)) { throw new SkipException("esignet is not deployed hence skipping the testcase"); } - testCaseName = isTestCaseValidForExecution(testCaseDTO); String[] templateFields = testCaseDTO.getTemplateFields(); String inputJson = getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate()); diff --git a/api-test/src/main/java/io/mosip/testrig/apirig/signup/utils/SignupUtil.java b/api-test/src/main/java/io/mosip/testrig/apirig/signup/utils/SignupUtil.java index f43cb0e4..05cc2d37 100644 --- a/api-test/src/main/java/io/mosip/testrig/apirig/signup/utils/SignupUtil.java +++ b/api-test/src/main/java/io/mosip/testrig/apirig/signup/utils/SignupUtil.java @@ -3,6 +3,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import javax.ws.rs.core.MediaType; @@ -235,4 +237,73 @@ public static String otpHandler(String inputJson, String testCaseName) { return inputJson; } + public static JSONArray signupActuatorResponseArray = null; + + public static String getValueFromSignupActuator(String section, String key) { + String url = SignupConfigManager.getSignupBaseUrl() + SignupConfigManager.getproperty("actuatorSignupEndpoint"); + String actuatorCacheKey = url + section + key; + String value = actuatorValueCache.get(actuatorCacheKey); + if (value != null && !value.isEmpty()) + return value; + + try { + if (signupActuatorResponseArray == null) { + Response response = null; + JSONObject responseJson = null; + response = RestClient.getRequest(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); + responseJson = new JSONObject(response.getBody().asString()); + signupActuatorResponseArray = responseJson.getJSONArray("propertySources"); + } + + for (int i = 0, size = signupActuatorResponseArray.length(); i < size; i++) { + JSONObject eachJson = signupActuatorResponseArray.getJSONObject(i); + if (eachJson.get("name").toString().contains(section)) { + logger.info(eachJson.getJSONObject(GlobalConstants.PROPERTIES)); + value = eachJson.getJSONObject(GlobalConstants.PROPERTIES).getJSONObject(key) + .get(GlobalConstants.VALUE).toString(); + if (SignupConfigManager.IsDebugEnabled()) + logger.info("Actuator: " + url + " key: " + key + " value: " + value); + break; + } + } + actuatorValueCache.put(actuatorCacheKey, value); + + return value; + } catch (Exception e) { + logger.error(GlobalConstants.EXCEPTION_STRING_2 + e); + return value; + } + + } + + public static void getSupportedLanguage() { + String supportedLanguages = getValueFromSignupActuator("systemEnvironment", + "MOSIP_SIGNUP_SUPPORTED_LANGUAGES"); + + if (supportedLanguages == null || supportedLanguages.isBlank() == true) { + supportedLanguages = getValueFromSignupActuator("classpath:/application-default.properties", + "mosip.signup.supported-languages"); + } + + if (supportedLanguages != null && supportedLanguages.isBlank() == false) { + supportedLanguages = supportedLanguages.replace("{", "").replace("}", "").replace("'", ""); + + // Split the string by commas + String[] languages = supportedLanguages.split(","); + + // Use a TreeSet to sort the languages + Set sortedLanguages = new TreeSet<>(); + for (String language : languages) { + sortedLanguages.add(language.trim()); // Trim to remove any extra spaces + } + + // Add sorted languages to the languageList + BaseTestCase.languageList.addAll(sortedLanguages); + + logger.info("languageList " + BaseTestCase.languageList); + } else { + logger.error("Language not found"); + } + } + } \ No newline at end of file diff --git a/api-test/src/main/resources/config/signup.properties b/api-test/src/main/resources/config/signup.properties index 7831bfdb..34229cd4 100644 --- a/api-test/src/main/resources/config/signup.properties +++ b/api-test/src/main/resources/config/signup.properties @@ -1,5 +1,6 @@ #---------------------------------- End point(s) relative URLs ----------------------------------# actuatorEsignetEndpoint=/v1/esignet/actuator/env +actuatorSignupEndpoint=/v1/signup/actuator/env tokenEndpoint=/v1/esignet/oauth/token validateBindingEndpoint=ida-binding esignetWellKnownEndPoint=/v1/esignet/oidc/.well-known/openid-configuration