Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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 @@ -125,6 +125,9 @@
import io.mosip.testrig.apirig.testrunner.OTPListener;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import com.github.jknack.handlebars.EscapingStrategy;
import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;

/**
* @author Ravi Kant
Expand Down Expand Up @@ -3816,8 +3819,16 @@ public String getJsonFromTemplate(String input, String template) {

}

public static Handlebars handlebars = new Handlebars();
public static Handlebars handlebars = new Handlebars().with(EscapingStrategy.NOOP);
public static Gson gson = new Gson();
static {
handlebars.registerHelper("json", new Helper<Object>() {
@Override
public CharSequence apply(Object context, Options options) {
return gson.toJson(context);
}
});
}
Comment thread
SradhaMohanty5899 marked this conversation as resolved.

public String getJsonFromTemplate(String input, String template, boolean readFile) {
String resultJson = null;
Expand Down Expand Up @@ -5446,7 +5457,7 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) {
JSONObject identityJson = new JSONObject();
identityJson.put("UIN", "{{UIN}}");
JSONArray handleArray = new JSONArray();
handleArray.put("handles");
handleArray.put("handle");

List<String> selectedHandles = new ArrayList<>();

Expand Down Expand Up @@ -5643,6 +5654,21 @@ public static String modifySchemaGenerateHbs(boolean regenerateHbs) {
identityHbs = requestJson.toString();
return identityHbs;
}

public static String modifySchemaGenerateHbsV2(boolean regenerateHbs) {

String hbs = modifySchemaGenerateHbs(regenerateHbs);

JSONObject requestJson = new JSONObject(hbs);
requestJson.getJSONObject("request").put("verifiedAttributes", "$VERIFIED_ATTRIBUTES$");

return requestJson.toString().replace("\"$VERIFIED_ATTRIBUTES$\"", buildVerifiedAttributesHbs());
}

private static String buildVerifiedAttributesHbs() {

return "{{{json verifiedAttributes}}}";
}

public static String getSchemaURL() {
String schemaURL = ApplnURI + properties.getProperty(GlobalConstants.MASTER_SCHEMA_URL);
Expand Down Expand Up @@ -5706,7 +5732,7 @@ public static String updateIdentityHbs(boolean regenerateHbs) {
JSONObject identityJson = new JSONObject();
identityJson.put("UIN", "{{UIN}}");
JSONArray handleArray = new JSONArray();
handleArray.put("handles");
handleArray.put("handle");
List<String> selectedHandles = new ArrayList<>();

for (int i = 0, size = requiredPropsArray.length(); i < size; i++) {
Expand Down Expand Up @@ -5822,6 +5848,16 @@ else if (eachRequiredProp.contains(GlobalConstants.GENDER))
updateIdentityHbs = requestJson.toString();
return updateIdentityHbs;
}

public static String updateIdentityHbsV2(boolean regenerateHbs) {

String hbs = updateIdentityHbs(regenerateHbs);

JSONObject requestJson = new JSONObject(hbs);
requestJson.getJSONObject("request").put("verifiedAttributes", "$VERIFIED_ATTRIBUTES$");

Comment thread
SradhaMohanty5899 marked this conversation as resolved.
return requestJson.toString().replace("\"$VERIFIED_ATTRIBUTES$\"", buildVerifiedAttributesHbs());
}

public static String generateLatestSchemaVersion() {
kernelAuthLib = new KernelAuthentication();
Expand Down Expand Up @@ -5892,7 +5928,7 @@ public static String generateHbsForUpdateDraft() {
requestJson.put("registrationId", "{{registrationId}}");
JSONObject identityJson = new JSONObject();
JSONArray handleArray = new JSONArray();
handleArray.put("handles");
handleArray.put("handle");
List<String> selectedHandles = new ArrayList<>();

for (int i = 0, size = requiredPropsArray.length(); i < size; i++) {
Expand Down Expand Up @@ -6129,11 +6165,11 @@ public static String generateHbsForPrereg(boolean isItUpdate) {
JSONArray arr = new JSONArray();
JSONObject entry = new JSONObject();
if (eachRequiredProp.equals(emailFieldName)) {
entry.put("value", "$EMAILVALUE$"); entry.put("tags", new JSONArray().put("handles"));
entry.put("value", "$EMAILVALUE$"); entry.put("tags", new JSONArray().put("handle"));
} else if (eachRequiredProp.equals(phoneFieldName)) {
entry.put("value", "{{phone}}"); entry.put("tags", new JSONArray().put("handles"));
entry.put("value", "{{phone}}"); entry.put("tags", new JSONArray().put("handle"));
} else {
entry.put("value", "$FUNCTIONALID$"); entry.put("tags", new JSONArray().put("handles"));
entry.put("value", "$FUNCTIONALID$"); entry.put("tags", new JSONArray().put("handle"));
}
arr.put(entry);
identityJson.put(eachRequiredProp, arr);
Expand Down Expand Up @@ -6166,7 +6202,7 @@ public static String generateHbsForPrereg(boolean isItUpdate) {
if ("array".equals(fieldType)) {
JSONArray emailArray = new JSONArray();
JSONObject emailEntry = new JSONObject();
emailEntry.put("value", "$EMAILVALUE$"); emailEntry.put("tags", new JSONArray().put("handles"));
emailEntry.put("value", "$EMAILVALUE$"); emailEntry.put("tags", new JSONArray().put("handle"));
emailArray.put(emailEntry); identityJson.put(eachRequiredProp, emailArray);
} else {
identityJson.put(eachRequiredProp, "$EMAILVALUE$");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public class GlobalConstants {
public static final String SESSION = "SESSION";
public static final String COOKIE_NAME = "cookieName";
public static final String ACCEPT_HEADER = "acceptHeader";

public static final String ADD_IDENTITY_V2_ENDPOINT = "/v1/identity/v2";

public static final String ACTIVE_PROFILES = "activeProfiles";

Expand Down
Loading