Merge pull request #1754 from vramik/migration-kc15

arquillian-testsuite add migration-kc15
This commit is contained in:
Stian Thorgersen 2015-10-19 08:44:51 +02:00
commit e4412523d4
13 changed files with 511 additions and 17 deletions

View file

@ -26,6 +26,12 @@
<module>eap6</module>
</modules>
</profile>
<profile>
<id>migration-kc15</id>
<modules>
<module>wildfly_kc15</module>
</modules>
</profile>
<profile>
<id>migration-kc14</id>
<modules>

View file

@ -0,0 +1,29 @@
<assembly>
<id>auth-server-wildfly-kc14</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${keycloak.server.home}</directory>
<outputDirectory>keycloak-1.5.1.Final</outputDirectory>
<excludes>
<exclude>**/*.sh</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${keycloak.server.home}</directory>
<outputDirectory>keycloak-1.5.1.Final</outputDirectory>
<includes>
<include>**/*.sh</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>
</assembly>

View file

@ -0,0 +1,199 @@
<?xml version="1.0"?>
<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">
<parent>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-servers</artifactId>
<version>1.6.0.Final-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-arquillian-server-wildfly-kc15</artifactId>
<packaging>pom</packaging>
<name>Keycloak 1.5.1.Final on Wildfly</name>
<properties>
<keycloak.server.home>${project.build.directory}/unpacked/keycloak-1.5.1.Final</keycloak.server.home>
<jdbc.mvn.driver.deployment.dir>${keycloak.server.home}/modules/system/layers/base/com/${jdbc.mvn.artifactId}/main</jdbc.mvn.driver.deployment.dir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>enforce-properties</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>jdbc.mvn.groupId</property>
</requireProperty>
<requireProperty>
<property>jdbc.mvn.artifactId</property>
</requireProperty>
<requireProperty>
<property>jdbc.mvn.version</property>
</requireProperty>
<requireProperty>
<property>keycloak.connectionsJpa.url</property>
</requireProperty>
<requireProperty>
<property>keycloak.connectionsJpa.user</property>
</requireProperty>
<requireProperty>
<property>keycloak.connectionsJpa.password</property>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-server</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-dist</artifactId>
<version>1.5.1.Final</version>
<type>zip</type>
<outputDirectory>${project.build.directory}/unpacked</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>jdbc-driver</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${jdbc.mvn.groupId}</groupId>
<artifactId>${jdbc.mvn.artifactId}</artifactId>
<version>${jdbc.mvn.version}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
<outputDirectory>${jdbc.mvn.driver.deployment.dir}</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<executions>
<execution>
<id>configure-wildfly-datasource</id>
<phase>process-resources</phase>
<goals>
<goal>transform</goal>
</goals>
<configuration>
<transformationSets>
<!-- create module.xml in modules -->
<transformationSet>
<dir>${keycloak.server.home}/modules/system/layers/base/com/h2database/h2/main</dir>
<stylesheet>src/main/xslt/module.xsl</stylesheet>
<includes>
<include>module.xml</include>
</includes>
<outputDir>${jdbc.mvn.driver.deployment.dir}</outputDir>
<parameters>
<parameter>
<name>database</name>
<value>${jdbc.mvn.artifactId}</value>
</parameter>
<parameter>
<name>version</name>
<value>${jdbc.mvn.version}</value>
</parameter>
</parameters>
</transformationSet>
<!-- add datasource to standalone.xml -->
<transformationSet>
<dir>${keycloak.server.home}/standalone/configuration</dir>
<stylesheet>src/main/xslt/datasource.xsl</stylesheet>
<includes>
<include>standalone.xml</include>
</includes>
<outputDir>${keycloak.server.home}/standalone/configuration</outputDir>
<parameters>
<parameter>
<name>jdbc.url</name>
<value>${keycloak.connectionsJpa.url}</value>
</parameter>
<parameter>
<name>driver</name>
<value>${jdbc.mvn.artifactId}</value>
</parameter>
<parameter>
<name>username</name>
<value>${keycloak.connectionsJpa.user}</value>
</parameter>
<parameter>
<name>password</name>
<value>${keycloak.connectionsJpa.password}</value>
</parameter>
</parameters>
</transformationSet>
<!-- add logger for org.hibernate.dialect.Dialect to standalone.xml-->
<transformationSet>
<dir>${keycloak.server.home}/standalone/configuration</dir>
<stylesheet>src/main/xslt/add-dialect-logger.xsl</stylesheet>
<includes>
<include>standalone.xml</include>
</includes>
<outputDir>${keycloak.server.home}/standalone/configuration</outputDir>
</transformationSet>
</transformationSets>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
version="2.0"
exclude-result-prefixes="xalan">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
<xsl:variable name="nsDS" select="'urn:jboss:domain:logging:'"/>
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
/*[local-name()='root-logger' and starts-with(namespace-uri(), $nsDS)]">
<logger category="org.hibernate.dialect.Dialect">
<level name="ALL"/>
</logger>
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- Copy everything else. -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,94 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:j="urn:jboss:domain:3.0"
xmlns:ds="urn:jboss:domain:datasources:3.0"
xmlns:k="urn:jboss:domain:keycloak:1.1"
xmlns:sec="urn:jboss:domain:security:1.2"
version="2.0"
exclude-result-prefixes="xalan j ds k sec">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" standalone="no"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="nsDS" select="'urn:jboss:domain:datasources:'"/>
<!-- Remove keycloak datasource definition. -->
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
/*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
/*[local-name()='datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name='KeycloakDS']">
</xsl:template>
<xsl:param name="jdbc.url" select="'jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE'"/>
<xsl:param name="driver" select="'h2'"/>
<xsl:param name="username" select="'sa'"/>
<xsl:param name="password" select="'sa'"/>
<xsl:param name="min.poolsize" select="'10'"/>
<xsl:param name="max.poolsize" select="'50'"/>
<xsl:param name="pool.prefill" select="'true'"/>
<xsl:variable name="newDatasourceDefinition">
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>
<xsl:value-of select="$jdbc.url"/>
</connection-url>
<driver>
<xsl:value-of select="$driver"/>
</driver>
<security>
<user-name>
<xsl:value-of select="$username"/>
</user-name>
<password>
<xsl:value-of select="$password"/>
</password>
</security>
<pool>
<min-pool-size>
<xsl:value-of select="$min.poolsize"/>
</min-pool-size>
<max-pool-size>
<xsl:value-of select="$max.poolsize"/>
</max-pool-size>
<prefill>
<xsl:value-of select="$pool.prefill"/>
</prefill>
</pool>
</datasource>
</xsl:variable>
<xsl:variable name="newDriverDefinition">
<xsl:if test="$driver != 'h2'">
<driver name="{$driver}" module="com.{$driver}" />
</xsl:if>
</xsl:variable>
<!-- Add new datasource definition. -->
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
/*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]">
<xsl:copy>
<xsl:copy-of select="$newDatasourceDefinition"/>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- Add new driver definition. -->
<xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
/*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
/*[local-name()='drivers' and starts-with(namespace-uri(), $nsDS)]">
<xsl:copy>
<xsl:copy-of select="$newDriverDefinition"/>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<!-- Copy everything else. -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,33 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:m="urn:jboss:module:1.3"
version="2.0"
exclude-result-prefixes="xalan m">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" xalan:indent-amount="4" />
<xsl:param name="database" select="''"/>
<xsl:param name="version" select="''"/>
<xsl:variable name="newModuleDefinition">
<module xmlns="urn:jboss:module:1.3" name="com.{$database}">
<resources>
<resource-root path="{$database}-{$version}.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
</xsl:variable>
<!-- clear whole document -->
<xsl:template match="/*" />
<!-- Copy new module definition. -->
<xsl:template match="/*">
<xsl:copy-of select="$newModuleDefinition"/>
</xsl:template>
</xsl:stylesheet>

View file

@ -44,14 +44,6 @@ public class LoginActions extends AuthRealm {
@FindBy(css = "span.kc-feedback-text")
private WebElement feedbackText;
@FindBy(xpath = "//div[@id='kc-error-message']/p")
private WebElement error;
public String getErrorMessage() {
waitGuiForElementPresent(error, "Error message should be visible");
return error.getText();
}
public String getFeedbackText() {
waitGuiForElementPresent(feedbackText, "Feedback message should be visible");
return feedbackText.getText();

View file

@ -1,9 +1,41 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.keycloak.testsuite.auth.page.login;
import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
/**
*
* @author vramik
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class VerifyEmail extends Authenticate {
@FindBy(xpath = "//div[@id='kc-form-wrapper']/p")
private WebElement instruction;
public String getInstructionMessage() {
waitGuiForElement(instruction);
return instruction.getText();
}
}

View file

@ -1,5 +1,6 @@
package org.keycloak.testsuite.console.page.realm;
import java.util.Map;
import org.jboss.arquillian.graphene.findby.FindByJQuery;
import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
@ -66,5 +67,13 @@ public class EmailSettings extends RealmSettings {
public void setFromInput(String value) {
setInputValue(fromInput, value);
}
public void setSmtpServer(Map<String, String> smtpServer) {
setFromInput(smtpServer.get("from"));
setHostInput(smtpServer.get("host"));
setPortInput(smtpServer.get("port"));
save();
}
}
}

View file

@ -49,7 +49,7 @@ public class VerifyEmailTest extends AbstractAccountManagementTest {
@Before
public void beforeVerifyEmail() {
// enable verify email and configure smpt server in test realm
log.info("enable verify email and configure smpt server in test realm");
RealmRepresentation testRealmRep = testRealmResource().toRepresentation();
testRealmRep.setSmtpServer(suiteContext.getSmtpServer());
testRealmRep.setVerifyEmail(true);
@ -75,11 +75,11 @@ public class VerifyEmailTest extends AbstractAccountManagementTest {
assertEquals("You need to verify your email address to activate your account.",
testRealmVerifyEmailPage.getFeedbackText());
String url = assertEmailAndGetUrl(MailServerConfiguration.FROM, testUser.getEmail(),
String verifyEmailUrl = assertEmailAndGetUrl(MailServerConfiguration.FROM, testUser.getEmail(),
"Someone has created a Test account with this email address.");
log.info("navigating to " + url);
driver.navigate().to(url);
log.info("navigating to url from email: " + verifyEmailUrl);
driver.navigate().to(verifyEmailUrl);
assertCurrentUrlStartsWith(testRealmAccountManagementPage);
testRealmAccountManagementPage.signOut();
testRealmLoginPage.form().login(testUser);

View file

@ -27,6 +27,7 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import static org.keycloak.testsuite.admin.ApiUtil.createUserAndResetPasswordWithAdminClient;
import static org.keycloak.testsuite.admin.Users.setPasswordFor;
@ -37,6 +38,7 @@ import org.keycloak.testsuite.auth.page.login.Registration;
import org.keycloak.testsuite.auth.page.login.ResetCredentials;
import org.keycloak.testsuite.auth.page.login.VerifyEmail;
import org.keycloak.testsuite.console.page.realm.LoginSettings.RequireSSLOption;
import org.keycloak.testsuite.util.MailServer;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
import org.openqa.selenium.Cookie;
@ -44,7 +46,6 @@ import org.openqa.selenium.Cookie;
/**
*
* @author tkyjovsk
* @author vramik
*/
@Ignore
public class LoginSettingsTest extends AbstractRealmTest {
@ -212,15 +213,23 @@ public class LoginSettingsTest extends AbstractRealmTest {
@Test
public void verifyEmail() {
log.info("enabling verify email");
MailServer.start();
MailServer.createEmailAccount(testUser.getEmail(), "password");
log.info("enabling verify email in login settings");
loginSettingsPage.form().setVerifyEmailAllowed(true);
loginSettingsPage.form().save();
log.debug("enabled");
log.info("configure smpt server in test realm");
RealmRepresentation testRealmRep = testRealmResource().toRepresentation();
testRealmRep.setSmtpServer(suiteContext.getSmtpServer());
testRealmResource().update(testRealmRep);
testAccountPage.navigateTo();
testRealmLoginPage.form().login(testUser);
Assert.assertEquals("Failed to send email, please try again later.",
testRealmVerifyEmailPage.getErrorMessage());
Assert.assertEquals("An email with instructions to verify your email address has been sent to you.",
testRealmVerifyEmailPage.getInstructionMessage());
log.info("verified verify email is enabled");
@ -243,6 +252,8 @@ public class LoginSettingsTest extends AbstractRealmTest {
testAccountPage.waitForAccountLinkPresent();
log.info("verified verify email is disabled");
MailServer.stop();
}
@Test

View file

@ -21,6 +21,17 @@
<!-- PREVIOUS VERSIONS KEYCLOAK FOR MIGRATION TESTS -->
<!-- IT HAS TO BE LISTED ABOWE KEYCLOAK AUTH SERVERS -->
<container qualifier="keycloak-1.5.1.Final" mode="suite" >
<configuration>
<property name="enabled">${migration.kc15}</property>
<property name="adapterImplClass">org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</property>
<property name="jbossHome">${keycloak-1.5.1.Final.home}</property>
<property name="javaVmArguments">-Djboss.socket.binding.port-offset=${auth.server.port.offset} -Xms64m -Xmx512m -XX:MaxPermSize=256m</property>
<property name="managementPort">${auth.server.management.port}</property>
<property name="startupTimeoutInSeconds">${startup.timeout.sec}</property>
</configuration>
</container>
<container qualifier="keycloak-1.4.0.Final" mode="suite" >
<configuration>
<property name="enabled">${migration.kc14}</property>

View file

@ -451,6 +451,56 @@
<!-- Profiles for migration tests-->
<profile>
<id>migration-kc15</id>
<properties>
<keycloak-1.5.1.Final.home>${containers.home}/keycloak-1.5.1.Final</keycloak-1.5.1.Final.home>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>unpack-previous</id>
<phase>generate-test-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.keycloak.testsuite</groupId>
<artifactId>integration-arquillian-server-wildfly-kc15</artifactId>
<version>${project.version}</version>
<type>zip</type>
</artifactItem>
</artifactItems>
<outputDirectory>${containers.home}</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<migration>true</migration>
<migration.kc15>true</migration.kc15>
<keycloak-1.5.1.Final.home>${keycloak-1.5.1.Final.home}</keycloak-1.5.1.Final.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>migration-kc14</id>
<properties>