Skip to content

Commit

Permalink
MOSIP-35390
Browse files Browse the repository at this point in the history
Signed-off-by: Sohan Kumar Dey <72375959+Sohandey@users.noreply.github.com>
  • Loading branch information
Sohandey committed Sep 3, 2024
1 parent bd54664 commit 362f89f
Showing 1 changed file with 93 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5128,8 +5128,14 @@ else if (eachPropDataJson.has("$ref") && eachPropDataJson.get("$ref").toString()
identityJson.put(eachRequiredProp, genStringAsperRegex(
eachPropDataJson.getJSONArray("validators").getJSONObject(0).getString("validator")));
} else if (eachRequiredProp.equals(result)) {
if(eachPropDataJson.has("handle")){
selectedHandles.add(eachRequiredProp);
}
identityJson.put(eachRequiredProp, "$PHONENUMBERFORIDENTITY$");
} else if (eachRequiredProp.equals(emailResult)) {
if(eachPropDataJson.has("handle")){
selectedHandles.add(eachRequiredProp);
}
identityJson.put(eachRequiredProp, "$EMAILVALUE$");
}

Expand Down Expand Up @@ -5337,9 +5343,15 @@ else if (eachRequiredProp.equals("individualBiometrics")) {
identityJson.remove("individualBiometrics");
}
else if (eachRequiredProp.equals(emailResult)) {
if(eachPropDataJson.has("handle")){
selectedHandles.add(eachRequiredProp);
}
identityJson.put(eachRequiredProp, "$EMAILVALUE$");
}
else if (eachRequiredProp.equals(result)) {
if(eachPropDataJson.has("handle")){
selectedHandles.add(eachRequiredProp);
}
identityJson.put(eachRequiredProp, "$PHONENUMBERFORIDENTITY$");
}
else if (eachRequiredProp.equals("proofOfIdentity")) {
Expand Down Expand Up @@ -7776,7 +7788,48 @@ public String replaceArrayHandleValues(String inputJson, String testCaseName) {
}
handleArray.put(obj);
}
} else {
}
//43 in update identity
else if (testCaseName.contains("_removeexceptfirsthandle")) {
if (identity.has("selectedHandles")) {

if (selectedHandles.length() > 0) {
String firstHandleToKeep = selectedHandles.getString(0);

for (int j = 1; j < selectedHandles.length(); j++) {
if (identity.has(handle)) {
identity.remove(handle);
}
}
while (selectedHandles.length() > 1) {
selectedHandles.remove(1);
}
}
}
}
//44 in update identity
else if (testCaseName.contains("_withinvaliddemofield_inupdate")) {
if (identity.has("selectedHandles")) {

if (selectedHandles.length() > 0) {
String firstHandleToKeep = selectedHandles.getString(0);

for (int j = 1; j < selectedHandles.length(); j++) {
if (identity.has(handle)) {
identity.remove(handle);
}
}
while (selectedHandles.length() > 1) {
selectedHandles.remove(1);
}
}
}
}




else {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject obj = handleArray.getJSONObject(j);
obj.put("value", obj.getString("value"));
Expand Down Expand Up @@ -7806,7 +7859,6 @@ public String replaceArrayHandleValuesForUpdateIdentity(String inputJson, String
if (identity.has(handle) && identity.get(handle) instanceof JSONArray) {
JSONArray handleArray = identity.getJSONArray(handle);

// Process based on testCaseName
if (testCaseName.contains("_withupdatevalues")) {
for (int j = 0; j < handleArray.length(); j++) {
JSONObject handleObj = handleArray.getJSONObject(j);
Expand Down Expand Up @@ -7960,6 +8012,45 @@ else if (testCaseName.contains("_withouthandlesattr")) {
}
}

//44
else if (testCaseName.contains("_withinvaliddemofield")) {
if (identity.has("selectedHandles")) {
for (int j = 0; j < selectedHandles.length(); j++) {
if (identity.has(handle)) {
Object currentValue = identity.get(handle);
if (currentValue instanceof String) {
identity.put(handle, "invalid_" + currentValue);
} else if (currentValue instanceof JSONArray) {
JSONArray jsonArray = (JSONArray) currentValue;
for (int k = 0; k < jsonArray.length(); k++) {
JSONObject obj = jsonArray.getJSONObject(k);
if (obj.has("value")) {
obj.put("value", "invalid_" + obj.getString("value"));
}
}
identity.put(handle, jsonArray);
}
}
selectedHandles.put(i, "invalid_" + handle);
}
identity.put("selectedHandles", selectedHandles);
}
}
//49
else if (testCaseName.contains("_withoutselectedhandlesandattri")) {

for (int j = 0; j < selectedHandles.length(); j++) {

if (identity.has(handle)) {
identity.remove(handle);
}
}

identity.remove("selectedHandles");
}



else if (testCaseName.contains("_witharandomnonhandleattr")) {
if (identity.has("selectedHandles")) {
List<String> existingHandles = new ArrayList<>();
Expand Down

0 comments on commit 362f89f

Please sign in to comment.