-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOSIP-33299 added testcases for revamp ui automation (#817)
* MOSIP-33299 Signed-off-by: Anup Nehe <[email protected]> * resolve conflicts Signed-off-by: Anup Nehe <[email protected]> * resolve conflicts Signed-off-by: Anup Nehe <[email protected]> --------- Signed-off-by: Anup Nehe <[email protected]>
- Loading branch information
Showing
17 changed files
with
802 additions
and
70 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
uitest-pmprevamp/src/main/java/io/mosip/testrig/pmprevampui/fw/util/AdminTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package io.mosip.testrig.pmprevampui.fw.util; | ||
import static io.restassured.RestAssured.given; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
|
||
import org.json.JSONObject; | ||
|
||
import io.mosip.testrig.pmprevampui.authentication.fw.util.RestClient; | ||
import io.mosip.testrig.pmprevampui.kernel.util.ConfigManager; | ||
import io.mosip.testrig.pmprevampui.kernel.util.KeycloakUserManager; | ||
import io.mosip.testrig.pmprevampui.utility.BaseTestCaseFunc; | ||
import io.mosip.testrig.pmprevampui.utility.TestRunner; | ||
import io.restassured.http.ContentType; | ||
import io.restassured.response.Response; | ||
|
||
public class AdminTestUtil extends BaseTestCaseFunc { | ||
|
||
private static final org.slf4j.Logger logger= org.slf4j.LoggerFactory.getLogger(RestClient.class); | ||
public static String token; | ||
public static String user; | ||
public static String tokenRoleIdRepo = "idrepo"; | ||
public static String tokenRoleAdmin = "admin"; | ||
private static String serverComponentsCommitDetails; | ||
public static String propsHealthCheckURL = TestRunner.getResourcePath() + "/" | ||
+ "config/healthCheckEndpoint.properties"; | ||
public static boolean initialized = false; | ||
|
||
|
||
public static String getServerComponentsDetails() { | ||
if (serverComponentsCommitDetails != null && !serverComponentsCommitDetails.isEmpty()) | ||
return serverComponentsCommitDetails; | ||
|
||
File file = new File(propsHealthCheckURL); | ||
FileReader fileReader = null; | ||
BufferedReader bufferedReader = null; | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
try { | ||
fileReader = new FileReader(file); | ||
bufferedReader = new BufferedReader(fileReader); | ||
String line; | ||
|
||
while ((line = bufferedReader.readLine()) != null) { | ||
if (line.trim().equals("") || line.trim().startsWith("#")) | ||
continue; | ||
String[] parts = line.trim().split("="); | ||
if (parts.length > 1) { | ||
if (ConfigManager.isInServiceNotDeployedList(parts[1])) { | ||
continue; | ||
} | ||
stringBuilder.append("\n") | ||
.append(getCommitDetails(BaseTestCaseFunc.ApplnURI + parts[1].replace("health", "info"))); | ||
} | ||
} | ||
} catch (Exception e) { | ||
logger.error(e.getMessage()); | ||
} finally { | ||
AdminTestUtil.closeBufferedReader(bufferedReader); | ||
AdminTestUtil.closeFileReader(fileReader); | ||
} | ||
serverComponentsCommitDetails = stringBuilder.toString(); | ||
return serverComponentsCommitDetails; | ||
} | ||
public static void closeBufferedReader(BufferedReader bufferedReader) { | ||
if (bufferedReader != null) { | ||
try { | ||
bufferedReader.close(); | ||
} catch (IOException e) { | ||
// logger.error(GlobalConstants.EXCEPTION_STRING_2 + e.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
public static void closeFileReader(FileReader fileReader) { | ||
if (fileReader != null) { | ||
try { | ||
fileReader.close(); | ||
} catch (IOException e) { | ||
// logger.error(GlobalConstants.EXCEPTION_STRING_2 + e.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
public static String getCommitDetails(String path) { | ||
|
||
Response response = null; | ||
response = given().contentType(ContentType.JSON).get(path); | ||
if (response != null && response.getStatusCode() == 200) { | ||
logger.info(response.getBody().asString()); | ||
JSONObject jsonResponse = new JSONObject(response.getBody().asString()); | ||
return "Group: " + jsonResponse.getJSONObject("build").getString("group") + ", Artifact: " | ||
+ jsonResponse.getJSONObject("build").getString("artifact") + ", version: " | ||
+ jsonResponse.getJSONObject("build").getString("version") + ", Commit ID: " | ||
+ jsonResponse.getJSONObject("git").getJSONObject("commit").getString("id"); | ||
} | ||
return path + "- No Response"; | ||
} | ||
public static String UserMapping() { | ||
return user; | ||
|
||
} | ||
|
||
public static void initialize() { | ||
if (initialized == false) { | ||
ConfigManager.init(); | ||
|
||
|
||
BaseTestCaseFunc.initialize(); | ||
HashMap<String, List<String>> attrmap=new HashMap<String, List<String>>(); | ||
List<String> list=new ArrayList<String>(); | ||
String val= "11000000"; | ||
list.add(val); | ||
attrmap.put("individualId",list); | ||
KeycloakUserManager.createUsers(); | ||
BaseTestCaseFunc.mapUserToZone(BaseTestCaseFunc.currentModule+"-"+propsKernel.getProperty("admin_userName"),"CSB"); | ||
BaseTestCaseFunc.mapZone(BaseTestCaseFunc.currentModule+"-"+propsKernel.getProperty("admin_userName")); | ||
initialized = true; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
uitest-pmprevamp/src/main/java/io/mosip/testrig/pmprevampui/pages/ApiKeyPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package io.mosip.testrig.pmprevampui.pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
|
||
public class ApiKeyPage extends BasePage{ | ||
|
||
@FindBy(xpath = "Enter a name for API key") | ||
private WebElement enterNameOfApiKeyTextBox; | ||
|
||
@FindBy(xpath = "generate_submit_btn") | ||
private WebElement submitButton; | ||
|
||
@FindBy(id = "generate_partner_id") | ||
private WebElement partnerIdDropdown; | ||
|
||
@FindBy(id = "generate_policy_name") | ||
private WebElement policyNameDropdown; | ||
|
||
@FindBy(id = "generate_api_key_btn") | ||
private WebElement generateAPIKey; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'Partner ID')]") | ||
private WebElement partnerIDHeaderText; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'Policy Group')]") | ||
private WebElement PolicyGroupHeaderText; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'Policy Name')]") | ||
private WebElement PolicyNameHeaderText; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'API Key Name')]") | ||
private WebElement ApiKeyHeaderText; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'Created Date')]") | ||
private WebElement CreatedDateHeaderText; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'Status')]") | ||
private WebElement StatusHeaderText; | ||
|
||
@FindBy(xpath = "//*[contains(text(), 'Action')]") | ||
private WebElement ActionHeaderText; | ||
|
||
public ApiKeyPage(WebDriver driver) { | ||
super(driver); | ||
} | ||
|
||
public void enterNameOfApiKeyTextBox(String value) { | ||
enter(enterNameOfApiKeyTextBox,value); | ||
} | ||
|
||
public void selectPartnerIdDropdown(String value) { | ||
clickOnElement(partnerIdDropdown); | ||
clickOnElement(driver.findElement(By.xpath("(//*[contains(text(),'"+value+"')])[2]"))); | ||
} | ||
|
||
public boolean isPartnerIdDropdownDisplayed() { | ||
return isElementDisplayed(partnerIdDropdown); | ||
} | ||
|
||
public boolean isPolicyNameDropdownDisplayed() { | ||
return isElementDisplayed(policyNameDropdown); | ||
} | ||
|
||
public void selectPolicyNameDropdown(String value) { | ||
dropdownByIndex(policyNameDropdown,0); | ||
} | ||
|
||
public boolean isGenerateAPIKeyDisplayed() { | ||
return isElementDisplayed(generateAPIKey); | ||
} | ||
|
||
public void ClickOnAPIKeyDisplayed() { | ||
clickOnElement(generateAPIKey); | ||
} | ||
|
||
public void ClickOnSubmitButton() { | ||
clickOnElement(submitButton); | ||
} | ||
|
||
public boolean isPartnerIDHeaderTextDisplayed() { | ||
return isElementDisplayed(partnerIDHeaderText); | ||
} | ||
|
||
public boolean isPolicyGroupHeaderTextDisplayed() { | ||
return isElementDisplayed(PolicyGroupHeaderText); | ||
} | ||
|
||
public boolean isPolicyNameHeaderTextDisplayed() { | ||
return isElementDisplayed(PolicyNameHeaderText); | ||
} | ||
|
||
public boolean isApiKeyHeaderTextDisplayed() { | ||
return isElementDisplayed(ApiKeyHeaderText); | ||
} | ||
|
||
public boolean isCreatedDateHeaderTextDisplayed() { | ||
return isElementDisplayed(CreatedDateHeaderText); | ||
} | ||
|
||
public boolean isStatusHeaderTextDisplayed() { | ||
return isElementDisplayed(StatusHeaderText); | ||
} | ||
|
||
public boolean isActionHeaderTextDisplayed() { | ||
return isElementDisplayed(ActionHeaderText); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.