Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1669

Merged
merged 2 commits into from
Nov 14, 2024
Merged

Develop #1669

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

}

}


Loading