From 678c2d293d1b62d5c91a11f464485e20453b88c3 Mon Sep 17 00:00:00 2001 From: Sohan Kumar Dey <72375959+Sohandey@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:45:07 +0530 Subject: [PATCH] MOSIP-36175 Signed-off-by: Sohan Kumar Dey <72375959+Sohandey@users.noreply.github.com> --- .../apirig/dbaccess/AuditDBManager.java | 24 +- .../apirig/testrunner/BaseTestCase.java | 30 +- .../apirig/testrunner/MockSMTPListener.java | 4 +- .../apirig/testrunner/MosipTestRunner.java | 2 +- .../testrig/apirig/utils/AdminTestUtil.java | 54 +- .../testrig/apirig/utils/CommonLibrary.java | 28 +- .../testrig/apirig/utils/ConfigManager.java | 1124 +++-------------- .../apirig/utils/KernelAuthentication.java | 8 +- 8 files changed, 270 insertions(+), 1004 deletions(-) diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/AuditDBManager.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/AuditDBManager.java index e859826ea6..c4213a599a 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/AuditDBManager.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/AuditDBManager.java @@ -123,29 +123,29 @@ private static Session getDataBaseConnection(String dbName) { private static SessionFactory getDataBaseConnectionSessionFactory(String dbName) { SessionFactory factory = null; - String dbschema = ConfigManager.getValueForKey("audit_db_schema"); + String dbschema = ConfigManager.getAuditDbSchema(); if(dbName.equalsIgnoreCase("partner")) - dbschema=ConfigManager.getValueForKey("ida_db_schema"); + dbschema=ConfigManager.getIdaDbSchema(); if(dbName.equalsIgnoreCase("master")) - dbschema=ConfigManager.getValueForKey("master_db_schema"); + dbschema=ConfigManager.getMasterDbSchema(); try { Configuration config = new Configuration(); - config.setProperty("hibernate.connection.driver_class", propsKernel.getProperty("driver_class")); + config.setProperty("hibernate.connection.driver_class", ConfigManager.getproperty("driver_class")); config.setProperty("hibernate.connection.url", - "jdbc:" + propsKernel.getProperty("postgresqlUser") + "://" - + ConfigManager.getValueForKey("db-server") + ":" + ConfigManager.getValueForKey("db-port") + "jdbc:" + ConfigManager.getproperty("postgresqlUser") + "://" + + ConfigManager.getDbServer() + ":" + ConfigManager.getDbPort() + "/mosip_" + dbschema); config.setProperty("hibernate.connection.username", ConfigManager.getAuditDbUser()); - config.setProperty("hibernate.connection.password", ConfigManager.getValueForKey(ConfigManager.DB_PASSWORD_KEY)); - config.setProperty("hibernate.default_schema", propsKernel.getProperty(dbName + "_default_schema")); - config.setProperty("hibernate.connection.pool_size", propsKernel.getProperty("pool_size")); - config.setProperty("hibernate.dialect", propsKernel.getProperty("dialect")); - config.setProperty("hibernate.show_sql", propsKernel.getProperty("show_sql")); + config.setProperty("hibernate.connection.password", ConfigManager.getAuditDbPass()); + config.setProperty("hibernate.default_schema", ConfigManager.getproperty(dbName + "_default_schema")); + config.setProperty("hibernate.connection.pool_size", ConfigManager.getproperty("pool_size")); + config.setProperty("hibernate.dialect", ConfigManager.getproperty("dialect")); + config.setProperty("hibernate.show_sql", ConfigManager.getproperty("show_sql")); config.setProperty("hibernate.current_session_context_class", - propsKernel.getProperty("current_session_context_class")); + ConfigManager.getproperty("current_session_context_class")); factory = config.buildSessionFactory(); } catch (HibernateException e) { DBCONNECTION_LOGGER.error("Exception in Database Connection with following message: " + e.getMessage()); diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java index df1eaec587..6951cd8048 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java @@ -179,8 +179,10 @@ public class BaseTestCase extends AbstractTestNGSpringContextTests { private static String zoneMappingRequest = "config/Authorization/zoneMappingRequest.json"; public static Properties props = getproperty( MosipTestRunner.getGlobalResourcePath() + "/" + "config/application.properties"); - public static Properties propsKernel = getproperty( - MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); + /* + * public static Properties propsKernel = getproperty( + * MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); + */ public static String currentRunningLanguage = ""; @@ -420,7 +422,7 @@ private void copyReportAndLog() { public static void mapUserToZone() { String token = kernelAuthLib.getTokenByRole("globalAdmin"); - String url = ApplnURI + propsKernel.getProperty("zoneMappingUrl"); + String url = ApplnURI + ConfigManager.getproperty("zoneMappingUrl"); org.json.simple.JSONObject actualrequest = getRequestJson(zoneMappingRequest); JSONObject request = new JSONObject(); request.put("zoneCode", hierarchyZoneCode); @@ -441,7 +443,7 @@ public static void mapUserToZone() { public static void mapUserToZone(String user, String zone) { String token = kernelAuthLib.getTokenByRole("globalAdmin"); - String url = ApplnURI + propsKernel.getProperty("zoneMappingUrl"); + String url = ApplnURI + ConfigManager.getproperty("zoneMappingUrl"); org.json.simple.JSONObject actualrequest = getRequestJson(zoneMappingRequest); JSONObject request = new JSONObject(); request.put("zoneCode", zone); @@ -460,7 +462,7 @@ public static void mapUserToZone(String user, String zone) { public static void mapZone() { String token = kernelAuthLib.getTokenByRole("globalAdmin"); - String url = ApplnURI + propsKernel.getProperty("zoneMappingActivateUrl"); + String url = ApplnURI + ConfigManager.getproperty("zoneMappingActivateUrl"); HashMap map = new HashMap<>(); map.put(GlobalConstants.ISACTIVE, GlobalConstants.TRUE_STRING); map.put("userId", BaseTestCase.currentModule + "-" + ConfigManager.getUserAdminName()); @@ -472,7 +474,7 @@ public static void mapZone() { public static void mapZone(String user) { String token = kernelAuthLib.getTokenByRole("globalAdmin"); - String url = ApplnURI + propsKernel.getProperty("zoneMappingActivateUrl"); + String url = ApplnURI + ConfigManager.getproperty("zoneMappingActivateUrl"); HashMap map = new HashMap<>(); map.put(GlobalConstants.ISACTIVE, GlobalConstants.TRUE_STRING); map.put("userId", user); @@ -484,7 +486,7 @@ public static void mapZone(String user) { public static boolean zoneName() { boolean firstUser = true; String token = kernelAuthLib.getTokenByRole("admin"); - String url = ApplnURI + propsKernel.getProperty("zoneNameUrl"); + String url = ApplnURI + ConfigManager.getproperty("zoneNameUrl"); HashMap map = new HashMap<>(); @@ -506,7 +508,7 @@ public static boolean zoneName() { public static void userCenterMapping() { String token = kernelAuthLib.getTokenByRole("admin"); - String url = ApplnURI + propsKernel.getProperty("userCenterMappingUrl"); + String url = ApplnURI + ConfigManager.getproperty("userCenterMappingUrl"); HashMap requestMap = new HashMap<>(); @@ -534,7 +536,7 @@ public static void userCenterMapping() { public static void userCenterMappingStatus() { String token = kernelAuthLib.getTokenByRole("admin"); - String url = ApplnURI + propsKernel.getProperty("userCenterMappingUrl"); + String url = ApplnURI + ConfigManager.getproperty("userCenterMappingUrl"); HashMap map = new HashMap<>(); @@ -596,12 +598,12 @@ public static List getLanguageList() { section = "/mosip-config/sandbox/admin-mz.properties"; try { - optionalLanguages = getValueFromActuators(propsKernel.getProperty("actuatorMasterDataEndpoint"), section, + optionalLanguages = getValueFromActuators(ConfigManager.getproperty("actuatorMasterDataEndpoint"), section, "mosip.optional-languages"); logger.info("optionalLanguages from env:" + optionalLanguages); - mandatoryLanguages = getValueFromActuators(propsKernel.getProperty("actuatorMasterDataEndpoint"), section, + mandatoryLanguages = getValueFromActuators(ConfigManager.getproperty("actuatorMasterDataEndpoint"), section, "mosip.mandatory-languages"); logger.info("mandatoryLanguages from env:" + mandatoryLanguages); @@ -626,7 +628,7 @@ public static boolean isTargetEnvLTS() { Response response = null; org.json.JSONObject responseJson = null; - String url = ApplnURI + propsKernel.getProperty("auditActuatorEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("auditActuatorEndpoint"); try { response = RestClient.getRequest(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); GlobalMethods.reportResponse(response.getHeaders().asList().toString(), url, response); @@ -683,7 +685,7 @@ public static List getSupportedIdTypesValueFromActuator() { org.json.JSONObject responseJson = null; JSONArray responseArray = null; - String url = ApplnURI + propsKernel.getProperty("actuatorIDAEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("actuatorIDAEndpoint"); try { response = RestClient.getRequest(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); GlobalMethods.reportResponse(response.getHeaders().asList().toString(), url, response); @@ -743,7 +745,7 @@ public static String generateRandomNumberString(int length) { } public static int getRecommendedHierarchyLevel() { - String recommendedHierarchLevel = getValueFromActuators(propsKernel.getProperty("actuatorMasterDataEndpoint"), + String recommendedHierarchLevel = getValueFromActuators(ConfigManager.getproperty("actuatorMasterDataEndpoint"), "/mosip-config/application-default.properties", "mosip.recommended.centers.locCode"); return Integer.parseInt(recommendedHierarchLevel); } diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MockSMTPListener.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MockSMTPListener.java index 2bcdc86844..c65d040769 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MockSMTPListener.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MockSMTPListener.java @@ -40,9 +40,9 @@ public MockSMTPListener() { public void run() { try { - Properties kernelprops = ConfigManager.propsKernel; +// Properties kernelprops = ConfigManager.propsKernel; String a1 = "wss://smtp."; - String externalurl = kernelprops.getProperty("keycloak-external-url"); + String externalurl = ConfigManager.getIAMUrl(); String a2 = externalurl.substring(externalurl.indexOf(".") + 1); String a3 = "/mocksmtp/websocket"; diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java index 95e34b9ac6..029162631d 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/MosipTestRunner.java @@ -69,7 +69,7 @@ public static void main(String[] arg) { } else { ExtractResource.copyCommonResources(); } - ConfigManager.init(); +// ConfigManager.init(); BaseTestCase.suiteSetup(); setLogLevels(); diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java index 5613300760..6cfb47b2c8 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java @@ -132,8 +132,10 @@ public class AdminTestUtil extends BaseTestCase { MosipTestRunner.getGlobalResourcePath() + "/" + "config/valueMapping.properties"); protected static final Properties propsBio = getproperty( MosipTestRunner.getGlobalResourcePath() + "/" + "config/bioValue.properties"); - protected static final Properties propsKernel = getproperty( - MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); + /* + * protected static final Properties propsKernel = getproperty( + * MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); + */ public static String propsHealthCheckURL = MosipTestRunner.getGlobalResourcePath() + "/" + "config/healthCheckEndpoint.properties"; private static String serverComponentsCommitDetails; @@ -1651,7 +1653,7 @@ public static void initialUserCreation() { Response response = null; String token = kernelAuthLib.getTokenByRole(GlobalConstants.ADMIN); org.json.simple.JSONObject actualRequestGeneration = BaseTestCase.getRequestJson("config/bulkUpload.json"); - String url = ApplnURI + propsKernel.getProperty("bulkUploadUrl"); + String url = ApplnURI + ConfigManager.getproperty("bulkUploadUrl"); JSONObject req = new JSONObject(actualRequestGeneration); @@ -2928,7 +2930,7 @@ public String getJsonFromTemplateForMapApi(String input, String inputTemplate, M public List getRolesByUser(String username) { - return List.of(propsKernel.getProperty("ROLES." + username.replaceAll(" ", "")).split(",")); + return List.of(ConfigManager.getproperty("ROLES." + username.replaceAll(" ", "")).split(",")); } @@ -2938,9 +2940,9 @@ public String uriKeyWordHandelerUri(String uri, String testCaseName) { return uri; } if (uri.contains(GlobalConstants.KEYCLOAK_USER_1)) - uri = uri.replace(GlobalConstants.KEYCLOAK_USER_1, propsKernel.getProperty("KEYCLOAKUSER1")); + uri = uri.replace(GlobalConstants.KEYCLOAK_USER_1, ConfigManager.getproperty("KEYCLOAKUSER1")); if (uri.contains(GlobalConstants.KEYCLOAK_USER_2)) - uri = uri.replace(GlobalConstants.KEYCLOAK_USER_2, propsKernel.getProperty("KEYCLOAKUSER2")); + uri = uri.replace(GlobalConstants.KEYCLOAK_USER_2, ConfigManager.getproperty("KEYCLOAKUSER2")); if (uri.contains(GlobalConstants.MODULENAME)) { uri = uri.replace(GlobalConstants.MODULENAME, BaseTestCase.certsForModule); } @@ -3123,10 +3125,10 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) { if (jsonString.contains(GlobalConstants.KEYCLOAK_USER_1)) jsonString = replaceKeywordWithValue(jsonString, GlobalConstants.KEYCLOAK_USER_1, - propsKernel.getProperty("KEYCLOAKUSER1")); + ConfigManager.getproperty("KEYCLOAKUSER1")); if (jsonString.contains(GlobalConstants.KEYCLOAK_USER_2)) jsonString = replaceKeywordWithValue(jsonString, GlobalConstants.KEYCLOAK_USER_2, - propsKernel.getProperty("KEYCLOAKUSER2")); + ConfigManager.getproperty("KEYCLOAKUSER2")); if (jsonString.contains("$RIDDEL$")) jsonString = replaceKeywordWithValue(jsonString, "$RIDDEL$", genRidDel); if (jsonString.contains("$ID:")) { @@ -3211,7 +3213,7 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) { jsonString = replaceKeywordWithValue(jsonString, "$ZONE_CODE$", ZonelocationCode); if (jsonString.contains("$USERID$")) jsonString = replaceKeywordWithValue(jsonString, "$USERID$", - BaseTestCase.currentModule + propsKernel.getProperty("admin_userName")); + BaseTestCase.currentModule + ConfigManager.getproperty("admin_userName")); if (jsonString.contains("$LOCATIONCODE$")) jsonString = replaceKeywordWithValue(jsonString, "$LOCATIONCODE$", locationCode); @@ -3384,7 +3386,7 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) { jsonString = replaceKeywordWithValue(jsonString, "$BASEURI$", ApplnURI); } if (jsonString.contains("$IDPUSER$")) { - jsonString = replaceKeywordWithValue(jsonString, "$IDPUSER$", propsKernel.getProperty("idpClientId")); + jsonString = replaceKeywordWithValue(jsonString, "$IDPUSER$", ConfigManager.getproperty("idpClientId")); } if (jsonString.contains("$OIDCCLIENT$")) { jsonString = replaceKeywordWithValue(jsonString, "$OIDCCLIENT$", @@ -3405,7 +3407,7 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) { } if (jsonString.contains("$BASE64URI$")) { String redirectUri = ApplnURI.replace(GlobalConstants.API_INTERNAL, GlobalConstants.RESIDENT) - + propsKernel.getProperty("currentUserURI"); + + ConfigManager.getproperty("currentUserURI"); jsonString = replaceKeywordWithValue(jsonString, "$BASE64URI$", encodeBase64(redirectUri)); } if (jsonString.contains("$JWKKEY$")) { @@ -3822,7 +3824,7 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) { } else { tempUrl = getValueFromEsignetWellKnownEndPoint("issuer", ConfigManager.getEsignetBaseUrl()); if (tempUrl.contains("esignet.")) { - tempUrl = tempUrl.replace("esignet.", propsKernel.getProperty("esignetMockBaseURL")); + tempUrl = tempUrl.replace("esignet.", ConfigManager.getproperty("esignetMockBaseURL")); } } jsonString = replaceKeywordWithValue(jsonString, "$PROOF_JWT_2$", @@ -6252,7 +6254,7 @@ public static void createAndPublishPolicyForKyc() { public static String signJWKKeyForMock(String clientId, RSAKey jwkKey) { String tempUrl = getValueFromEsignetWellKnownEndPoint("token_endpoint", ConfigManager.getEsignetBaseUrl()); if (tempUrl.contains("esignet.")) { - tempUrl = tempUrl.replace("esignet.", propsKernel.getProperty("esignetMockBaseURL")); + tempUrl = tempUrl.replace("esignet.", ConfigManager.getproperty("esignetMockBaseURL")); } int idTokenExpirySecs = Integer .parseInt(getValueFromEsignetActuator(ConfigManager.getEsignetActuatorPropertySection(), @@ -6329,7 +6331,7 @@ public static String signJWKKey(String clientId, RSAKey jwkKey, String tempUrl) public static String getWlaToken(String individualId, RSAKey jwkKey, String certData) throws JoseException, JOSEException { - String tempUrl = propsKernel.getProperty("validateBindingEndpoint"); + String tempUrl = ConfigManager.getproperty("validateBindingEndpoint"); int idTokenExpirySecs = Integer .parseInt(getValueFromEsignetActuator(ConfigManager.getEsignetActuatorPropertySection(), GlobalConstants.MOSIP_ESIGNET_ID_TOKEN_EXPIRE_SECONDS)); @@ -6397,7 +6399,7 @@ public static int getOtpExpTimeFromActuator() { Response response = null; org.json.JSONObject responseJson = null; JSONArray responseArray = null; - String url = ApplnURI + propsKernel.getProperty("actuatorIDAEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("actuatorIDAEndpoint"); try { response = RestClient.getRequest(url, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); @@ -6425,7 +6427,7 @@ public static int getOtpExpTimeFromActuator() { } public static String getValueFromEsignetWellKnownEndPoint(String key, String baseURL) { - String url = baseURL + propsKernel.getProperty("esignetWellKnownEndPoint"); + String url = baseURL + ConfigManager.getproperty("esignetWellKnownEndPoint"); Response response = null; JSONObject responseJson = null; if (responseJson == null) { @@ -6441,7 +6443,7 @@ public static String getValueFromEsignetWellKnownEndPoint(String key, String bas } public static String getValueFromInjiCertifyWellKnownEndPoint(String key, String baseURL) { - String url = baseURL + propsKernel.getProperty("injiCertifyWellKnownEndPoint"); + String url = baseURL + ConfigManager.getproperty("injiCertifyWellKnownEndPoint"); String actuatorCacheKey = url + key; String value = actuatorValueCache.get(actuatorCacheKey); @@ -6466,7 +6468,7 @@ public static String getValueFromInjiCertifyWellKnownEndPoint(String key, String public static JSONObject signUpSettingsResponseJson = null; public String getValueFromSignUpSettings(String key) { - String url = ApplnURI + propsKernel.getProperty("signupSettingsEndPoint"); + String url = ApplnURI + ConfigManager.getproperty("signupSettingsEndPoint"); String actuatorCacheKey = url + key; String value = actuatorValueCache.get(actuatorCacheKey); if (value != null && !value.isEmpty()) @@ -6500,7 +6502,7 @@ public String getValueFromSignUpSettings(String key) { public static JSONArray residentActuatorResponseArray = null; public static String getValueFromActuator(String section, String key) { - String url = ApplnURI + propsKernel.getProperty("actuatorEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("actuatorEndpoint"); String actuatorCacheKey = url + section + key; String value = actuatorValueCache.get(actuatorCacheKey); if (value != null && !value.isEmpty()) @@ -6538,7 +6540,7 @@ 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 url = ApplnURI + ConfigManager.getproperty("actuatorMimotoEndpoint"); if (!(System.getenv("useOldContextURL") == null) && !(System.getenv("useOldContextURL").isBlank()) && System.getenv("useOldContextURL").equalsIgnoreCase("true")) { @@ -6585,7 +6587,7 @@ public static String getValueFromMimotoActuator(String section, String key) { public static JSONArray regprocActuatorResponseArray = null; public static String getValueFromRegprocActuator(String section, String key) { - String url = ApplnURI + propsKernel.getProperty("regprocActuatorEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("regprocActuatorEndpoint"); String actuatorCacheKey = url + section + key; String value = actuatorValueCache.get(actuatorCacheKey); if (value != null && !value.isEmpty()) @@ -6623,7 +6625,7 @@ public static String getValueFromRegprocActuator(String section, String key) { public static JSONArray esignetActuatorResponseArray = null; public static String getValueFromEsignetActuator(String section, String key) { - String url = ConfigManager.getEsignetBaseUrl() + propsKernel.getProperty("actuatorEsignetEndpoint"); + String url = ConfigManager.getEsignetBaseUrl() + ConfigManager.getproperty("actuatorEsignetEndpoint"); String actuatorCacheKey = url + section + key; String value = actuatorValueCache.get(actuatorCacheKey); if (value != null && !value.isEmpty()) @@ -6661,7 +6663,7 @@ public static String getValueFromEsignetActuator(String section, String key) { public static JSONArray authActuatorResponseArray = null; public static String getValueFromAuthActuator(String section, String key) { - String url = ApplnURI + propsKernel.getProperty("actuatorIDAEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("actuatorIDAEndpoint"); String actuatorCacheKey = url + section + key; String value = actuatorValueCache.get(actuatorCacheKey); if (value != null && !value.isEmpty()) @@ -6700,7 +6702,7 @@ public static String getValueFromAuthActuator(String section, String key) { public static String getValueFromConfigActuator() { - String url = ApplnURI + propsKernel.getProperty("actuatorEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("actuatorEndpoint"); String actuatorCacheKey = url + "mosip.iam.module.login_flow.claims"; @@ -6744,7 +6746,7 @@ public static String getValueFromConfigActuator() { public static JSONArray regProcActuatorResponseArray = null; public static String getRegprocWaitFromActuator() { - String url = ApplnURI + propsKernel.getProperty("actuatorRegprocEndpoint"); + String url = ApplnURI + ConfigManager.getproperty("actuatorRegprocEndpoint"); String actuatorCacheKey = url + "registration.processor.reprocess.minutes"; String waitInterval = actuatorValueCache.get(actuatorCacheKey); @@ -7189,7 +7191,7 @@ public static void checkDbAndValidate(String timeStamp, String dbChecker) throws + "' AND session_user_name = '" + dbChecker + "';"; Map response = AuditDBManager - .executeQueryAndGetRecord(propsKernel.getProperty("audit_default_schema"), sqlQuery); + .executeQueryAndGetRecord(ConfigManager.getproperty("audit_default_schema"), sqlQuery); Map> objMap = new HashMap<>(); List objList = new ArrayList<>(); diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/CommonLibrary.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/CommonLibrary.java index b9b6c5555c..4ca486041b 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/CommonLibrary.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/CommonLibrary.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -150,18 +151,25 @@ public Map readProperty(String propertyFileName) { FileInputStream inputStream = null; Map mapProp = null; try { - logger.info("propertyFileName: " + propertyFileName + "Path :" + getResourcePathForKernel() + "config/" - + propertyFileName + ".properties"); - logger.info("propertyFileName: " + propertyFileName + "Path :" + getResourcePathForKernel() + "config/" - + propertyFileName + ".properties"); - File propertyFile = new File(getResourcePathForKernel() + "config/" + propertyFileName + ".properties"); - inputStream = new FileInputStream(propertyFile); - prop.load(inputStream); +// File propertyFile = new File( CommonLibrary.class.getClassLoader().getResourceAsStream("config/kernel.properties")); + + try (InputStream input = ConfigManager.class.getClassLoader().getResourceAsStream("config/kernel.properties")) { + if (input != null) { + // Load the properties from the input stream + prop.load(input); + } + else { + logger.error("Couldn't find kernerl.properties file"); + } + } catch (Exception ex) { + logger.error(ex.getMessage()); + } + + /* + * inputStream = new FileInputStream(propertyFile); prop.load(inputStream); + */ mapProp = prop.entrySet().stream() .collect(Collectors.toMap(e -> (String) e.getKey(), e -> (String) e.getValue())); - } catch (IOException e) { - logger.info("Error occrued while reading propertyFileName " + propertyFileName + e.getMessage()); - logger.info(e.getMessage()); } finally { AdminTestUtil.closeInputStream(inputStream); } diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java index c2cd7d78b6..f54b8645b4 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java @@ -3,7 +3,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,485 +17,61 @@ import io.mosip.testrig.apirig.testrunner.MosipTestRunner; public class ConfigManager { - private static final Logger LOGGER = Logger.getLogger(ConfigManager.class); - private static String MOSIP_PMS_CLIENT_SECRET = "mosip_pms_client_secret"; - private static String MOSIP_PARTNER_CLIENT_SECRET = "mosip_partner_client_secret"; - private static String MOSIP_PMS_CLIENT_ID = "mosip_pms_client_id"; - private static String MOSIP_PMS_APP_ID = "mosip_pms_app_id"; - private static String MOSIP_PARTNER_CLIENT_ID = "mosip_partner_client_id"; - - private static String MOSIP_RESIDENT_CLIENT_SECRET = "mosip_resident_client_secret"; - private static String MOSIP_RESIDENT_CLIENT_ID = "mosip_resident_client_id"; - private static String MOSIP_RESIDENT_APP_ID = "mosip_resident_app_id"; - - private static String MOSIP_MOBILE_CLIENT_ID = "mpartner_default_mobile_client_id"; - private static String MOSIP_MOBILE_CLIENT_SECRET = "mpartner_default_mobile_secret"; - - 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_REGPROC_CLIENT_SECRET = "mosip_regproc_client_secret"; - private static String MOSIP_REGPROC_CLIENT_ID = "mosip_regproc_client_id"; - private static String MOSIP_REGPROC_APP_ID = "mosip_regprocclient_app_id"; - - private static String MOSIP_IDA_CLIENT_SECRET = "mosip_ida_client_secret"; - private static String MOSIP_IDA_CLIENT_ID = "mosip_ida_client_id"; - private static String MOSIP_IDA_APP_ID = "mosip_ida_app_id"; - - private static String MOSIP_HOTLIST_CLIENT_SECRET = "mosip_hotlist_client_secret"; - private static String MOSIP_HOTLIST_CLIENT_ID = "mosip_hotlist_client_id"; - private static String MOSIP_HOTLIST_APP_ID = "mosip_hotlist_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"; - - public static String DB_PASSWORD_KEY = "postgres-password"; - public static String DB_USER_KEY = "db-su-user"; - - private static String S3_HOST = "s3-host"; - 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 S3_ACCOUNT_FOR_PERSONA_DATA = "s3-account-for-persona-data"; - private static String PUSH_TO_S3 = "push-reports-to-s3"; - private static String ENABLE_DEBUG = "enableDebug"; - private static String REPORT_IGNORED_TEST_CASES = "reportIgnoredTestCases"; - private static String REPORT_KNOWN_ISSUE_TEST_CASES = "reportKnownIssueTestCases"; - private static String THREAD_COUNT = "threadCount"; - private static String LANG_SELECT = "langselect"; - - private static String USEPRECONFIGOTP = "usePreConfiguredOtp"; - private static String ESIGNET_BASE_URL = "eSignetbaseurl"; - private static String ESIGNET_ACTUATOR_PROPERTY_SECTION = "esignetActuatorPropertySection"; - private static String INJI_CERTIFY_BASE_URL = "injiCertifyBaseURL"; - - private static String ESIGNET_MOCK_BASE_URL = "esignetMockBaseURL"; - private static String SUNBIRD_BASE_URL = "sunBirdBaseURL"; - - private static String PRECONFIGOTP = "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_USER_KEY; - private static String AUDIT_DB_PASS = DB_PASSWORD_KEY; - private static String AUDIT_DB_SCHEMA = "audit_db_schema"; - - private static String IDA_DB_USER = DB_USER_KEY; - private static String IDREPO_DB_USER = DB_USER_KEY; - private static String IDA_DB_PASS = DB_PASSWORD_KEY; - private static String IDA_DB_SCHEMA = "ida_db_schema"; - - private static String PMS_DB_USER = DB_USER_KEY; - private static String PMS_DB_PASS = DB_PASSWORD_KEY; - private static String PMS_DB_SCHEMA = "pms_db_schema"; - - private static String KM_DB_USER = DB_USER_KEY; - private static String KM_DB_PASS = DB_PASSWORD_KEY; - private static String KM_DB_SCHEMA = "km_db_schema"; - - private static String MASTER_DB_USER = DB_USER_KEY; - private static String MASTER_DB_PASS = DB_PASSWORD_KEY; - private static String MASTER_DB_SCHEMA = "master_db_schema"; - - private static String IAM_EXTERNAL_URL = "keycloak-external-url"; - 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 SLACK_WEBHOOK_URL = "slack-webhook-url"; - - private static String USE_EXTERNAL_SCENARIO_SHEET = "useExternalScenarioSheet"; - private static String useExternalScenario_sheet; - - private static String MOUNT_PATH = "mountPath"; - private static String AUTHCERTS_PATH = "authCertsPath"; - private static String MOUNT_PATH_FOR_SCENARIO = "mountPathForScenario"; - private static String MOCK_NOTIFICATION_CHANNEL = "mockNotificationChannel"; - private static String MOUNT_PATH_FOR_REPORT = "mountPathForReport"; - - private static String SERVER_ERRORS_TO_MONITOR = "serverErrorsToMonitor"; - - private static String PACKET_UTILITY_BASE_URL = "packetUtilityBaseUrl"; - - private static String REPORT_EXPIRATION_IN_DAYS = "reportExpirationInDays"; - - private static String SCENARIOS_TO_BE_SKIPPED = "scenariosToSkip"; - private static String SCENARIOS_TO_BE_EXECUTED = "scenariosToExecute"; - - private static String SERVICES_NOT_DEPLOYED = "servicesNotDeployed"; - - private static String ADMIN_USER_NAME = "admin_userName"; - - private static String PARTNER_URL_SUFFIX = "partnerUrlSuffix"; - - private static String MOSIP_COMPONENTS_BASE_URLS = "mosip_components_base_urls"; private static Map mosip_components_base_urls = new HashMap<>(); - - private static String partnerUrlSuffix; - - private static String serviceNotDeployedList; - - private static String toSkippedList; - private static String toExecuteList; - private static String userAdminName; - - private static String pms_client_secret; - private static String partner_client_secret; - private static String pms_client_id; - private static String pms_app_id; - private static String partner_client_id; - - private static String resident_client_secret; - private static String resident_client_id; - private static String resident_app_id; - - private static String mpartner_mobile_client_id; - private static String mpartner_mobile_client_secret; - - 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 regprocessor_client_secret; - private static String regprocessor_client_id; - private static String regprocessor_app_id; - - private static String ida_client_secret; - private static String ida_client_id; - private static String ida_app_id; - - private static String hotlist_client_secret; - private static String hotlist_client_id; - private static String hotlist_app_id; - - private static String automation_client_secret; - private static String automation_client_id; - private static String automation_app_id; - - private static String s3Region; - private static String s3Host; - private static String s3UserKey; - private static String s3Account; - private static String s3AccountForPersonaData; - private static String s3SecretKey; - private static String push_reports_to_s3; - private static String enableDebug; - private static String reportIgnoredTestCases; - private static String reportKnownIssueTestCases; - private static String threadCount; - private static String langselect; - private static String usePreConfiguredOtp; - private static String preconfiguredOtp; - private static String eSignetbaseurl; - private static String esignetMockBaseURL; - private static String sunBirdBaseURL; - private static String esignetActuatorPropertySection; - private static String injiCertifyBaseURL; - - private static String dbPort; - private static String dbDomain; - private static String hibernateConnectionDriverClass; - private static String hibernateConnectionPoolSize; - private static String hibernateDialect; - private static String hibernateShowSql; - private static String hibernate_current_session_context_class; - - private static String auditDBUser; - private static String auditDBPass; - private static String auditDBSchema; - - private static String idaDBUser; - private static String idRepoDBUser; - private static String idaDBPass; - private static String idaDBSchema; - - private static String pmsDBUser; - private static String pmsDBPass; - private static String pmsDBSchema; - - private static String kmDBUser; - private static String kmDBPass; - private static String kmDBSchema; - - private static String masterDBUser; - private static String masterDBPass; - private static String masterDBSchema; - - private static String iamExternalURL; - private static String iamRealmID; - private static String getSlackWebHookUrl; - - private static String iamUsersToCreate; - private static String iamUsersPassword; - - private static String serverErrorsToMonitor; - - private static String mountPath; - private static String mountPathForReport; - private static String authCertsPath; - private static String mockNotificationChannel; - private static String mountPathForScenario; - private static String packetUtilityBaseUrl; - public static Properties propsKernel; - private static String reportExpirationInDays; - - public static boolean getUsePreConfiguredOtp; - - 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); + protected static Map propertiesMap = new HashMap<>(); + + private static void init() { + Properties kernelProps = new Properties(); + try (InputStream input = ConfigManager.class.getClassLoader().getResourceAsStream("config/kernel.properties")) { + if (input != null) { + // Load the properties from the input stream + kernelProps.load(input); + } else { + LOGGER.error("Couldn't find kernel.properties file"); + } + } catch (Exception ex) { + LOGGER.error(ex.getMessage()); + } + // Iterate over all keys in kernelProps and process them + for (String key : kernelProps.stringPropertyNames()) { + getValueForKeyAddToPropertiesMap(kernelProps, key); } } - 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() { - propsKernel = getproperty(MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); - - pms_client_secret = getValueForKey(MOSIP_PMS_CLIENT_SECRET); - partner_client_secret = getValueForKey(MOSIP_PARTNER_CLIENT_SECRET); - pms_client_id = getValueForKey(MOSIP_PMS_CLIENT_ID); - partner_client_id = getValueForKey(MOSIP_PARTNER_CLIENT_ID); - - pms_app_id = getValueForKey(MOSIP_PMS_APP_ID); - resident_client_secret = getValueForKey(MOSIP_RESIDENT_CLIENT_SECRET); - resident_client_id = getValueForKey(MOSIP_RESIDENT_CLIENT_ID); - resident_app_id = getValueForKey(MOSIP_RESIDENT_APP_ID); - mpartner_mobile_client_id = getValueForKey(MOSIP_MOBILE_CLIENT_ID); - mpartner_mobile_client_secret = getValueForKey(MOSIP_MOBILE_CLIENT_SECRET); - 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); - - regprocessor_client_secret = getValueForKey(MOSIP_REGPROC_CLIENT_SECRET); - regprocessor_client_id = getValueForKey(MOSIP_REGPROC_CLIENT_ID); - regprocessor_app_id = getValueForKey(MOSIP_REGPROC_APP_ID); - - ida_client_secret = getValueForKey(MOSIP_IDA_CLIENT_SECRET); - ida_client_id = getValueForKey(MOSIP_IDA_CLIENT_ID); - ida_app_id = getValueForKey(MOSIP_IDA_APP_ID); - hotlist_client_secret = getValueForKey(MOSIP_HOTLIST_CLIENT_SECRET); - hotlist_client_id = getValueForKey(MOSIP_HOTLIST_CLIENT_ID); - hotlist_app_id = getValueForKey(MOSIP_HOTLIST_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); - s3Host = getValueForKey(S3_HOST); - s3Region = getValueForKey(S3_REGION); - s3UserKey = getValueForKey(S3_USER_KEY); - s3SecretKey = getValueForKey(S3_SECRET_KEY); - s3Account = getValueForKey(S3_ACCOUNT); - s3AccountForPersonaData = getValueForKey(S3_ACCOUNT_FOR_PERSONA_DATA); - dbPort = getValueForKey(DB_PORT); - dbDomain = getValueForKey(DB_DOMAIN); - hibernateConnectionDriverClass = getValueForKey(HIBERNATE_CONNECTION_DRIVER_CLASS); - hibernateConnectionPoolSize = getValueForKey(HIBERNATE_CONNECTION_POOL_SIZE); - hibernateDialect = getValueForKey(HIBERNATE_DIALECT); - hibernateShowSql = getValueForKey(HIBERNATE_SHOW_SQL); - hibernate_current_session_context_class = getValueForKey(HIBERNATE_CONTEXT_CLASS); - auditDBUser = getValueForKey(AUDIT_DB_USER); - auditDBPass = getValueForKey(AUDIT_DB_PASS); - auditDBSchema = getValueForKey(AUDIT_DB_SCHEMA); - idaDBUser = getValueForKey(IDA_DB_USER); - idRepoDBUser = getValueForKey(IDREPO_DB_USER); - idaDBPass = getValueForKey(IDA_DB_PASS); - idaDBSchema = getValueForKey(IDA_DB_SCHEMA); - pmsDBUser = getValueForKey(PMS_DB_USER); - pmsDBPass = getValueForKey(PMS_DB_PASS); - pmsDBSchema = getValueForKey(PMS_DB_SCHEMA); - kmDBUser = getValueForKey(KM_DB_USER); - kmDBPass = getValueForKey(KM_DB_PASS); - kmDBSchema = getValueForKey(KM_DB_SCHEMA); - masterDBUser = getValueForKey(MASTER_DB_USER); - masterDBPass = getValueForKey(MASTER_DB_PASS); - masterDBSchema = getValueForKey(MASTER_DB_SCHEMA); - iamExternalURL = getValueForKey(IAM_EXTERNAL_URL); - LOGGER.info("keycloakendpoint from config manager::" + iamExternalURL); - - iamRealmID = getValueForKey(IAM_REALM_ID); - getSlackWebHookUrl = getValueForKey(SLACK_WEBHOOK_URL); - iamUsersToCreate = getValueForKey(IAM_USERS_TO_CREATE); - iamUsersPassword = getValueForKey(IAM_USERS_PASSWORD); - - 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); - - serverErrorsToMonitor = System.getenv(SERVER_ERRORS_TO_MONITOR) == null - ? propsKernel.getProperty(SERVER_ERRORS_TO_MONITOR) - : propsKernel.getProperty(SERVER_ERRORS_TO_MONITOR) + "," + System.getenv(SERVER_ERRORS_TO_MONITOR); - propsKernel.setProperty(SERVER_ERRORS_TO_MONITOR, serverErrorsToMonitor); - - 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); - - mountPath = System.getenv(MOUNT_PATH) == null ? propsKernel.getProperty(MOUNT_PATH) : System.getenv(MOUNT_PATH); - propsKernel.setProperty(MOUNT_PATH, mountPath); - - mountPathForReport = System.getenv(MOUNT_PATH_FOR_REPORT) == null - ? propsKernel.getProperty(MOUNT_PATH_FOR_REPORT) - : System.getenv(MOUNT_PATH_FOR_REPORT); - propsKernel.setProperty(MOUNT_PATH_FOR_REPORT, mountPathForReport); - - - mockNotificationChannel = System.getenv(MOCK_NOTIFICATION_CHANNEL) == null - ? propsKernel.getProperty(MOCK_NOTIFICATION_CHANNEL) - : System.getenv(MOCK_NOTIFICATION_CHANNEL); - propsKernel.setProperty(MOCK_NOTIFICATION_CHANNEL, mockNotificationChannel); - - 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); - - reportIgnoredTestCases = System.getenv(REPORT_IGNORED_TEST_CASES) == null - ? propsKernel.getProperty(REPORT_IGNORED_TEST_CASES) - : System.getenv(REPORT_IGNORED_TEST_CASES); - propsKernel.setProperty(REPORT_IGNORED_TEST_CASES, reportIgnoredTestCases); - - reportKnownIssueTestCases = System.getenv(REPORT_KNOWN_ISSUE_TEST_CASES) == null - ? propsKernel.getProperty(REPORT_KNOWN_ISSUE_TEST_CASES) - : System.getenv(REPORT_KNOWN_ISSUE_TEST_CASES); - propsKernel.setProperty(REPORT_KNOWN_ISSUE_TEST_CASES, reportKnownIssueTestCases); - - 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); - - 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); - - useExternalScenario_sheet = System.getenv(USE_EXTERNAL_SCENARIO_SHEET) == null - ? propsKernel.getProperty(USE_EXTERNAL_SCENARIO_SHEET) - : System.getenv(USE_EXTERNAL_SCENARIO_SHEET); - propsKernel.setProperty(USE_EXTERNAL_SCENARIO_SHEET, useExternalScenario_sheet); - - esignetActuatorPropertySection = System.getenv(ESIGNET_ACTUATOR_PROPERTY_SECTION) == null - ? propsKernel.getProperty(ESIGNET_ACTUATOR_PROPERTY_SECTION) - : System.getenv(ESIGNET_ACTUATOR_PROPERTY_SECTION); - propsKernel.setProperty(ESIGNET_ACTUATOR_PROPERTY_SECTION, esignetActuatorPropertySection); - - if (System.getenv(ESIGNET_BASE_URL) != null) { - eSignetbaseurl = System.getenv(ESIGNET_BASE_URL); - } else { - eSignetbaseurl = System.getProperty("env.endpoint").replace("api-internal", "esignet"); - } - propsKernel.setProperty(ESIGNET_BASE_URL, eSignetbaseurl); - - if (System.getenv(INJI_CERTIFY_BASE_URL) != null) { - injiCertifyBaseURL = System.getenv(INJI_CERTIFY_BASE_URL); - } else { - injiCertifyBaseURL = System.getProperty("env.endpoint").replace("api-internal", "injicertify"); + public static void init(Map additionalPropertiesMap) { + //Load common properties + init(); + // Add all entries from dslpropertiesMap to propertiesMap + propertiesMap.putAll(additionalPropertiesMap); + } + + public static void getValueForKeyAddToPropertiesMap(Properties props, String key) { + if(key.equalsIgnoreCase("serverErrorsToMonitor")){ + String value = System.getenv("serverErrorsToMonitor") == null + ? props.getProperty("serverErrorsToMonitor") + : props.getProperty("serverErrorsToMonitor") + "," + System.getenv("serverErrorsToMonitor"); + propertiesMap.put(key, value); + } else if (key.equalsIgnoreCase("eSignetbaseurl")){ + String value = ""; + if (System.getenv("eSignetbaseurl") != null) { + value = System.getenv("eSignetbaseurl"); + } else { + value = System.getProperty("env.endpoint").replace("-internal", ""); + } + propertiesMap.put(key, value); + } else if (key.equalsIgnoreCase("mosip_components_base_urls")){ + String components_base_urls = System.getenv("mosip_components_base_urls") == null + ? props.getProperty("mosip_components_base_urls") + : System.getenv("mosip_components_base_urls"); + loadComponentBaseURLs(components_base_urls); + } else{ + String value = System.getenv(key) == null ? props.getProperty(key) : System.getenv(key); + propertiesMap.put(key, value); } - propsKernel.setProperty(INJI_CERTIFY_BASE_URL, injiCertifyBaseURL); - - esignetMockBaseURL = System.getenv(ESIGNET_MOCK_BASE_URL) == null - ? propsKernel.getProperty(ESIGNET_MOCK_BASE_URL) - : System.getenv(ESIGNET_MOCK_BASE_URL); - propsKernel.setProperty(ESIGNET_MOCK_BASE_URL, esignetMockBaseURL); - - sunBirdBaseURL = System.getenv(SUNBIRD_BASE_URL) == null - ? propsKernel.getProperty(SUNBIRD_BASE_URL) - : System.getenv(SUNBIRD_BASE_URL); - propsKernel.setProperty(SUNBIRD_BASE_URL, sunBirdBaseURL); - - serviceNotDeployedList = System.getenv(SERVICES_NOT_DEPLOYED) == null - ? propsKernel.getProperty(SERVICES_NOT_DEPLOYED) - : System.getenv(SERVICES_NOT_DEPLOYED); - propsKernel.setProperty(SERVICES_NOT_DEPLOYED, serviceNotDeployedList); - - toSkippedList = System.getenv(SCENARIOS_TO_BE_SKIPPED) == null - ? propsKernel.getProperty(SCENARIOS_TO_BE_SKIPPED) - : System.getenv(SCENARIOS_TO_BE_SKIPPED); - propsKernel.setProperty(SCENARIOS_TO_BE_SKIPPED, toSkippedList); - - toExecuteList = System.getenv(SCENARIOS_TO_BE_EXECUTED) == null - ? propsKernel.getProperty(SCENARIOS_TO_BE_EXECUTED) - : System.getenv(SCENARIOS_TO_BE_EXECUTED); - propsKernel.setProperty(SCENARIOS_TO_BE_EXECUTED, toExecuteList); - - partnerUrlSuffix = System.getenv(PARTNER_URL_SUFFIX) == null ? propsKernel.getProperty(PARTNER_URL_SUFFIX) - : System.getenv(PARTNER_URL_SUFFIX); - propsKernel.setProperty(PARTNER_URL_SUFFIX, partnerUrlSuffix); - - userAdminName = System.getenv(ADMIN_USER_NAME) == null ? propsKernel.getProperty(ADMIN_USER_NAME) - : System.getenv(ADMIN_USER_NAME); - propsKernel.setProperty(ADMIN_USER_NAME, userAdminName); - - String components_base_urls = System.getenv(MOSIP_COMPONENTS_BASE_URLS) == null - ? propsKernel.getProperty(MOSIP_COMPONENTS_BASE_URLS) - : System.getenv(MOSIP_COMPONENTS_BASE_URLS); - loadComponentBaseURLs(components_base_urls); } + public static void loadComponentBaseURLs(String components_base_urls) { if (components_base_urls != null && !components_base_urls.isEmpty()) { @@ -509,482 +88,157 @@ public static void loadComponentBaseURLs(String components_base_urls) { } } - public static boolean isInServiceNotDeployedList(String stringToFind) { - synchronized (serviceNotDeployedList) { - if (serviceNotDeployedList.isBlank()) - return false; - List serviceNotDeployed = Arrays.asList(serviceNotDeployedList.trim().split(",")); - if (ConfigManager.IsDebugEnabled()) - LOGGER.info("serviceNotDeployedList: " + serviceNotDeployedList + ", serviceNotDeployed : " - + serviceNotDeployed + ", stringToFind : " + stringToFind); - for (String string : serviceNotDeployed) { - if (string.equalsIgnoreCase(stringToFind)) - return true; - else if (stringToFind.toLowerCase().contains(string.toLowerCase())) { - return true; - } - } + protected static Properties getproperties(String path) { + Properties prop = new Properties(); + FileInputStream inputStream = null; + try { + File file = new File(path); + inputStream = new FileInputStream(file); + prop.load(inputStream); + } catch (IOException e) { + LOGGER.error(GlobalConstants.EXCEPTION_STRING_2 + e.getMessage()); + } finally { + AdminTestUtil.closeInputStream(inputStream); } - return false; + return prop; } - public static boolean isInTobeSkippedList(String stringToFind) { - synchronized (toSkippedList) { - List toBeSkippedLsit = Arrays.asList(toSkippedList.split(",")); - if (ConfigManager.IsDebugEnabled()) - LOGGER.info("toSkippedList: " + toSkippedList + ", toBeSkippedLsit : " + toBeSkippedLsit - + ", stringToFind : " + stringToFind); - for (String string : toBeSkippedLsit) { - if (string.equalsIgnoreCase(stringToFind)) - return true; - } - } - return false; - } - public static boolean isInTobeExecuteList(String stringToFind) { - synchronized (toExecuteList) { - // If there are no specific execution list is provided , execute all scenarios - if (toExecuteList != null && toExecuteList.isEmpty()) + public static String getproperty(String key) { + return propertiesMap.get(key) == null ? "" : propertiesMap.get(key).toString(); + } + + + public static String getRolesForUser(String userId) { + Properties props = getproperties(MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); + return props.getProperty("roles." + userId); + } + + public static String getServerErrorsToMonitor() { return getproperty("serverErrorsToMonitor"); } + public static String getEnableDebug() { return getproperty("enableDebug"); } + public static String getPmsClientId() { return getproperty("mosip_pms_client_id"); } + public static String getmountPath() { return getproperty("mountPath"); } + public static Boolean IsDebugEnabled() { return getproperty("enableDebug").equalsIgnoreCase("yes"); } + public static Boolean reportIgnoredTestCases() { return getproperty("reportIgnoredTestCases").equalsIgnoreCase("yes"); } + public static String getS3Host() { return getproperty("s3-host"); } + public static String getS3Region() { return getproperty("s3-region"); } + public static String getS3UserKey() { return getproperty("s3-user-key"); } + public static String getS3SecretKey() { return getproperty("s3-user-secret"); } + public static String getS3Account() { return getproperty("s3-account"); } + public static String getS3AccountForPersonaData() { return getproperty("s3-account-for-persona-data"); } + public static String getPushReportsToS3() { return getproperty("push-reports-to-s3"); } + public static String getKMDbSchema() { return getproperty("km_db_schema"); } + public static String getMasterDbSchema() { return getproperty("master_db_schema"); } + public static String getPMSDbSchema() { return getproperty("pms_db_schema"); } + public static String getAuditDbSchema() { return getproperty("audit_db_schema"); } + + public static String getDbPort() { return getproperty("db-port"); } + public static String getDbServer() { return getproperty("db-server"); } + public static String getMockNotificationChannel() { return getproperty("mockNotificationChannel"); } + + + public static String getIdaDbSchema() { return getproperty("ida_db_schema"); } + public static int getLangselect() { return Integer.parseInt(getproperty("langselect")); } + public static String getauthCertsPath(){ return getproperty("authCertsPath"); } + public static String getAuthDemoServiceBaseUrl() { return getproperty("authDemoServiceBaseURL"); } + public static String getAuthDemoServicePort() { return getproperty("authDemoServicePort"); } + public static String getReportExpirationInDays() { return getproperty("reportExpirationInDays"); } + public static String getDbDriverClass() { return getproperty("hibernate.connection.driver_class"); } + public static String getDbConnectionPoolSize() { return getproperty("hibernate.connection.pool_size"); } + public static String getDbDialect() { return getproperty("hibernate.dialect"); } + public static String getShowSql() { return getproperty("hibernate.show_sql"); } + public static String getDbSessionContext() { return getproperty("hibernate.current_session_context_class"); } + public static String getUsePreConfiguredOtp() { return getproperty("usePreConfiguredOtp"); } + public static String getPreConfiguredOtp() { return getproperty("preconfiguredOtp"); } + public static String getPartnerUrlSuffix() { return getproperty("partnerUrlSuffix"); } + public static String getSlackWebHookUrl() { return getproperty("slack-webhook-url"); } + public static String getIAMRealmId() { return getproperty("keycloak-realm-id"); } + public static String getIdaDbUrl() { return "jdbc:postgresql://" + getproperty("db-server") + ":" + getproperty("db-port") + "/mosip_ida"; } + public static String getAuditDbUrl() { return "jdbc:postgresql://" + getproperty("db-server") + ":" + getproperty("db-port") + "/mosip_audit"; } + + public static String getIdRepoDbUrl() { return "jdbc:postgresql://" + getproperty("db-server") + ":" + getproperty("db-port") + "/mosip_idrepo"; } + + public static String getPMSDbUrl() { return "jdbc:postgresql://" + getproperty("db-server") + ":" + getproperty("db-port") + "/mosip_pms"; } + public static String getKMDbUrl() { return "jdbc:postgresql://" + getproperty("db-server") + ":" + getproperty("db-port") + "/mosip_keymgr"; } + public static String getMASTERDbUrl() { return "jdbc:postgresql://" + getproperty("db-server") + ":" + getproperty("db-port") + "/mosip_master"; } + public static String getUserAdminName() { return getproperty("admin_userName"); } + public static String getPmsClientSecret() { return getproperty("mosip_pms_client_secret"); } + public static String getPartnerClientSecret() { return getproperty("mosip_partner_client_secret"); } + public static String getPartnerClientId() { return getproperty("mosip_partner_client_id"); } + public static String getPmsAppId() { return getproperty("mosip_pms_app_id"); } + public static String getResidentClientSecret() { return getproperty("mosip_resident_client_secret"); } + public static String getResidentClientId() { return getproperty("mosip_resident_client_id"); } + public static String getResidentAppId() { return getproperty("mosip_resident_app_id"); } + public static String getMPartnerMobileClientId() { return getproperty("mpartner_default_mobile_client_id"); } + public static String getMPartnerMobileClientSecret() { return getproperty("mpartner_default_mobile_secret"); } + public static String getAdminClientSecret() { return getproperty("mosip_admin_client_secret"); } + public static String getAdminClientId() { return getproperty("mosip_admin_client_id"); } + public static String getAdminAppId() { return getproperty("mosip_admin_app_id"); } + public static String getIdRepoClientSecret() { return getproperty("mosip_idrepo_client_secret"); } + public static String getidRepoClientId() { return getproperty("mosip_idrepo_client_id"); } + public static String getidRepoAppId() { return getproperty("mosip_idrepo_app_id"); } + public static String getRegprocClientSecret() { return getproperty("mosip_regproc_client_secret"); } + public static String getRegprocClientId() { return getproperty("mosip_regproc_client_id"); } + public static String getRegprocAppId() { return getproperty("mosip_regprocclient_app_id"); } + //public static String getRegprocessorClientSecret() { return getproperty("mosip_regproc_client_secret"); } + //public static String getRegprocessorClientId() { return getproperty("mosip_regproc_client_id"); } + //public static String getRegprocessorAppId() { return getproperty("mosip_regprocclient_app_id"); } + public static String getIdaClientSecret() { return getproperty("mosip_ida_client_secret"); } + public static String getIdaClientId() { return getproperty("mosip_ida_client_id"); } + public static String getIdaAppId() { return getproperty("mosip_ida_app_id"); } + public static String getHotListClientSecret() { return getproperty("mosip_hotlist_client_secret"); } + public static String getHotListClientId() { return getproperty("mosip_hotlist_client_id"); } + public static String getHotListAppId() { return getproperty("mosip_hotlist_app_id"); } + public static String getAutomationClientSecret() { return getproperty("mosip_testrig_client_secret"); } + public static String getAutomationClientId() { return getproperty("mosip_testrig_client_id"); } + public static String getAutomationAppId() { return getproperty("mosip_automation_app_id"); } + public static String getTargetEnvName() { return getproperty("db-server"); } + public static String getAuditDbUser() { return getproperty("db-su-user"); } + public static String getIdRepoDbUser() { return getproperty("db-su-user"); } + public static String getAuditDbPass() { return getproperty("postgres-password"); } + public static String getIdaDbUser() { return getAuditDbUser(); } + public static String getIdaDbPass() { return getAuditDbPass(); } + public static String getPMSDbUser() { return getAuditDbUser(); } + public static String getPMSDbPass() { return getAuditDbPass(); } + public static String getKMDbUser() { return getAuditDbUser(); } + public static String getKMDbPass() { return getAuditDbPass(); } + public static String getMasterDbUser() { return getAuditDbUser(); } + public static String getMasterDbPass() { return getAuditDbPass(); } + public static String getIAMUsersToCreate() { return getproperty("iam-users-to-create"); } + public static String getIAMUsersPassword() { return getproperty("iam-users-password"); } + public static String getIAMUrl() { return getproperty("keycloak-external-url") + "/auth"; } + public static String getMountPathForReport() { return getproperty("mountPathForReport"); } + public static Boolean reportKnownIssueTestCases() { return getproperty("reportKnownIssueTestCases").equalsIgnoreCase("yes");} + + // TO DO -- To be removed from commons + public static String getEsignetActuatorPropertySection() { return getproperty("esignetActuatorPropertySection");} + public static String getEsignetBaseUrl() { return getproperty("eSignetbaseurl");} + public static String getEsignetMockBaseURL() { return getproperty("esignetMockBaseURL");} + public static String getInjiCertifyBaseUrl() { return getproperty("injiCertifyBaseURL");} + + public static synchronized boolean isInServiceNotDeployedList(String stringToFind) { + String serviceNotDeployedList = getproperty("servicesNotDeployed"); + + if (serviceNotDeployedList.isBlank()) + return false; + + List serviceNotDeployed = Arrays.asList(serviceNotDeployedList.trim().split(",")); + if (ConfigManager.IsDebugEnabled()) + LOGGER.info("serviceNotDeployedList: " + serviceNotDeployedList + ", serviceNotDeployed : " + + serviceNotDeployed + ", stringToFind : " + stringToFind); + for (String string : serviceNotDeployed) { + if (string.equalsIgnoreCase(stringToFind)) + return true; + else if (stringToFind.toLowerCase().contains(string.toLowerCase())) { return true; - - List toBeExecuteList = Arrays.asList(toExecuteList.split(",")); - if (ConfigManager.IsDebugEnabled()) - LOGGER.info("toExecuteList: " + toExecuteList + ", toBeExecuteList : " + toBeExecuteList - + ", stringToFind : " + stringToFind); - for (String string : toBeExecuteList) { - if (string.trim().equalsIgnoreCase(stringToFind)) - return true; } } return false; } - public static String getEsignetActuatorPropertySection() { - return esignetActuatorPropertySection; - - } public static String getComponentBaseURL(String component) { return mosip_components_base_urls.get(component); } - public static String getServerErrorsToMonitor() { - return serverErrorsToMonitor; - } - - public static String getUserAdminName() { - return userAdminName; - - } - - public static String getPartnerUrlSuffix() { - return partnerUrlSuffix; - } - - public static Boolean useExternalScenarioSheet() { - return useExternalScenario_sheet.equalsIgnoreCase("yes"); - } - - public static Boolean IsDebugEnabled() { - return enableDebug.equalsIgnoreCase("yes"); - } - - public static Boolean reportIgnoredTestCases() { - return reportIgnoredTestCases.equalsIgnoreCase("yes"); - } - - public static Boolean reportKnownIssueTestCases() { - return reportKnownIssueTestCases.equalsIgnoreCase("yes"); - } - - public static String getReportExpirationInDays() { - return reportExpirationInDays; - } - - public static int getLangselect() { - return Integer.parseInt(langselect); - - } - - public static String getEsignetBaseUrl() { - return eSignetbaseurl; - - } - - public static String getInjiCertifyBaseUrl() { - return injiCertifyBaseURL; - - } - - public static String getEsignetMockBaseURL() { - return esignetMockBaseURL; - - } - - public static String getSunBirdBaseURL() { - return sunBirdBaseURL; - - } - - public static String getUsePreConfiguredOtp() { - return usePreConfiguredOtp; - - } - - public static String getPreConfiguredOtp() { - return preconfiguredOtp; - - } - - public static String getThreadCount() { - return threadCount; - - } - - public static String getEnableDebug() { - return enableDebug; - - } - - public static String getmountPath() { - return mountPath; - } - - public static String getMountPathForReport() { - return mountPathForReport; - } - - public static String getmountPathForScenario() { - return mountPathForScenario; - } - - public static String getpacketUtilityBaseUrl() { - return packetUtilityBaseUrl; - } - - public static String getMockNotificationChannel() { - return mockNotificationChannel; - } - - public static String getauthCertsPath() { - return authCertsPath; - } - - public static Properties init(String abc) { - propsKernel = getproperty(MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); - - return propsKernel; - } - - public static String getPmsClientSecret() { - return pms_client_secret; - } - - public static String getPartnerClientSecret() { - return partner_client_secret; - } - - public static String getPmsClientId() { - return pms_client_id; - } - - public static String getPartnerClientId() { - return partner_client_id; - } - - public static String getPmsAppId() { - return pms_app_id; - } - - public static String getResidentClientSecret() { - return resident_client_secret; - } - - public static String getResidentClientId() { - return resident_client_id; - } - - public static String getResidentAppId() { - return resident_app_id; - } - - public static String getMPartnerMobileClientId() { - return mpartner_mobile_client_id; - } - - public static String getMPartnerMobileClientSecret() { - return mpartner_mobile_client_secret; - } - - public static String getAdminClientSecret() { - return admin_client_secret; - } - - 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 getRegprocessorClientSecret() { - return regprocessor_client_secret; - } - - public static String getRegprocessorClientId() { - return regprocessor_client_id; - } - - public static String getRegprocessorAppId() { - return regprocessor_app_id; - } - - public static String getIdaClientSecret() { - return ida_client_secret; - } - - public static String getIdaClientId() { - return ida_client_id; - } - - public static String getIdaAppId() { - return ida_app_id; - } - - public static String getHotListClientSecret() { - return hotlist_client_secret; - } - - public static String getHotListClientId() { - return hotlist_client_id; - } - - public static String getHotListAppId() { - return hotlist_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 s3Host; - } - - public static String getS3Region() { - return s3Region; - } - - public static String getS3UserKey() { - return s3UserKey; - } - - public static String getS3SecretKey() { - return s3SecretKey; - } - - public static String getS3Account() { - return s3Account; - } - - public static String getS3AccountForPersonaData() { - return s3AccountForPersonaData; - } - - public static String getPushReportsToS3() { - return push_reports_to_s3; - } - - public static String getTargetEnvName() { - return dbDomain; - } - - public static String getIdaDbUrl() { - return "jdbc:postgresql://" + dbDomain + ":" + dbPort + "/mosip_ida"; - } - - public static String getIdRepoDbUrl() { - return "jdbc:postgresql://" + dbDomain + ":" + dbPort + "/mosip_idrepo"; - } - - public static String getAuditDbUrl() { - return "jdbc:postgresql://" + dbDomain + ":" + dbPort + "/mosip_audit"; - } - - public static String getDbDriverClass() { - return hibernateConnectionDriverClass; - } - - public static String getDbConnectionPoolSize() { - return hibernateConnectionPoolSize; - } - - public static String getDbDialect() { - return hibernateDialect; - } - - public static String getShowSql() { - return hibernateShowSql; - } - - public static String getDbSessionContext() { - return hibernate_current_session_context_class; - } - - public static String getAuditDbUser() { - return auditDBUser; - } - - public static String getAuditDbPass() { - LOGGER.info("DB Password from ENV::: " + System.getenv(AUDIT_DB_PASS)); - return auditDBPass; - } - - public static String getAuditDbSchema() { - return auditDBSchema; - } - - public static String getIdaDbUser() { - return idaDBUser; - } - - public static String getIdRepoDbUser() { - return idRepoDBUser; - } - - public static String getIdaDbPass() { - return idaDBPass; - } - - public static String getIdaDbSchema() { - return idaDBSchema; - } - - - - public static String getPMSDbUrl() { - return "jdbc:postgresql://" + dbDomain + ":" + dbPort + "/mosip_pms"; - } - - public static String getKMDbUrl() { - return "jdbc:postgresql://" + dbDomain + ":" + dbPort + "/mosip_keymgr"; - } - - public static String getMASTERDbUrl() { - return "jdbc:postgresql://" + dbDomain + ":" + dbPort + "/mosip_master"; - } - - public static String getPMSDbUser() { - return pmsDBUser; - } - - public static String getPMSDbPass() { - return pmsDBPass; - } - - public static String getPMSDbSchema() { - return pmsDBSchema; - } - - public static String getKMDbUser() { - return kmDBUser; - } - - public static String getKMDbPass() { - return kmDBPass; - } - - public static String getKMDbSchema() { - return kmDBSchema; - } - - public static String getMasterDbUser() { - return masterDBUser; - } - - public static String getMasterDbPass() { - return masterDBPass; - } - - public static String getMasterDbSchema() { - return masterDBSchema; - } - - public static String getIAMUrl() { - LOGGER.info("keycloak url from ENV::: " + System.getenv(IAM_EXTERNAL_URL) + "/auth"); - LOGGER.info("keycloak url from Property::: " + System.getProperty(IAM_EXTERNAL_URL) + "/auth"); - LOGGER.info("keycloak url from Config::: " + propsKernel.getProperty(IAM_EXTERNAL_URL) + "/auth"); - LOGGER.info("keycloak url is:::" + iamExternalURL + "/auth"); - return iamExternalURL + "/auth"; - } - - public static String getIAMRealmId() { - return iamRealmID; - } - - public static String getIAMUsersToCreate() { - return iamUsersToCreate; - } - - public static String getIAMUsersPassword() { - return iamUsersPassword; - } - - public static String getSlackWebHookUrl() { - return getSlackWebHookUrl; - } - - public static String getRolesForUser(String userId) { - propsKernel = getproperty(MosipTestRunner.getGlobalResourcePath() + "/" + "config/Kernel.properties"); - return propsKernel.getProperty("roles." + userId); - } - - private static Properties getproperty(String path) { - Properties prop = new Properties(); - FileInputStream inputStream = null; - try { - File file = new File(path); - inputStream = new FileInputStream(file); - prop.load(inputStream); - } catch (IOException e) { - LOGGER.error(GlobalConstants.EXCEPTION_STRING_2 + e.getMessage()); - } finally { - AdminTestUtil.closeInputStream(inputStream); - } - return prop; - } -} \ No newline at end of file +} diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java index f32f6b75a8..b1e85245d7 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java @@ -541,7 +541,7 @@ public String getPreRegToken() { JSONObject actualRequest_validation = getRequestJson("config/prereg_ValidateOtp.json"); appl.postWithJson(preregSendOtp, actualRequest_generation); String otp = null; - if (ConfigManager.getUsePreConfiguredOtp) + if (ConfigManager.getUsePreConfiguredOtp().equalsIgnoreCase("yes")) //TODO REMOVE THE HARDCODING otp = "111111"; else { @@ -581,9 +581,9 @@ public String getAuthForRegProc() { JSONObject actualrequest = getRequestJson(authRequest); JSONObject request = new JSONObject(); - request.put(GlobalConstants.APPID, ConfigManager.getRegprocessorAppId()); - request.put(GlobalConstants.CLIENTID, ConfigManager.getRegprocessorClientId()); - request.put(GlobalConstants.SECRETKEY, ConfigManager.getRegprocessorClientSecret()); + request.put(GlobalConstants.APPID, ConfigManager.getRegprocAppId()); + request.put(GlobalConstants.CLIENTID, ConfigManager.getRegprocClientId()); + request.put(GlobalConstants.SECRETKEY, ConfigManager.getRegprocClientSecret()); actualrequest.put(GlobalConstants.REQUEST, request); Response reponse = appl.postWithJson(props.get(GlobalConstants.AUTH_CLIENT_IDSECRET_KEYURL), actualrequest);