Skip to content

Commit

Permalink
Merge pull request #1488 from Sohandey/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lsivanand authored Jul 8, 2024
2 parents d4bf16d + ebd13c1 commit 2664948
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand All @@ -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);
Expand Down Expand Up @@ -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<JSONObject> getInputTestCase(TestCaseDTO testCaseDTO) {
String[] templateFields = testCaseDTO.getTemplateFields();
Expand Down Expand Up @@ -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;
Expand All @@ -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")) {
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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() {
Expand Down
18 changes: 10 additions & 8 deletions apitest-commons/src/main/resources/config/Kernel.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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----------------------------------------------------------#
Expand All @@ -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

Expand Down

0 comments on commit 2664948

Please sign in to comment.