Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit b9f585fe authored by Mihai BOZ's avatar Mihai BOZ
Browse files

Pull request #170: EDELIVERY-14013 Test automation Create 1 happy flow for the...

Pull request #170: EDELIVERY-14013 Test automation Create 1 happy flow for the new functionality added in 5.1

Merge in EDELIVERY/smp from EDELIVERY-14013-Test-automation-Create-1-happy-flow-for-the-new-functionality-added-in-5.1 to development

* commit 'ea793859':
  added tests for Edit resource page configuration tab
  added tests for Edit resource page configuration tab
  added tests for Domain page configuration tab
  added tests for reset password functionality.
  added tests for reset password functionality.
parents 9fd71865 ea793859
No related branches found
No related tags found
No related merge requests found
Pipeline #218050 failed
Showing
with 822 additions and 50 deletions
......@@ -17,25 +17,25 @@
<!-- Only selected modules are deployed -->
<maven.deploy.skip>false</maven.deploy.skip>
<!-- dependencies versions-->
<commons-csv_version>1.10.0</commons-csv_version>
<selenium-chrome-driver_version>4.16.1</selenium-chrome-driver_version>
<selenium-java_version>4.16.1</selenium-java_version>
<poi-ooxml_version>5.2.4</poi-ooxml_version>
<commons-csv_version>1.12.0</commons-csv_version>
<selenium-chrome-driver_version>4.25.0</selenium-chrome-driver_version>
<selenium-java_version>4.25.0</selenium-java_version>
<poi-ooxml_version>5.3.0</poi-ooxml_version>
<reflections_version>0.10.2</reflections_version>
<jersey-client_version>1.19.4</jersey-client_version>
<jersey-multipart_version>1.19.4</jersey-multipart_version>
<json_version>20231013</json_version>
<jackson_version>2.15.2</jackson_version>
<json_version>20240303</json_version>
<jackson_version>2.18.0</jackson_version>
<javax.ws.rs-api_version>2.1.1</javax.ws.rs-api_version>
<javax.ws.rs-api_version>2.1.1</javax.ws.rs-api_version>
<xmlunit_version>1.6</xmlunit_version>
<testng_version>7.8.0</testng_version>
<logback-classic_version>1.4.11</logback-classic_version>
<extentreports_version>5.1.1</extentreports_version>
<commons-lang3_version>3.13.0</commons-lang3_version>
<commons-io_version>2.15.0</commons-io_version>
<testng_version>7.10.2</testng_version>
<logback-classic_version>1.5.8</logback-classic_version>
<extentreports_version>5.1.2</extentreports_version>
<commons-lang3_version>3.17.0</commons-lang3_version>
<commons-io_version>2.17.0</commons-io_version>
<!-- plugin versions-->
<maven-surefire-plugin_version>3.2.2</maven-surefire-plugin_version>
<maven-surefire-plugin_version>3.5.1</maven-surefire-plugin_version>
<plugin.dependency-check-maven.version>9.0.7</plugin.dependency-check-maven.version>
<maven-compiler-plugin>3.11.0</maven-compiler-plugin>
......@@ -174,7 +174,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
<version>4.5.0-M2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
......
......@@ -61,6 +61,8 @@ public class DomiSMPPage extends DComponent {
actions.moveToElement(logoutMenuBtn);
actions.perform();
logoutMenuBtn.click();
data.getCookies().clear();
data.setXSRFToken("");
}
public void refreshPage() {
......
package ddsl.dcomponents;
import ddsl.dcomponents.mat.MatSelect;
import ddsl.dobjects.DButton;
import ddsl.dobjects.DInput;
import ddsl.dobjects.DSelect;
import ddsl.dobjects.DWait;
import ddsl.dobjects.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import utils.TestRunData;
......@@ -24,6 +21,10 @@ public class DComponent {
return new DButton(driver, element);
}
protected DCheckbox weToDChecked(WebElement element) {
return new DCheckbox(driver, element);
}
protected DInput weToDInput(WebElement element) {
return new DInput(driver, element);
}
......
package ddsl.dcomponents.Grid;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.PageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.NoSuchElementException;
public class GridWithoutPagination extends DComponent {
protected static final By gridHeadersLocator = By.cssSelector("table thead th");
protected static final By gridRowsLocator = By.cssSelector("table tbody tr");
private final static Logger LOG = LoggerFactory.getLogger(GridWithoutPagination.class);
private final WebElement parentElement;
public GridWithoutPagination(WebDriver driver, WebElement parentElement) {
super(driver);
PageFactory.initElements(driver, this);
this.parentElement = parentElement;
wait.forXMillis(200);
}
public List<WebElement> getGridHeaders() {
return parentElement.findElements(gridHeadersLocator);
}
public List<WebElement> getRows() {
return parentElement.findElements(gridRowsLocator);
}
public List<WebElement> getCells(WebElement row) {
return row.findElements(By.cssSelector("td"));
}
public void searchAndDoubleClickElementInColumn(String columnName, String value) {
wait.forXMillis(100);
List<WebElement> rowHeaders = getGridHeaders();
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
LOG.error("No element found");
throw new NoSuchElementException("Column not found");
}
List<WebElement> rows = getRows();
for (WebElement row : rows) {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equalsIgnoreCase(value)) {
LOG.debug("Value: " + value + " has been found");
//Double Click on top right corner of element to prevent clicking on tooltip
Actions act = new Actions(driver);
act.moveToElement(currentCell, currentCell.getSize().getWidth() - 1, 0)
.doubleClick()
.perform();
return;
}
}
LOG.error("Value " + value + " has not been found in the grid");
}
public WebElement searchAndGetPrecedentSiblingElementInColumn(String columnName, String value) {
wait.forXMillis(100);
List<WebElement> rowHeaders = getGridHeaders();
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
return null;
}
List<WebElement> rows = getRows();
for (WebElement row : rows) {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equals(value)) {
LOG.debug("[{}] found", value);
return currentCell.findElement(By.xpath("preceding-sibling::*"));
}
}
return null;
}
public WebElement searchAndGetFollowingSiblingElementInColumn(String columnName, String value) {
wait.forXMillis(100);
List<WebElement> rowHeaders = getGridHeaders();
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
return null;
}
List<WebElement> rows = getRows();
for (WebElement row : rows) {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equals(value)) {
LOG.debug("[{}] found", value);
return currentCell.findElement(By.xpath("following-sibling::*"));
}
}
return null;
}
}
package ddsl.dcomponents.commonComponents.domanPropertyEditDialog;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class DomainPropertyEditDialog extends DComponent {
@FindBy(css = "#mat-expansion-panel-header-1")
private WebElement propertyNameExpand;
@FindBy(css = "mat-card-content mat-checkbox:nth-of-type(1)")
private WebElement useDefaultValueCheckBox;
@FindBy(css = "mat-card-content mat-form-field div div input")
private WebElement domainValueInput;
@FindBy(css = "mat-card-content mat-checkbox:nth-of-type(2)")
private WebElement domainValueCheckbox;
@FindBy(id = "updatePropertyButton")
private WebElement okBtn;
@FindBy(css = ".mat-mdc-dialog-actions > button:nth-child(2)")
private WebElement cancelBtn;
public DomainPropertyEditDialog(WebDriver driver) {
super(driver);
PageFactory.initElements(driver, this);
wait.forElementToBeVisible(cancelBtn);
}
public void setDomainValue(String domainValue) throws Exception {
if (weToDChecked(useDefaultValueCheckBox).isChecked()) {
weToDChecked(useDefaultValueCheckBox).uncheck();
}
if (weToDInput(domainValueInput).isEnabled()) {
weToDInput(domainValueInput).fill(domainValue);
}
}
public void setDomainValue(boolean isEnabled) throws Exception {
if (weToDChecked(useDefaultValueCheckBox).isChecked()) {
weToDChecked(useDefaultValueCheckBox).uncheck();
}
if (isEnabled) {
if (!weToDChecked(domainValueCheckbox).isChecked()) {
weToDChecked(domainValueCheckbox).check();
}
} else {
if (weToDChecked(domainValueCheckbox).isChecked()) {
weToDChecked(domainValueCheckbox).uncheck();
}
}
}
public void enableSystemValue() throws Exception {
if (!weToDChecked(useDefaultValueCheckBox).isChecked()) {
weToDChecked(useDefaultValueCheckBox).check();
}
}
public void disableSystemValue() throws Exception {
if (weToDChecked(useDefaultValueCheckBox).isChecked()) {
weToDChecked(useDefaultValueCheckBox).uncheck();
}
}
public void pressOk() {
if (weToDButton(okBtn).isEnabled()) {
weToDButton(okBtn).click();
}
}
}
package ddsl.dobjects;
import org.openqa.selenium.By;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.List;
public class DCheckbox extends DObject {
WebElement labelElement;
WebElement input;
public DCheckbox(WebDriver driver, WebElement element) {
this(driver, element, null);
input = element.findElement(By.cssSelector("input[type='checkbox']"));
}
public DCheckbox(WebDriver driver, WebElement element, WebElement labelElement) {
super(driver, element);
this.labelElement = labelElement;
}
public boolean isChecked() throws Exception {
if (isPresent()) {
if (null != input.getAttribute("checked")) {
return true;
}
List<WebElement> input = element.findElements(By.cssSelector("input[type='checkbox']"));
return !input.isEmpty() && null != input.get(0).getAttribute("checked");
}
throw new DObjectNotPresentException();
}
public void check() throws Exception {
if (isChecked()) return;
if (isEnabled()) {
clickCheckbox();
wait.forAttributeToContain(element, "class", "checkbox-checked");
return;
}
throw new Exception("Checkbox is not enabled");
}
public void uncheck() throws Exception {
if (!isChecked()) return;
if (isEnabled()) {
clickCheckbox();
wait.forAttributeToNOTContain(this.element, "class", "checkbox-checked");
return;
}
throw new Exception("Checkbox is not enabled");
}
private void clickCheckbox() {
try {
input.click();
} catch (ElementNotInteractableException ex) {
// in mat-checkbox the input is actually hidden, and the user has to click on the label to interact with it
if (this.labelElement != null)
this.labelElement.click();
}
}
}
package ddsl.dobjects;
public class DObjectNotPresentException extends Exception {
}
......@@ -16,11 +16,17 @@ import java.util.HashMap;
public class LoginPage extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(LoginPage.class);
@FindBy(id = "username_id")
private WebElement username;
private WebElement usernameInput;
@FindBy(id = "password_id")
private WebElement password;
private WebElement passwordInput;
@FindBy(id = "loginbutton_id")
private WebElement loginBtn;
@FindBy(css = ".mat-mdc-tab-labels > div:nth-child(2)")
private WebElement goToResetPasswordTab;
@FindBy(id = "reset_username_id")
private WebElement resetUsernameInput;
@FindBy(id = "resetbutton_id")
private WebElement requestResetPasswordBtn;
public LoginPage(WebDriver driver) {
super(driver);
......@@ -35,8 +41,8 @@ public class LoginPage extends DomiSMPPage {
LOG.debug("Login started " + usr.get("username") + " / " + usr.get("pass"));
goToLoginPage();
weToDInput(username).fill(usr.get("username"));
weToDInput(password).fill(usr.get("pass"));
weToDInput(usernameInput).fill(usr.get("username"));
weToDInput(passwordInput).fill(usr.get("pass"));
weToDButton(loginBtn).click();
try {
......@@ -46,9 +52,16 @@ public class LoginPage extends DomiSMPPage {
} catch (Exception e) {
LOG.debug("Password expiration popup is not present");
}
}
public String resetPassword(String user) {
LOG.debug("Resetting password for : " + user);
goToLoginPage();
weToDButton(goToResetPasswordTab).click();
weToDInput(resetUsernameInput).fill(user);
weToDButton(requestResetPasswordBtn).click();
return getAlertArea().getAlertMessage();
}
}
package pages;
import ddsl.DomiSMPPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.systemSettings.UsersPage;
import java.util.ArrayList;
import java.util.List;
public class ResetCredentialsPage extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(UsersPage.class);
@FindBy(id = "reset_username_id")
private WebElement usernameInput;
@FindBy(id = "np_id")
private WebElement newPasswordInput;
@FindBy(id = "cnp_id")
private WebElement confirmNewPasswordInput;
@FindBy(id = "closeDialogButton")
private WebElement canceBtn;
@FindBy(id = "changeCurrentUserPasswordButton")
private WebElement setNewPasswordBtn;
@FindBy(css = ".smp-field-error")
private List<WebElement> fieldsError;
public ResetCredentialsPage(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public void fillChangePasswordFields(String username, String newPassword, String confirmNewPassword) {
weToDInput(usernameInput).fill(username, true);
weToDInput(newPasswordInput).fill(newPassword, true);
weToDInput(confirmNewPasswordInput).fill(confirmNewPassword);
}
public void clickSetChangePasswordButton() {
if (weToDButton(setNewPasswordBtn).isEnabled()) {
weToDButton(setNewPasswordBtn).click();
} else {
LOG.error("Set/Change password button is disabled");
}
}
public List<String> getFieldErrorMessage() {
ArrayList<String> fieldErrors = new ArrayList<>();
if (!fieldsError.isEmpty()) {
fieldsError.forEach(error -> {
fieldErrors.add(error.getText());
});
}
return fieldErrors;
}
}
......@@ -4,6 +4,8 @@ import ddsl.CommonPageWithTabsAndGrid;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.systemSettings.domainsPage.ConfigurationTab.ConfigurationTab;
/**
* Page object for the Edit domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
......@@ -20,6 +22,12 @@ public class EditDomainsPage extends CommonPageWithTabsAndGrid {
return new DomainMembersTab(driver);
}
public ConfigurationTab getConfigurationTab() {
return new ConfigurationTab(driver);
}
public GroupTab getGroupTab() {
return new GroupTab(driver);
......
......@@ -46,12 +46,17 @@ public class CreateResourceDetailsDialog extends DComponent {
}
public Boolean tryClickOnSave() {
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
return true;
} else {
try {
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
package pages.systemSettings.domainsPage.ConfigurationTab;
import ddsl.dcomponents.DComponent;
import ddsl.dcomponents.Grid.GridWithoutPagination;
import ddsl.dcomponents.commonComponents.domanPropertyEditDialog.DomainPropertyEditDialog;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Page object for the Configuration tab of Domains/Edit Domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class ConfigurationTab extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(ConfigurationTab.class);
@FindBy(css = "[class~=smp-column-data]")
public WebElement rightPanel;
@FindBy(id = "saveButton")
public WebElement saveBtn;
public ConfigurationTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
private GridWithoutPagination getConfigurationGrid() {
return new GridWithoutPagination(driver, rightPanel);
}
public DomainPropertyEditDialog openProperty(String propertyName) {
getConfigurationGrid().searchAndDoubleClickElementInColumn("Domain property", propertyName);
return new DomainPropertyEditDialog(driver);
}
public void saveChanges() {
try {
weToDButton(saveBtn).click();
} catch (Exception e) {
LOG.error("Could not save changes on Configuration tab!");
}
}
public Boolean isSystemValueUsed(String propertyName) {
WebElement currentCell = getConfigurationGrid().searchAndGetPrecedentSiblingElementInColumn("Domain property", propertyName);
//check if previous sibling is checked
return currentCell.findElement(By.cssSelector("mat-checkbox")).getAttribute("class").contains("checkbox-checked");
}
public String getCurrentPropertyValue(String propertyName) {
WebElement currentCell = getConfigurationGrid().searchAndGetFollowingSiblingElementInColumn("Domain property", propertyName);
//check if previous sibling is checked
return currentCell.getText();
}
}
......@@ -7,14 +7,17 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.systemSettings.domainsPage.ConfigurationTab.ConfigurationTab;
/**
* Page object for the Users page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class DomainsPage extends CommonPageWithTabsAndGrid {
private final static Logger LOG = LoggerFactory.getLogger(DomainsPage.class);
@FindBy(css = "smp-warning-panel span")
private WebElement warningLabel;
public DomainsPage(WebDriver driver) {
super(driver);
LOG.debug("Loading Domains page.");
......@@ -24,11 +27,6 @@ public class DomainsPage extends CommonPageWithTabsAndGrid {
return new DButton(driver, addBtn);
}
public ResourceTab getResourceTab() {
return new ResourceTab(driver);
}
public DomainTab getDomainTab() {
return new DomainTab(driver);
......@@ -44,6 +42,11 @@ public class DomainsPage extends CommonPageWithTabsAndGrid {
return new MembersTab(driver);
}
public ConfigurationTab getConfigurationTab() {
return new ConfigurationTab(driver);
}
public String getDomainWarningMessage() {
return warningLabel.getText();
}
......
......@@ -30,11 +30,12 @@ public class DomainClient extends BaseRestClient {
public DomainModel createDomain(DomainModel domainModel) {
JSONObject domainJson = new JSONObject(domainModel);
startSession();
String createDomainPath = RestServicePaths.getCreateDomainPath(TestRunData.getInstance().getUserId());
ClientResponse response = jsonPUT(resource.path(createDomainPath), domainJson);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not create domain", response);
throw new SMPRestException("Could not create domain", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......@@ -51,7 +52,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = jsonPUT(resource.path(addMemberPath), membersJson);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not create domain", response);
throw new SMPRestException("Could not create domain", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......@@ -72,7 +73,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = requestPOST(resource.path(addMemberPath), resourceTypes);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not add resource!", response);
throw new SMPRestException("Could not add resource!", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......@@ -87,7 +88,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = jsonPUT(resource.path(createGroupPath), groupJson);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not create group!", response);
throw new SMPRestException("Could not create group!", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......
package rest;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import utils.TestRunData;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.testng.AssertJUnit.fail;
public class InbucketRestClient {
private final static Logger LOG = LoggerFactory.getLogger(InbucketRestClient.class);
protected TestRunData data = TestRunData.getInstance();
protected Client client = Client.create();
public WebResource resource = client.resource(TestRunData.getInstance().getPropertyValue(TestRunData.TestEnvironmentProperty.MAIL_URL));
private JSONArray getAllMessagesOfUser(String userName) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
WebResource.Builder builder = resource.path("api/v1/mailbox/" + userName).getRequestBuilder();
String rawStringResponse = builder.get(String.class);
JSONArray jsonArray = new JSONArray(rawStringResponse);
LOG.debug("All messages of users have been retrieved!");
return jsonArray;
}
public JsonObject getlastmessageOfUser(String userName) {
JSONArray getAllMessagesOfUser = getAllMessagesOfUser(userName);
JSONObject lastmessage = (JSONObject) getAllMessagesOfUser.get(getAllMessagesOfUser.length() - 1);
String lastmessageId = lastmessage.get("id").toString();
WebResource.Builder builder = resource.path("serve/mailbox/" + userName + "/" + lastmessageId).getRequestBuilder();
String rawStringResponse = builder.get(String.class);
JsonObject jsonArray = JsonParser.parseString(rawStringResponse).getAsJsonObject();
LOG.debug("Last email of user has been retrieved!");
return jsonArray;
}
public String getResetPasswordTokenFromLastEmailOfUser(String userName) {
JsonObject lastMessageArray = getlastmessageOfUser(userName);
if (lastMessageArray.isEmpty()) {
LOG.error("Last email of user is empty!");
fail();
}
String subject = lastMessageArray.get("subject").toString();
if (subject.contains("Request for reset of the Credential")) {
String text = lastMessageArray.get("text").toString();
String regex = "http://[^\\s\"<>]+(?=\\s|<|$)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
return matcher.group(0);
}
LOG.error("Reset URL found in the email: " + text);
throw new NullPointerException("Reset URL found in the email: " + text);
}
throw new NullPointerException("Last email is not a reset email. The current subject found is: " + subject);
}
}
......@@ -18,4 +18,15 @@ public class SMPRestException extends Exception {
"CONTENT = " + response.getEntity(String.class)));
}
public SMPRestException(String message, int responseStatus, String responseContent) {
super(String.format("%s \n %s \n %s \n",
message,
"STATUS = " + responseStatus,
"CONTENT = " + responseContent));
log.error(String.format("%s \n %s \n %s \n",
message,
"STATUS = " + responseStatus,
"CONTENT = " + responseContent));
}
}
......@@ -41,6 +41,8 @@ public class TestRunData {
TEST_DATA_PASSWORD_DEFAULT("test.data.password.default", "QW!@QW!@qw12qw12", "Default password when creating new users"),
TEST_DATA_PASSWORD_NEW("test.data.password.new", "Test1234!Test1234!", "New Password when changing users password "),
MAIL_URL("test.mail.url", "http://localhost:9005/", "Webdriver type: chrome, gecko, edge"),
;
String propertyName;
......@@ -78,12 +80,11 @@ public class TestRunData {
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("TestEnvironmentProperty {");
sb.append("propertyName='").append(propertyName).append('\'');
sb.append(", defaultValue='").append(defaultValue).append('\'');
sb.append(", description='").append(description).append('\'');
sb.append('}');
return sb.toString();
String sb = "TestEnvironmentProperty {" + "propertyName='" + propertyName + '\'' +
", defaultValue='" + defaultValue + '\'' +
", description='" + description + '\'' +
'}';
return sb;
}
}
......
......@@ -8,6 +8,7 @@ test.webdriver.type=firefox
test.webdriver.headless=false
test.application.ui.url=http://eulogin.protected.smp.local:8982/smp/ui
test.sml.url=http://localhost:8982/edelivery-sml/listDNS
test.mail.url=http://localhost:9005/
test.timeout.long=15
test.timeout.short=5
test.reports.folder=./reports/
......
package domiSMPTests.ui;
import ddsl.DomiSMPPage;
import ddsl.dcomponents.commonComponents.domanPropertyEditDialog.DomainPropertyEditDialog;
import ddsl.enums.Pages;
import ddsl.enums.ResourceTypes;
import ddsl.enums.ResponseCertificates;
import domiSMPTests.SeleniumTest;
import org.openqa.selenium.WebElement;
......@@ -13,7 +15,12 @@ import pages.SmlPage;
import pages.administration.editDomainsPage.EditDomainsPage;
import pages.systemSettings.domainsPage.DomainsPage;
import rest.models.DomainModel;
import rest.models.MemberModel;
import rest.models.UserModel;
import utils.TestRunData;
import java.util.Arrays;
import java.util.List;
/**
* This class has the tests against Domains Page
......@@ -173,4 +180,79 @@ public class DomainsPgTests extends SeleniumTest {
soft.assertAll();
}
@Test(description = "DOM-19 - Domain admins are able to change default properties for domains")
public void systemAdminsAreAbleToChangeDefaultPropertiesForDomains() throws Exception {
DomainModel domainModel = DomainModel.generatePublicDomainModelWithSML();
MemberModel superMember = new MemberModel();
superMember.setUsername(TestRunData.getInstance().getAdminUsername());
superMember.setRoleType("ADMIN");
//create domain
domainModel = rest.domains().createDomain(domainModel);
// rest.domains().addMembersToDomain(domainModel, adminMember);
rest.domains().addMembersToDomain(domainModel, superMember);
//add resources to domain
List<ResourceTypes> resourcesToBeAdded = Arrays.asList(ResourceTypes.OASIS1, ResourceTypes.OASIS3, ResourceTypes.OASIS2);
domainModel = rest.domains().addResourcesToDomain(domainModel, resourcesToBeAdded);
domainsPage.refreshPage();
domainsPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", domainModel.getDomainCode());
domainsPage.goToTab("Configuration");
//Check is modifying boolean values
String boolPropertyName = "identifiersBehaviour.scheme.mandatory";
DomainPropertyEditDialog domainPropertyEditDialog = domainsPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.setDomainValue(false);
domainPropertyEditDialog.pressOk();
domainsPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertFalse(domainsPage.getConfigurationTab().isSystemValueUsed(boolPropertyName), "Property is marked as it's using system value");
soft.assertEquals("false", domainsPage.getConfigurationTab().getCurrentPropertyValue(boolPropertyName));
//Verify disabling system property
String useDomainProperty = "identifiersBehaviour.ParticipantIdentifierScheme.validationRegex";
domainPropertyEditDialog = domainsPage.getConfigurationTab().openProperty(useDomainProperty);
domainPropertyEditDialog.disableSystemValue();
domainPropertyEditDialog.pressOk();
domainsPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertFalse(domainsPage.getConfigurationTab().isSystemValueUsed(useDomainProperty), "Property is marked as it's using system value");
//Verify change to enabling system property
domainPropertyEditDialog = domainsPage.getConfigurationTab().openProperty(useDomainProperty);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
domainsPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertTrue(domainsPage.getConfigurationTab().isSystemValueUsed(useDomainProperty));
// String property value
String stringProperty = "identifiersBehaviour.caseSensitive.DocumentIdentifierSchemes";
String defaultPropertyValue = domainsPage.getConfigurationTab().getCurrentPropertyValue(stringProperty);
domainPropertyEditDialog = domainsPage.getConfigurationTab().openProperty(stringProperty);
domainPropertyEditDialog.setDomainValue("${identifier}${identifier}");
domainPropertyEditDialog.pressOk();
domainsPage.getConfigurationTab().saveChanges();
soft.assertFalse(domainsPage.getConfigurationTab().isSystemValueUsed(stringProperty), "Property is marked as it's using system value");
soft.assertTrue(domainsPage.getConfigurationTab().getCurrentPropertyValue(stringProperty).equalsIgnoreCase("${identifier}${identifier}"), "Configuration table is not showing updated value");
//Check if the property value is updated with system value after use system value is enabled
domainPropertyEditDialog = domainsPage.getConfigurationTab().openProperty(stringProperty);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
domainsPage.getConfigurationTab().saveChanges();
soft.assertTrue(domainsPage.getConfigurationTab().getCurrentPropertyValue(stringProperty).equalsIgnoreCase(defaultPropertyValue), "Configuration table is not showing system value");
soft.assertAll();
}
}
package domiSMPTests.ui;
import ddsl.DomiSMPPage;
import ddsl.dcomponents.commonComponents.domanPropertyEditDialog.DomainPropertyEditDialog;
import ddsl.dcomponents.commonComponents.members.InviteMembersWithGridPopup;
import ddsl.enums.Pages;
import ddsl.enums.ResourceTypes;
import domiSMPTests.SeleniumTest;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeMethod;
......@@ -11,11 +13,13 @@ import org.testng.asserts.SoftAssert;
import pages.LoginPage;
import pages.administration.editDomainsPage.CreateGroupDetailsDialog;
import pages.administration.editDomainsPage.EditDomainsPage;
import pages.administration.editGroupsPage.CreateResourceDetailsDialog;
import pages.administration.editGroupsPage.EditGroupsPage;
import rest.models.DomainModel;
import rest.models.GroupModel;
import rest.models.MemberModel;
import rest.models.UserModel;
import rest.models.*;
import utils.TestRunData;
import java.util.Arrays;
import java.util.List;
/**
* Test class for Edit domains page tests.
......@@ -28,6 +32,10 @@ public class EditDomainsPgTests extends SeleniumTest {
EditDomainsPage editDomainPage;
DomainModel domainModel;
UserModel adminUser;
UserModel normalUser;
MemberModel memberAdmin;
MemberModel memberUser;
SoftAssert soft;
@BeforeMethod(alwaysRun = true)
......@@ -35,14 +43,24 @@ public class EditDomainsPgTests extends SeleniumTest {
soft = new SoftAssert();
domainModel = DomainModel.generatePublicDomainModelWithSML();
adminUser = UserModel.generateUserWithADMINrole();
normalUser = UserModel.generateUserWithUSERrole();
memberAdmin = new MemberModel();
memberAdmin.setUsername(adminUser.getUsername());
memberAdmin.setRoleType("ADMIN");
MemberModel domainMember = new MemberModel();
domainMember.setUsername(adminUser.getUsername());
domainMember.setRoleType("ADMIN");
memberUser = new MemberModel();
memberUser.setUsername(normalUser.getUsername());
memberUser.setRoleType("ADMIN");
rest.users().createUser(adminUser);
rest.users().createUser(normalUser);
domainModel = rest.domains().createDomain(domainModel);
rest.domains().addMembersToDomain(domainModel, domainMember);
rest.domains().addMembersToDomain(domainModel, memberAdmin);
rest.domains().addMembersToDomain(domainModel, memberUser);
homePage = new DomiSMPPage(driver);
loginPage = homePage.goToLoginPage();
......@@ -134,4 +152,161 @@ public class EditDomainsPgTests extends SeleniumTest {
soft.assertEquals(deleteMessage, String.format("Domain group [%s] deleted", groupToBeDeleted.getGroupName()));
soft.assertAll();
}
@Test(description = "EDTDOM-09 Domain admins are able to change default properties for domains")
public void domainAdminsAreAbleToChangeDefaultPropertiesForDomains() throws Exception {
DomainModel currentDomainModel = DomainModel.generatePublicDomainModelWithSML();
//create domain
currentDomainModel = rest.domains().createDomain(currentDomainModel);
// rest.domains().addMembersToDomain(domainModel, adminMember);
rest.domains().addMembersToDomain(currentDomainModel, memberUser);
//add resources to domain
List<ResourceTypes> resourcesToBeAdded = Arrays.asList(ResourceTypes.OASIS1, ResourceTypes.OASIS3, ResourceTypes.OASIS2);
currentDomainModel = rest.domains().addResourcesToDomain(currentDomainModel, resourcesToBeAdded);
editDomainPage.logout();
//Login with user role which is domain admin
loginPage.login(normalUser.getUsername(), data.getNewPassword());
editDomainPage = homePage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_DOMAINS);
editDomainPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", currentDomainModel.getDomainCode());
editDomainPage.goToTab("Configuration");
//Check is modifying boolean values
String boolPropertyName = "identifiersBehaviour.scheme.mandatory";
DomainPropertyEditDialog domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.setDomainValue(false);
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertFalse(editDomainPage.getConfigurationTab().isSystemValueUsed(boolPropertyName), "Property is marked as it's using system value");
soft.assertEquals("false", editDomainPage.getConfigurationTab().getCurrentPropertyValue(boolPropertyName));
//Verify disabling system property
String useDomainProperty = "identifiersBehaviour.ParticipantIdentifierScheme.validationRegex";
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(useDomainProperty);
domainPropertyEditDialog.disableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertFalse(editDomainPage.getConfigurationTab().isSystemValueUsed(useDomainProperty), "Property is marked as it's using system value");
//Verify change to enabling system property
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(useDomainProperty);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertTrue(editDomainPage.getConfigurationTab().isSystemValueUsed(useDomainProperty));
// String property value
String stringProperty = "identifiersBehaviour.caseSensitive.DocumentIdentifierSchemes";
String defaultPropertyValue = editDomainPage.getConfigurationTab().getCurrentPropertyValue(stringProperty);
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(stringProperty);
domainPropertyEditDialog.setDomainValue("${identifier}${identifier}");
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
soft.assertFalse(editDomainPage.getConfigurationTab().isSystemValueUsed(stringProperty), "Property is marked as it's using system value");
soft.assertTrue(editDomainPage.getConfigurationTab().getCurrentPropertyValue(stringProperty).equalsIgnoreCase("${identifier}${identifier}"), "Configuration table is not showing updated value");
//Check if the property value is updated with system value after use system value is enabled
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(stringProperty);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
soft.assertTrue(editDomainPage.getConfigurationTab().getCurrentPropertyValue(stringProperty).equalsIgnoreCase(defaultPropertyValue), "Configuration table is not showing system value");
soft.assertAll();
}
@Test(description = "EDTDOM-11 Domain properties values are applied")
public void domanPropertiesAreApplied() throws Exception {
DomainModel currentDomainModel = DomainModel.generatePublicDomainModelWithSML();
GroupModel currentGroupModel = GroupModel.generatePublicGroup();
MemberModel superMember = new MemberModel();
superMember.setUsername(TestRunData.getInstance().getAdminUsername());
superMember.setRoleType("ADMIN");
//create domain
currentDomainModel = rest.domains().createDomain(currentDomainModel);
rest.domains().addMembersToDomain(currentDomainModel, memberUser);
rest.domains().addMembersToDomain(currentDomainModel, superMember);
//add resources to domain
List<ResourceTypes> resourcesToBeAdded = Arrays.asList(ResourceTypes.OASIS1, ResourceTypes.OASIS3, ResourceTypes.OASIS2);
currentDomainModel = rest.domains().addResourcesToDomain(currentDomainModel, resourcesToBeAdded);
//create group for domain
currentGroupModel = rest.domains().createGroupForDomain(currentDomainModel, currentGroupModel);
//add users to groups
rest.groups().addMembersToGroup(currentDomainModel, currentGroupModel, memberUser);
editDomainPage.logout();
//Login with user role which is domain admin
loginPage.login(normalUser.getUsername(), data.getNewPassword());
editDomainPage = homePage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_DOMAINS);
editDomainPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", currentDomainModel.getDomainCode());
editDomainPage.goToTab("Configuration");
//Remove resource schema mandatory
String boolPropertyName = "identifiersBehaviour.scheme.mandatory";
DomainPropertyEditDialog domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.setDomainValue(false);
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
EditGroupsPage editGroupsPage = editDomainPage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_GROUPS);
editGroupsPage.selectDomain(currentDomainModel, currentGroupModel);
editGroupsPage.goToTab("Resources");
CreateResourceDetailsDialog createResourceDetailsDialog = editGroupsPage.getResourceTab().clickOnCreateNewResource();
//create resource without Resource schema field
ResourceModel resourceModel = ResourceModel.generatePublicResource();
resourceModel.setIdentifierScheme("");
createResourceDetailsDialog.fillResourceDetails(resourceModel);
createResourceDetailsDialog.tryClickOnSave();
soft.assertTrue(editGroupsPage.getResourceTab().getGrid().isValuePresentInColumn("Identifier", resourceModel.getIdentifierValue()), "Resource was not found in the grid");
//Enable resource schema mandatory
editGroupsPage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_DOMAINS);
editDomainPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", currentDomainModel.getDomainCode());
editDomainPage.goToTab("Configuration");
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify is schema is mandatory - using system property value
editGroupsPage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_GROUPS);
editGroupsPage.selectDomain(currentDomainModel, currentGroupModel);
editGroupsPage.goToTab("Resources");
createResourceDetailsDialog = editGroupsPage.getResourceTab().clickOnCreateNewResource();
//create resource without Resource schema field
ResourceModel resourceModel2 = ResourceModel.generatePublicResource();
resourceModel2.setIdentifierScheme("");
createResourceDetailsDialog.fillResourceDetails(resourceModel2);
Boolean saveisDisabled = createResourceDetailsDialog.tryClickOnSave();
soft.assertFalse(saveisDisabled, "Save action didn't worked");
soft.assertFalse(editGroupsPage.getResourceTab().getGrid().isValuePresentInColumn("Identifier", resourceModel2.getIdentifierValue()), "Resource is present in the grid");
soft.assertAll();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment