Skip to content

Commit

Permalink
Merge branch 'mosip:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohanraj209 authored Oct 7, 2024
2 parents 3d43a15 + 68d6235 commit bea7e66
Show file tree
Hide file tree
Showing 210 changed files with 278 additions and 192 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
build-maven-apitest-prereg:
uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21
with:
SERVICE_LOCATION: ./apitest
SERVICE_LOCATION: ./api-test
BUILD_ARTIFACT: apitest-prereg
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
Expand All @@ -110,7 +110,7 @@ jobs:
needs: build-maven-apitest-prereg
uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21
with:
SERVICE_LOCATION: ./apitest
SERVICE_LOCATION: ./api-test
secrets:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }}
Expand All @@ -125,7 +125,7 @@ jobs:
env:
NAMESPACE: ${{ secrets.dev_namespace_docker_hub }}
SERVICE_NAME: apitest-prereg
SERVICE_LOCATION: apitest
SERVICE_LOCATION: api-test
BUILD_ARTIFACT: apitest-prereg-local
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
strategy:
matrix:
include:
- SERVICE_LOCATION: 'apitest'
- SERVICE_LOCATION: 'api-test'
SERVICE_NAME: 'apitest-prereg'
BUILD_ARTIFACT: 'apitest-prereg-local'
ONLY_DOCKER: true
Expand All @@ -193,7 +193,7 @@ jobs:
if: "${{ github.event_name != 'pull_request' }}"
uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21
with:
SERVICE_LOCATION: ./apitest
SERVICE_LOCATION: ./api-test
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
ORG_KEY: ${{ secrets.ORG_KEY }}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion apitest/Dockerfile → api-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ WORKDIR /home/${container_user}
ENV work_dir=/home/${container_user}

# Combine all necessary files into a single COPY command
COPY ./apitest/target $work_dir/
COPY ./api-test/target $work_dir/
COPY entrypoint.sh $work_dir

# install packages and create user
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
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;

/**
* Class to initiate mosip api test execution
Expand Down Expand Up @@ -62,14 +64,17 @@ 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();
BaseTestCase.suiteSetup(getRunType());
SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt");
setLogLevels();


Expand All @@ -91,7 +96,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 @@ -122,7 +127,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 All @@ -145,34 +150,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))
Expand All @@ -189,15 +175,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() {
Expand Down Expand Up @@ -291,7 +268,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 @@ -28,10 +28,11 @@
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;
import io.restassured.response.Response;
Expand All @@ -43,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);
Expand Down Expand Up @@ -81,6 +82,7 @@ public Object[] getTestCaseList(ITestContext context) {
*/
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
String regCenterId = null;
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
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;
import io.restassured.response.Response;
Expand All @@ -42,7 +44,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);
Expand Down Expand Up @@ -84,6 +86,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
String timeSlotFrom = null;
String timeSlotTo = null;
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -31,6 +32,8 @@
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;

Expand All @@ -42,7 +45,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);
Expand Down Expand Up @@ -83,6 +86,7 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO)
throws AuthenticationTestException, AdminTestException, NoSuchAlgorithmException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
Expand Down Expand Up @@ -117,8 +121,18 @@ public void test(TestCaseDTO testCaseDTO)
} else {
response = postWithBodyAndCookieForAutoGeneratedId(ApplnURI + testCaseDTO.getEndPoint(), inputJson,
COOKIENAME, testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), idKeyName);
Map<String, List<OutputValidationDto>> ouputValid = OutputValidationUtil
.doJsonOutputValidation(response.asString(), outputJson, testCaseDTO, response.getStatusCode());
Map<String, List<OutputValidationDto>> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
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;

Expand All @@ -39,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);
Expand Down Expand Up @@ -75,6 +77,7 @@ public Object[] getTestCaseList(ITestContext context) {
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
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;

Expand All @@ -40,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);
Expand Down Expand Up @@ -78,6 +80,7 @@ public Object[] getTestCaseList(ITestContext context) {
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
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;

Expand All @@ -41,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);
Expand Down Expand Up @@ -80,6 +82,7 @@ public Object[] getTestCaseList(ITestContext context) {
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
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;

Expand All @@ -38,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);
Expand Down Expand Up @@ -77,6 +79,7 @@ public Object[] getTestCaseList(ITestContext context) {
@Test(dataProvider = "testcaselist")
public void test(TestCaseDTO testCaseDTO) throws AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = PreRegUtil.isTestCaseValidForExecution(testCaseDTO);
String inputJson = getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate());
testCaseDTO = AdminTestUtil.filterHbs(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
Expand Down
Loading

0 comments on commit bea7e66

Please sign in to comment.