Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-38558 incorporate new changes #1706

Merged
merged 9 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,40 @@ protected Response postWithPathParamsBodyAndCookie(String url, String jsonInput,
return response;
}
}


protected Response postWithPathParamsBodyAndCookieForAutoGeneratedId(String url, String jsonInput,
String cookieName, String role, String testCaseName, String pathParams, String idKeyName) {
Response response = null;
String inputJson = inputJsonKeyWordHandeler(jsonInput, testCaseName);
url = uriKeyWordHandelerUri(url, testCaseName);
JSONObject req = new JSONObject(inputJson);
HashMap<String, String> pathParamsMap = new HashMap<>();
String[] params = pathParams.split(",");
for (String param : params) {
if (req.has(param)) {
pathParamsMap.put(param, req.get(param).toString());
req.remove(param);
} else
logger.error(GlobalConstants.ERROR_STRING_2 + param + GlobalConstants.IN_STRING + inputJson);
}

token = kernelAuthLib.getTokenByRole(role);
logger.info(GlobalConstants.POST_REQ_URL + url);
GlobalMethods.reportRequest(null, inputJson, url);
try {
response = RestClient.postWithPathParamsBodyAndCookie(url, pathParamsMap, req.toString(),
MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, cookieName, token);
GlobalMethods.reportResponse(response.getHeaders().asList().toString(), url, response);

if (testCaseName.toLowerCase().contains("_sid")) {
writeAutoGeneratedId(response, idKeyName, testCaseName);
}
} catch (Exception e) {
logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
}
return response;
}

protected Response postWithPathParamsBodyHeaderAndCookie(String url, String jsonInput, String cookieName,
String role, String testCaseName, String pathParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ public String getTokenByRole(String role, String tokenType) {
case "invalid":
return "anyRandomString";
case "invalidtoken":
String encodingToken = "AnyRandomString-ToCreate-Jwt";
invalidcookie = kernelAuthLib.encodeBase64(encodingToken);
return invalidcookie;
return kernelAuthLib.encodeBase64("AnyRandomString-ToCreate-Jwt");
case "regAdmin":
if (!kernelCmnLib.isValidToken(regAdminCookie))
regAdminCookie = kernelAuthLib.getAuthForRegistrationAdmin();
Expand Down
Loading