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

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

Added TrustorePage and TrustorePGtests - work in progress

Added FileUtils class.
parent 967e8c72
No related branches found
No related tags found
No related merge requests found
Pipeline #82615 passed with warnings
...@@ -10,6 +10,7 @@ import org.openqa.selenium.support.PageFactory; ...@@ -10,6 +10,7 @@ import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pages.TruststorePage;
import pages.UsersPage; import pages.UsersPage;
import pages.domainsPage.DomainsPage; import pages.domainsPage.DomainsPage;
import pages.editDomainsPage.EditDomainsPage; import pages.editDomainsPage.EditDomainsPage;
...@@ -127,9 +128,10 @@ public class SideNavigationComponent extends DomiSMPPage { ...@@ -127,9 +128,10 @@ public class SideNavigationComponent extends DomiSMPPage {
// case SYSTEM_SETTINGS_KEYSTORE: // case SYSTEM_SETTINGS_KEYSTORE:
// expandSection(systemSettingsExpand); // expandSection(systemSettingsExpand);
// return new DLink(driver, keystoreLnk); // return new DLink(driver, keystoreLnk);
// case SYSTEM_SETTINGS_TRUSTSTORE: if (page == Pages.SYSTEM_SETTINGS_TRUSTSTORE) {
// expandSection(systemSettingsExpand); openSubmenu(systemSettingsExpand, truststoreLnk);
// return new DLink(driver, truststoreLnk); return (T) new TruststorePage(driver);
}
// case SYSTEM_SETTINGS_EXTENSIONS: // case SYSTEM_SETTINGS_EXTENSIONS:
// expandSection(systemSettingsExpand); // expandSection(systemSettingsExpand);
// return new DLink(driver, extensionsLnk); // return new DLink(driver, extensionsLnk);
......
package pages;
import ddsl.PageWithGrid;
import ddsl.dcomponents.Grid.SmallGrid;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TruststorePage extends PageWithGrid {
/**
* Page object for the Truststorepage. This contains the locators of the page and the methods for the behaviour of the page
*/
//TODO work in progress
@FindBy(id = "custom-file-upload")
private WebElement uploadInput;
@FindBy(id = "publicKeyType_id")
private WebElement publicKeyTypeLbl;
@FindBy(id = "alias_id")
private WebElement aliasIdLbl;
@FindBy(id = "certificateId_id")
private WebElement smpCertificateId;
@FindBy(id = "subject_id")
private WebElement subjectName;
public TruststorePage(WebDriver driver) {
super(driver);
}
public SmallGrid getGrid() {
return new SmallGrid(driver, dataPanel);
}
public String addCertificateAndReturnAlias(String filePath) {
uploadInput.sendKeys(filePath);
String certificateAlias = getAlertMessageAndClose();
Pattern pattern = Pattern.compile("(?<=alias \\[)(.*?)(?=\\])");
Matcher matcher = pattern.matcher(certificateAlias);
if (matcher.find()) {
String result = matcher.group(1);
return result;
}
return null;
}
}
package utils;
import java.io.File;
public class FileUtils {
public static String getAbsolutePath(String relativePath) {
return new File(relativePath).getAbsolutePath();
}
}
-----BEGIN CERTIFICATE-----
MIICyjCCAbKgAwIBAgIEX3SoITANBgkqhkiG9w0BAQsFADAnMQswCQYDVQQGEwJC
RTELMAkGA1UECwwCU1QxCzAJBgNVBAMMAlRFMB4XDTIwMDkzMDE1NDUzN1oXDTIx
MDkzMDE1NDUzN1owJzELMAkGA1UEBhMCQkUxCzAJBgNVBAsMAlNUMQswCQYDVQQD
DAJURTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKPhUN8vXynyj41Y
W8S+KIYqz+9TOyaVW2blAEqc3jiN83baPBnjEqPQjnTuWGTBE4jV4rR9FGjp48z9
evhEvhoKjntzmN6UnsWELMFC6l3JgP6fci7WdEgS3gw7lgYxfbU4VNXtC4cSRbkD
vV5ccZa3EW3FzRk9PWRCL18xdh3BC/vwZ+FZ85Vv80F1PdO7gu+jPihT4lkWrZ0j
8dVUoMtwul5yXXrTR/cePJjG7jo+lamy7bIiBYxHFYq79ZbVaYfpjuhIsd83LR8u
LV3DrSFcSJ7SUPBWzEwLWh57SfnnEfy+CApufWioYgEkRoV0v6gvEO3cBRwyMenH
V4FuhncCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAHCnhGR9VlKSDmQw2j/tSwdOc
nfhctdOZNvlLzUBIPC4S4w49WtegwQEdxSN2+X/icJTJGUnnxeC3GPamH/2bOG5j
hw+5BYDYj3PfRHwvvhA/W2HwRXWdR4/WqVZhNKYI4qp1+zKV5B5oKmpy/K08aele
tlMSP4e8Pu9cABa3mhMj8oEC/DEkV44yTGphnNnKyBlCaL9vRzRJzHEzLV/RC8H2
RpJrS3m8DTUaIsp+Ysm3j+hyYlUrd4+Yt/LDuyI2ZwsyRq/leaHJe13BguUniu73
XXHsZEj9hLkTpclz7q0g38XqYiMr4bizHi02sDujpzpACo/iec8PUeB3aAsrhA==
-----END CERTIFICATE-----
package domiSMPTests.ui;
import ddsl.DomiSMPPage;
import ddsl.enums.Pages;
import domiSMPTests.SeleniumTest;
import org.testng.Assert;
import org.testng.annotations.Test;
import pages.LoginPage;
import pages.TruststorePage;
import utils.FileUtils;
public class TrustorePgTests extends SeleniumTest {
//TODO work in progress
@Test(description = "TRST-01 System admin is able to import certificates")
public void SystemAdminIsAbleToImportCertificates() throws Exception {
DomiSMPPage homePage = new DomiSMPPage(driver);
LoginPage loginPage = homePage.goToLoginPage();
loginPage.login(data.getAdminUser().get("username"), data.getAdminUser().get("password"));
TruststorePage truststorepage = homePage.getSidebar().navigateTo(Pages.SYSTEM_SETTINGS_TRUSTSTORE);
String path = FileUtils.getAbsolutePath("./src/main/resources/truststore/test.cer");
String certificateALias = truststorepage.addCertificateAndReturnAlias(path);
Assert.assertNotNull(certificateALias);
}
}
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