From 54fb8e3b984f9a8a30f1078491125dff585367f2 Mon Sep 17 00:00:00 2001 From: Marek Marusic Date: Thu, 27 Jun 2019 15:53:17 +0200 Subject: [PATCH] [HAL-1593] Test for certificate authority configuration --- .../ElytronOtherSettingsPage.java | 16 +++- .../elytron/ElytronFixtures.java | 5 ++ .../account/CertificateAuthorityTest.java | 86 +++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/other/settings/certificate/authority/account/CertificateAuthorityTest.java diff --git a/common/src/main/java/org/jboss/hal/testsuite/page/configuration/ElytronOtherSettingsPage.java b/common/src/main/java/org/jboss/hal/testsuite/page/configuration/ElytronOtherSettingsPage.java index 99fd90b1..7426b56c 100644 --- a/common/src/main/java/org/jboss/hal/testsuite/page/configuration/ElytronOtherSettingsPage.java +++ b/common/src/main/java/org/jboss/hal/testsuite/page/configuration/ElytronOtherSettingsPage.java @@ -140,6 +140,12 @@ public class ElytronOtherSettingsPage extends BasePage { @FindBy(id = ELYTRON_DIR_CONTEXT + "-" + CREDENTIAL_REFERENCE + "-" + FORM) private FormFragment dirContextCredentialReferenceForm; @FindBy(id = ELYTRON_DIR_CONTEXT + "-" + TAB_CONTAINER) private TabsFragment dirContextTabs; + @FindBy(id = ELYTRON_CERTIFICATE_AUTHORITY + "-" + TABLE + WRAPPER) + private TableFragment certificateAuthorityTable; + + @FindBy(id = ELYTRON_CERTIFICATE_AUTHORITY + "-" + FORM) + private FormFragment certificateAuthorityForm; + @FindBy(id = ELYTRON_CERTIFICATE_AUTHORITY_ACCOUNT + "-" + TABLE + WRAPPER) private TableFragment certificateAuthorityAccountTable; @@ -420,6 +426,14 @@ public TabsFragment getDirContextTabs() { return dirContextTabs; } + public TableFragment getCertificateAuthorityTable() { + return certificateAuthorityTable; + } + + public FormFragment getCertificateAuthorityForm() { + return certificateAuthorityForm; + } + public TableFragment getCertificateAuthorityAccountTable() { return certificateAuthorityAccountTable; } @@ -465,4 +479,4 @@ public TableFragment getServerSSLSNIContextTable() { public FormFragment getServerSSLSNIContextForm() { return serverSSLSNIContextForm; } -} \ No newline at end of file +} diff --git a/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/ElytronFixtures.java b/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/ElytronFixtures.java index 2b096e73..9c24899d 100644 --- a/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/ElytronFixtures.java +++ b/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/ElytronFixtures.java @@ -157,6 +157,7 @@ public final class ElytronFixtures { public static final String CACHING_REALM_ITEM = "elytron-caching-realm-item"; public static final String CERTIFICATE_FROM = "certificate-from"; public static final String CERTIFICATE_AUTHORITY_ACCOUNT_ITEM = "elytron-certificate-authority-account-item"; + public static final String CERTIFICATE_AUTHORITY_ITEM = "elytron-certificate-authority-item"; public static final String CERTIFICATE_REVOCATION_LIST = "certificate-revocation-list"; public static final String CHAINED_PRINCIPAL_TRANSFORMER_ITEM = Ids.build(ELYTRON_CHAINED_PRINCIPAL_TRANSFORMER, ITEM); public static final String CLEAR_PASSWORD_MAPPER = "clear-password-mapper"; @@ -1248,6 +1249,10 @@ public static Address certificateAuthorityAccountAddress(String name) { return SUBSYSTEM_ADDRESS.and("certificate-authority-account", name); } + public static Address certificateAuthorityAddress(String name) { + return SUBSYSTEM_ADDRESS.and("certificate-authority", name); + } + // ------------- mapped-role-mapper public static Address mappedRoleMapperAddress(String name) { diff --git a/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/other/settings/certificate/authority/account/CertificateAuthorityTest.java b/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/other/settings/certificate/authority/account/CertificateAuthorityTest.java new file mode 100644 index 00000000..a55e2cfb --- /dev/null +++ b/tests/basic/src/test/java/org/jboss/hal/testsuite/test/configuration/elytron/other/settings/certificate/authority/account/CertificateAuthorityTest.java @@ -0,0 +1,86 @@ +package org.jboss.hal.testsuite.test.configuration.elytron.other.settings.certificate.authority.account; + +import java.io.IOException; + +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.hal.dmr.ModelDescriptionConstants; +import org.jboss.hal.testsuite.Random; +import org.jboss.hal.testsuite.test.configuration.elytron.ElytronFixtures; +import org.jboss.hal.testsuite.test.configuration.elytron.other.settings.AbstractOtherSettingsTest; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.wildfly.extras.creaper.core.online.operations.OperationException; +import org.wildfly.extras.creaper.core.online.operations.Values; + +@RunWith(Arquillian.class) +public class CertificateAuthorityTest extends AbstractOtherSettingsTest { + + private static final String CERTIFICATE_AUTHORITY_CREATE = + "certificate-authority-to-be-created-" + Random.name(); + + private static final String CERTIFICATE_AUTHORITY_UPDATE = + "certificate-authority-to-be-updated-" + Random.name(); + + private static final String CERTIFICATE_AUTHORITY_DELETE = + "certificate-authority-to-be-deleted-" + Random.name(); + + private static final String LOCALHOST = "http://localhost"; + + + @BeforeClass + public static void initResources() throws IOException { + operations.add(ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_UPDATE), Values.of(ModelDescriptionConstants.URL, LOCALHOST)); + operations.add(ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_DELETE), Values.of(ModelDescriptionConstants.URL, LOCALHOST)); + } + + @AfterClass + public static void cleanUp() throws IOException, OperationException { + operations.removeIfExists( + ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_CREATE)); + operations.removeIfExists( + ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_UPDATE)); + operations.removeIfExists( + ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_DELETE)); + } + + @Before + public void navigateToCertificateAuthority() { + console.verticalNavigation() + .selectSecondary(ElytronFixtures.OTHER_ITEM, ElytronFixtures.CERTIFICATE_AUTHORITY_ITEM); + } + + @Test + public void create() throws Exception { + crud.create(ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_CREATE), + page.getCertificateAuthorityTable(), formFragment -> { + formFragment.text("name", CERTIFICATE_AUTHORITY_CREATE); + formFragment.text(ModelDescriptionConstants.URL, LOCALHOST); + }); + } + + @Test + public void delete() throws Exception { + crud.delete(ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_DELETE), + page.getCertificateAuthorityTable(), CERTIFICATE_AUTHORITY_DELETE); + } + + @Test + public void editUrl() throws Exception { + page.getCertificateAuthorityTable().select(CERTIFICATE_AUTHORITY_UPDATE); + crud.update(ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_UPDATE), + page.getCertificateAuthorityForm(), ModelDescriptionConstants.URL, "https://example.com"); + } + + + @Test + public void editStagingUrl() throws Exception { + page.getCertificateAuthorityTable().select(CERTIFICATE_AUTHORITY_UPDATE); + crud.update(ElytronFixtures.certificateAuthorityAddress(CERTIFICATE_AUTHORITY_UPDATE), + page.getCertificateAuthorityForm(), "staging-url", "https://example.com"); + } + + +}