Merge pull request #2278 from mbaluch/master
KPR-147 - Initial login scenarios around admin password - test
This commit is contained in:
commit
d766c56eba
6 changed files with 177 additions and 3 deletions
|
@ -152,6 +152,7 @@ integration-arquillian
|
||||||
│
|
│
|
||||||
├──console (activated by -Pconsole-ui-tests)
|
├──console (activated by -Pconsole-ui-tests)
|
||||||
├──mod_auth_mellon (activated by -Pmod_auth_mellon)
|
├──mod_auth_mellon (activated by -Pmod_auth_mellon)
|
||||||
|
├──console_no_users (activated by -Pconsole-ui-no-users-tests)
|
||||||
└──...
|
└──...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
package org.keycloak.testsuite.auth.page;
|
package org.keycloak.testsuite.auth.page;
|
||||||
|
|
||||||
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
|
@ -38,7 +39,8 @@ public class WelcomePage extends AuthServer {
|
||||||
private WebElement createButton;
|
private WebElement createButton;
|
||||||
|
|
||||||
public boolean isPasswordSet() {
|
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) {
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<property name="enabled">${auth.server.wildfly}</property>
|
<property name="enabled">${auth.server.wildfly}</property>
|
||||||
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
|
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
|
||||||
<property name="jbossHome">${keycloak.home}</property>
|
<property name="jbossHome">${keycloak.home}</property>
|
||||||
<property name="javaVmArguments">-Djboss.socket.binding.port-offset=${auth.server.port.offset} -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}</property>
|
<property name="javaVmArguments">-Djboss.socket.binding.port-offset=${auth.server.port.offset} -Djboss.bind.address=0.0.0.0 -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}</property>
|
||||||
<property name="managementPort">${auth.server.management.port}</property>
|
<property name="managementPort">${auth.server.management.port}</property>
|
||||||
<property name="startupTimeoutInSeconds">${startup.timeout.sec}</property>
|
<property name="startupTimeoutInSeconds">${startup.timeout.sec}</property>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
<property name="enabled">${auth.server.eap7}</property>
|
<property name="enabled">${auth.server.eap7}</property>
|
||||||
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
|
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
|
||||||
<property name="jbossHome">${keycloak.home}</property>
|
<property name="jbossHome">${keycloak.home}</property>
|
||||||
<property name="javaVmArguments">-Djboss.socket.binding.port-offset=${auth.server.port.offset} -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}</property>
|
<property name="javaVmArguments">-Djboss.socket.binding.port-offset=${auth.server.port.offset} -Djboss.bind.address=0.0.0.0 -Xms64m -Xmx512m -XX:MaxPermSize=256m ${adapter.test.props}</property>
|
||||||
<property name="startupTimeoutInSeconds">${startup.timeout.sec}</property>
|
<property name="startupTimeoutInSeconds">${startup.timeout.sec}</property>
|
||||||
<property name="managementPort">${auth.server.management.port}</property>
|
<property name="managementPort">${auth.server.management.port}</property>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.keycloak.testsuite</groupId>
|
||||||
|
<artifactId>integration-arquillian-tests-other</artifactId>
|
||||||
|
<version>1.9.1.Final-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>integration-arquillian-tests-console-no-users</artifactId>
|
||||||
|
|
||||||
|
<name>Admin Console UI Tests - Without pre-configured accounts</name>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-admin-user-json-file</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -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<RealmRepresentation> 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<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
for (NetworkInterface ni : Collections.list(netInterfaces)) {
|
||||||
|
Enumeration<InetAddress> 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."));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -134,6 +134,12 @@
|
||||||
<module>console</module>
|
<module>console</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>console-ui-no-users-tests</id>
|
||||||
|
<modules>
|
||||||
|
<module>console_no_users</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>mod_auth_mellon</id>
|
<id>mod_auth_mellon</id>
|
||||||
<modules>
|
<modules>
|
||||||
|
|
Loading…
Reference in a new issue