Skip to content

Commit

Permalink
Merge pull request #1227 from nandhu-kumar/camdgc-develop
Browse files Browse the repository at this point in the history
MOSIP-30525
  • Loading branch information
lsivanand authored Dec 1, 2023
2 parents f28fd00 + 886ba9f commit 5ffdeef
Show file tree
Hide file tree
Showing 59 changed files with 150 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,29 +510,40 @@ else if (!checkErrorsOnlyInResponse)
}

public static boolean doesResponseHasErrors(String responseString) {
JSONObject responseJson = new JSONObject(responseString);
boolean breturn = false;
JSONArray errors = null;
String error = null;
if (responseJson.has("errors")) {
errors = responseJson.optJSONArray("errors");
} else if (responseJson.has("error")) {
error = responseJson.getString("error");
try {
JSONObject responseJson = new JSONObject(responseString);
JSONArray errors = null;
String error = null;
if (responseJson.has("errors")) {
errors = responseJson.optJSONArray("errors");
}
else if (responseJson.has("error")) {
error = responseJson.getString("error");
}

if (errors != null)
breturn = (errors.length() > 0);
else if (error != null)
breturn = true;

} catch (JSONException e) {
OUTPUTVALIDATION_LOGGER.error("Invalid JSON response: " + responseString);
}
if (errors != null)
breturn = (errors.length() > 0);
else if (error != null)
breturn = true;


return breturn;
}

public static boolean doesResponseHasErrorCode(String responseString, int errorCode) {
JSONObject responseJson = new JSONObject(responseString);
if (responseJson.has("status")) {
return responseJson.getInt("status") == errorCode;
try {
JSONObject responseJson = new JSONObject(responseString);
if (responseJson.has("status")) {
return responseJson.getInt("status") == errorCode;
}
} catch (JSONException e) {
OUTPUTVALIDATION_LOGGER.error("Invalid JSON response: " + responseString);
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public class GlobalConstants {
public static final String EXPECTED_VS_ACTUAL = "EXPECTED vs ACTUAL";
public static final String RID_GENERATOR = "ridgenerator";
public static final String VID_FEATURE_NOT_SUPPORTED = "VID feature not supported. Hence skipping the testcase";
public static final String UIN_FEATURE_NOT_SUPPORTED = "UIN feature not supported. Hence skipping the testcase";
public static final String FEATURE_NOT_SUPPORTED = "feature not supported";
public static final String SKIPPED = "Skipped";
public static final String TARGET_ENV_HEALTH_CHECK_FAILED = GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.mosip.testrig.apirig.authentication.fw.util.OutputValidationUtil;
import io.mosip.testrig.apirig.authentication.fw.util.ReportUtil;
import io.mosip.testrig.apirig.authentication.fw.util.RestClient;
import io.mosip.testrig.apirig.global.utils.GlobalConstants;
import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.apirig.kernel.util.KernelAuthentication;
import io.mosip.testrig.apirig.kernel.util.KeycloakUserManager;
Expand Down Expand Up @@ -89,7 +90,7 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
testCaseDTO.setInputTemplate(AdminTestUtil.modifySchemaGenerateHbs(testCaseDTO.isRegenerateHbs()));
String uin = JsonPrecondtion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
String[] templateFields = testCaseDTO.getTemplateFields();
List<String> queryProp = Arrays.asList(templateFields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
String[] kycFields = testCaseDTO.getKycFields();

if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
throw new SkipException("Idtype UIN is not supported. Hence skipping the testcase");
throw new SkipException(GlobalConstants.UIN_FEATURE_NOT_SUPPORTED);
}
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down Expand Up @@ -166,7 +166,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad

}
} else {
if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
|| BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
if (testCaseDTO.getEndPoint().contains("$partnerKeyURL$")) {
testCaseDTO.setEndPoint(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.mosip.testrig.apirig.authentication.fw.util.OutputValidationUtil;
import io.mosip.testrig.apirig.authentication.fw.util.ReportUtil;
import io.mosip.testrig.apirig.authentication.fw.util.RestClient;
import io.mosip.testrig.apirig.global.utils.GlobalConstants;
import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.apirig.kernel.util.KernelAuthentication;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
String timeSlotTo = null;
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
Response slotAvailabilityResponse = RestClient.getRequestWithCookie(
ApplnURI + properties.getProperty("appointmentavailabilityurl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.mosip.testrig.apirig.authentication.fw.util.AuthenticationTestException;
import io.mosip.testrig.apirig.authentication.fw.util.OutputValidationUtil;
import io.mosip.testrig.apirig.authentication.fw.util.ReportUtil;
import io.mosip.testrig.apirig.global.utils.GlobalConstants;
import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.apirig.service.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void test(TestCaseDTO testCaseDTO)
throws AuthenticationTestException, AdminTestException, NoSuchAlgorithmException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
testCaseDTO.setInputTemplate(AdminTestUtil.generateHbsForPrereg(false));
String[] templateFields = testCaseDTO.getTemplateFields();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

String inputJson = getJsonFromTemplate(testCaseDTO.getInput(), testCaseDTO.getInputTemplate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}
if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ public Object[] getTestCaseList(ITestContext context) {
public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
throw new SkipException("Idtype UIN is not supported. Hence skipping the testcase");
throw new SkipException(GlobalConstants.UIN_FEATURE_NOT_SUPPORTED);
}
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down Expand Up @@ -149,7 +149,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
ActualOPJson = AdminTestUtil.getRequestJson("config/errorUIN.json").toString();
}
} else {
if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
|| BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ public void test(TestCaseDTO testCaseDTO)
testCaseName = testCaseDTO.getTestCaseName();
String[] kycFields = testCaseDTO.getKycFields();
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
throw new SkipException("Idtype UIN is not supported. Hence skipping the testcase");
throw new SkipException(GlobalConstants.UIN_FEATURE_NOT_SUPPORTED);
}
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down Expand Up @@ -221,7 +221,7 @@ public void test(TestCaseDTO testCaseDTO)

}
} else {
if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
|| BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
throw new SkipException("Idtype UIN is not supported. Hence skipping the testcase");
throw new SkipException(GlobalConstants.UIN_FEATURE_NOT_SUPPORTED);
}
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down Expand Up @@ -167,7 +167,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
ActualOPJson = AdminTestUtil.getRequestJson("config/errorUINIdp.json").toString();
}
} else {
if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
|| BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
testCaseName = testCaseDTO.getTestCaseName();
testCaseName = isTestCaseValidForExecution(testCaseDTO);
if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public void test(TestCaseDTO testCaseDTO) throws AdminTestException {
testCaseName = testCaseDTO.getTestCaseName();

if (HealthChecker.signalTerminateExecution) {
throw new SkipException("Target env health check failed " + HealthChecker.healthCheckFailureMapS);
throw new SkipException(GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
}

if (testCaseDTO.getTestCaseName().contains("vid") || testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
&& !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
Expand Down
Loading

0 comments on commit 5ffdeef

Please sign in to comment.