From 8ac7bda52cf9576efb89dafedf6ac8cd420c95d7 Mon Sep 17 00:00:00 2001 From: vramik Date: Tue, 26 Jun 2018 13:24:38 +0200 Subject: [PATCH] KEYCLOAK-7589 - adapter tests - Fuse7.0 provider --- .../servers/app-server/karaf/fuse70/pom.xml | 27 +++- .../Fuse70AppServerArquillianExtension.java | 41 +++++ .../container/Fuse70AppServerProvider.java | 92 +++++++++++ ...boss.arquillian.core.spi.LoadableExtension | 1 + ...llian.container.AppServerContainerProvider | 1 + .../integration-arquillian/tests/base/pom.xml | 54 +++++++ .../testsuite/adapter/page/Hawtio2Page.java | 8 +- .../testsuite/adapter/page/HawtioPage.java | 18 ++- .../page/fuse/AbstractFuseExample.java | 3 +- .../containers/ContainerConstants.java | 1 + .../testsuite/util/ContainerAssume.java | 9 ++ .../example/fuse/FuseAdminAdapterTest.java | 151 +++++++++++++++--- .../example/fuse/FuseExampleAdapterTest.java | 1 + .../tests/other/adapters/karaf/fuse70/pom.xml | 48 ------ .../example/Fuse70AdminAdapterTest.java | 96 ----------- .../example/Fuse70ExampleAdapterTest.java | 26 --- .../tests/other/adapters/karaf/pom.xml | 6 - .../integration-arquillian/tests/pom.xml | 6 + 18 files changed, 379 insertions(+), 210 deletions(-) create mode 100644 testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/Fuse70AppServerArquillianExtension.java create mode 100644 testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/container/Fuse70AppServerProvider.java create mode 100644 testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension create mode 100644 testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.keycloak.testsuite.arquillian.container.AppServerContainerProvider delete mode 100644 testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/pom.xml delete mode 100644 testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70AdminAdapterTest.java delete mode 100644 testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70ExampleAdapterTest.java diff --git a/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/pom.xml b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/pom.xml index 78db5af2bb..653a257f47 100644 --- a/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/pom.xml +++ b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/pom.xml @@ -26,8 +26,8 @@ 4.0.0 integration-arquillian-servers-app-server-fuse70 - pom - App Server - Karaf - JBoss Fuse 7.0 + jar + App Server - Fuse 7.0 fuse70 @@ -38,6 +38,29 @@ -u admin -p admin + + + org.keycloak.testsuite + integration-arquillian-servers-app-server-spi + ${project.version} + + + org.keycloak.testsuite + integration-arquillian-util + ${project.version} + + + org.jboss.arquillian.container + arquillian-container-osgi + + + com.google.guava + guava + + + + + diff --git a/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/Fuse70AppServerArquillianExtension.java b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/Fuse70AppServerArquillianExtension.java new file mode 100644 index 0000000000..003e53531a --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/Fuse70AppServerArquillianExtension.java @@ -0,0 +1,41 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.keycloak.testsuite.arquillian.fuse; + +import org.jboss.arquillian.container.osgi.OSGiApplicationArchiveProcessor; +import org.jboss.arquillian.container.spi.client.container.DeployableContainer; +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; +import org.keycloak.testsuite.utils.arquillian.fuse.CustomFuseContainer; +import org.keycloak.testsuite.utils.arquillian.fuse.KeycloakOSGiApplicationArchiveProcessor; + +/** + * + * @author Vlasta Ramik + */ +public class Fuse70AppServerArquillianExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + + builder.service(DeployableContainer.class, CustomFuseContainer.class); + + builder.override(ApplicationArchiveProcessor.class, OSGiApplicationArchiveProcessor.class, KeycloakOSGiApplicationArchiveProcessor.class); + + } + +} diff --git a/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/container/Fuse70AppServerProvider.java b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/container/Fuse70AppServerProvider.java new file mode 100644 index 0000000000..fda6070a47 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/java/org/keycloak/testsuite/arquillian/fuse/container/Fuse70AppServerProvider.java @@ -0,0 +1,92 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.testsuite.arquillian.fuse.container; + +import java.util.ArrayList; +import java.util.List; +import org.jboss.arquillian.core.spi.Validate; +import org.jboss.shrinkwrap.descriptor.spi.node.Node; +import org.keycloak.testsuite.arquillian.container.AppServerContainerProvider; +import org.keycloak.testsuite.utils.arquillian.fuse.CustomFuseContainer; + +/** + * @author Vlasta Ramik + */ +public class Fuse70AppServerProvider implements AppServerContainerProvider { + + private Node configuration; + private static final String containerName = "fuse70"; + + private final String appServerHome; + private final String appServerJavaHome; + private final String managementUser; + private final String managementPassword; + + public Fuse70AppServerProvider() { + appServerHome = System.getProperty("app.server.home"); + appServerJavaHome = System.getProperty("app.server.java.home"); + managementUser = System.getProperty("app.server.management.user"); + managementPassword = System.getProperty("app.server.management.password"); + + Validate.notNullOrEmpty(appServerHome, "app.server.home is not set."); + Validate.notNullOrEmpty(appServerJavaHome, "app.server.java.home is not set."); + Validate.notNullOrEmpty(managementUser, "app.server.management.user is not set."); + Validate.notNullOrEmpty(managementPassword, "app.server.management.password is not set."); + } + + @Override + public String getName() { + return containerName; + } + + @Override + public List getContainers() { + List containers = new ArrayList<>(); + + containers.add(standaloneContainer()); + + return containers; + } + + private void createChild(String name, String text) { + configuration.createChild("property").attribute("name", name).text(text); + } + + private Node standaloneContainer() { + Node container = new Node("container"); + container.attribute("mode", "manual"); + container.attribute("qualifier", AppServerContainerProvider.APP_SERVER + "-" + containerName); + + configuration = container.createChild("configuration"); + createChild("enabled", "true"); + createChild("adapterImplClass", CustomFuseContainer.class.getName()); + createChild("autostartBundle", "false"); + createChild("karafHome", appServerHome); + createChild("javaHome", appServerJavaHome); + createChild("javaVmArguments", + System.getProperty("app.server.karaf.jvm.debug.args", "") + " " + + System.getProperty("adapter.test.props", " ") + ); + + createChild("jmxServiceURL", "service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root"); + createChild("jmxUsername", managementUser); + createChild("jmxPassword", managementPassword); + + return container; + } +} diff --git a/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..2b8cf1704b --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.keycloak.testsuite.arquillian.fuse.Fuse70AppServerArquillianExtension diff --git a/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.keycloak.testsuite.arquillian.container.AppServerContainerProvider b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.keycloak.testsuite.arquillian.container.AppServerContainerProvider new file mode 100644 index 0000000000..01068c3035 --- /dev/null +++ b/testsuite/integration-arquillian/servers/app-server/karaf/fuse70/src/main/resources/META-INF/services/org.keycloak.testsuite.arquillian.container.AppServerContainerProvider @@ -0,0 +1 @@ +org.keycloak.testsuite.arquillian.fuse.container.Fuse70AppServerProvider diff --git a/testsuite/integration-arquillian/tests/base/pom.xml b/testsuite/integration-arquillian/tests/base/pom.xml index 169b48f9c1..1cf8f024cb 100644 --- a/testsuite/integration-arquillian/tests/base/pom.xml +++ b/testsuite/integration-arquillian/tests/base/pom.xml @@ -563,6 +563,60 @@ + + app-server-fuse70 + + + app.server + fuse70 + + + + fuse70 + false + + + 0 + 8080 + 9990 + + 8181 + + admin + admin + -agentlib:jdwp=transport=dt_socket,server=y,suspend=${app.server.debug.suspend},address=localhost:${app.server.debug.port} + + + + org.keycloak.testsuite + integration-arquillian-servers-app-server-fuse70 + ${project.version} + runtime + + + org.jboss.arquillian.container + arquillian-container-karaf-managed + + + + + + org.commonjava.maven.plugins + directory-maven-plugin + + + maven-surefire-plugin + + + ${app.server.management.user} + ${app.server.management.password} + ${app.server.karaf.jvm.debug.args} + + + + + + auth-servers-crossdc-undertow diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/Hawtio2Page.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/Hawtio2Page.java index 257c85f623..8ff4d91c11 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/Hawtio2Page.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/Hawtio2Page.java @@ -1,11 +1,11 @@ package org.keycloak.testsuite.adapter.page; import org.keycloak.testsuite.page.AbstractPage; -import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import javax.ws.rs.core.UriBuilder; +import org.keycloak.testsuite.util.JavascriptBrowser; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; @@ -27,15 +27,17 @@ public class Hawtio2Page extends AbstractPage { } @FindBy(xpath = "//a[@id ='userDropdownMenu']") + @JavascriptBrowser private WebElement dropDownMenu; @FindBy(xpath = "//a[@ng-click='userDetails.logout()']") + @JavascriptBrowser private WebElement logoutButton; public void logout() { - waitUntilElement(dropDownMenu).is().visible(); + waitUntilElement(dropDownMenu).is().clickable(); dropDownMenu.click(); - waitUntilElement(logoutButton).is().visible(); + waitUntilElement(logoutButton).is().clickable(); logoutButton.click(); } } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/HawtioPage.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/HawtioPage.java index b8b3562480..aaab9cf39e 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/HawtioPage.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/HawtioPage.java @@ -1,11 +1,11 @@ package org.keycloak.testsuite.adapter.page; import org.keycloak.testsuite.page.AbstractPage; -import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import javax.ws.rs.core.UriBuilder; +import org.keycloak.testsuite.util.JavascriptBrowser; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; @@ -27,18 +27,24 @@ public class HawtioPage extends AbstractPage { } @FindBy(xpath = "//a[@class='dropdown-toggle' and @data-original-title='Preferences and log out']") + @JavascriptBrowser private WebElement dropDownMenu; @FindBy(xpath = "//a[@ng-click='logout()']") + @JavascriptBrowser private WebElement logoutButton; + @FindBy(xpath = "//input[@type='submit' and @value='Yes']") + @JavascriptBrowser + private WebElement modal; + public void logout() { - waitUntilElement(dropDownMenu).is().visible(); + log.debug("logging out"); + waitUntilElement(dropDownMenu).is().clickable(); dropDownMenu.click(); - waitUntilElement(logoutButton).is().visible(); + waitUntilElement(logoutButton).is().clickable(); logoutButton.click(); - By modal = By.xpath("//input[@type='submit' and @value='Yes']"); - waitUntilElement(modal).is().visible(); - driver.findElement(modal).click(); + waitUntilElement(modal).is().clickable(); + modal.click(); } } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/fuse/AbstractFuseExample.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/fuse/AbstractFuseExample.java index 1024c3e93c..e82e4d9923 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/fuse/AbstractFuseExample.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/adapter/page/fuse/AbstractFuseExample.java @@ -21,6 +21,7 @@ import org.keycloak.testsuite.adapter.page.AppServerContextRoot; import java.net.MalformedURLException; import java.net.URL; +import org.keycloak.testsuite.util.DroneUtils; /** * @@ -54,7 +55,7 @@ public abstract class AbstractFuseExample extends AppServerContextRoot { public void navigateTo() { super.navigateTo(); - if (driver.getPageSource().contains("")) { + if (DroneUtils.getCurrentDriver().getPageSource().contains("")) { log.debug("Page wasn't properly loaded - redirecting."); super.navigateTo(); } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/ContainerConstants.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/ContainerConstants.java index f67fa0b714..558686a699 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/ContainerConstants.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/arquillian/containers/ContainerConstants.java @@ -36,4 +36,5 @@ public interface ContainerConstants { public static final String APP_SERVER_EAP6_CLUSTER = APP_SERVER_EAP6 + "-ha-node-1;" + APP_SERVER_EAP6 + "-ha-node-2"; public static final String APP_SERVER_FUSE63 = APP_SERVER_PREFIX + "fuse63"; + public static final String APP_SERVER_FUSE70 = APP_SERVER_PREFIX + "fuse70"; } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/ContainerAssume.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/ContainerAssume.java index c42baa6f7e..84a63b747d 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/ContainerAssume.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/ContainerAssume.java @@ -24,6 +24,8 @@ import org.keycloak.testsuite.arquillian.AuthServerTestEnricher; public class ContainerAssume { private static final Logger log = Logger.getLogger(ContainerAssume.class); + private static final String fuse6 = "fuse63"; + private static final String fuse7 = "fuse70"; public static void assumeNotAuthServerUndertow() { Assume.assumeFalse("Doesn't work on auth-server-undertow", @@ -40,4 +42,11 @@ public class ContainerAssume { System.getProperty("app.server", "undertow").equals("undertow")); } + public static void assumeNotAppServerFuse6() { + Assume.assumeFalse("The test doesn't work on " + fuse6, fuse6.equals(System.getProperty("app.server"))); + } + + public static void assumeNotAppServerFuse7() { + Assume.assumeFalse("The test doesn't work on " + fuse7, fuse7.equals(System.getProperty("app.server"))); + } } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseAdminAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseAdminAdapterTest.java index e7594ccc6a..99a8fbceab 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseAdminAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseAdminAdapterTest.java @@ -17,6 +17,7 @@ package org.keycloak.testsuite.adapter.example.fuse; import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertThat; @@ -29,6 +30,7 @@ import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; import java.util.List; @@ -53,25 +55,49 @@ import org.apache.sshd.client.channel.ClientChannelEvent; import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.client.session.ClientSession.ClientSessionEvent; import org.hamcrest.Matchers; +import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.graphene.page.Page; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest; +import org.keycloak.testsuite.adapter.page.Hawtio2Page; import org.keycloak.testsuite.adapter.page.HawtioPage; import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; import org.keycloak.testsuite.arquillian.containers.ContainerConstants; +import org.keycloak.testsuite.auth.page.login.OIDCLogin; +import org.keycloak.testsuite.util.ContainerAssume; +import org.keycloak.testsuite.util.DroneUtils; +import org.keycloak.testsuite.util.JavascriptBrowser; +import org.keycloak.testsuite.util.WaitUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; @AppServerContainer(ContainerConstants.APP_SERVER_FUSE63) +@AppServerContainer(ContainerConstants.APP_SERVER_FUSE70) public class FuseAdminAdapterTest extends AbstractExampleAdapterTest { - + + @Drone + @JavascriptBrowser + protected WebDriver jsDriver; + @Page + @JavascriptBrowser private HawtioPage hawtioPage; - + + @Page + @JavascriptBrowser + private Hawtio2Page hawtio2Page; + + @Page + @JavascriptBrowser + private OIDCLogin testRealmLoginPageFuse; + private SshClient client; - + protected enum Result { OK, NOT_FOUND, NO_CREDENTIALS, NO_ROLES }; - + @Override public void addAdapterTestRealms(List testRealms) { RealmRepresentation fuseRealm = loadRealm(new File(EXAMPLES_HOME_DIR + "/fuse/demorealm.json")); @@ -81,41 +107,122 @@ public class FuseAdminAdapterTest extends AbstractExampleAdapterTest { @Override public void setDefaultPageUriParameters() { super.setDefaultPageUriParameters(); - testRealmPage.setAuthRealm(DEMO); - testRealmLoginPage.setAuthRealm(DEMO); + testRealmLoginPageFuse.setAuthRealm(DEMO); } - + + @Before + public void addJsDriver() { + DroneUtils.addWebDriver(jsDriver); + } + @Test - public void hawtioLoginTest() throws Exception { - // Note that this does works only in Fuse 6 with Hawtio 1 since Fuse 7 contains Hawtio 2, and is thus overriden in Fuse 7 test classes + public void hawtio1LoginTest() throws Exception { + // Note that this does work only in Fuse 6 with Hawtio 1, Fuse 7 contains Hawtio 2 + ContainerAssume.assumeNotAppServerFuse7(); + hawtioPage.navigateTo(); - testRealmLoginPage.form().login("user", "invalid-password"); + testRealmLoginPageFuse.form().login("user", "invalid-password"); assertCurrentUrlDoesntStartWith(hawtioPage); - testRealmLoginPage.form().login("invalid-user", "password"); + testRealmLoginPageFuse.form().login("invalid-user", "password"); assertCurrentUrlDoesntStartWith(hawtioPage); - testRealmLoginPage.form().login("root", "password"); - assertCurrentUrlStartsWith(hawtioPage.toString() + "/welcome", hawtioPage.getDriver()); + testRealmLoginPageFuse.form().login("root", "password"); + assertCurrentUrlStartsWith(hawtioPage.toString() + "/welcome"); hawtioPage.logout(); - assertCurrentUrlStartsWith(testRealmLoginPage); - + assertCurrentUrlStartsWith(testRealmLoginPageFuse); + hawtioPage.navigateTo(); - testRealmLoginPage.form().login("mary", "password"); - assertThat(driver.getPageSource(), not(containsString("welcome"))); + log.debug("logging in as mary"); + testRealmLoginPageFuse.form().login("mary", "password"); + log.debug("Previous WARN waitForPageToLoad time exceeded! is expected"); + assertThat(DroneUtils.getCurrentDriver().getPageSource(), + allOf( + containsString("Unauthorized User"), + not(containsString("welcome")) + ) + ); } - - - + @Test - public void sshLoginTest() throws Exception { - // Note that this does not work for Fuse 7 since the error codes have changed, and is thus overriden for Fuse 7 test classes + public void hawtio2LoginTest() throws Exception { + // Note that this does work only in Fuse 7 with Hawtio 2, Fuse 6 contains Hawtio 1 + ContainerAssume.assumeNotAppServerFuse6(); + + hawtio2Page.navigateTo(); + WaitUtils.waitForPageToLoad(); + + testRealmLoginPageFuse.form().login("user", "invalid-password"); + assertCurrentUrlDoesntStartWith(hawtio2Page); + + testRealmLoginPageFuse.form().login("invalid-user", "password"); + assertCurrentUrlDoesntStartWith(hawtio2Page); + + testRealmLoginPageFuse.form().login("root", "password"); + assertCurrentUrlStartsWith(hawtio2Page.toString()); + WaitUtils.waitForPageToLoad(); + WaitUtils.waitUntilElement(By.xpath("//img[@alt='Red Hat Fuse Management Console']")).is().present(); + hawtio2Page.logout(); + WaitUtils.waitForPageToLoad(); + + assertCurrentUrlStartsWith(testRealmLoginPageFuse); + + hawtio2Page.navigateTo(); + WaitUtils.waitForPageToLoad(); + + log.debug("logging in as mary"); + testRealmLoginPageFuse.form().login("mary", "password"); + log.debug("Current URL: " + DroneUtils.getCurrentDriver().getCurrentUrl()); + assertCurrentUrlStartsWith(hawtio2Page.toString()); + WaitUtils.waitForPageToLoad(); + assertThat(DroneUtils.getCurrentDriver().getPageSource(), + allOf( + containsString("keycloak-session-iframe"),//todo check this if it's correct + not(containsString("Camel")) + ) + ); + } + + @Test + public void sshLoginTestFuse6() throws Exception { + // Note that this does not work for Fuse 7 since the error codes have changed + ContainerAssume.assumeNotAppServerFuse7(); + assertCommand("mary", "password", "shell:date", Result.NO_CREDENTIALS); assertCommand("john", "password", "shell:info", Result.NO_CREDENTIALS); assertCommand("john", "password", "shell:date", Result.OK); assertCommand("root", "password", "shell:info", Result.OK); } + @Test + public void sshLoginTestFuse7() throws Exception { + // Note that this works for Fuse 7 and newer + ContainerAssume.assumeNotAppServerFuse6(); + + assertCommand("mary", "password", "shell:date", Result.NOT_FOUND); + assertCommand("john", "password", "shell:info", Result.NOT_FOUND); + assertCommand("john", "password", "shell:date", Result.OK); + assertRoles("root", + "ssh", + "jmxAdmin", + "admin", + "manager", + "viewer", + "Administrator", + "Auditor", + "Deployer", + "Maintainer", + "Operator", + "SuperUser" + ); + } + + private void assertRoles(String username, String... expectedRoles) throws Exception { + final String commandOutput = getCommandOutput(username, "password", "jaas:whoami -r --no-format"); + final List parsedOutput = Arrays.asList(commandOutput.split("\\n+")); + assertThat(parsedOutput, Matchers.containsInAnyOrder(expectedRoles)); + } + @Test public void jmxLoginTest() throws Exception { setJMXAuthentication("keycloak", "password"); diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseExampleAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseExampleAdapterTest.java index f3687563d1..3caadb3943 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseExampleAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/example/fuse/FuseExampleAdapterTest.java @@ -46,6 +46,7 @@ import org.keycloak.testsuite.util.WaitUtils; * @author tkyjovsk */ @AppServerContainer(ContainerConstants.APP_SERVER_FUSE63) +@AppServerContainer(ContainerConstants.APP_SERVER_FUSE70) public class FuseExampleAdapterTest extends AbstractExampleAdapterTest { @Page diff --git a/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/pom.xml b/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/pom.xml deleted file mode 100644 index adf009eeb7..0000000000 --- a/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - 4.0.0 - - - org.keycloak.testsuite - integration-arquillian-tests-adapters-karaf - 4.1.0.Final-SNAPSHOT - - - integration-arquillian-tests-adapters-fuse70 - - Adapter Tests - Karaf - JBoss Fuse 7.0 - - - fuse70 - - admin - admin - - - - - org.apache.httpcomponents - httpclient - - - - diff --git a/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70AdminAdapterTest.java b/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70AdminAdapterTest.java deleted file mode 100644 index 9da6110db4..0000000000 --- a/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70AdminAdapterTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2016 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.testsuite.adapter.example; - -import org.keycloak.testsuite.adapter.page.Hawtio2Page; -import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; -import org.keycloak.testsuite.util.WaitUtils; -import java.util.Arrays; -import java.util.List; -import org.hamcrest.Matchers; -import org.jboss.arquillian.graphene.page.Page; -import org.junit.Test; -import org.openqa.selenium.By; -import static org.junit.Assert.assertThat; -import org.keycloak.testsuite.adapter.example.fuse.FuseAdminAdapterTest; -import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlDoesntStartWith; -import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; - -@AppServerContainer("app-server-fuse70") -public class Fuse70AdminAdapterTest extends FuseAdminAdapterTest { - - @Page - protected Hawtio2Page hawtioPage; - - @Test - @Override - public void hawtioLoginTest() throws Exception { - hawtioPage.navigateTo(); - WaitUtils.waitForPageToLoad(); - - testRealmLoginPage.form().login("user", "invalid-password"); - assertCurrentUrlDoesntStartWith(hawtioPage); - - testRealmLoginPage.form().login("invalid-user", "password"); - assertCurrentUrlDoesntStartWith(hawtioPage); - - testRealmLoginPage.form().login("root", "password"); - assertCurrentUrlStartsWith(hawtioPage.toString(), hawtioPage.getDriver()); - WaitUtils.waitForPageToLoad(); - WaitUtils.waitUntilElement(By.linkText("Camel")); - hawtioPage.logout(); - WaitUtils.waitForPageToLoad(); - - assertCurrentUrlStartsWith(testRealmLoginPage); - - hawtioPage.navigateTo(); - WaitUtils.waitForPageToLoad(); - - testRealmLoginPage.form().login("mary", "password"); - assertCurrentUrlStartsWith(hawtioPage.toString(), hawtioPage.getDriver()); - WaitUtils.waitForPageToLoad(); - WaitUtils.waitUntilElementIsNotPresent(By.linkText("Camel")); - } - - @Test - @Override - public void sshLoginTest() throws Exception { - assertCommand("mary", "password", "shell:date", Result.NOT_FOUND); - assertCommand("john", "password", "shell:info", Result.NOT_FOUND); - assertCommand("john", "password", "shell:date", Result.OK); - assertRoles("root", - "ssh", - "jmxAdmin", - "admin", - "manager", - "viewer", - "Administrator", - "Auditor", - "Deployer", - "Maintainer", - "Operator", - "SuperUser" - ); - } - - private void assertRoles(String username, String... expectedRoles) throws Exception { - final String commandOutput = getCommandOutput(username, "password", "jaas:whoami -r --no-format"); - final List parsedOutput = Arrays.asList(commandOutput.split("\\n+")); - assertThat(parsedOutput, Matchers.containsInAnyOrder(expectedRoles)); - } -} diff --git a/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70ExampleAdapterTest.java b/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70ExampleAdapterTest.java deleted file mode 100644 index b4144def05..0000000000 --- a/testsuite/integration-arquillian/tests/other/adapters/karaf/fuse70/src/test/java/org/keycloak/testsuite/adapter/example/Fuse70ExampleAdapterTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2016 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.testsuite.adapter.example; - -import org.keycloak.testsuite.adapter.example.fuse.FuseExampleAdapterTest; -import org.keycloak.testsuite.arquillian.annotation.AppServerContainer; - -@AppServerContainer("app-server-fuse70") -public class Fuse70ExampleAdapterTest extends FuseExampleAdapterTest { - -} diff --git a/testsuite/integration-arquillian/tests/other/adapters/karaf/pom.xml b/testsuite/integration-arquillian/tests/other/adapters/karaf/pom.xml index 7c9d9d41a4..0e4e6b9a24 100644 --- a/testsuite/integration-arquillian/tests/other/adapters/karaf/pom.xml +++ b/testsuite/integration-arquillian/tests/other/adapters/karaf/pom.xml @@ -65,12 +65,6 @@ fuse62 - - app-server-fuse70 - - fuse70 - - diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index c573874dd8..ae4db08ec2 100755 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -1492,6 +1492,12 @@ ${project.version} + + org.keycloak.testsuite + integration-arquillian-util + ${project.version} + +