Skip to content

Commit

Permalink
Merge pull request #1345 from Sohandey/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ckm007 authored Oct 3, 2024
2 parents 041aac1 + 4293be0 commit 7f8cf4a
Show file tree
Hide file tree
Showing 22 changed files with 99 additions and 951 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.mosip.testrig.apirig.utils.EncryptionDecrptionUtil;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.GlobalMethods;
import io.mosip.testrig.apirig.utils.IdAuthConfigManager;
import io.mosip.testrig.apirig.utils.JWKKeyUtil;
import io.mosip.testrig.apirig.utils.KeyCloakUserAndAPIKeyGeneration;
import io.mosip.testrig.apirig.utils.KeycloakUserManager;
Expand Down Expand Up @@ -65,14 +66,16 @@ public static void main(String[] arg) {
for (String envName : envMap.keySet()) {
LOGGER.info(String.format("ENV %s = %s%n", envName, envMap.get(envName)));
}
BaseTestCase.setRunContext(getRunType(), jarUrl);
ExtractResource.removeOldMosipTestTestResource();
if (checkRunType().equalsIgnoreCase("JAR")) {
if (getRunType().equalsIgnoreCase("JAR")) {
ExtractResource.extractCommonResourceFromJar();
} else {
ExtractResource.copyCommonResources();
}
ConfigManager.init();
BaseTestCase.suiteSetup();
IdAuthConfigManager.init();

BaseTestCase.suiteSetup(getRunType());
SkipTestCaseHandler.loadTestcaseToBeSkippedList("testCaseSkippedList.txt");
setLogLevels();

Expand Down Expand Up @@ -114,7 +117,7 @@ public static void main(String[] arg) {
LOGGER.error("Exception " + e.getMessage());
}

MockSMTPListener.bTerminate = true;
OTPListener.bTerminate = true;

if (BaseTestCase.isTargetEnvLTS())
HealthChecker.bTerminate = true;
Expand Down Expand Up @@ -145,7 +148,7 @@ public static void startTestRunner() {
List<String> modulesToRun = BaseTestCase.listOfModules;
String os = System.getProperty("os.name");
LOGGER.info(os);
if (checkRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
if (getRunType().contains("IDE") || os.toLowerCase().contains("windows")) {
homeDir = new File(System.getProperty("user.dir") + "/testNgXmlFiles");
LOGGER.info("IDE :" + homeDir);
} else {
Expand Down Expand Up @@ -176,10 +179,10 @@ public static void startTestRunner() {
*/
/*
* public static String getGlobalResourcePath() { if
* (checkRunType().equalsIgnoreCase("JAR")) { return new
* (getRunType().equalsIgnoreCase("JAR")) { return new
* File(jarUrl).getParentFile().getAbsolutePath() +
* "/MosipTestResource/MosipTemporaryTestResource"; } else if
* (checkRunType().equalsIgnoreCase("IDE")) { String path = new
* (getRunType().equalsIgnoreCase("IDE")) { String path = new
* File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).
* getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource"; if
* (path.contains(GlobalConstants.TESTCLASSES)) path =
Expand All @@ -193,9 +196,9 @@ public static String getGlobalResourcePath() {
}

String path = null;
if (checkRunType().equalsIgnoreCase("JAR")) {
if (getRunType().equalsIgnoreCase("JAR")) {
path = new File(jarUrl).getParentFile().getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource";
} else if (checkRunType().equalsIgnoreCase("IDE")) {
} else if (getRunType().equalsIgnoreCase("IDE")) {
path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath()
+ "/MosipTestResource/MosipTemporaryTestResource";
if (path.contains(GlobalConstants.TESTCLASSES))
Expand All @@ -212,9 +215,9 @@ public static String getGlobalResourcePath() {

public static String getResourcePath() {
return getGlobalResourcePath();
// if (checkRunType().equalsIgnoreCase("JAR")) {
// if (getRunType().equalsIgnoreCase("JAR")) {
// return new File(jarUrl).getParentFile().getAbsolutePath();
// } else if (checkRunType().equalsIgnoreCase("IDE")) {
// } else if (getRunType().equalsIgnoreCase("IDE")) {
// String path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath();
// if (path.contains(GlobalConstants.TESTCLASSES))
// path = path.replace(GlobalConstants.TESTCLASSES, "classes");
Expand Down Expand Up @@ -314,7 +317,7 @@ public static Properties getproperty(String path) {
*
* @return
*/
public static String checkRunType() {
public static String getRunType() {
if (MosipTestRunner.class.getResource("MosipTestRunner.class").getPath().contains(".jar"))
return "JAR";
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.GlobalConstants;
import io.mosip.testrig.apirig.utils.IdAuthConfigManager;
import io.mosip.testrig.apirig.utils.IdAuthenticationUtil;
import io.mosip.testrig.apirig.utils.KernelAuthentication;
import io.mosip.testrig.apirig.utils.KeycloakUserManager;
Expand Down Expand Up @@ -125,8 +126,8 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
String picture = properties.getProperty("picturevalue");
list.add(picture);
attrmap.put("picture", list);
KeycloakUserManager.createVidUsers(propsKernel.getProperty("new_Resident_User"),
propsKernel.getProperty("new_Resident_Password"), propsKernel.getProperty("new_Resident_Role"),
KeycloakUserManager.createVidUsers(IdAuthConfigManager.getproperty("new_Resident_User"),
IdAuthConfigManager.getproperty("new_Resident_Password"), IdAuthConfigManager.getproperty("new_Resident_Role"),
attrmap);
}

Expand All @@ -137,7 +138,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
inputJson = inputJson.replace("$UIN$", uin);
inputJson = inputJson.replace("$RID$", genRid);
String phoneNumber = "";
String email = testCaseName + "@mosip.net";
String email = testCaseName +"@mosip.net";
if (inputJson.contains("$PHONENUMBERFORIDENTITY$")) {
if (!phoneSchemaRegex.isEmpty())
try {
Expand All @@ -147,7 +148,7 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
}
inputJson = replaceKeywordWithValue(inputJson, "$PHONENUMBERFORIDENTITY$", phoneNumber);
inputJson = replaceKeywordWithValue(inputJson, "$EMAILVALUE$", email);

}

response = postWithBodyAndCookie(ApplnURI + testCaseDTO.getEndPoint(), inputJson, COOKIENAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.BioDataUtility;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.IdAuthConfigManager;
import io.mosip.testrig.apirig.utils.EncryptionDecrptionUtil;
import io.mosip.testrig.apirig.utils.IdAuthenticationUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
Expand All @@ -47,7 +47,7 @@ public class BioAuth extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (IdAuthConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down Expand Up @@ -159,206 +159,10 @@ public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, Ad
throw new AdminTestException("Failed at output validation");


/*
* if (testCaseName.toLowerCase().contains("kyc")) { String error = null; if
* (response.getBody().asString().contains("errors")) error =
* JsonPrecondtion.getJsonValueFromJson(response.getBody().asString(),
* "errors"); if (error.equalsIgnoreCase("null"))
* encryptDecryptUtil.validateThumbPrintAndIdentity(response,
* testCaseDTO.getEndPoint()); }
*/


/*
* if
* (!encryptDecryptUtil.verifyResponseUsingDigitalSignature(response.asString(),
* response.getHeader(props.getProperty("signatureheaderKey")))) throw new
* AdminTestException("Failed at Signature validation");
*/

}



// /**
// * Test method for OTP Generation execution
// *
// * @param objTestParameters
// * @param testScenario
// * @param testcaseName
// * @throws AuthenticationTestException
// * @throws AdminTestException
// */
// @Test(dataProvider = "testcaselist")
// public void test(TestCaseDTO testCaseDTO) throws AuthenticationTestException, AdminTestException {
// testCaseName = testCaseDTO.getTestCaseName();
// String[] kycFields = testCaseDTO.getKycFields();
//
// if (HealthChecker.signalTerminateExecution) {
// throw new SkipException(
// GlobalConstants.TARGET_ENV_HEALTH_CHECK_FAILED + HealthChecker.healthCheckFailureMapS);
// }
//
// testCaseName = isTestCaseValidForExecution(testCaseDTO);
//
// if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
// if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
// && !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
// throw new SkipException(GlobalConstants.UIN_FEATURE_NOT_SUPPORTED);
// }
// }
//
// if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
// if (!BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
// && !BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
// throw new SkipException(GlobalConstants.VID_FEATURE_NOT_SUPPORTED);
// }
// }
//
// if (testCaseDTO.getEndPoint().contains("$PartnerKeyURL$")) {
// testCaseDTO.setEndPoint(
// testCaseDTO.getEndPoint().replace("$PartnerKeyURL$", PartnerRegistration.partnerKeyUrl));
// }
//
// if (testCaseDTO.getEndPoint().contains("$KycPartnerKeyURL$")) {
// testCaseDTO.setEndPoint(
// testCaseDTO.getEndPoint().replace("$KycPartnerKeyURL$", PartnerRegistration.ekycPartnerKeyUrl));
// }
//
// if (testCaseDTO.getEndPoint().contains("$UpdatedPartnerKeyURL$")) {
// testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$UpdatedPartnerKeyURL$",
// PartnerRegistration.updatedpartnerKeyUrl));
// }
//
// if (testCaseDTO.getEndPoint().contains("$PartnerName$")) {
// testCaseDTO.setEndPoint(testCaseDTO.getEndPoint().replace("$PartnerName$", PartnerRegistration.partnerId));
// }
//
// if (testCaseDTO.getEndPoint().contains("$KycPartnerName$")) {
// testCaseDTO.setEndPoint(
// testCaseDTO.getEndPoint().replace("$KycPartnerName$", PartnerRegistration.ekycPartnerId));
// }
// String request = testCaseDTO.getInput();
// request = buildIdentityRequest(request);
//
// String inputJSON = getJsonFromTemplate(request, testCaseDTO.getInputTemplate());
// String resolvedUri = null;
// String individualId = null;
// resolvedUri = uriKeyWordHandelerUri(testCaseDTO.getEndPoint(), testCaseName);
//
// individualId = AdminTestUtil.getValueFromUrl(resolvedUri, "id");
//
// String url = ConfigManager.getAuthDemoServiceUrl();
//
// response = postWithBodyAndCookie(url + testCaseDTO.getEndPoint(), inputJSON, COOKIENAME, testCaseDTO.getRole(),
// testCaseDTO.getTestCaseName());
//
// String ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
//
// if (testCaseDTO.getTestCaseName().contains("uin") || testCaseDTO.getTestCaseName().contains("UIN")) {
// if (BaseTestCase.getSupportedIdTypesValueFromActuator().contains("UIN")
// || BaseTestCase.getSupportedIdTypesValueFromActuator().contains("uin")) {
// ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
// } else {
// if (testCaseDTO.getTestCaseName().contains("auth_EkycBio")) {
// ActualOPJson = AdminTestUtil.getRequestJson("config/errorUINKyc.json").toString();
// } else {
// ActualOPJson = AdminTestUtil.getRequestJson("config/errorUIN.json").toString();
// }
//
// }
// } else {
// if (testCaseDTO.getTestCaseName().contains("VID") || testCaseDTO.getTestCaseName().contains("Vid")) {
// if (BaseTestCase.getSupportedIdTypesValueFromActuator().contains("VID")
// || BaseTestCase.getSupportedIdTypesValueFromActuator().contains("vid")) {
// ActualOPJson = getJsonFromTemplate(testCaseDTO.getOutput(), testCaseDTO.getOutputTemplate());
// } else {
// if (testCaseDTO.getTestCaseName().contains("auth_EkycBio")) {
// ActualOPJson = AdminTestUtil.getRequestJson("config/errorUINKyc.json").toString();
// } else {
// ActualOPJson = AdminTestUtil.getRequestJson("config/errorUIN.json").toString();
// }
//
// }
// }
// }
//
// Map<String, List<OutputValidationDto>> ouputValid = OutputValidationUtil
// .doJsonOutputValidation(response.asString(), ActualOPJson, testCaseDTO, response.getStatusCode());
// Reporter.log(ReportUtil.getOutputValidationReport(ouputValid));
//
// if (!OutputValidationUtil.publishOutputResult(ouputValid))
// throw new AdminTestException("Failed at output validation");
//
// if (testCaseName.toLowerCase().contains("kyc")) {
// JSONObject resJsonObject = new JSONObject(response.asString());
// String res = "";
// try {
// // res = resJsonObject.get("response").toString();
// resJsonObject = new JSONObject(response.getBody().asString()).getJSONObject("authResponse")
// .getJSONObject("body").getJSONObject("response");
//
// res = AdminTestUtil.ekycDataDecryption(url, resJsonObject, PartnerRegistration.ekycPartnerId, true);
//
// JSONObject jsonObjectkycRes = new JSONObject(res);
// JSONObject jsonObjectFromKycData = new JSONObject();
// JSONObject jsonObjectFromIdentityData = new JSONObject();
// // List<String> myList =new ArrayList<>();
//
// ArrayList<String> names = new ArrayList<>();
// ArrayList<String> names2 = new ArrayList<>();
//
// for (int i = 0; i < kycFields.length; i++) {
// for (String key : jsonObjectkycRes.keySet()) {
// if (key.contains(kycFields[i])) {
// names.add(key);// dob gender_eng
// names2.add(kycFields[i]);// dob gender
// jsonObjectFromKycData.append(key, jsonObjectkycRes.getString(key));
// break;
// }
// }
//
// }
//
// newResponse = RestClient.getRequestWithCookie(
// ApplnURI + props.getProperty("retrieveIdByUin") + individualId, MediaType.APPLICATION_JSON,
// MediaType.APPLICATION_JSON, COOKIENAME, kernelAuthLib.getTokenByRole("idrepo"),
// IDTOKENCOOKIENAME, null);
//
// GlobalMethods.reportResponse(newResponse.getHeaders().asList().toString(), url, newResponse);
//
// JSONObject responseBody = new JSONObject(newResponse.getBody().asString()).getJSONObject("response")
// .getJSONObject("identity");
//
// for (int j = 0; j < names2.size(); j++) {
//
// String mappingField = getValueFromAuthActuator("json-property", names2.get(j));
// mappingField = mappingField.replaceAll("\\[\"|\"\\]", "");
// JSONArray valueOfJsonArray = responseBody.optJSONArray(mappingField);
// if (valueOfJsonArray != null) {
// jsonObjectFromIdentityData.append(names.get(j), valueOfJsonArray.getJSONObject(0).get("value"));
//
// valueOfJsonArray = null;
// } else {
// jsonObjectFromIdentityData.append(names.get(j), responseBody.getString(mappingField));
// }
//
// }
//
// ouputValid = OutputValidationUtil.doJsonOutputValidation(jsonObjectFromIdentityData.toString(),
// jsonObjectFromKycData.toString(), testCaseDTO, response.getStatusCode());
// Reporter.log(ReportUtil.getOutputValidationReport(ouputValid));
//
// if (!OutputValidationUtil.publishOutputResult(ouputValid))
// throw new AdminTestException("Failed at output validation");
//
// } catch (JSONException e) {
// logger.error(e.getMessage());
// }
//
// }
// }

/**
* The method ser current test name to result
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import io.mosip.testrig.apirig.utils.AdminTestException;
import io.mosip.testrig.apirig.utils.AdminTestUtil;
import io.mosip.testrig.apirig.utils.AuthenticationTestException;
import io.mosip.testrig.apirig.utils.ConfigManager;
import io.mosip.testrig.apirig.utils.IdAuthConfigManager;
import io.mosip.testrig.apirig.utils.EncryptionDecrptionUtil;
import io.mosip.testrig.apirig.utils.IdAuthenticationUtil;
import io.mosip.testrig.apirig.utils.OutputValidationUtil;
Expand All @@ -46,7 +46,7 @@ public class DemoAuth extends AdminTestUtil implements ITest {

@BeforeClass
public static void setLogLevel() {
if (ConfigManager.IsDebugEnabled())
if (IdAuthConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
Expand Down
Loading

0 comments on commit 7f8cf4a

Please sign in to comment.