Skip to content

Commit

Permalink
MOSIP-35390
Browse files Browse the repository at this point in the history
Signed-off-by: Sohan Kumar Dey <[email protected]>
  • Loading branch information
Sohandey committed Aug 28, 2024
1 parent adfaec2 commit 9f7f7ba
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public class AdminTestUtil extends BaseTestCase {
public static String propsHealthCheckURL = MosipTestRunner.getGlobalResourcePath() + "/"
+ "config/healthCheckEndpoint.properties";
private static String serverComponentsCommitDetails;
private static boolean foundHandlesInIdSchema= false;

protected static String token = null;
String idToken = null;
Expand Down Expand Up @@ -5139,6 +5140,7 @@ else if (eachPropDataJson.has("$ref") && eachPropDataJson.get("$ref").toString()
}
}
if (selectedHandles != null) {
setfoundHandlesInIdSchema(true);
identityJson.put("selectedHandles", selectedHandles);
}

Expand Down Expand Up @@ -6579,6 +6581,12 @@ public static String isTestCaseValidForExecution(TestCaseDTO testCaseDTO) {
&& (!isElementPresent(new JSONArray(schemaRequiredField), dob))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}

if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("_handle")) {
throw new SkipException(GlobalConstants.HANDLE_SCHEMA_NOT_DEPLOYED_MESSAGE);
}



else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Email")
&& (!isElementPresent(new JSONArray(schemaRequiredField), email))) {
Expand Down Expand Up @@ -6636,6 +6644,8 @@ else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Inva
&& BaseTestCase.currentModule.equalsIgnoreCase("resident") && testCaseName.contains("_SignJWT_")) {
throw new SkipException("esignet module is not deployed");
}



if ((ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET))
&& BaseTestCase.currentModule.equalsIgnoreCase("resident")
Expand Down Expand Up @@ -7439,7 +7449,7 @@ public String replaceArrayHandleValues(String inputJson, String testCaseName) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.remove("value");
}
} else if (testCaseName.endsWith("_withoutvalues")) {
} else if (testCaseName.endsWith("_withouttags")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.remove("tags");
Expand All @@ -7448,14 +7458,143 @@ public String replaceArrayHandleValues(String inputJson, String testCaseName) {
else if (testCaseName.endsWith("_withtagwithoutselectedhandles")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.remove("selectedHandles");
}
}
else if (testCaseName.endsWith("_withinvalidtag")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
JSONArray tags = handleObj.optJSONArray("tags");
if (tags != null) {
for (int k = 0; k < tags.length(); k++) {
String tag = tags.getString(k);
tags.put(k, tag + "_invalid"+ RANDOM_ID);
}
handleObj.put("tags", tags);
}
}
}


else if (testCaseName.endsWith("_withmultiplevalues")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
JSONArray valuesArray = new JSONArray();
valuesArray.put("mosip501724826584965_modified_1");
valuesArray.put("mosip501724826584965_modified_2");
valuesArray.put("mosip501724826584965_modified_3");
handleObj.put("values", valuesArray);

}
}

else if (testCaseName.endsWith("_withmultiplevaluesandwithouttags")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
JSONArray valuesArray = new JSONArray();
valuesArray.put("mosip501724826584965_modified_1");
valuesArray.put("mosip501724826584965_modified_2");
valuesArray.put("mosip501724826584965_modified_3");
handleObj.put("values", valuesArray);
handleObj.remove("tags");
}
}

else if (testCaseName.endsWith("_withemptyselecthandles")) {
identity.put("selectedHandles", new JSONArray());
}



else if (testCaseName.endsWith("_withoutselectedhandles")) {
identity.remove("selectedHandles");
break;
} else {
}

else if (testCaseName.endsWith("_withmultiplehandleswithoutvalue")) {
String phone = getValueFromAuthActuator("json-property", "phone_number");
String result = phone.replaceAll("\\[\"|\"\\]", "");
boolean containsPhone = false;
for (int j = 0; j < selectedHandles.length(); j++) {
if (result.equalsIgnoreCase(selectedHandles.getString(j))) {
containsPhone = true;
break;
}
}
if (!containsPhone) {
selectedHandles.put(result);
JSONObject phoneEntry = new JSONObject();
phoneEntry.put("value", "$PHONENUMBERFORIDENTITY$");
JSONArray phoneArray = new JSONArray();
phoneArray.put(phoneEntry);
identity.put(result, phoneArray);

}
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.remove("value");
}
}

// Jayesh TCs

else if (testCaseName.endsWith("_withfunctionalIds") && handle.equals("functionalId")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.remove("tags");
}
} else if (testCaseName.endsWith("_withfunctionalIdsUsedFirstTwoValue") && handle.equals("functionalId")) {
if (handleArray.length() < 3) {
JSONObject secondValue = new JSONObject();
secondValue.put("value", "RANDOM_ID_2" + 12);
secondValue.put("tags", new JSONArray().put("handle"));
JSONObject thirdValue = new JSONObject();
thirdValue.put("value", "RANDOM_ID_2" + 34);
handleArray.put(secondValue);
handleArray.put(thirdValue);
}
} else if (testCaseName.endsWith("_withfunctionalIdsandPhoneWithoutTags")) {
String phone = getValueFromAuthActuator("json-property", "phone_number");
String result = phone.replaceAll("\\[\"|\"\\]", "");
boolean containsPhone = false;
for (int j = 0; j < selectedHandles.length(); j++) {
if (result.equalsIgnoreCase(selectedHandles.getString(j))) {
containsPhone = true;
break;
}
}
if (!containsPhone) {
selectedHandles.put(result);
JSONObject phoneEntry = new JSONObject();
phoneEntry.put("value", "$PHONENUMBERFORIDENTITY$");
JSONArray phoneArray = new JSONArray();
phoneArray.put(phoneEntry);
identity.put(result, phoneArray);

}
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.remove("tags");
}
} else if (testCaseName.endsWith("_withfunctionalIdsUsedFirstTwoValueOutOfFive")) {
String baseValue = "";
if (handleArray.length() > 0) {
baseValue = handleArray.getJSONObject(0).getString("value");
}
for (int j = 0; j < 4; j++) {
JSONObject handleObj = new JSONObject();
if (j < 1) {
handleObj.put("value", baseValue + j);
handleObj.put("tags", new JSONArray().put("handle"));
} else {
handleObj.put("value", baseValue + j);
}
handleArray.put(handleObj);
}
}


else {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
handleObj.put("value", handleObj.getString("value") + "_modified");
Expand All @@ -7468,6 +7607,16 @@ else if (testCaseName.endsWith("_withoutselectedhandles")) {

return jsonObj.toString();
}

public static void setfoundHandlesInIdSchema(boolean foundHandles) {

foundHandlesInIdSchema=foundHandles;
}

public static boolean isHandlesAvailableInIdSchema(boolean foundHandles) {

return foundHandlesInIdSchema;
}


// public static boolean checkIsCertTrusted(String certIssuer, JSONArray ArrayOfJsonObjects, int recursiveCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public class GlobalConstants {
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_MESSAGE = "feature not supported. Hence skipping the testcase";
public static final String HANDLE_SCHEMA_NOT_DEPLOYED_MESSAGE = "ARRAY HANDLE Related Schema is not there Hence skipping the testcase";
public static final String VID_GENERATED_USING_RESIDENT_API_SO_FEATURE_NOT_SUPPORTED_OR_NEEDED_MESSAGE = "Generating VID using Resident API. So, this feature not supported/needed. Hence skipping the testcase";
public static final String SERVICE_NOT_DEPLOYED_MESSAGE = "Service not deployed. Hence skipping the testcase";
public static final String FEATURE_NOT_SUPPORTED = "feature not supported";
Expand Down

0 comments on commit 9f7f7ba

Please sign in to comment.