From c864b893f21e219214aa00415d094eaee2e0b39a Mon Sep 17 00:00:00 2001 From: Sohan Kumar Dey <72375959+Sohandey@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:33:40 +0530 Subject: [PATCH] MOSIP-37651 Signed-off-by: Sohan Kumar Dey <72375959+Sohandey@users.noreply.github.com> --- .../testrig/apirig/utils/AdminTestUtil.java | 57 +++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java index 3fe2070e7c..8db5dc5614 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java @@ -57,6 +57,7 @@ import java.util.Map; import java.util.Objects; import java.util.Properties; +import java.util.Random; import java.util.Set; import java.util.TimeZone; import java.util.UUID; @@ -162,7 +163,6 @@ public class AdminTestUtil extends BaseTestCase { String signupAutoGeneratedIdPropFileName = properties.getProperty("signupAutoGeneratedIdPropFileName"); String fullNameForSunBirdRC = properties.getProperty("fullNameForSunBirdRC"); String dobForSunBirdRC = properties.getProperty("dobForSunBirdRC"); - public static String PASSWORD_FOR_ADDIDENTITY_AND_REGISTRATION = null; public static String PASSWORD_TO_RESET = null; public static final String RESOURCE_FOLDER_NAME = "MosipTemporaryTestResource"; @@ -3260,6 +3260,15 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) { } jsonString = replaceKeywordWithValue(jsonString, "$PHONENUMBERFORIDENTITY$", phoneNumber); } + + if (jsonString.contains("$NRCID$")) { + String nrcId = (100000 + new Random().nextInt(900000)) + "/" + (10 + new Random().nextInt(90)) + "/" + (1 + new Random().nextInt(9)); + + jsonString = replaceKeywordWithValue(jsonString, "$NRCID$", nrcId); + } + + + if (jsonString.contains("$1STLANG$")) jsonString = replaceKeywordWithValue(jsonString, "$1STLANG$", BaseTestCase.languageList.get(0)); if (jsonString.contains("$2NDLANG$")) @@ -5297,6 +5306,8 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) { String phone = getValueFromAuthActuator("json-property", "phone_number"); String result = phone.replaceAll("\\[\"|\"\\]", ""); + + if (!isElementPresent(requiredPropsArray, result)) { requiredPropsArray.put(result); @@ -5356,7 +5367,15 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) { //"tags": ":["handle"] eachValueJsonForHandles.put("tags", handleArray); selectedHandles.add(result); - } else { + } + + else if (eachRequiredProp.equals("nrcId")) { + eachValueJsonForHandles.put("value", "$NRCID$"); + eachValueJsonForHandles.put("tags", handleArray); + selectedHandles.add("nrcId"); + } + + else { eachValueJsonForHandles.put("value", "$FUNCTIONALID$"); eachValueJsonForHandles.put("tags", handleArray); selectedHandles.add(eachRequiredProp); @@ -5424,6 +5443,14 @@ else if (eachPropDataJson.has("$ref") && eachPropDataJson.get("$ref").toString() identityJson.put(eachRequiredProp, "$EMAILVALUE$"); } + else if (eachRequiredProp.equals("nrcId")) { + String nrcID = "$NRCID$"; + if(eachPropDataJson.has("handle")){ + selectedHandles.add(eachRequiredProp); + } + identityJson.put(eachRequiredProp, nrcID); + } + else if (eachRequiredProp.equals("password")) { identityJson.put(eachRequiredProp, new HashMap<>()); if (addIdentityPassword.isBlank() && addIdentitySalt.isBlank()) @@ -5581,11 +5608,21 @@ public static String updateIdentityHbs(boolean regenerateHbs) { //"tags": ":["handle"] eachValueJsonForHandles.put("tags", handleArray); selectedHandles.add(result); - } else { + } + + else if (eachRequiredProp.equals("nrcId")) { + eachValueJsonForHandles.put("value", "$NRCID$"); + eachValueJsonForHandles.put("tags", handleArray); + selectedHandles.add("nrcId"); + } + + else { eachValueJsonForHandles.put("value", "$FUNCTIONALID$"); eachValueJsonForHandles.put("tags", handleArray); selectedHandles.add(eachRequiredProp); } + + eachPropDataArrayForHandles.put(eachValueJsonForHandles); identityJson.put(eachRequiredProp, eachPropDataArrayForHandles); @@ -5639,6 +5676,13 @@ else if (eachRequiredProp.equals(result)) { } identityJson.put(eachRequiredProp, "$PHONENUMBERFORIDENTITY$"); } + else if (eachRequiredProp.equals("nrcId")) { + String nrcID = "$NRCID$"; + if(eachPropDataJson.has("handle")){ + selectedHandles.add(eachRequiredProp); + } + identityJson.put(eachRequiredProp, nrcID); + } else if (eachRequiredProp.equals("proofOfIdentity")) { identityJson.remove("proofOfIdentity"); } @@ -5771,6 +5815,11 @@ public static String generateHbsForUpdateDraft() { identityJson.getJSONObject(eachRequiredProp).put("type", "DOC001"); identityJson.getJSONObject(eachRequiredProp).put("value", "fileReferenceID"); } + + else if (eachRequiredProp.equals("nrcId")) { + String nrcID = "$NRCID$"; + identityJson.put(eachRequiredProp, nrcID); + } else if (eachRequiredProp.equals("individualBiometrics")) { identityJson.put(eachRequiredProp, new HashMap<>()); @@ -7162,7 +7211,7 @@ else if (testCaseName.startsWith("Prereg_") || 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_"))