diff --git a/testsuite/integration-arquillian/README.md b/testsuite/integration-arquillian/README.md
index 39168de056..1adc0547bc 100644
--- a/testsuite/integration-arquillian/README.md
+++ b/testsuite/integration-arquillian/README.md
@@ -152,6 +152,7 @@ integration-arquillian
│
├──console (activated by -Pconsole-ui-tests)
├──mod_auth_mellon (activated by -Pmod_auth_mellon)
+ ├──console_no_users (activated by -Pconsole-ui-no-users-tests)
└──...
```
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java
index 72d389c556..9f34a40bb8 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java
@@ -17,6 +17,7 @@
package org.keycloak.testsuite.auth.page;
+import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@@ -38,7 +39,8 @@ public class WelcomePage extends AuthServer {
private WebElement createButton;
public boolean isPasswordSet() {
- return !driver.getPageSource().contains("Please create an initial admin user to get started.");
+ return !(driver.getPageSource().contains("Please create an initial admin user to get started.") ||
+ driver.getPageSource().contains("You need local access to create the initial admin user."));
}
public void setPassword(String username, String password) {
@@ -58,4 +60,8 @@ public class WelcomePage extends AuthServer {
}
}
+ public void navigateToAdminConsole() {
+ driver.findElement(By.linkText("Administration Console")).click();
+ }
+
}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml
index d267f06a1f..e0cfefd5f5 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml
+++ b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml
@@ -60,7 +60,7 @@
${auth.server.wildfly}
org.jboss.as.arquillian.container.managed.ManagedDeployableContainer
${keycloak.home}
- -Djboss.socket.binding.port-offset=${auth.server.port.offset} -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}
+ -Djboss.socket.binding.port-offset=${auth.server.port.offset} -Djboss.bind.address=0.0.0.0 -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}
${auth.server.management.port}
${startup.timeout.sec}
@@ -131,7 +131,7 @@
${auth.server.eap7}
org.jboss.as.arquillian.container.managed.ManagedDeployableContainer
${keycloak.home}
- -Djboss.socket.binding.port-offset=${auth.server.port.offset} -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}
+ -Djboss.socket.binding.port-offset=${auth.server.port.offset} -Djboss.bind.address=0.0.0.0 -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}
${startup.timeout.sec}
${auth.server.management.port}
diff --git a/testsuite/integration-arquillian/tests/other/console_no_users/pom.xml b/testsuite/integration-arquillian/tests/other/console_no_users/pom.xml
new file mode 100644
index 0000000000..220a10b510
--- /dev/null
+++ b/testsuite/integration-arquillian/tests/other/console_no_users/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+ 4.0.0
+
+
+ org.keycloak.testsuite
+ integration-arquillian-tests-other
+ 1.9.1.Final-SNAPSHOT
+
+
+ integration-arquillian-tests-console-no-users
+
+ Admin Console UI Tests - Without pre-configured accounts
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ copy-admin-user-json-file
+ none
+
+
+
+
+
+
+
diff --git a/testsuite/integration-arquillian/tests/other/console_no_users/src/test/java/org/keycloak/testsuite/console/pages/WelcomePageTest.java b/testsuite/integration-arquillian/tests/other/console_no_users/src/test/java/org/keycloak/testsuite/console/pages/WelcomePageTest.java
new file mode 100644
index 0000000000..1051bb11cb
--- /dev/null
+++ b/testsuite/integration-arquillian/tests/other/console_no_users/src/test/java/org/keycloak/testsuite/console/pages/WelcomePageTest.java
@@ -0,0 +1,112 @@
+package org.keycloak.testsuite.console.pages;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import org.jboss.arquillian.graphene.page.Page;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+import org.keycloak.representations.idm.RealmRepresentation;
+import org.keycloak.testsuite.AbstractKeycloakTest;
+import org.keycloak.testsuite.auth.page.WelcomePage;
+import org.keycloak.testsuite.auth.page.login.OIDCLogin;
+
+/**
+ *
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class WelcomePageTest extends AbstractKeycloakTest {
+
+ @Page
+ private WelcomePage welcomePage;
+
+ @Page
+ protected OIDCLogin loginPage;
+
+ @Override
+ public void addTestRealms(List testRealms) {
+ // no operation
+ }
+
+ /*
+ * Leave out client initialization and creation of a user account. We
+ * don't need those.
+ */
+ @Before
+ @Override
+ public void beforeAbstractKeycloakTest() {
+ setDefaultPageUriParameters();
+ driverSettings();
+ }
+
+ /**
+ * Attempt to resolve the floating IP address. This is where EAP/WildFly
+ * will be accessible. See "-Djboss.bind.address=0.0.0.0".
+ *
+ * @return
+ * @throws Exception
+ */
+ private String getFloatingIpAddress() throws Exception {
+ Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
+ for (NetworkInterface ni : Collections.list(netInterfaces)) {
+ Enumeration inetAddresses = ni.getInetAddresses();
+ for (InetAddress a : Collections.list(inetAddresses)) {
+ if (!a.isLoopbackAddress() && a.isSiteLocalAddress()) {
+ return a.getHostAddress();
+ }
+ }
+ }
+ return null;
+ }
+
+ private URL getPublicServerUrl() throws Exception {
+ String floatingIp = getFloatingIpAddress();
+ if (floatingIp == null) {
+ throw new RuntimeException("Could not determine floating IP address.");
+ }
+ return new URL("http", floatingIp, welcomePage.getInjectedUrl().getPort(), "");
+ }
+
+ @Test
+ public void test_1_LocalAccessNoAdmin() throws Exception {
+ welcomePage.navigateTo();
+ Assert.assertFalse("Welcome page did not ask to create a new admin user.", welcomePage.isPasswordSet());
+ }
+
+ @Test
+ public void test_2_RemoteAccessNoAdmin() throws Exception {
+ driver.navigate().to(getPublicServerUrl());
+ Assert.assertFalse("Welcome page did not ask to create a new admin user.", welcomePage.isPasswordSet());
+ }
+
+ @Test
+ public void test_3_LocalAccessWithAdmin() throws Exception {
+ welcomePage.navigateTo();
+ welcomePage.setPassword("admin", "admin");
+ Assert.assertTrue(driver.getPageSource().contains("User created"));
+
+ welcomePage.navigateTo();
+ Assert.assertTrue("Welcome page asked to set admin password.", welcomePage.isPasswordSet());
+ }
+
+ @Test
+ public void test_4_RemoteAccessWithAdmin() throws Exception {
+ driver.navigate().to(getPublicServerUrl());
+ Assert.assertTrue("Welcome page asked to set admin password.", welcomePage.isPasswordSet());
+ }
+
+ @Test
+ public void test_5_AccessCreatedAdminAccount() throws Exception {
+ welcomePage.navigateToAdminConsole();
+ loginPage.form().login("admin", "admin");
+ Assert.assertFalse("Login with 'admin:admin' failed",
+ driver.getPageSource().contains("Invalid username or password."));
+ }
+
+}
diff --git a/testsuite/integration-arquillian/tests/other/pom.xml b/testsuite/integration-arquillian/tests/other/pom.xml
index 19648b7b45..8b04c0777d 100644
--- a/testsuite/integration-arquillian/tests/other/pom.xml
+++ b/testsuite/integration-arquillian/tests/other/pom.xml
@@ -134,6 +134,12 @@
console
+
+ console-ui-no-users-tests
+
+ console_no_users
+
+
mod_auth_mellon