diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/DBManager.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/DBManager.java index d4ed9ab896..111f7d4025 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/DBManager.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/DBManager.java @@ -34,6 +34,37 @@ public static void clearPMSDbData() { } } } + + public static void clearPartnerRevampDbData() { + Session session = null; + try { + session = getDataBaseConnection(ConfigManager.getPMSDbUrl(), ConfigManager.getPMSDbUser(), + ConfigManager.getPMSDbPass(), ConfigManager.getPMSDbSchema()); + executeQueries(session, MosipTestRunner.getGlobalResourcePath() + "/" + "config/partnerRevampDataDeleteQueries.txt"); + } catch (Exception e) { + logger.error("Error:: While executing PMS REVAMP DB Quiries." + e.getMessage()); + } finally { + if (session != null) { + session.close(); + } + } + } + + public static void clearKeyManagerDbDataForPartnerRevamp() { + Session session = null; + try { + session = getDataBaseConnection(ConfigManager.getKMDbUrl(), ConfigManager.getKMDbUser(), + ConfigManager.getKMDbPass(), ConfigManager.getKMDbSchema()); + executeQueries(session, MosipTestRunner.getGlobalResourcePath() + "/" + "config/partnerRevampDataDeleteQueriesForKeyMgr.txt"); + } catch (Exception e) { + logger.error("Error:: While executing PMS DB Quiries." + e.getMessage()); + } finally { + if (session != null) { + session.close(); + } + } + } + public static void clearKeyManagerDbData() { Session session = null; try { 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 b22ffd1b8d..0e165c72c2 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 @@ -74,6 +74,7 @@ public class BaseTestCase { public String zonalApproverCookie = null; public String adminCookie = null; public String partnerCookie = null; + public String partnerrevampCookie = null; public String partnerNewCookie = null; public String withoutpartnerCookie = null; public String withoutpolicyCookie = null; @@ -306,6 +307,16 @@ public static void suiteSetup() { setReportName("partner"); AdminTestUtil.copyPartnerTestResource(); } + + if (listOfModules.contains(GlobalConstants.PARTNERNEW)) { + BaseTestCase.currentModule = GlobalConstants.PARTNERNEW; + DBManager.clearPartnerRevampDbData(); + DBManager.clearKeyManagerDbDataForPartnerRevamp(); + //DBManager.clearKeyManagerDbData(); + BaseTestCase.currentModule = GlobalConstants.PARTNERNEW; + setReportName(GlobalConstants.PARTNERNEW); + AdminTestUtil.copyPmsNewTestResource(); + } if (listOfModules.contains(GlobalConstants.PREREG)) { BaseTestCase.currentModule = GlobalConstants.PREREG; setReportName(GlobalConstants.PREREG); 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 2cb7c71d5f..53380d3a1f 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 @@ -144,6 +144,12 @@ public static void main(String[] arg) { if (BaseTestCase.isTargetEnvLTS()) HealthChecker.bTerminate = true; + + if (BaseTestCase.listOfModules.contains("partner")) { + DBManager.clearPMSDbData(); + DBManager.clearKeyManagerDbData(); + } + System.exit(0); 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 7b488e4aed..075016ba84 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 @@ -149,7 +149,8 @@ public class AdminTestUtil extends BaseTestCase { String prerequisiteAutoGeneratedIdPropFileName = properties.getProperty("prerequisiteAutoGeneratedIdPropFileName"); String regProcAutoGeneratedIdPropFileName = properties.getProperty("regProcAutoGeneratedIdPropFileName"); String mimotoAutoGeneratedIdPropFileName = properties.getProperty("mimotoAutoGeneratedIdPropFileName"); - + String pmsAutoGeneratedIdPropFileName = properties.getProperty("pmsAutoGeneratedIdPropFileName"); + public static final String PASSWORD_FOR_ADDIDENTITY_AND_REGISTRATION = properties .getProperty("passwordForAddIdentity"); public static final String PASSWORD_TO_RESET = properties.getProperty("passwordToReset"); @@ -418,11 +419,13 @@ protected Response postWithBodyAndCookie(String url, String jsonInput, boolean a Response response = null; String inputJson = inputJsonKeyWordHandeler(jsonInput, testCaseName); url = uriKeyWordHandelerUri(url, testCaseName); - /*if (BaseTestCase.currentModule.equals(GlobalConstants.PREREG) || BaseTestCase.currentModule.equals("auth") + if (BaseTestCase.currentModule.equals(GlobalConstants.PREREG) || BaseTestCase.currentModule.equals("auth") || BaseTestCase.currentModule.equals(GlobalConstants.RESIDENT) - || BaseTestCase.currentModule.equals(GlobalConstants.MASTERDATA)) {*/ + || BaseTestCase.currentModule.equals(GlobalConstants.MASTERDATA) + || BaseTestCase.currentModule.equals(GlobalConstants.PREREG) + ) { inputJson = smtpOtpHandler(inputJson, testCaseName); - /* } */ + } if (bothAccessAndIdToken) { token = kernelAuthLib.getTokenByRole(role, ACCESSTOKENCOOKIENAME); @@ -2759,9 +2762,6 @@ public static void copymoduleSpecificAndConfigFile(String moduleName) { File source = new File(RunConfigUtil.getGlobalResourcePath() .replace("MosipTestResource/MosipTemporaryTestResource", "") + moduleName); FileUtils.copyDirectoryToDirectory(source, destination); - -// source = new File(RunConfigUtil.getGlobalResourcePath() + "/config"); -// FileUtils.copyDirectoryToDirectory(source, destination); logger.info("Copied the test resource successfully for " + moduleName); } catch (Exception e) { logger.error( @@ -4033,6 +4033,8 @@ else if (testCaseName.toLowerCase().startsWith(GlobalConstants.PREREG)) autoGenFileName = preregAutoGeneratedIdPropFileName; else if (testCaseName.toLowerCase().startsWith(GlobalConstants.PARTNER)) autoGenFileName = partnerAutoGeneratedIdPropFileName; + else if (testCaseName.toLowerCase().startsWith(GlobalConstants.PARTNERNEW)) + autoGenFileName = pmsAutoGeneratedIdPropFileName; else if (testCaseName.toLowerCase().startsWith("idrepo")) autoGenFileName = idrepoAutoGeneratedIdPropFileName; else if (testCaseName.toLowerCase().startsWith(GlobalConstants.RESIDENT)) @@ -4047,6 +4049,9 @@ else if (testCaseName.toLowerCase().startsWith(GlobalConstants.MIMOTO)) autoGenFileName = mimotoAutoGeneratedIdPropFileName; else if (testCaseName.toLowerCase().startsWith(GlobalConstants.ESIGNET)) autoGenFileName = esignetAutoGeneratedIdPropFileName; + else if (testCaseName.toLowerCase().startsWith(GlobalConstants.PARTNERNEW)) + autoGenFileName = pmsAutoGeneratedIdPropFileName; + else { autoGenFileName = "default"; logger.info("testCaseName: " + testCaseName); @@ -4424,6 +4429,10 @@ public static void copyResidentTestResource() { public static void copyPartnerTestResource() { copymoduleSpecificAndConfigFile(GlobalConstants.PARTNER); } + + public static void copyPmsNewTestResource() { + copymoduleSpecificAndConfigFile(GlobalConstants.PARTNERNEW); + } public static ArrayList getInputTestCase(TestCaseDTO testCaseDTO) { String[] templateFields = testCaseDTO.getTemplateFields(); @@ -6489,7 +6498,6 @@ else if (testCaseName.contains("_Exceeding_Limit_Value_On_Name_Field_Neg")) } public static String smtpOtpHandler(String inputJson, String testCaseName) { - JSONObject request = new JSONObject(inputJson); String emailId = null; String otp = null; @@ -6512,8 +6520,18 @@ public static String smtpOtpHandler(String inputJson, String testCaseName) { } } } - - + if (BaseTestCase.currentModule.equals(GlobalConstants.PREREG)) { + if (request.has(GlobalConstants.REQUEST)) { + if (request.getJSONObject(GlobalConstants.REQUEST).has("otp")) { + emailId = request.getJSONObject(GlobalConstants.REQUEST).getString("userId"); + logger.info(emailId); + otp = MockSMTPListener.getOtp(emailId); + request.getJSONObject(GlobalConstants.REQUEST).put("otp", otp); + inputJson = request.toString(); + return inputJson; + } + } + } if (BaseTestCase.currentModule.equals("auth")) { if (testCaseName.startsWith("auth_GenerateVID") || testCaseName.startsWith("auth_AuthLock") || testCaseName.startsWith("auth_AuthUnLock") || testCaseName.startsWith("auth_RevokeVID")) { @@ -6596,9 +6614,7 @@ public static String smtpOtpHandler(String inputJson, String testCaseName) { } } } - if (BaseTestCase.currentModule.equals(GlobalConstants.ESIGNET) - || BaseTestCase.currentModule.equals(GlobalConstants.MIMOTO) || testCaseName.startsWith("Mimoto_WalletBinding")) { if (request.has(GlobalConstants.REQUEST)) { if (request.getJSONObject(GlobalConstants.REQUEST).has("otp")) { @@ -6647,9 +6663,7 @@ public static String smtpOtpHandler(String inputJson, String testCaseName) { return inputJson; } } - } - if (BaseTestCase.currentModule.equals(GlobalConstants.RESIDENT)) { if (request.has(GlobalConstants.REQUEST)) { if (request.getJSONObject(GlobalConstants.REQUEST).has("otp")) { diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java index 1ed990a319..4f0312c55d 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalConstants.java @@ -190,6 +190,7 @@ public class GlobalConstants { public static final String HEALTHSERVICES = "healthservices"; public static final String REMOVE = "$REMOVE$"; public static final String PARTNER = "partner"; + public static final String PARTNERNEW = "pms"; public static final String LANGNUMBER = "$LANGNUMBER$"; public static final String RESPONSE_CENTER_DETAILS = "response.centerDetails["; public static final String TIMESLOTS_FROMTIME = "].timeSlots[0].fromTime"; 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 71b2ce4391..619c9858f4 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 @@ -28,6 +28,7 @@ public class KernelAuthentication extends BaseTestCase { private String partner_password = props.get("partner_user_password"); private String partner_userName = props.get("partner_userName"); + private String partner_revamp_userName = props.get("partner_revamp_userName"); private String partner_userName_without_role = props.get("policytest_userName"); private String partner_userName_without_pm_role = props.get("policytest_without_pmrole_userName"); @@ -114,9 +115,13 @@ public String getTokenByRole(String role, String tokenType) { if (!kernelCmnLib.isValidToken(zonalApproverCookie)) zonalApproverCookie = kernelAuthLib.getAuthForZonalApprover(); return zonalApproverCookie; + case "partnerrevamp": + if (!kernelCmnLib.isValidToken(partnerrevampCookie)) + partnerrevampCookie = kernelAuthLib.getAuthForPartner(); + return partnerrevampCookie; case "partner": if (!kernelCmnLib.isValidToken(partnerCookie)) - partnerCookie = kernelAuthLib.getAuthForPartner(); + partnerCookie = kernelAuthLib.getAuthForPartnerRevamp(); return partnerCookie; case "partnernew": if (!kernelCmnLib.isValidToken(partnerNewCookie)) @@ -283,6 +288,30 @@ public String getAuthForPartner() { String responseBody = reponse.getBody().asString(); return new org.json.JSONObject(responseBody).getJSONObject(dataKey).getString(GlobalConstants.TOKEN); } + + @SuppressWarnings({ "unchecked" }) + public String getAuthForPartnerRevamp() { + + JSONObject request = new JSONObject(); + + request.put(GlobalConstants.APPID, ConfigManager.getPmsAppId()); + request.put(GlobalConstants.PASSWORD, partner_password); + request.put(GlobalConstants.USER_NAME, BaseTestCase.currentModule + "-" + partner_revamp_userName); + JSONObject actualInternalrequest = getRequestJson(authInternalRequest); + if (BaseTestCase.isTargetEnvLTS()) { + request.put(GlobalConstants.CLIENTID, ConfigManager.getPmsClientId()); + request.put(GlobalConstants.CLIENTSECRET, ConfigManager.getPmsClientSecret()); + } else { + request.put(GlobalConstants.CLIENTID, ConfigManager.getPartnerClientId()); + request.put(GlobalConstants.CLIENTSECRET, ConfigManager.getPartnerClientSecret()); + } + request.put(GlobalConstants.CLIENTID, ConfigManager.getPmsClientId()); + + actualInternalrequest.put(GlobalConstants.REQUEST, request); + Response reponse = appl.postWithJson(authenticationInternalEndpoint, actualInternalrequest); + String responseBody = reponse.getBody().asString(); + return new org.json.JSONObject(responseBody).getJSONObject(dataKey).getString(GlobalConstants.TOKEN); + } @SuppressWarnings({ "unchecked" }) public String getAuthForNewPartner() { diff --git a/apitest-commons/src/main/resources/config/Kernel.properties b/apitest-commons/src/main/resources/config/Kernel.properties index 888da558a7..585f85fb4d 100644 --- a/apitest-commons/src/main/resources/config/Kernel.properties +++ b/apitest-commons/src/main/resources/config/Kernel.properties @@ -105,6 +105,7 @@ pmsAuthInternal=true mosip_pms_app_id=partner partner_password=mosip123 partner_userName=111997 +partner_revamp_userName=111999 partner_user_password=mosip123 mosip_pms_client_id=mosip-pms-client mosip_partner_client_id=mosip-partner-client @@ -168,11 +169,12 @@ mosip_testrig_client_id=mosip-testrig-client mosip_testrig_client_secret=AonuXbikoWmHP5ug keycloak-realm-id=mosip -iam-users-to-create=111997,111998,220005,111992,globaladmin,111887 +iam-users-to-create=111997,111998,220005,111992,globaladmin,111887,111999 #iam-users-to-create=111997,220005,111992 iam-users-password=mosip123,mosip123,mosip123,mosip123,mosip123 roles.220005=GLOBAL_ADMIN,ID_AUTHENTICATION,REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,ZONAL_ADMIN roles.111997=AUTH_PARTNER,PARTNER_ADMIN,PMS_ADMIN,POLICYMANAGER,REGISTRATION_SUPERVISOR +roles.111999=AUTH_PARTNER,PARTNER_ADMIN,PMS_ADMIN,POLICYMANAGER,REGISTRATION_SUPERVISOR roles.111887=AUTH_PARTNER,PARTNER_ADMIN,PMS_ADMIN,REGISTRATION_SUPERVISOR roles.111998=POLICYMANAGER roles.111992=GLOBAL_ADMIN @@ -205,7 +207,7 @@ s3-region=null reportExpirationInDays=3 s3-account-for-persona-data=personaData # supported values yes or no -push-reports-to-s3=no +push-reports-to-s3=yes enableDebug=yes # supported values are 1 to 8 threadCount=1 @@ -230,12 +232,12 @@ ida_db_schema=ida #----------------------------------AuthDemoService Host properties----------------------------------------------------------# #To run locally -authDemoServiceBaseURL=http://localhost -authDemoServicePort=8082 +#authDemoServiceBaseURL=http://localhost +#authDemoServicePort=8082 #To run in Docker -#authDemoServiceBaseURL=http://authdemo.apitestrig -#authDemoServicePort=80 +authDemoServiceBaseURL=http://authdemo.apitestrig +authDemoServicePort=80 #----------------------------------e-Signet properties----------------------------------------------------------# @@ -254,10 +256,10 @@ esignetWellKnownEndPoint=/v1/esignet/oidc/.well-known/openid-configuration signupSettingsEndPoint=/v1/signup/settings #To run in Docker -#authCertsPath=/home/mosip/authcerts +authCertsPath=/home/mosip/authcerts #To run locally -authCertsPath= +#authCertsPath= preconfiguredOtp=111111 usePreConfiguredOtp=true