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

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

renamed elements on KeyStorePage, changed element to get text value, created...

renamed elements on KeyStorePage, changed element to get text value, created method to search and click in grid, added asserts for tests.
parent 037032d5
No related branches found
No related tags found
No related merge requests found
Pipeline #103406 passed with warnings
......@@ -9,23 +9,23 @@ public class CommonCertificatePage extends CommonPageWithGrid {
* Common page used for Keystore and Truststore
*/
@FindBy(id = "publicKeyType_id")
private WebElement publicKeyTypeLbl;
private WebElement publicKeyTypeInput;
@FindBy(id = "alias_id")
private WebElement aliasIdLbl;
private WebElement aliasIdInput;
@FindBy(id = "certificateId_id")
private WebElement smpCertificateIdLbl;
private WebElement smpCertificateIdInput;
@FindBy(id = "subject_id")
private WebElement subjectNameLbl;
private WebElement subjectNameInput;
@FindBy(css = "certificate-panel [placeholder=\"Valid from date\"]")
private WebElement validFromLbl;
private WebElement validFromInput;
@FindBy(css = "certificate-panel [placeholder=\"Valid to date\"]")
private WebElement validToLbl;
private WebElement validToInput;
@FindBy(id = "issuer_id")
private WebElement issuerLbl;
private WebElement issuerInput;
@FindBy(id = "servialNumber_id")
private WebElement serialNumberLbl;
private WebElement serialNumberInput;
@FindBy(id = "clrUrl_id")
private WebElement certificateRevolcationListURLlbl;
private WebElement certificateRevolcationListURLInput;
@FindBy(css = ".smp-warning-panel span")
private WebElement smpWarningLbl;
......@@ -33,39 +33,39 @@ public class CommonCertificatePage extends CommonPageWithGrid {
super(driver);
}
public String getPublicKeyTypeLbl() {
return publicKeyTypeLbl.getText();
public String getPublicKeyTypeValue() {
return weToDInput(publicKeyTypeInput).getText();
}
public String getAliasIdLbl() {
return aliasIdLbl.getText();
public String getAliasIdValue() {
return weToDInput(aliasIdInput).getText();
}
public String getSmpCertificateIdLbl() {
return smpCertificateIdLbl.getText();
public String getSmpCertificateIdValue() {
return weToDInput(smpCertificateIdInput).getText();
}
public String getSubjectNameLbl() {
return subjectNameLbl.getText();
public String getSubjectNameValue() {
return weToDInput(subjectNameInput).getText();
}
public String getValidFromLbl() {
return validFromLbl.getText();
public String getValidFromValue() {
return weToDInput(validFromInput).getText();
}
public String getValidToLbl() {
return validToLbl.getText();
public String getValidToValue() {
return weToDInput(validToInput).getText();
}
public String getIssuerLbl() {
return issuerLbl.getText();
public String getIssuerValue() {
return weToDInput(issuerInput).getText();
}
public String getSerialNumberLbl() {
return serialNumberLbl.getText();
public String getSerialNumberValue() {
return weToDInput(serialNumberInput).getText();
}
public String getCertificateRevolcationListURLlbl() {
return certificateRevolcationListURLlbl.getText();
public String getCertificateRevolcationListURLValue() {
return weToDInput(certificateRevolcationListURLInput).getText();
}
}
......@@ -71,6 +71,38 @@ public class SmallGrid extends DComponent {
}
return null;
}
public void searchAndClickElementInColumn(String columnName, String value) {
wait.forXMillis(100);
Integer numOfPages = getGridPagination().getTotalPageNumber();
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");
;
}
for (int pageNr = 1; pageNr < numOfPages + 1; pageNr++) {
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 on page [{}]", value, pageNr);
currentCell.click();
}
}
getGridPagination().goToNextPage();
}
LOG.error("No element found");
}
}
......
package utils;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Utils {
public static <T extends Enum<?>> T randomEnum(T[] values) {
int x = new Random().nextInt(values.length);
return values[x];
}
public static String getAliasFromMessage(String message){
Pattern pattern = Pattern.compile("(?<= \\[)(.*?)(?=\\])");
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
String result = matcher.group(1);
return result;
}
return null;
}
}
......@@ -13,6 +13,7 @@ import pages.systemSettings.keyStorePage.KeyStoreImportDialog;
import pages.systemSettings.keyStorePage.KeystorePage;
import rest.models.UserModel;
import utils.FileUtils;
import utils.Utils;
public class KeystorePgTests extends SeleniumTest {
......@@ -37,16 +38,25 @@ public class KeystorePgTests extends SeleniumTest {
}
@Test(description = "KEYS-02 System admin is able to import JKS Keystore")
@Test(description = "KEYS-02 System admin is able to import JKS Keystore", priority = 0)
public void systemAdminIsAbleToImportJKS() throws Exception {
String path = FileUtils.getAbsoluteKeystorePath("expired_keystore_JKS.jks");
KeyStoreImportDialog keyStoreImportDialog = keystorePage.clickImportkeyStoreBtn();
keyStoreImportDialog.addCertificate(path, KeyStoreTypes.JKS, "test1234");
keyStoreImportDialog.clickImport();
String value = keystorePage.getAlertArea().getAlertMessage();
String alias = Utils.getAliasFromMessage(value);
keystorePage.getGrid().searchAndClickElementInColumn("Alias", alias);
soft.assertEquals(keystorePage.getPublicKeyTypeValue(),"RSA");
soft.assertEquals(keystorePage.getSmpCertificateIdValue(), "CN=blue_gw,O=edelivery,C=BE:00000000645901cb");
soft.assertEquals(keystorePage.getSubjectNameValue(),"CN=blue_gw,O=edelivery,C=BE" );
soft.assertEquals(keystorePage.getValidFromValue(),"5/8/2023, 5:06:03 PM");
soft.assertEquals(keystorePage.getValidToValue(), "5/1/2023, 5:06:03 PM");
soft.assertEquals(keystorePage.getIssuerValue(), "CN=blue_gw,O=edelivery,C=BE");
soft.assertEquals(keystorePage.getSerialNumberValue(),"645901cb");
sofAssertThatContains("Certificates added [blue_gw", value);
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