Skip to content

Commit

Permalink
MOSIP-34117 - Fixed merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Mohanachandran S <[email protected]>
  • Loading branch information
mohanachandran-s committed Jul 5, 2024
1 parent c098904 commit 8b7c280
Showing 1 changed file with 87 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ protected Response postWithBodyAndCookie(String url, String jsonInput, boolean a
}

}

logger.info(GlobalConstants.POST_REQ_URL + url);
GlobalMethods.reportRequest(null, inputJson, url);
try {
Expand Down Expand Up @@ -1117,7 +1117,8 @@ protected Response postWithBodyAndCookieForAutoGeneratedId(String url, String js
if (BaseTestCase.currentModule.equals(GlobalConstants.MIMOTO) || BaseTestCase.currentModule.equals("auth")
|| BaseTestCase.currentModule.equals(GlobalConstants.ESIGNET)
|| BaseTestCase.currentModule.equals(GlobalConstants.RESIDENT)
|| BaseTestCase.currentModule.equals(GlobalConstants.MASTERDATA)) {
|| BaseTestCase.currentModule.equals(GlobalConstants.MASTERDATA)
|| BaseTestCase.currentModule.equals(GlobalConstants.PREREG)) {
inputJson = smtpOtpHandler(inputJson, testCaseName);
}
if (bothAccessAndIdToken) {
Expand Down Expand Up @@ -2271,6 +2272,40 @@ protected byte[] postWithBodyAndCookieForPdf(String url, String jsonInput, Strin
}
}

protected byte[] postWithFormDataBodyForPdf(String url, String jsonInput, String cookieName, String role,
String testCaseName) {

HashMap<String, String> formDataMap = new HashMap<>();
jsonInput = inputJsonKeyWordHandeler(jsonInput, testCaseName);
logger.info("inputJson is::" + jsonInput);

JSONObject req = new JSONObject(jsonInput);
logger.info(GlobalConstants.REQ_STR + req);
jsonInput = req.toString();

byte[] pdf = null;

try {
formDataMap = new Gson().fromJson(jsonInput, new TypeToken<HashMap<String, String>>() {
}.getType());
} catch (Exception e) {
logger.error(
GlobalConstants.ERROR_STRING_1 + jsonInput + GlobalConstants.EXCEPTION_STRING_1 + e.getMessage());
}

logger.info("******Post request to EndPointUrl: " + url);
GlobalMethods.reportRequest(null, jsonInput, url);

try {
pdf = RestClient.postRequestWithFormDataBodyForPdf(url, formDataMap);
return pdf;
} catch (Exception e) {
logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
return pdf;
}

}

protected byte[] getWithQueryParamAndCookieForPdf(String url, String jsonInput, String cookieName, String role,
String testCaseName) {
return getWithQueryParamAndCookieForPdf(url, jsonInput, cookieName, role, testCaseName, false);
Expand Down Expand Up @@ -3312,10 +3347,18 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
jsonString = replaceKeywordWithValue(jsonString, "$OIDCCLIENT$",
getValueFromActuator(GlobalConstants.RESIDENT_DEFAULT_PROPERTIES, "mosip.iam.module.clientID"));
}
if (jsonString.contains("$GETCLIENTIDFROMMIMOTOACTUATOR$")) {
jsonString = replaceKeywordWithValue(jsonString, "$GETCLIENTIDFROMMIMOTOACTUATOR$",
getValueFromMimotoActuator("configService:overrides", "mimoto.oidc.partner.clientid"));
}
if (jsonString.contains("$IDPREDIRECTURI$")) {
jsonString = replaceKeywordWithValue(jsonString, "$IDPREDIRECTURI$",
ApplnURI.replace(GlobalConstants.API_INTERNAL, "healthservices") + "/userprofile");
}
if (jsonString.contains("$INJIREDIRECTURI$")) {
jsonString = replaceKeywordWithValue(jsonString, "$INJIREDIRECTURI$",
ApplnURI.replace(GlobalConstants.API_INTERNAL, "inji") + "/redirect");
}
if (jsonString.contains("$BASE64URI$")) {
String redirectUri = ApplnURI.replace(GlobalConstants.API_INTERNAL, GlobalConstants.RESIDENT)
+ propsKernel.getProperty("currentUserURI");
Expand Down Expand Up @@ -6039,6 +6082,44 @@ public static String getValueFromActuator(String section, String key) {
}

}

public static JSONArray mimotoActuatorResponseArray = null;

public static String getValueFromMimotoActuator(String section, String key) {
String url = ApplnURI + propsKernel.getProperty("actuatorMimotoEndpoint");
String actuatorCacheKey = url + section + key;
String value = actuatorValueCache.get(actuatorCacheKey);
if (value != null && !value.isEmpty())
return value;

try {
if (mimotoActuatorResponseArray == null) {
Response response = null;
JSONObject responseJson = null;
response = RestClient.getRequest(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON);

responseJson = new JSONObject(response.getBody().asString());
mimotoActuatorResponseArray = responseJson.getJSONArray("propertySources");
}
for (int i = 0, size = mimotoActuatorResponseArray.length(); i < size; i++) {
JSONObject eachJson = mimotoActuatorResponseArray.getJSONObject(i);
if (eachJson.get("name").toString().contains(section)) {
value = eachJson.getJSONObject(GlobalConstants.PROPERTIES).getJSONObject(key)
.get(GlobalConstants.VALUE).toString();
if (ConfigManager.IsDebugEnabled())
logger.info("Actuator: " + url + " key: " + key + " value: " + value);
break;
}
}
actuatorValueCache.put(actuatorCacheKey, value);

return value;
} catch (Exception e) {
logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
return "";
}

}

public static JSONArray regprocActuatorResponseArray = null;

Expand Down Expand Up @@ -6431,18 +6512,7 @@ public static String smtpOtpHandler(String inputJson, String testCaseName) {
}
}
}
if (BaseTestCase.currentModule.equals(GlobalConstants.PREREG)) {
if (request.has(GlobalConstants.REQUEST)) {
if (request.getJSONObject(GlobalConstants.REQUEST).has("otp")) {
emailId = request.getJSONObject(GlobalConstants.REQUEST).getString("userId");
logger.info(emailId);
otp = MockSMTPListener.getOtp(emailId);
request.getJSONObject(GlobalConstants.REQUEST).put("otp", otp);
inputJson = request.toString();
return inputJson;
}
}
}


if (BaseTestCase.currentModule.equals("auth")) {
if (testCaseName.startsWith("auth_GenerateVID") || testCaseName.startsWith("auth_AuthLock")
Expand Down Expand Up @@ -6528,6 +6598,7 @@ public static String smtpOtpHandler(String inputJson, String testCaseName) {
}

if (BaseTestCase.currentModule.equals(GlobalConstants.ESIGNET)
|| BaseTestCase.currentModule.equals(GlobalConstants.MIMOTO)
|| testCaseName.startsWith("Mimoto_WalletBinding")) {
if (request.has(GlobalConstants.REQUEST)) {
if (request.getJSONObject(GlobalConstants.REQUEST).has("otp")) {
Expand Down Expand Up @@ -6604,7 +6675,8 @@ public static String smtpOtpHandler(String inputJson, String testCaseName) {
.getString(GlobalConstants.CHALLENGE).endsWith(GlobalConstants.MOSIP_NET)
|| request.getJSONObject(GlobalConstants.REQUEST)
.getJSONArray(GlobalConstants.CHALLENGELIST).getJSONObject(0)
.getString(GlobalConstants.CHALLENGE).endsWith(GlobalConstants.OTP_AS_PHONE)) {
.getString(GlobalConstants.CHALLENGE)
.endsWith(GlobalConstants.OTP_AS_PHONE)) {
emailId = request.getJSONObject(GlobalConstants.REQUEST)
.getJSONArray(GlobalConstants.CHALLENGELIST).getJSONObject(0)
.getString(GlobalConstants.CHALLENGE);
Expand Down

0 comments on commit 8b7c280

Please sign in to comment.