Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit df26bc03 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #63: Update ui tests

Merge in EDELIVERY/smp from EDELIVERY-12658-update-ui-tests to development

* commit 'ff53fe73':
  Update ui tests
  Update ui tests
parents a2f4a1e3 ff53fe73
No related branches found
No related tags found
No related merge requests found
Pipeline #130941 canceled
Showing
with 102 additions and 33 deletions
......@@ -11,8 +11,8 @@
<!-- configuration example-->
<test.properties.path>./src/main/resources/myLocal.properties</test.properties.path>
<commons-csv_version>1.10.0</commons-csv_version>
<selenium-chrome-driver_version>4.15.0</selenium-chrome-driver_version>
<selenium-java_version>4.15.0</selenium-java_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>
<reflections_version>0.10.2</reflections_version>
<jersey-client_version>1.19.4</jersey-client_version>
......
......@@ -26,4 +26,14 @@ public class MatSelect extends DObject {
wait.forElementToBeVisible(option);
option.click();
}
/**
* Method returns the current selected text!
*
* @return the text displayed in the select
*/
public String getCurrentText() {
return element.getText();
}
}
......@@ -60,9 +60,9 @@ public class DObject {
throw new Exception();
}
public String getText() throws Exception {
public String getText() {
if (!isPresent()) {
throw new Exception();
throw new ElementNotInteractableException("Element: ["+ element.getAccessibleName() +"] not present");
}
scrollIntoView();
String text = ((JavascriptExecutor) driver).executeScript("return arguments[0].innerText;", element).toString();
......@@ -73,7 +73,7 @@ public class DObject {
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
}
public void click() throws ElementNotInteractableException {
public void click() {
if (isEnabled()) {
wait.forElementToBeClickable(element).click();
} else {
......
......@@ -4,11 +4,14 @@ import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generic wrapper for select element.
*/
public class DSelect extends DObject {
private final static Logger LOG = LoggerFactory.getLogger(DSelect.class);
Select select = new Select(element);
public DSelect(WebDriver driver, WebElement element) {
super(driver, element);
......@@ -22,6 +25,8 @@ public class DSelect extends DObject {
select.getWrappedElement().sendKeys(Keys.ENTER);
}
wait.forXMillis(10);
LOG.debug("Selecting by visible text: [{}]", value);
select.getAllSelectedOptions().stream().forEach(e -> LOG.debug("value to select", e.getText()));
select.selectByVisibleText(value);
}
......
package ddsl.enums;
/**
* Enumeration of data for provided certificates in the test truststure.
* This is used to select the correct certificate in the UI.
*/
public enum ResponseCertificates {
SMP_DOMAIN_02("smp_domain_02 (CN=smp_domain_02,O=digit,C=eu:000000006443d987)"),
SMP_EDDSA_448("smp_eddsa_448 (CN=smp_eddsa_448,O=digit,C=eu:000000006443fcba)"),
SMP_ECDSA_NIST_B409("smp_ecdsa_nist-b409 (CN=smp_ecdsa_nist-b409,O=digit,C=eu:000000006443fd57)"),
SMP_DOMAIN_01("smp_domain_01 (CN=smp_domain_01,O=digit,C=eu:000000006443d8a8)"),
SAMPLE_KEY("sample_key (CN=demo-smp-signing-key,O=digit,C=eu:000000006443f9bc)"),
SMP_EDDSA_25519("smp_eddsa_25519 (CN=smp_eddsa_25519,O=digit,C=eu:000000006443d95d)");
public String getName() {
return name;
SAMPLE_KEY("sample_key", "sample_key (CN=demo-smp-signing-key,O=digit,C=eu:000000006443f9bc)"),
SMP_DOMAIN_01("smp_domain_01", "smp_domain_01 (CN=smp_domain_01,O=digit,C=eu:000000006443d8a8)"),
SMP_DOMAIN_02("smp_domain_02", "smp_domain_02 (CN=smp_domain_02,O=digit,C=eu:000000006443d987)"),
SMP_ECDSA_NIST_B409("smp_ecdsa_nist-b409", "smp_ecdsa_nist-b409 (CN=smp_ecdsa_nist-b409,O=digit,C=eu:000000006443fd57)"),
SMP_EDDSA_448("smp_eddsa_448", "smp_eddsa_448 (CN=smp_eddsa_448,O=digit,C=eu:000000006443fcba)"),
SMP_EDDSA_25519("smp_eddsa_25519", "smp_eddsa_25519 (CN=smp_eddsa_25519,O=digit,C=eu:000000006443d95d)");
private final String text;
private final String alias;
ResponseCertificates(String alias, String text) {
this.alias = alias;
this.text = text;
}
public final String name;
public String getText() {
return text;
}
public String getAlias() {
return alias;
}
ResponseCertificates(String name) {
this.name = name;
public static ResponseCertificates getByAlias(String alias) {
for (ResponseCertificates e : values()) {
if (e.getAlias().equals(alias)) {
return e;
}
}
return null;
}
public static String getTextForAlias(String alias) {
ResponseCertificates certificates = getByAlias(alias);
return certificates != null ? certificates.getText() : null;
}
}
package pages.systemSettings.domainsPage;
import ddsl.dcomponents.DComponent;
import ddsl.enums.ResponseCertificates;
import org.apache.poi.util.StringUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -22,6 +24,7 @@ public class DomainTab extends DComponent {
private WebElement visibilityOfDomainDdl;
@FindBy(id = "saveButton")
private WebElement saveBtn;
public DomainTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
......@@ -33,7 +36,7 @@ public class DomainTab extends DComponent {
}
public String getResponseSignatureCertificateSelectedValue() {
return weToDSelect(responseSignatureCertificateDdl).getCurrentValue();
return weToMatSelect(responseSignatureCertificateDdl).getCurrentText();
}
public String getVisibilityOfDomainSelectedValue() {
......@@ -41,9 +44,18 @@ public class DomainTab extends DComponent {
}
public void fillDomainData(DomainModel domainModel) {
ResponseCertificates responseCertificates = ResponseCertificates
.getByAlias(domainModel.getSignatureKeyAlias());
if (StringUtil.isNotBlank(domainModel.getSignatureKeyAlias()) && responseCertificates == null) {
LOG.warn("Cannot find signature key for alias [{}]", domainModel.getSignatureKeyAlias());
}
domainIdInput.sendKeys(domainModel.getDomainCode());
weToDSelect(responseSignatureCertificateDdl).selectByVisibleText(domainModel.getSignatureKeyAlias(), true);
if (responseCertificates != null) {
weToMatSelect(responseSignatureCertificateDdl)
.selectByVisibleText(responseCertificates.getText());
}
weToDSelect(visibilityOfDomainDdl).selectValue(domainModel.getVisibility());
}
......
......@@ -2,6 +2,8 @@ package pages.systemSettings.domainsPage;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dcomponents.DComponent;
import ddsl.enums.ResponseCertificates;
import org.apache.poi.util.StringUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -39,11 +41,19 @@ public class SMLIntegrationTab extends DComponent {
}
public void fillSMLIntegrationTab(DomainModel domainModel) {
ResponseCertificates responseCertificates = ResponseCertificates
.getByAlias(domainModel.getSignatureKeyAlias());
if (StringUtil.isNotBlank(domainModel.getSignatureKeyAlias()) && responseCertificates== null) {
LOG.warn("Cannot find signature key for alias [{}]", domainModel.getSignatureKeyAlias());
}
try {
weToDInput(smlDomainInput).fill(domainModel.getSmlSubdomain());
weToDInput(smlsmpIdentifierInput).fill(domainModel.getSmlSmpId());
//TODO : check of clientcertificatealias is changed from mat-select to select
weToDSelect(smlClientCertificateAliasDdl).selectByVisibleText(domainModel.getSignatureKeyAlias(), true);
if (responseCertificates != null) {
weToDSelect(smlClientCertificateAliasDdl)
.selectByVisibleText(responseCertificates.getText(), true);
}
weToDButton(useClientCertBtn).click();
} catch (Exception e) {
......
package rest.models;
import ddsl.enums.ResponseCertificates;
import org.apache.commons.lang3.StringUtils;
import utils.Generator;
import utils.Utils;
......@@ -149,19 +148,19 @@ public class DomainModel {
public static DomainModel generatePublicDomainModelWithSML() {
DomainModel domainModel = new DomainModel();
domainModel.domainCode = "AUTDom" + Generator.randomAlphaNumericValue(6);
domainModel.signatureKeyAlias = Utils.randomEnum(new ResponseCertificates[]{SMP_DOMAIN_01, SMP_DOMAIN_02}).getName();
domainModel.signatureKeyAlias = Utils.randomEnum(new ResponseCertificates[]{SMP_DOMAIN_01, SMP_DOMAIN_02}).getAlias();
domainModel.visibility = "PUBLIC";
domainModel.smlClientCertAuth = true;
domainModel.smlSubdomain = "AUTDomSML" + Generator.randomAlphaNumericValue(6);
domainModel.smlSmpId = "AUTSMLSMP" + Generator.randomAlphaNumericValue(4);
domainModel.smlClientKeyAlias = StringUtils.lowerCase(Utils.randomEnum(new ResponseCertificates[]{SMP_DOMAIN_01, SMP_DOMAIN_02}).toString());
domainModel.smlClientKeyAlias = Utils.randomEnum(new ResponseCertificates[]{SMP_DOMAIN_01, SMP_DOMAIN_02}).getAlias();
return domainModel;
}
public static DomainModel generatePublicDomainModelWithoutSML() {
DomainModel domainModel = new DomainModel();
domainModel.domainCode = "AUTDom" + Generator.randomAlphaNumericValue(6);
domainModel.signatureKeyAlias = Utils.randomEnum(ResponseCertificates.values()).getName();
domainModel.signatureKeyAlias = Utils.randomEnum(ResponseCertificates.values()).getAlias();
domainModel.visibility = "PUBLIC";
return domainModel;
}
......
......@@ -58,6 +58,7 @@ public class SeleniumTest {
try {
driver.get(data.getUiBaseUrl());
} catch (Exception e) {
LOG.warn("Driver is not initialized, try to reninitialize it");
driver = DriverManager.getDriver();
driver.get(data.getUiBaseUrl());
}
......
......@@ -2,6 +2,7 @@ package domiSMPTests.ui;
import ddsl.DomiSMPPage;
import ddsl.enums.Pages;
import ddsl.enums.ResponseCertificates;
import domiSMPTests.SeleniumTest;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeMethod;
......@@ -48,7 +49,7 @@ public class DomainsPgTests extends SeleniumTest {
soft.assertEquals(alert, "Domain: [" + domainModel.getDomainCode() + "] was created!");
domainsPage.getLeftSideGrid().searchAndGetElementInColumn("Domain code", domainModel.getDomainCode()).click();
soft.assertEquals(domainModel.getSignatureKeyAlias(), domainsPage.getDomainTab().getResponseSignatureCertificateSelectedValue());
soft.assertEquals(ResponseCertificates.getTextForAlias(domainModel.getSignatureKeyAlias()), domainsPage.getDomainTab().getResponseSignatureCertificateSelectedValue());
soft.assertEquals(domainModel.getVisibility(), domainsPage.getDomainTab().getVisibilityOfDomainSelectedValue());
soft.assertEquals(domainsPage.getDomainWarningMessage(), "To complete domain configuration, please:\n" +
"select at least one resource type from the Resource Types tab\n" +
......
......@@ -34,14 +34,14 @@
</mat-form-field>
<mat-form-field style="width:100%">
<mat-label>Response signature Certificate (Signature CertAlias)</mat-label>
<select matNativeControl matInput formControlName="signatureKeyAlias"
<mat-select formControlName="signatureKeyAlias"
matTooltip="Certificate is used for signing REST responses for the domain."
id="signatureKeyAlias_id">
<option [value]="''" ></option>
<option *ngFor="let cert of keystoreCertificates" [value]="cert.alias">
<mat-option [value]="''" ></mat-option>
<mat-option *ngFor="let cert of keystoreCertificates" [value]="cert.alias">
{{cert.alias}} ({{cert.certificateId}})
</option>
</select>
</mat-option>
</mat-select>
<mat-hint align="end">Empty value will cause that Resource responses will not be signed by SMP!
</mat-hint>
</mat-form-field>
......
......@@ -44,6 +44,11 @@ td , th {
padding: 10px !important;
}
.mat-select {
padding-top: 0 !important;
padding-bottom: 0 !important;
}
.text-select {
-webkit-user-select: text;
-moz-user-select: text;
......
......@@ -6,7 +6,9 @@ services:
testui:
image: ${IMAGE_TAG:-edeliverytest}/${IMAGE_SMP_TEST_UI}:${SMP_VERSION}
environment:
- TZ=CEST # set timezone CEST because of hardoced date UI test assertions
- TZ=CEST
- SCREEN_WIDTH=1920
- SCREEN_HEIGHT=1080
networks:
- test-network
networks:
......
......@@ -21,5 +21,5 @@ DOCKER_NETWORK_NAME="${PLAN_PREFIX}_default"
export DOCKER_NETWORK_NAME
# Starting Docker Compose TEST (in specific project to avoid orphan container warning)
docker-compose -f docker-compose.test-ui.yml -p "run-${PLAN_PREFIX}" up
docker compose -f docker-compose.test-ui.yml -p "run-${PLAN_PREFIX}" up
docker cp "run-${PLAN_PREFIX}_testui_1:/results/surefire-reports" ./results
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