Skip to content

Commit

Permalink
MOSIP-28379 MOSIP-28374
Browse files Browse the repository at this point in the history
  • Loading branch information
anup-nehe committed Aug 1, 2023
1 parent 41f2e4d commit 71e9e1e
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 163 deletions.
410 changes: 379 additions & 31 deletions pmptest/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ public static String UserMapping() {
public static void initialize() {
String adminuser="";
if (initialized == false) {
ConfigManager.init();
BaseTestCaseFunc.initialize();
// Initializing or setting up execution
ConfigManager.init(); //Langauge Independent
//Langauge Independent

// Generate Keycloak Users
KeycloakUserManager.createUsers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class ConfigManager {
// 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 IAM_ADMINPORTAL_PATH = "PmpPortalPath";
private static String IAM_APIENVUSER = "apiEnvUser";
private static String IAM_APIINTERNALENDPOINT = "apiInternalEndPoint";
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";
Expand Down Expand Up @@ -176,6 +179,9 @@ public class ConfigManager {
private static String iam_realm_id;
private static String iam_users_to_create;
private static String iam_users_password;
private static String iam_adminportal_path;
private static String iam_apienvuser;
private static String iam_apiinternalendpoint;
// private static String authDemoServicePort;
// private static String authDemoServiceBaseUrl;
//
Expand Down Expand Up @@ -212,6 +218,19 @@ public static void init() {
// 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);
iam_adminportal_path =System.getenv(IAM_ADMINPORTAL_PATH) == null
? propsKernel.getProperty(IAM_ADMINPORTAL_PATH)
: System.getenv(IAM_ADMINPORTAL_PATH);

logger.info("adminportal_path from config manager::" + iam_adminportal_path);
iam_apienvuser = System.getenv(IAM_APIENVUSER) == null
? propsKernel.getProperty(IAM_APIENVUSER)
: System.getenv(IAM_APIENVUSER);
logger.info("apienvuser from config manager::" + iam_apienvuser);
iam_apiinternalendpoint = System.getenv(IAM_APIINTERNALENDPOINT) == null
? propsKernel.getProperty(IAM_APIINTERNALENDPOINT)
: System.getenv(IAM_APIINTERNALENDPOINT);
logger.info("apiinternalendpoint from config manager::" + iam_apiinternalendpoint);
idrepo_client_secret = getValueForKey(MOSIP_IDREPO_CLIENT_SECRET);
idrepo_client_id = getValueForKey(MOSIP_IDREPO_CLIENT_ID);
idrepo_app_id = getValueForKey(MOSIP_IDREPO_APP_ID);
Expand Down Expand Up @@ -260,6 +279,22 @@ public static void init() {
master_db_schema = getValueForKey(MASTER_DB_SCHEMA);
iam_external_url = getValueForKey(IAM_EXTERNAL_URL);
logger.info("keycloakendpoint from config manager::" + iam_external_url);

iam_external_url = getValueForKey(IAM_EXTERNAL_URL);
logger.info("keycloakendpoint from config manager::" + iam_external_url);
iam_adminportal_path =System.getenv(IAM_ADMINPORTAL_PATH) == null
? propsKernel.getProperty(IAM_ADMINPORTAL_PATH)
: System.getenv(IAM_ADMINPORTAL_PATH);

logger.info("adminportal_path from config manager::" + iam_adminportal_path);
iam_apienvuser = System.getenv(IAM_APIENVUSER) == null
? propsKernel.getProperty(IAM_APIENVUSER)
: System.getenv(IAM_APIENVUSER);
logger.info("apienvuser from config manager::" + iam_apienvuser);
iam_apiinternalendpoint = System.getenv(IAM_APIINTERNALENDPOINT) == null
? propsKernel.getProperty(IAM_APIINTERNALENDPOINT)
: System.getenv(IAM_APIINTERNALENDPOINT);
logger.info("apiinternalendpoint from config manager::" + iam_apiinternalendpoint);
//
iam_realm_id = getValueForKey(IAM_REALM_ID);
iam_users_to_create = getValueForKey(IAM_USERS_TO_CREATE);
Expand Down Expand Up @@ -413,6 +448,15 @@ public static String getidRepoClientId() {
public static String getidRepoAppId() {
return idrepo_app_id;
}
public static String getiam_adminportal_path() {
return iam_adminportal_path;
}
public static String getiam_apienvuser() {
return iam_apienvuser;
}
public static String getiam_apiinternalendpoint() {
return iam_apiinternalendpoint;
}
//
// public static String getRegprocClientSecret() {
// return regproc_client_secret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import io.mosip.testrig.pmpui.utility.BaseClass;
import io.mosip.testrig.pmpui.utility.Commons;
import io.mosip.testrig.pmpui.utility.RealTimeReport;
import io.mosip.testrig.pmpui.utility.Reporter;

import org.testng.annotations.Listeners;

@Listeners(value=Reporter.class)

public class AdminUploadCaCertTest extends BaseClass {

@Test(groups = "UFCC",dataProvider = "data-provider-ca")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
Expand All @@ -22,6 +24,7 @@
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.ITest;
import org.testng.Reporter;
// Generated by Selenium IDE
//import org.junit.Test;
//import org.junit.Before;
Expand Down Expand Up @@ -50,10 +53,10 @@
public class BaseClass {
protected WebDriver driver;
protected Map<String, Object> vars;
protected JavascriptExecutor js;
protected static JavascriptExecutor js;
protected String langcode;
protected String envPath = System.getProperty("path");
protected String env=System.getProperty("env.user");
protected String envPath = ConfigManager.getiam_adminportal_path();
protected String env=ConfigManager.getiam_apienvuser();
protected String userid = KeycloakUserManager.moduleSpecificUser;
protected String[] allpassword = ConfigManager.getIAMUsersPassword().split(",");
protected String password = allpassword[0];
Expand All @@ -74,6 +77,8 @@ public void set() {
}
@BeforeMethod
public void setUp() throws Exception {
Reporter.log("BaseClass",true);
test=extent.createTest(getCommitId(),getCommitId());
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
String headless=JsonUtil.JsonObjParsing(Commons.getTestData(),"headless");
Expand Down Expand Up @@ -179,5 +184,19 @@ public static String[] readFolderJsonList(String str) {
}
return contents;
}
private String getCommitId(){

Properties properties = new Properties();
try (InputStream is = ExtentReportManager.class.getClassLoader().getResourceAsStream("git.properties")) {
properties.load(is);

return "Commit Id is: " + properties.getProperty("git.commit.id.abbrev") + " & Branch Name is:" + properties.getProperty("git.branch");

} catch (IOException e) {
// logger.error(e.getStackTrace());
return "";
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.mosip.testrig.pmpui.authentication.fw.util.RestClient;
import io.mosip.testrig.pmpui.kernel.util.CommonLibrary;
import io.mosip.testrig.pmpui.kernel.util.ConfigManager;
import io.mosip.testrig.pmpui.kernel.util.KernelAuthentication;
import io.restassured.response.Response;

Expand Down Expand Up @@ -69,9 +70,9 @@ public static String getOSType() {
public static List<String> getLanguageList() {
logger.info("We have created a Config Manager. Beginning to read properties!");

environment = System.getProperty("env.user");
environment = ConfigManager.getiam_apienvuser();
logger.info("Environemnt is ==== :" + environment);
ApplnURI = System.getProperty("env.endpoint");
ApplnURI = ConfigManager.getiam_apiinternalendpoint();
logger.info("Application URI ======" + ApplnURI);

logger.info("Configs from properties file are set.");
Expand Down Expand Up @@ -118,9 +119,9 @@ public static void initialize() {

environment = System.getProperty("env.user");
logger.info("Environemnt is ==== :" + environment);
ApplnURI = System.getProperty("env.endpoint");
ApplnURI = ConfigManager.getiam_apiinternalendpoint();
logger.info("Application URI ======" + ApplnURI);
ApplnURIForKeyCloak = System.getProperty("env.keycloak");
ApplnURIForKeyCloak = ConfigManager.getIAMUrl();
logger.info("Application URI ======" + ApplnURIForKeyCloak);
testLevel = System.getProperty("env.testLevel");
logger.info("Test Level ======" + testLevel);
Expand Down
23 changes: 18 additions & 5 deletions pmptest/src/main/java/io/mosip/testrig/pmpui/utility/Commons.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,29 @@ public static void click(ExtentTest test,WebDriver driver, By by) {
System.out.println( "Element identified by " + by.toString() + " was not clickable after 20 seconds");
} catch (Exception e) {
try {
test.fail(e.getMessage(), MediaEntityBuilder.createScreenCaptureFromBase64String(Screenshot.ClickScreenshot(driver)).build());
} catch (IOException e1) {
test.fail(e.getMessage());
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", driver.findElement(by));

}}

public static void clickWebelement(ExtentTest test,WebDriver driver, By by) throws IOException, InterruptedException {
logger.info("Clicking " + by );

try {
(new WebDriverWait(driver, 20)).until(ExpectedConditions.elementToBeClickable(by));
Thread.sleep(500);
WebElement checkbox= driver.findElement(by);
js.executeScript("arguments[0].click();", checkbox);
Thread.sleep(500);
}catch (StaleElementReferenceException sere) {
// simply retry finding the element in the refreshed DOM
driver.findElement(by).click();
}
}


public static void enter(ExtentTest test,WebDriver driver, By by,String value) {
Expand Down Expand Up @@ -261,8 +274,8 @@ public static void selOption(ExtentTest test,WebDriver driver, By by,String valu
Thread.sleep(50);
String val="'"+value +"'";
//select/option[contains(text(),'FTM Provider')]
String xpath="//select/option[contains(text(),"+val+"]";
clickAction(test,driver,By.xpath(xpath));
// String xpath="//select/option[contains(text(),"+val+"]";
//clickAction(test,driver,By.xpath(xpath));
try {
Thread.sleep(50);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static ExtentReports getReports() {
if(extent==null) {
extent=new ExtentReports();
extent=new ExtentReports();
Filepath=System.getProperty("user.dir")+"/Reports/"+"admin-ui-report-"+Commons.appendDate+".html";
Filepath=System.getProperty("user.dir")+"/Reports/"+"pmp-ui-report-"+Commons.appendDate+".html";
html=new ExtentSparkReporter(Filepath);
extent.attachReporter(html);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.util.HashMap;
Expand All @@ -23,6 +24,7 @@
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.ITest;
import org.testng.Reporter;
// Generated by Selenium IDE
//import org.junit.Test;
//import org.junit.Before;
Expand Down Expand Up @@ -55,8 +57,8 @@ public class RegisterBaseClass {
protected Map<String, Object> vars;
protected JavascriptExecutor js;
protected String langcode;
protected String envPath = System.getProperty("path");
protected String env=System.getProperty("env.user");
protected String envPath = ConfigManager.getiam_adminportal_path();
protected String env=ConfigManager.getiam_apienvuser();
protected String userid = KeycloakUserManager.moduleSpecificUser;
protected String[] allpassword = ConfigManager.getIAMUsersPassword().split(",");
protected String password = allpassword[0];
Expand All @@ -78,6 +80,9 @@ public void set() {

@BeforeMethod
public void setUp() throws Exception {
Reporter.log("BaseClass",true);
test=extent.createTest(getCommitId(),getCommitId());

WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
String headless=JsonUtil.JsonObjParsing(Commons.getTestData(),"headless");
Expand Down Expand Up @@ -106,7 +111,7 @@ public void tearDown() throws InterruptedException {

@AfterSuite
public void pushFileToS3() {

getCommitId();
if (ConfigManager.getPushReportsToS3().equalsIgnoreCase("yes")) {
// EXTENT REPORT

Expand All @@ -119,7 +124,7 @@ public void pushFileToS3() {
boolean isStoreSuccess = false;
try {
isStoreSuccess = s3Adapter.putObject(ConfigManager.getS3Account(), BaseTestCaseFunc.testLevel, null,
"pmpui",env+BaseTestCaseFunc.currentModule+data+".html", repotFile);
"PmpUi",env+BaseTestCaseFunc.currentModule+data+".html", repotFile);

System.out.println("isStoreSuccess:: " + isStoreSuccess);
} catch (Exception e) {
Expand Down Expand Up @@ -183,7 +188,20 @@ public static String[] readFolderJsonList(String str) {
return contents;
}


private String getCommitId(){

Properties properties = new Properties();
try (InputStream is = ExtentReportManager.class.getClassLoader().getResourceAsStream("git.properties")) {
properties.load(is);

return "Commit Id is: " + properties.getProperty("git.commit.id.abbrev") + " & Branch Name is:" + properties.getProperty("git.branch");

} catch (IOException e) {
// logger.error(e.getStackTrace());
return "";
}

}


// public static String[] readFolderJsonList() {
Expand Down
Loading

0 comments on commit 71e9e1e

Please sign in to comment.