Skip to content

Commit

Permalink
Merge pull request mosip#1066 from Sohandey/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ckm007 authored Aug 12, 2024
2 parents 9faf4db + 47bb23a commit 534631e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.lang.reflect.Field;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -26,6 +28,7 @@

import io.mosip.testrig.apirig.dto.OutputValidationDto;
import io.mosip.testrig.apirig.dto.TestCaseDTO;
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
import io.mosip.testrig.apirig.testrunner.HealthChecker;
import io.mosip.testrig.apirig.testrunner.JsonPrecondtion;
import io.mosip.testrig.apirig.utils.AdminTestException;
Expand All @@ -34,6 +37,7 @@
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.KernelAuthentication;
import io.mosip.testrig.apirig.utils.KeycloakUserManager;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
import io.mosip.testrig.apirig.utils.ReportUtil;
import io.mosip.testrig.apirig.utils.RestClient;
Expand Down Expand Up @@ -104,13 +108,34 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
String timestampValue = dateFormatter.format(cal.getTime());
String genRid = "27847" + generateRandomNumberString(10) + timestampValue;

if (testCaseName.equals("Resident_AddIdentity_Valid_Params_AddUser_smoke_Pos")) {

KeycloakUserManager.removeVidUser();
Map<String, List<String>> attrmap = new HashMap<>();
List<String> list = new ArrayList<>();
list.add(uin);
attrmap.put("individual_id", list);
list = new ArrayList<>();
String token = AdminTestUtil.generateTokenID(uin, properties.getProperty("partner_Token_Id"));
list.add(token);
attrmap.put("ida_token", list);
list = new ArrayList<>();
String picture = properties.getProperty("picturevalue");
list.add(picture);
attrmap.put("picture", list);
KeycloakUserManager.createVidUsers(propsKernel.getProperty("new_Resident_User"),
propsKernel.getProperty("new_Resident_Password"), propsKernel.getProperty("new_Resident_Role"),
attrmap);
}

String jsonInput = testCaseDTO.getInput();

String inputJson = getJsonFromTemplate(jsonInput, testCaseDTO.getInputTemplate(), false);

inputJson = inputJson.replace("$UIN$", uin);
inputJson = inputJson.replace("$RID$", genRid);
String phoneNumber = "";
String email = testCaseName +"@mosip.net";
if (inputJson.contains("$PHONENUMBERFORIDENTITY$")) {
if (!phoneSchemaRegex.isEmpty())
try {
Expand All @@ -119,6 +144,8 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
logger.error(e.getMessage());
}
inputJson = replaceKeywordWithValue(inputJson, "$PHONENUMBERFORIDENTITY$", phoneNumber);
inputJson = replaceKeywordWithValue(inputJson, "$EMAILVALUE$", email);

}

response = postWithBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(), inputJson, COOKIENAME,
Expand Down Expand Up @@ -163,10 +190,13 @@ public void setResultTestName(ITestResult result) {

@AfterClass(alwaysRun = true)
public void waittime() {

try {
logger.info(
"waiting for " + properties.getProperty("Delaytime") + " mili secs after UIN Generation In IDREPO"); //
Thread.sleep(Long.parseLong(properties.getProperty("Delaytime")));
if (BaseTestCase.currentModule.equals("auth") || BaseTestCase.currentModule.equals("esignet")) {
logger.info("waiting for " + properties.getProperty("Delaytime")
+ " mili secs after UIN Generation In IDREPO"); //
Thread.sleep(Long.parseLong(properties.getProperty("Delaytime")));
}
} catch (Exception e) {
logger.error("Exception : " + e.getMessage());
Thread.currentThread().interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,46 +90,9 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
}
}

String jsonInput = testCaseDTO.getInput();

if (BaseTestCase.languageList.size() == 2) {
jsonInput = jsonInput.replace(", { \"language\": \"$3RDLANG$\", \"value\": \"FR\" }", "");
jsonInput = jsonInput.replace(", { \"language\": \"$3RDLANG$\", \"value\": \"Female\" }", "");
jsonInput = jsonInput.replace(", { \"language\": \"$3RDLANG$\", \"value\": \"Mrs Lisa.GN\" }", "");
jsonInput = jsonInput.replace(", { \"language\": \"$3RDLANG$\", \"value\": \"Line1\" }", "");
jsonInput = jsonInput.replace(", { \"language\": \"$3RDLANG$\", \"value\": \"Line2\" }", "");
jsonInput = jsonInput.replace(", { \"language\": \"$3RDLANG$\", \"value\": \"Line3\" }", "");
} else if (BaseTestCase.languageList.size() == 1) {
jsonInput = jsonInput.replace(
", { \"language\": \"$2NDLANG$\", \"value\": \"FR\" }, { \"language\": \"$3RDLANG$\", \"value\": \"FR\" }",
"");
jsonInput = jsonInput.replace(
", { \"language\": \"$2NDLANG$\", \"value\": \"Female\" }, { \"language\": \"$3RDLANG$\", \"value\": \"Female\" }",
"");
jsonInput = jsonInput.replace(
", { \"language\": \"$2NDLANG$\", \"value\": \"Mrs Lisa.GN\" }, { \"language\": \"$3RDLANG$\", \"value\": \"Mrs Lisa.GN\" }",
"");
jsonInput = jsonInput.replace(
", { \"language\": \"$2NDLANG$\", \"value\": \"Line1\" }, { \"language\": \"$3RDLANG$\", \"value\": \"Line1\" }",
"");
jsonInput = jsonInput.replace(
", { \"language\": \"$2NDLANG$\", \"value\": \"Line2\" }, { \"language\": \"$3RDLANG$\", \"value\": \"Line2\" }",
"");
jsonInput = jsonInput.replace(
", { \"language\": \"$2NDLANG$\", \"value\": \"Line3\" }, { \"language\": \"$3RDLANG$\", \"value\": \"Line3\" }",
"");
}

String inputJson = getJsonFromTemplate(jsonInput, testCaseDTO.getInputTemplate(), false);

if (inputJson.contains("$1STLANG$"))
inputJson = inputJson.replace("$1STLANG$", BaseTestCase.languageList.get(0));
if (inputJson.contains("$2NDLANG$"))
inputJson = inputJson.replace("$2NDLANG$", BaseTestCase.languageList.get(1));
if (inputJson.contains("$3RDLANG$"))
inputJson = inputJson.replace("$3RDLANG$", BaseTestCase.languageList.get(2));

response = patchWithPathParamsBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(), inputJson, COOKIENAME,
testCaseDTO.getRole(), testCaseDTO.getTestCaseName(), pathParams);

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ UpdateIdentity:
input: '{
"registrationId":"$RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"status": "DEACTIVATED",
"phone": "8249742850",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
"version": "v1"
Expand All @@ -27,9 +25,7 @@ UpdateIdentity:
input: '{
"registrationId":"$RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"status": "ACTIVATED",
"phone": "8249742850",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
"version": "v1"
Expand All @@ -46,8 +42,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
Expand All @@ -71,8 +65,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
Expand All @@ -96,8 +88,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
Expand All @@ -121,8 +111,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$T",
Expand All @@ -146,8 +134,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "",
Expand All @@ -171,8 +157,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": " ",
Expand All @@ -196,8 +180,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "2022-05-23T06:56:01.667Z",
Expand All @@ -221,8 +203,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "2072-05-23T06:56:01.667Z",
Expand All @@ -246,8 +226,6 @@ UpdateIdentity:
input: '{
"registrationId":"$REMOVE$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
Expand All @@ -270,8 +248,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
Expand All @@ -294,8 +270,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
"requesttime": "$REMOVE$",
Expand All @@ -318,8 +292,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "8249742850",
"status": "ACTIVATED",
"dateOfBirth": "1992/15",
"requesttime": "$TIMESTAMP$",
Expand All @@ -342,7 +314,6 @@ UpdateIdentity:
input: '{
"registrationId":"$ID:AddIdentity_withValidParameters_smoke_Pos_RID$",
"UIN":"$ID:AddIdentity_withValidParameters_smoke_Pos_UIN$",
"email": "[email protected]",
"phone": "824222@@@@@####850",
"status": "ACTIVATED",
"dateOfBirth": "1992/04/15",
Expand Down Expand Up @@ -391,9 +362,7 @@ UpdateIdentity:
input: '{
"registrationId":"$RID$",
"UIN":"$ID:AddIdentity_For_DeactivateScen_smoke_Pos_UIN$",
"email": "[email protected]",
"status": "DEACTIVATED",
"phone": "8249742850",
"dateOfBirth": "1992/04/15",
"requesttime": "$TIMESTAMP$",
"version": "v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"status": "{{status}}",
"identity": {
"IDSchemaVersion": "$SCHEMAVERSION$",
"email": "{{email}}",
"phone": "{{phone}}",
"dateOfBirth": "{{dateOfBirth}}",
"UIN": "{{UIN}}"

Expand Down

0 comments on commit 534631e

Please sign in to comment.