Skip to content

Commit

Permalink
Merge pull request #1669 from Sohandey/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mohanachandran-s authored Nov 14, 2024
2 parents 3337898 + 596e9cb commit 179be27
Showing 1 changed file with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.testrig.apirig.utils;

import static io.restassured.RestAssured.given;
import static org.mockito.ArgumentMatchers.contains;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
Expand Down Expand Up @@ -141,7 +142,7 @@ public class AdminTestUtil extends BaseTestCase {
+ "config/healthCheckEndpoint.properties";
private static String serverComponentsCommitDetails;
private static boolean foundHandlesInIdSchema= false;

private static JSONArray globalRequiredFields = null;
protected static String token = null;
String idToken = null;
String adminAutoGeneratedIdPropFileName = properties.getProperty("adminAutoGeneratedIdPropFileName");
Expand Down Expand Up @@ -7083,6 +7084,9 @@ public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {

JSONArray dobArray = new JSONArray(getValueFromAuthActuator("json-property", "dob"));
JSONArray emailArray = new JSONArray(getValueFromAuthActuator("json-property", "emailId"));
JSONArray phoneArray = new JSONArray(getValueFromAuthActuator("json-property", "phone_number"));
JSONArray postalCodeArray = new JSONArray(getValueFromAuthActuator("json-property", "postal_code"));

JSONArray individualBiometricsArray = new JSONArray(
getValueFromAuthActuator("json-property", "individualBiometrics"));
String dob = dobArray.getString(0);
Expand All @@ -7099,6 +7103,22 @@ public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

if (testCaseName.startsWith("IdRepository_") &&
(testCaseName.contains("_withInvalidEmail") ||
testCaseName.contains("_with_invalid_Email") ||
testCaseName.contains("_with_Missing_Email") ||
testCaseName.contains("_with_Empty_Email") ||
testCaseName.contains("_with_SpaceVal_Email")) &&
(globalRequiredFields != null && !globalRequiredFields.toList().contains(emailArray))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

if (testCaseName.startsWith("IdRepository_") &&
testCaseName.contains("_with_Missing_phone") &&
(globalRequiredFields != null && !globalRequiredFields.toList().contains(phoneArray))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}



else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Email")
Expand Down Expand Up @@ -7134,7 +7154,14 @@ else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Inva
&& (ConfigManager.isInServiceNotDeployedList(GlobalConstants.HOTLIST))) {
throw new SkipException(GlobalConstants.SERVICE_NOT_DEPLOYED_MESSAGE);
}

}
else if (testCaseName.startsWith("Prereg_")
&& (testCaseName.contains("_Invalid_PostalCode_")
|| testCaseName.contains("_SpacialCharacter_PostalCode_"))
&& (globalRequiredFields != null && !globalRequiredFields.toList().contains(postalCodeArray))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

// else if (BaseTestCase.currentModule.equalsIgnoreCase(GlobalConstants.ESIGNET)) {
// if ((testCaseName.startsWith("Esignet_") || testCaseName.startsWith("ESignet_"))
Expand Down Expand Up @@ -8695,6 +8722,38 @@ public static boolean isHandlesAvailableInIdSchema(boolean foundHandles) {
// }
// return false;
// }


public static JSONArray getRequiredField() {



JSONObject requestJson = new JSONObject();
kernelAuthLib = new KernelAuthentication();
String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN);
String url = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);

Response response = RestClient.getRequestWithCookie(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON,
GlobalConstants.AUTHORIZATION, token);

org.json.JSONObject responseJson = new org.json.JSONObject(response.asString());
org.json.JSONObject schemaData = (org.json.JSONObject) responseJson.get(GlobalConstants.RESPONSE);

Double schemaVersion = ((BigDecimal) schemaData.get(GlobalConstants.ID_VERSION)).doubleValue();
idSchemaVersion = ((BigDecimal) schemaData.get(GlobalConstants.ID_VERSION)).doubleValue();
String schemaJsonData = schemaData.getString(GlobalConstants.SCHEMA_JSON);

String schemaFile = schemaJsonData;

JSONObject schemaFileJson = new JSONObject(schemaFile);
JSONObject schemaPropsJson = schemaFileJson.getJSONObject("properties");
JSONObject schemaIdentityJson = schemaPropsJson.getJSONObject("identity");
globalRequiredFields = schemaIdentityJson.getJSONArray("required");

return globalRequiredFields;

}

}


0 comments on commit 179be27

Please sign in to comment.