mapProp = prop.entrySet().stream()
+ .collect(Collectors.toMap(e -> (String) e.getKey(), e -> (String) e.getValue()));
+
+ return mapProp;
+ }
+
+ // Get Requests:
+ /**
+ * @param url
+ * @param cookie
+ * @return this method is for get request with authentication(cookie) and
+ * without any param.
+ */
+ public Response getWithoutParams(String url, String cookie) {
+ logger.info("REST-ASSURED: Sending a Get request to " + url);
+ Cookie.Builder builder = new Cookie.Builder("Authorization", cookie);
+ Response getResponse = given().cookie(builder.build()).relaxedHTTPSValidation().log().all().when().get(url);
+ // log then response
+ responseLogger(getResponse);
+ logger.info("REST-ASSURED: the response Time is: " + getResponse.time());
+ return getResponse;
+ }
+
+
+ /**
+ * @param response
+ * this method is for logging the response in case of error only.
+ * this is used in get request response logging
+ */
+ public void responseLogger(Response response) {
+ int statusCode = response.statusCode();
+ if (statusCode < 200 || statusCode > 299) {
+ logger.info(response.asString());
+ } else
+ logger.info("status code: " + statusCode + "(success)");
+
+ }
+
+ public JSONObject readJsonData(String path, boolean isRelative) {
+ logger.info("path : " + path);
+ if(isRelative)
+ path = getResourcePath() + path;
+ logger.info("Relativepath : " + path);
+ File fileToRead = new File(path);
+ InputStream isOfFile = null;
+ try {
+ logger.info("fileToRead : " + fileToRead);
+ isOfFile = new FileInputStream(fileToRead);
+ } catch (FileNotFoundException e1) {
+ logger.info("error while reading the file : " + e1.getLocalizedMessage() );
+ e1.printStackTrace();
+ logger.info("File Not Found at the given path");
+ }
+ JSONObject jsonData = null;
+ try {
+ jsonData = (JSONObject) new JSONParser().parse(new InputStreamReader(isOfFile, "UTF-8"));
+ } catch (IOException | ParseException | NullPointerException e) {
+ logger.info(e.getMessage());
+ }
+ return jsonData;
+ }
+
+ /**
+ * @param url
+ * @param body
+ * @param contentHeader
+ * @param acceptHeader
+ * @return this method is for post request without authentication(cookie) and
+ * only with jsonData in request body.
+ */
+ public Response postWithJson(String url, Object body, String contentHeader, String acceptHeader) {
+ logger.info("REST:ASSURED:Sending post request to" + url);
+ Response postResponse = given().relaxedHTTPSValidation().body(body).contentType(contentHeader)
+ .accept(acceptHeader).log().all().when().post(url).then().log().all().extract().response();
+ // log then response
+ logger.info("REST-ASSURED: The response from request is: " + postResponse.asString());
+ logger.info("REST-ASSURED: The response Time is: " + postResponse.time());
+ return postResponse;
+ }
+}
diff --git a/injitest/src/main/java/inji/api/ConfigManager.java b/injitest/src/main/java/inji/api/ConfigManager.java
new file mode 100644
index 0000000000..cec929bae1
--- /dev/null
+++ b/injitest/src/main/java/inji/api/ConfigManager.java
@@ -0,0 +1,592 @@
+package inji.api;
+
+
+import inji.driver.TestRunner;
+import inji.utils.TestDataReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+
+public class ConfigManager {
+
+ private static final org.slf4j.Logger LOGGER= org.slf4j.LoggerFactory.getLogger(ConfigManager.class);
+
+ private static String USEPRECONFIGOTP = "usePreConfiguredOtp";
+ private static String PRECONFIGOTP = "preconfiguredOtp";
+
+ private static String MOSIP_IDREPO_CLIENT_SECRET = "mosip_idrepo_client_secret";
+ private static String MOSIP_IDREPO_CLIENT_ID = "mosip_idrepo_client_id";
+ private static String MOSIP_IDREPO_APP_ID = "mosip_idrepo_app_id";
+
+ private static String MOSIP_ADMIN_CLIENT_SECRET = "mosip_admin_client_secret";
+ private static String MOSIP_ADMIN_CLIENT_ID = "mosip_admin_client_id";
+ private static String MOSIP_ADMIN_APP_ID = "mosip_admin_app_id";
+
+ private static String MOSIP_REG_CLIENT_SECRET = "mosip_reg_client_secret";
+ private static String MOSIP_REG_CLIENT_ID = "mosip_reg_client_id";
+ private static String MOSIP_REGCLIENT_APP_ID = "mosip_regclient_app_id";
+
+
+
+ private static String MOSIP_AUTOMATION_CLIENT_SECRET = "mosip_testrig_client_secret";
+ private static String MOSIP_AUTOMATION_CLIENT_ID = "mosip_testrig_client_id";
+ private static String MOSIP_AUTOMATION_APP_ID = "mosip_automation_app_id";
+
+ private static String S3_HOST = "s3-host";
+ private static String usePreConfiguredOtp;
+ private static String S3_REGION = "s3-region";
+ private static String S3_USER_KEY = "s3-user-key";
+ private static String S3_SECRET_KEY = "s3-user-secret";
+ private static String S3_ACCOUNT = "s3-account";
+ private static String PUSH_TO_S3 = "push-reports-to-s3";
+ private static String ENABLE_DEBUG = "enableDebug";
+ private static String THREAD_COUNT = "threadCount";
+ private static String LANG_SELECT = "langselect";
+ private static String preconfiguredOtp;
+
+ private static String DB_PORT = "db-port";
+ private static String DB_DOMAIN = "db-server";
+ private static String HIBERNATE_CONNECTION_DRIVER_CLASS = "hibernate.connection.driver_class";
+ private static String HIBERNATE_CONNECTION_POOL_SIZE = "hibernate.connection.pool_size";
+ private static String HIBERNATE_DIALECT = "hibernate.dialect";
+ private static String HIBERNATE_SHOW_SQL = "hibernate.show_sql";
+ private static String HIBERNATE_CONTEXT_CLASS = "hibernate.current_session_context_class";
+
+ private static String AUDIT_DB_USER = "db-su-user";
+ private static String AUDIT_DB_PASS = "postgresql-password";
+ private static String AUDIT_DB_SCHEMA = "audit_db_schema";
+
+ private static String IDA_DB_USER = "db-su-user";
+ private static String IDA_DB_PASS = "postgresql-password";
+ private static String IDA_DB_SCHEMA = "ida_db_schema";
+
+ private static String PMS_DB_USER = "db-su-user";
+ private static String PMS_DB_PASS = "postgresql-password";
+ private static String PMS_DB_SCHEMA = "pms_db_schema";
+
+ private static String KM_DB_USER = "db-su-user";
+ private static String KM_DB_PASS = "postgresql-password";
+ private static String KM_DB_SCHEMA = "km_db_schema";
+
+ private static String MASTER_DB_USER = "db-su-user";
+ private static String MASTER_DB_PASS = "postgresql-password";
+ private static String MASTER_DB_SCHEMA = "master_db_schema";
+
+ private static String IAM_EXTERNAL_URL = "keycloak-external-url";
+ private static String IAM_ADMINPORTAL_PATH = "adminPortalPath";
+ private static String IAM_APIENVUSER = "apiEnvUser";
+ private static String IAM_APIINTERNALENDPOINT = "apiInternalEndPoint";
+ private static String IAM_REALM_ID = "keycloak-realm-id";
+ private static String IAM_USERS_TO_CREATE = "iam-users-to-create";
+ private static String IAM_USERS_PASSWORD = "iam-users-password";
+
+ private static String AUTH_DEMO_SERVICE_PORT = "authDemoServicePort";
+ private static String AUTH_DEMO_SERVICE_BASE_URL = "authDemoServiceBaseURL";
+ private static String MOUNT_PATH = "mountPath";
+ private static String AUTHCERTS_PATH = "authCertsPath";
+ private static String MOUNT_PATH_FOR_SCENARIO = "mountPathForScenario";
+
+ private static String PACKET_UTILITY_BASE_URL = "packetUtilityBaseUrl";
+
+ private static String REPORT_EXPIRATION_IN_DAYS = "reportExpirationInDays";
+
+ private static String idrepo_client_secret;
+ private static String idrepo_client_id;
+ private static String idrepo_app_id;
+
+ private static String admin_client_secret;
+ private static String admin_client_id;
+ private static String admin_app_id;
+
+ private static String regproc_client_secret;
+ private static String regproc_client_id;
+ private static String regproc_app_id;
+
+ private static String automation_client_secret;
+ private static String automation_client_id;
+ private static String automation_app_id;
+
+ private static String s3_region;
+ private static String s3_host;
+ private static String s3_user_key;
+ private static String s3_account;
+ private static String s3_secret_key;
+ private static String push_reports_to_s3;
+ private static String enableDebug;
+ private static String threadCount;
+ private static String langselect;
+
+ private static String db_port;
+ private static String db_domain;
+ private static String hibernate_connection_driver_class;
+ private static String hibernate_connection_pool_size;
+ private static String hibernate_dialect;
+ private static String hibernate_show_sql;
+ private static String hibernate_current_session_context_class;
+
+ private static String audit_db_user;
+ private static String audit_db_pass;
+ private static String audit_db_schema;
+
+ private static String ida_db_user;
+ private static String ida_db_pass;
+ private static String ida_db_schema;
+
+ private static String pms_db_user;
+ private static String pms_db_pass;
+ private static String pms_db_schema;
+
+ private static String km_db_user;
+ private static String km_db_pass;
+ private static String km_db_schema;
+
+ private static String master_db_user;
+ private static String master_db_pass;
+ private static String master_db_schema;
+
+ private static String iam_external_url;
+ private static String iam_realm_id;
+ private static String iam_users_to_create;
+ private static String iam_adminportal_path;
+ private static String iam_apienvuser;
+ private static String iam_apiinternalendpoint;
+ private static String iam_users_password;
+ private static String authDemoServicePort;
+ private static String authDemoServiceBaseUrl;
+
+ private static String mountPath;
+ private static String authCertsPath;
+ private static String mountPathForScenario;
+ private static String packetUtilityBaseUrl;
+ public static Properties propsKernel;
+ private static String reportExpirationInDays;
+ public static void setProperty(String key, String value) {
+ // Overwrite the value with only if the key exists
+ if (propsKernel.containsKey(key)) {
+ propsKernel.setProperty(key, value);
+ }
+ }
+
+ public static String getValueForKey(String key) {
+ String value = System.getenv(key) == null ? propsKernel.getProperty(key) : System.getenv(key);
+ setProperty(key, value);
+
+ return value;
+ }
+
+ public static void init() {
+ // Loading Kernel property
+ LOGGER.info("file location"+TestRunner.getResourcePath() + "/config/"+TestRunner.GetKernalFilename());
+ propsKernel = getproperty(TestRunner.getResourcePath() + "/config/"+TestRunner.GetKernalFilename());
+
+ idrepo_client_secret = getValueForKey(MOSIP_IDREPO_CLIENT_SECRET);
+ idrepo_client_id = getValueForKey(MOSIP_IDREPO_CLIENT_ID);
+ idrepo_app_id = getValueForKey(MOSIP_IDREPO_APP_ID);
+ admin_client_secret = getValueForKey(MOSIP_ADMIN_CLIENT_SECRET);
+ admin_client_id = getValueForKey(MOSIP_ADMIN_CLIENT_ID);
+ admin_app_id = getValueForKey(MOSIP_ADMIN_APP_ID);
+ regproc_client_secret = getValueForKey(MOSIP_REG_CLIENT_SECRET);
+ regproc_client_id = getValueForKey(MOSIP_REG_CLIENT_ID);
+ regproc_app_id = getValueForKey(MOSIP_REGCLIENT_APP_ID);
+ automation_client_secret = getValueForKey(MOSIP_AUTOMATION_CLIENT_SECRET);
+ automation_client_id = getValueForKey(MOSIP_AUTOMATION_CLIENT_ID);
+ automation_app_id = getValueForKey(MOSIP_AUTOMATION_APP_ID);
+ s3_host = getValueForKey(S3_HOST);
+ s3_region = getValueForKey(S3_REGION);
+ s3_user_key = getValueForKey(S3_USER_KEY);
+ s3_secret_key = getValueForKey(S3_SECRET_KEY);
+ s3_account = getValueForKey(S3_ACCOUNT);
+
+ iam_adminportal_path =System.getenv(IAM_ADMINPORTAL_PATH) == null
+ ? propsKernel.getProperty(IAM_ADMINPORTAL_PATH)
+ : System.getenv(IAM_ADMINPORTAL_PATH);
+
+ LOGGER.info("adminportal_path from config manager::" + iam_adminportal_path);
+ iam_apienvuser = System.getenv(IAM_APIENVUSER) == null
+ ? propsKernel.getProperty(IAM_APIENVUSER)
+ : System.getenv(IAM_APIENVUSER);
+ LOGGER.info("apienvuser from config manager::" + iam_apienvuser);
+ iam_apiinternalendpoint = System.getenv(IAM_APIINTERNALENDPOINT) == null
+ ? propsKernel.getProperty(IAM_APIINTERNALENDPOINT)
+ : System.getenv(IAM_APIINTERNALENDPOINT);
+ LOGGER.info("apiinternalendpoint from config manager::" + iam_apiinternalendpoint);
+ // push_reports_to_s3 = getValueForKey(PUSH_TO_S3);
+ db_port = getValueForKey(DB_PORT);
+ db_domain = getValueForKey(DB_DOMAIN);
+ hibernate_connection_driver_class = getValueForKey(HIBERNATE_CONNECTION_DRIVER_CLASS);
+ hibernate_connection_pool_size = getValueForKey(HIBERNATE_CONNECTION_POOL_SIZE);
+ hibernate_dialect = getValueForKey(HIBERNATE_DIALECT);
+ hibernate_show_sql = getValueForKey(HIBERNATE_SHOW_SQL);
+ hibernate_current_session_context_class = getValueForKey(HIBERNATE_CONTEXT_CLASS);
+ audit_db_user = getValueForKey(AUDIT_DB_USER);
+ audit_db_pass = getValueForKey(AUDIT_DB_PASS);
+ audit_db_schema = getValueForKey(AUDIT_DB_SCHEMA);
+ ida_db_user = getValueForKey(IDA_DB_USER);
+ ida_db_pass = getValueForKey(IDA_DB_PASS);
+ ida_db_schema = getValueForKey(IDA_DB_SCHEMA);
+ pms_db_user = getValueForKey(PMS_DB_USER);
+ pms_db_pass = getValueForKey(PMS_DB_PASS);
+ pms_db_schema = getValueForKey(PMS_DB_SCHEMA);
+ km_db_user = getValueForKey(KM_DB_USER);
+ km_db_pass = getValueForKey(KM_DB_PASS);
+ km_db_schema = getValueForKey(KM_DB_SCHEMA);
+ master_db_user = getValueForKey(MASTER_DB_USER);
+ master_db_pass = getValueForKey(MASTER_DB_PASS);
+ master_db_schema = getValueForKey(MASTER_DB_SCHEMA);
+ iam_external_url = getValueForKey(IAM_EXTERNAL_URL);
+ System.out.println("keycloakendpoint from config manager::" + iam_external_url);
+ reportExpirationInDays = System.getenv(REPORT_EXPIRATION_IN_DAYS) == null
+ ? propsKernel.getProperty(REPORT_EXPIRATION_IN_DAYS)
+ : System.getenv(REPORT_EXPIRATION_IN_DAYS);
+ propsKernel.setProperty(REPORT_EXPIRATION_IN_DAYS, reportExpirationInDays);
+ iam_realm_id = getValueForKey(IAM_REALM_ID);
+ iam_users_to_create = getValueForKey(IAM_USERS_TO_CREATE);
+ iam_users_password = getValueForKey(IAM_USERS_PASSWORD);
+
+ usePreConfiguredOtp = System.getenv(USEPRECONFIGOTP) == null ? propsKernel.getProperty(USEPRECONFIGOTP)
+ : System.getenv(USEPRECONFIGOTP);
+ propsKernel.setProperty(USEPRECONFIGOTP, usePreConfiguredOtp);
+
+ preconfiguredOtp = System.getenv(PRECONFIGOTP) == null ? propsKernel.getProperty(PRECONFIGOTP)
+ : System.getenv(PRECONFIGOTP);
+ propsKernel.setProperty(PRECONFIGOTP, preconfiguredOtp);
+
+ admin_client_secret = System.getenv(MOSIP_ADMIN_CLIENT_SECRET) == null
+ ? propsKernel.getProperty(MOSIP_ADMIN_CLIENT_SECRET)
+ : System.getenv(MOSIP_ADMIN_CLIENT_SECRET);
+
+ propsKernel.setProperty(MOSIP_ADMIN_CLIENT_SECRET, admin_client_secret);
+
+ authDemoServicePort = System.getenv(AUTH_DEMO_SERVICE_PORT) == null
+ ? propsKernel.getProperty(AUTH_DEMO_SERVICE_PORT)
+ : System.getenv(AUTH_DEMO_SERVICE_PORT);
+ propsKernel.setProperty(AUTH_DEMO_SERVICE_PORT, authDemoServicePort);
+
+ authDemoServiceBaseUrl = System.getenv(AUTH_DEMO_SERVICE_BASE_URL) == null
+ ? propsKernel.getProperty(AUTH_DEMO_SERVICE_BASE_URL)
+ : System.getenv(AUTH_DEMO_SERVICE_BASE_URL);
+ propsKernel.setProperty(AUTH_DEMO_SERVICE_BASE_URL, authDemoServiceBaseUrl);
+
+ mountPath = System.getenv(MOUNT_PATH) == null ? propsKernel.getProperty(MOUNT_PATH) : System.getenv(MOUNT_PATH);
+ propsKernel.setProperty(MOUNT_PATH, mountPath);
+
+ authCertsPath = System.getenv(AUTHCERTS_PATH) == null ? propsKernel.getProperty(AUTHCERTS_PATH) : System.getenv(AUTHCERTS_PATH);
+ propsKernel.setProperty(AUTHCERTS_PATH, authCertsPath);
+
+ mountPathForScenario = System.getenv(MOUNT_PATH_FOR_SCENARIO) == null ? propsKernel.getProperty(MOUNT_PATH_FOR_SCENARIO) : System.getenv(MOUNT_PATH_FOR_SCENARIO);
+ propsKernel.setProperty(MOUNT_PATH_FOR_SCENARIO, mountPathForScenario);
+
+ packetUtilityBaseUrl = System.getenv(PACKET_UTILITY_BASE_URL) == null ? propsKernel.getProperty(PACKET_UTILITY_BASE_URL) : System.getenv(PACKET_UTILITY_BASE_URL);
+ propsKernel.setProperty(PACKET_UTILITY_BASE_URL, packetUtilityBaseUrl);
+
+ push_reports_to_s3 =System.getenv(PUSH_TO_S3) == null ? propsKernel.getProperty(PUSH_TO_S3) : System.getenv(PUSH_TO_S3);
+ propsKernel.setProperty(PUSH_TO_S3, push_reports_to_s3);
+
+ enableDebug =System.getenv(ENABLE_DEBUG) == null ? propsKernel.getProperty(ENABLE_DEBUG) : System.getenv(ENABLE_DEBUG);
+ propsKernel.setProperty(ENABLE_DEBUG, enableDebug);
+
+ threadCount =System.getenv(THREAD_COUNT) == null ? propsKernel.getProperty(THREAD_COUNT) : System.getenv(THREAD_COUNT);
+ propsKernel.setProperty(THREAD_COUNT, threadCount);
+
+ langselect =System.getenv(LANG_SELECT) == null ? propsKernel.getProperty(LANG_SELECT) : System.getenv(LANG_SELECT);
+ propsKernel.setProperty(LANG_SELECT, langselect);
+
+
+
+ //enableDebug threadCount langselect
+
+ }
+
+ public static String getAuthDemoServicePort() {
+ return authDemoServicePort;
+ }
+
+ public static String getAuthDemoServiceBaseUrl() {
+ return authDemoServiceBaseUrl;
+
+ }
+
+
+ public static String getLangselect() {
+ return langselect;
+
+ }
+
+ public static String getThreadCount() {
+ return threadCount;
+
+ }
+
+
+
+ public static String getEnableDebug() {
+ return enableDebug;
+
+ }
+
+ public static String getmountPath() {
+ return mountPath;
+ }
+
+ public static String getmountPathForScenario() {
+ return mountPathForScenario;
+ }
+
+ public static String getpacketUtilityBaseUrl() {
+ return packetUtilityBaseUrl;
+ }
+
+ public static String getauthCertsPath() {
+ return authCertsPath;
+ }
+
+ public static Properties init(String abc) {
+ propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "/config/Kernel.properties");
+
+ return propsKernel;
+ }
+
+
+ public static String getAdminClientSecret() {
+ return admin_client_secret;
+ }
+
+ public static Boolean IsDebugEnabled() {
+ return enableDebug.equalsIgnoreCase("yes");
+ }
+
+ public static String getAdminClientId() {
+ return admin_client_id;
+ }
+
+ public static String getAdminAppId() {
+ return admin_app_id;
+ }
+
+ public static String getIdRepoClientSecret() {
+ return idrepo_client_secret;
+ }
+
+ public static String getidRepoClientId() {
+ return idrepo_client_id;
+ }
+
+ public static String getidRepoAppId() {
+ return idrepo_app_id;
+ }
+
+ public static String getRegprocClientSecret() {
+ return regproc_client_secret;
+ }
+
+ public static String getRegprocClientId() {
+ return regproc_client_id;
+ }
+
+ public static String getRegprocAppId() {
+ return regproc_app_id;
+ }
+
+
+ public static String getAutomationClientSecret() {
+ return automation_client_secret;
+ }
+
+ public static String getAutomationClientId() {
+ return automation_client_id;
+ }
+
+ public static String getAutomationAppId() {
+ return automation_app_id;
+ }
+
+ public static String getS3Host() {
+ return s3_host;
+ }
+ public static String getReportExpirationInDays() {
+ return reportExpirationInDays;
+ }
+
+ public static String getS3Region() {
+ return s3_region;
+ }
+
+ public static String getS3UserKey() {
+ return s3_user_key;
+ }
+
+ public static String getS3SecretKey() {
+ return s3_secret_key;
+ }
+
+ public static String getS3Account() {
+ return s3_account;
+ }
+
+ public static String getPushReportsToS3() {
+ return push_reports_to_s3;
+ }
+
+ public static String getIdaDbUrl() {
+ return "jdbc:postgresql://" + db_domain + ":" + db_port + "/mosip_ida";
+ }
+
+ public static String getAuditDbUrl() {
+ return "jdbc:postgresql://" + db_domain + ":" + db_port + "/mosip_audit";
+ }
+
+ public static String getDbDriverClass() {
+ return hibernate_connection_driver_class;
+ }
+
+ public static String getDbConnectionPoolSize() {
+ return hibernate_connection_pool_size;
+ }
+
+ public static String getDbDialect() {
+ return hibernate_dialect;
+ }
+
+ public static String getShowSql() {
+ return hibernate_show_sql;
+ }
+ public static String getiam_adminportal_path() {
+ return iam_adminportal_path;
+ }
+ public static String getiam_apienvuser() {
+ return iam_apienvuser;
+ }
+ public static String getiam_apiinternalendpoint() {
+ return iam_apiinternalendpoint;
+ }
+
+ public static String getDbSessionContext() {
+ return hibernate_current_session_context_class;
+ }
+
+ public static String getAuditDbUser() {
+ return audit_db_user;
+ }
+
+ public static String getAuditDbPass() {
+ System.out.println("DB Password from ENV::: " + System.getenv(AUDIT_DB_PASS));
+ return audit_db_pass;
+ }
+
+ public static String getAuditDbSchema() {
+ return audit_db_schema;
+ }
+
+ public static String getIdaDbUser() {
+ return ida_db_user;
+ }
+
+ public static String getIdaDbPass() {
+ return ida_db_pass;
+ }
+
+ public static String getIdaDbSchema() {
+ return ida_db_schema;
+ }
+
+ public static String getPMSDbUrl() {
+ return "jdbc:postgresql://" + db_domain + ":" + db_port + "/mosip_pms";
+ }
+
+ public static String getKMDbUrl() {
+ return "jdbc:postgresql://" + db_domain + ":" + db_port + "/mosip_keymgr";
+ }
+
+ public static String getMASTERDbUrl() {
+ return "jdbc:postgresql://" + db_domain + ":" + db_port + "/mosip_master";
+ }
+
+ public static String getPMSDbUser() {
+ return pms_db_user;
+ }
+
+ public static String getPMSDbPass() {
+ return pms_db_pass;
+ }
+
+ public static String getPMSDbSchema() {
+ return pms_db_schema;
+ }
+
+ public static String getKMDbUser() {
+ return km_db_user;
+ }
+
+ public static String getKMDbPass() {
+ return km_db_pass;
+ }
+
+ public static String getKMDbSchema() {
+ return km_db_schema;
+ }
+
+ public static String getMasterDbUser() {
+ return master_db_user;
+ }
+
+ public static String getMasterDbPass() {
+ return master_db_pass;
+ }
+
+ public static String getMasterDbSchema() {
+ return master_db_schema;
+ }
+
+ // from docker env getting only host url
+ public static String getIAMUrl() {
+ System.out.println("keycloak url from ENV::: " + System.getenv(IAM_EXTERNAL_URL) + "/auth");
+ System.out.println("keycloak url from Property::: " + System.getProperty(IAM_EXTERNAL_URL) + "/auth");
+ System.out.println("keycloak url from Config::: " + propsKernel.getProperty(IAM_EXTERNAL_URL) + "/auth");
+ System.out.println("keycloak url is:::" + iam_external_url + "/auth");
+ return iam_external_url + "/auth";
+ }
+
+ public static String getIAMRealmId() {
+ return iam_realm_id;
+ }
+
+ public static String getIAMUsersToCreate() {
+ return iam_users_to_create;
+ }
+
+ public static String getIAMUsersPassword() {
+ return iam_users_password;
+ }
+
+ public static String getUsePreConfiguredOtp() {
+ return usePreConfiguredOtp;
+ }
+
+ public static String getPreConfiguredOtp() {
+ return preconfiguredOtp;
+
+ }
+
+ public static String getRolesForUser(String userId) {
+ propsKernel = getproperty(TestRunner.getResourcePath() + "/" + "/config/Kernel.properties");
+ return propsKernel.getProperty("roles." + userId);
+ }
+
+ private static Properties getproperty(String path) {
+ Properties prop = new Properties();
+ try {
+ File file = new File(path);
+ prop.load(new FileInputStream(file));
+ } catch (IOException e) {
+ LOGGER.error("Exception " + e.getMessage());
+ }
+ return prop;
+ }
+
+ public static String getAuthDemoServiceUrl() {
+ return ConfigManager.getAuthDemoServiceBaseUrl() + ":" + ConfigManager.getAuthDemoServicePort();
+ }
+
+}
\ No newline at end of file
diff --git a/injitest/src/main/java/inji/api/GlobalConstants.java b/injitest/src/main/java/inji/api/GlobalConstants.java
new file mode 100644
index 0000000000..7d7a9d851d
--- /dev/null
+++ b/injitest/src/main/java/inji/api/GlobalConstants.java
@@ -0,0 +1,15 @@
+package inji.api;
+
+public class GlobalConstants {
+ public static final String EXCEPTION_STRING_2 = "Exception ";
+ public static final String REPORT_RESPONSE_PREFIX = "Actual Response Content: (EndPointUrl: ";
+ public static final String REPORT_RESPONSE_SUFFIX = "";
+ public static final String REPORT_RESPONSE_BODY = ") ";
+ public static final String TRUE_STRING = "true";
+ public static final String FAIL_STRING = "FAIL";
+ public static final String PROPERTIES = "properties";
+ public static final String VALUE = "value";
+
+
+
+}
diff --git a/injitest/src/main/java/inji/api/GlobalMethods.java b/injitest/src/main/java/inji/api/GlobalMethods.java
new file mode 100644
index 0000000000..4be90e7a89
--- /dev/null
+++ b/injitest/src/main/java/inji/api/GlobalMethods.java
@@ -0,0 +1,30 @@
+package inji.api;
+
+import io.restassured.response.Response;
+import org.testng.Reporter;
+public class GlobalMethods {
+
+ public static void reportResponse(String responseHeader, String url, Response response) {
+ String formattedHeader = ReportUtil.getTextAreaForHeaders(responseHeader);
+
+ Reporter.log(GlobalConstants.REPORT_RESPONSE_PREFIX + url + GlobalConstants.REPORT_RESPONSE_BODY + formattedHeader
+ + ReportUtil.getTextAreaJsonMsgHtml(response.asString()) + GlobalConstants.REPORT_RESPONSE_SUFFIX);
+ }
+
+ public static void reportResponse(String responseHeader, String url, String response) {
+ reportResponse(responseHeader, url, response, false);
+ }
+
+ public static void reportResponse(String responseHeader, String url, String response, boolean formatResponse) {
+ String formattedHeader = ReportUtil.getTextAreaForHeaders(responseHeader);
+
+ if (formatResponse)
+ Reporter.log(GlobalConstants.REPORT_RESPONSE_PREFIX + url + GlobalConstants.REPORT_RESPONSE_BODY + formattedHeader
+ + ReportUtil.getTextAreaJsonMsgHtml(response) + GlobalConstants.REPORT_RESPONSE_SUFFIX);
+ else
+ Reporter.log(GlobalConstants.REPORT_RESPONSE_PREFIX + url + GlobalConstants.REPORT_RESPONSE_BODY + responseHeader + response
+ + GlobalConstants.REPORT_RESPONSE_SUFFIX);
+ }
+
+
+}
diff --git a/injitest/src/main/java/inji/api/JsonPrecondtion.java b/injitest/src/main/java/inji/api/JsonPrecondtion.java
new file mode 100644
index 0000000000..c36364f13c
--- /dev/null
+++ b/injitest/src/main/java/inji/api/JsonPrecondtion.java
@@ -0,0 +1,32 @@
+package inji.api;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.log4j.Logger;
+
+public class JsonPrecondtion {
+ private static final Logger JSONPRECONDATION_LOGGER = Logger.getLogger(JsonPrecondtion.class);
+
+ public static String toPrettyFormat(String jsonString) {
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ JsonParser jp = new JsonParser();
+ JsonElement je = jp.parse(jsonString);
+ return gson.toJson(je);
+ }
+
+ public static String getValueFromJson(String jsonContent, String fieldMapper) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ Object jsonObj = mapper.readValue(jsonContent, Object.class);
+ return PropertyUtils.getProperty(jsonObj, fieldMapper).toString();
+ } catch (Exception expection) {
+ JSONPRECONDATION_LOGGER
+ .error("Exception Occured in retrieving the value from json file: " + expection.getMessage());
+ return "Cannot retrieve data or content for the object mapper from JSON";
+ }
+ }
+}
\ No newline at end of file
diff --git a/injitest/src/main/java/inji/api/KernelAuthentication.java b/injitest/src/main/java/inji/api/KernelAuthentication.java
new file mode 100644
index 0000000000..0d329a2a53
--- /dev/null
+++ b/injitest/src/main/java/inji/api/KernelAuthentication.java
@@ -0,0 +1,89 @@
+package inji.api;
+
+import io.restassured.response.Response;
+import org.json.simple.JSONObject;
+
+import java.util.Map;
+
+
+public class KernelAuthentication extends BaseTestCase {
+ private String authRequest="/config/Authorization/request.json";
+ private String authInternalRequest="/config/Authorization/internalAuthRequest.json";
+ String cookie;
+ static String dataKey = "response";
+ CommonLibrary clib= new CommonLibrary();
+ public final Map props = clib.readProperty("Kernel");
+ private String admin_password = props.get("admin_password");
+ private String admin_userName=props.get("admin_userName");
+ private String authenticationInternalEndpoint = props.get("authenticationInternal");
+ private ApplicationLibrary appl=new ApplicationLibrary();
+
+
+
+
+ public String getTokenByRole(String role) {
+ return getTokenByRole(role, null);
+ }
+
+ public String getTokenByRole(String role, String tokenType)
+ {
+ String insensitiveRole = null;
+ if(role!=null)
+ insensitiveRole = role.toLowerCase();
+ else return "";
+
+ switch(insensitiveRole) {
+
+ case "idrepo":
+ if(!kernelCmnLib.isValidToken(idrepoCookie))
+ idrepoCookie = kernelAuthLib.getAuthForIDREPO();
+ return idrepoCookie;
+ case "admin":
+ if(!kernelCmnLib.isValidToken(adminCookie))
+ adminCookie = kernelAuthLib.getAuthForAdmin();
+ return adminCookie;
+ default:
+ if(!kernelCmnLib.isValidToken(adminCookie))
+ adminCookie = kernelAuthLib.getAuthForAdmin();
+ return adminCookie;
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getAuthForIDREPO() {
+ JSONObject actualrequest = getRequestJson(authRequest);
+
+ JSONObject request=new JSONObject();
+ request.put("appId", ConfigManager.getidRepoAppId());
+ request.put("clientId", ConfigManager.getidRepoClientId());
+ request.put("secretKey", ConfigManager.getIdRepoClientSecret());
+ actualrequest.put("request", request);
+
+ Response reponse=appl.postWithJson(props.get("authclientidsecretkeyURL"), actualrequest);
+ cookie=reponse.getCookie("Authorization");
+ return cookie;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getAuthForAdmin() {
+
+ JSONObject actualrequest = getRequestJson(authInternalRequest);
+
+ JSONObject request = new JSONObject();
+ request.put("appId", ConfigManager.getAdminAppId());
+ request.put("password", admin_password);
+
+ //if(BaseTestCase.currentModule==null) admin_userName=
+ request.put("userName", BaseTestCase.currentModule +"-"+ admin_userName);
+
+ request.put("clientId", ConfigManager.getAdminClientId());
+ request.put("clientSecret", ConfigManager.getAdminClientSecret());
+ actualrequest.put("request", request);
+
+ Response reponse = appl.postWithJson(authenticationInternalEndpoint, actualrequest);
+ String responseBody = reponse.getBody().asString();
+ String token = new org.json.JSONObject(responseBody).getJSONObject(dataKey).getString("token");
+ return token;
+ }
+}
diff --git a/injitest/src/main/java/inji/api/KeycloakUserManager.java b/injitest/src/main/java/inji/api/KeycloakUserManager.java
new file mode 100644
index 0000000000..7536926867
--- /dev/null
+++ b/injitest/src/main/java/inji/api/KeycloakUserManager.java
@@ -0,0 +1,151 @@
+package inji.api;
+
+import inji.driver.TestRunner;
+import inji.utils.TestDataReader;
+import org.keycloak.OAuth2Constants;
+import org.keycloak.admin.client.CreatedResponseUtil;
+import org.keycloak.admin.client.Keycloak;
+import org.keycloak.admin.client.KeycloakBuilder;
+import org.keycloak.admin.client.resource.RealmResource;
+import org.keycloak.admin.client.resource.UserResource;
+import org.keycloak.admin.client.resource.UsersResource;
+import org.keycloak.representations.idm.CredentialRepresentation;
+import org.keycloak.representations.idm.RoleRepresentation;
+import org.keycloak.representations.idm.UserRepresentation;
+
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+
+public class KeycloakUserManager {
+
+ private static final org.slf4j.Logger logger= org.slf4j.LoggerFactory.getLogger(KeycloakUserManager.class);
+
+ public static Properties propsKernel = getproperty(TestRunner.getResourcePath() + "/config/"+TestRunner.GetKernalFilename());
+
+ private static Keycloak getKeycloakInstance() {
+ Keycloak key=null;
+ try {
+
+ key=KeycloakBuilder.builder().serverUrl(ConfigManager.getIAMUrl()).realm(ConfigManager.getIAMRealmId())
+ .grantType(OAuth2Constants.CLIENT_CREDENTIALS).clientId(ConfigManager.getAutomationClientId()).clientSecret(ConfigManager.getAutomationClientSecret())
+ .build();
+ System.out.println(ConfigManager.getIAMUrl());
+ System.out.println(key.toString() + key.realms());
+ }catch(Exception e)
+ {
+ throw e;
+
+ }
+ return key;
+ }
+
+ public static Properties getproperty(String path) {
+ Properties prop = new Properties();
+ try {
+ File file = new File(path);
+ prop.load(new FileInputStream(file));
+ } catch (IOException e) {
+ logger.error("Exception " + e.getMessage());
+ }
+ return prop;
+ }
+
+ public static void createUsers() {
+
+ List needsToBeCreatedUsers = List.of(ConfigManager.getIAMUsersToCreate().split(","));
+ Keycloak keycloakInstance = getKeycloakInstance();
+ for (String needsToBeCreatedUser : needsToBeCreatedUsers) {
+ UserRepresentation user = new UserRepresentation();
+ String moduleSpecificUser = null;
+ if (needsToBeCreatedUser.equals("globaladmin")) {
+ moduleSpecificUser = needsToBeCreatedUser;
+ }
+ else if(needsToBeCreatedUser.equals("masterdata-220005")){
+ moduleSpecificUser = needsToBeCreatedUser;
+
+ }
+
+ else {
+ moduleSpecificUser = BaseTestCase.currentModule +"-"+ needsToBeCreatedUser;
+ }
+
+ System.out.println(moduleSpecificUser);
+ user.setEnabled(true);
+ user.setUsername(moduleSpecificUser);
+ user.setFirstName(moduleSpecificUser);
+ user.setLastName(moduleSpecificUser);
+ user.setEmail("automation" + moduleSpecificUser + "@automationlabs.com");
+ // Get realm
+ RealmResource realmResource = keycloakInstance.realm(ConfigManager.getIAMRealmId());
+ UsersResource usersRessource = realmResource.users();
+ // Create user (requires manage-users role)
+ Response response = null;
+ response = usersRessource.create(user);
+ System.out.println(response);
+ System.out.printf("Repsonse: %s %s%n", response.getStatus(), response.getStatusInfo());
+ if (response.getStatus()==409) {
+ break;
+ }
+ System.out.println(response.getLocation());
+ String userId = CreatedResponseUtil.getCreatedId(response);
+ System.out.printf("User created with userId: %s%n", userId);
+
+ // Define password credential
+ CredentialRepresentation passwordCred = new CredentialRepresentation();
+
+ passwordCred.setTemporary(false);
+ passwordCred.setType(CredentialRepresentation.PASSWORD);
+
+ //passwordCred.setValue(userPassword.get(passwordIndex));
+ passwordCred.setValue("mosip123");
+
+ UserResource userResource = usersRessource.get(userId);
+
+ // Set password credential
+ userResource.resetPassword(passwordCred);
+
+ // Getting all the roles
+ List allRoles = realmResource.roles().list();
+ List availableRoles = new ArrayList<>();
+ List toBeAssignedRoles = List.of(ConfigManager.getRolesForUser(needsToBeCreatedUser).split(","));
+ for(String role : toBeAssignedRoles) {
+ if(allRoles.stream().anyMatch((r->r.getName().equalsIgnoreCase(role)))){
+ availableRoles.add(allRoles.stream().filter(r->r.getName().equals(role)).findFirst().get());
+ }else {
+ System.out.printf("Role not found in keycloak: %s%n", role);
+ }
+ }
+ // Assign realm role tester to user
+ userResource.roles().realmLevel() //
+ .add((availableRoles.isEmpty() ? allRoles : availableRoles));
+ //passwordIndex ++;
+ }
+ }
+
+ public static void removeUser() {
+ List needsToBeRemovedUsers = List.of(ConfigManager.getIAMUsersToCreate().split(","));
+ Keycloak keycloakInstance = getKeycloakInstance();
+ for (String needsToBeRemovedUser : needsToBeRemovedUsers) {
+ String moduleSpecificUserToBeRemoved = BaseTestCase.currentModule +"-"+ needsToBeRemovedUser;
+ RealmResource realmResource = keycloakInstance.realm(ConfigManager.getIAMRealmId());
+ UsersResource usersRessource = realmResource.users();
+
+ List usersFromDB = usersRessource.search(moduleSpecificUserToBeRemoved);
+ if (!usersFromDB.isEmpty()) {
+ UserResource userResource = usersRessource.get(usersFromDB.get(0).getId());
+ userResource.remove();
+ System.out.printf("User removed with name: %s%n", moduleSpecificUserToBeRemoved);
+ } else {
+ System.out.printf("User not found with name: %s%n", moduleSpecificUserToBeRemoved);
+ }
+
+ }
+ }
+
+}
diff --git a/injitest/src/main/java/inji/api/MockSMTPListener.java b/injitest/src/main/java/inji/api/MockSMTPListener.java
new file mode 100644
index 0000000000..f518493e90
--- /dev/null
+++ b/injitest/src/main/java/inji/api/MockSMTPListener.java
@@ -0,0 +1,208 @@
+package inji.api;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import inji.api.pojo.Root;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.WebSocket;
+import java.net.http.WebSocket.Listener;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CompletionStage;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class MockSMTPListener{
+ private static Logger logger = Logger.getLogger(MockSMTPListener.class);
+
+ public static Map