diff --git a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml
index b50a4f465f..5b0a0da893 100644
--- a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml
+++ b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml
@@ -31,7 +31,7 @@
-
+
@@ -47,14 +47,14 @@
-
+
-
-
+
+
\ No newline at end of file
diff --git a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.1.xml b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.1.xml
new file mode 100644
index 0000000000..4e0129eee7
--- /dev/null
+++ b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.1.xml
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml
index 6cd96c626c..3010118039 100755
--- a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml
+++ b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml
@@ -9,5 +9,5 @@
-
+
diff --git a/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java b/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java
index 60b063513e..401cf74b2d 100755
--- a/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java
+++ b/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java
@@ -12,7 +12,7 @@ public interface JpaUpdaterProvider extends Provider {
public String FIRST_VERSION = "1.0.0.Final";
- public String LAST_VERSION = "1.6.0";
+ public String LAST_VERSION = "1.6.1";
public String getCurrentVersionSql(String defaultSchema);
diff --git a/distribution/saml-adapters/jetty91-adapter-zip/pom.xml b/distribution/saml-adapters/jetty91-adapter-zip/pom.xml
index 2c15be444a..733aabf157 100755
--- a/distribution/saml-adapters/jetty91-adapter-zip/pom.xml
+++ b/distribution/saml-adapters/jetty91-adapter-zip/pom.xml
@@ -4,7 +4,7 @@
keycloak-parent
org.keycloak
- 1.6.0.Final-SNAPSHOT
+
../../../pom.xml
diff --git a/docbook/auth-server-docs/reference/en/en-US/modules/javascript-adapter.xml b/docbook/auth-server-docs/reference/en/en-US/modules/javascript-adapter.xml
index 33d62dca2d..2036afbd8a 100755
--- a/docbook/auth-server-docs/reference/en/en-US/modules/javascript-adapter.xml
+++ b/docbook/auth-server-docs/reference/en/en-US/modules/javascript-adapter.xml
@@ -210,6 +210,7 @@ new Keycloak({ url: 'http://localhost/auth', realm: 'myrealm', clientId: 'myApp'
prompt - can be set to 'none' to check if the user is logged in already (if not logged in, a login form is not displayed)
loginHint - used to pre-fill the username/email field on the login form
action - if value is 'register' then user is redirected to registration page, otherwise to login page
+ locale - specifies the desired locale for the UI
diff --git a/examples/pom.xml b/examples/pom.xml
index ec25be9438..6423a7c018 100755
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -14,14 +14,18 @@
pom
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+
-
- org.apache.maven.plugins
- maven-deploy-plugin
-
- true
-
-
org.apache.maven.plugins
maven-war-plugin
diff --git a/examples/saml/post-with-encryption/pom.xml b/examples/saml/post-with-encryption/pom.xml
index 0c95d95563..090f6afc0e 100755
--- a/examples/saml/post-with-encryption/pom.xml
+++ b/examples/saml/post-with-encryption/pom.xml
@@ -2,9 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
- org.keycloak.examples
+
+ keycloak-examples-saml-parent
+ org.keycloak
+ 1.7.0.Final-SNAPSHOT
+
+
saml-post-encryption
- 1.6.0.Final-SNAPSHOT
war
diff --git a/examples/saml/post-with-signature/pom.xml b/examples/saml/post-with-signature/pom.xml
index 8841ac054c..14db058a9b 100755
--- a/examples/saml/post-with-signature/pom.xml
+++ b/examples/saml/post-with-signature/pom.xml
@@ -2,9 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
- org.keycloak.examples
+
+ keycloak-examples-saml-parent
+ org.keycloak
+ 1.7.0.Final-SNAPSHOT
+
+
saml-post-signatures
- 1.6.0.Final-SNAPSHOT
war
diff --git a/examples/saml/redirect-with-signature/pom.xml b/examples/saml/redirect-with-signature/pom.xml
index 55f426b7df..06a4e55d5e 100755
--- a/examples/saml/redirect-with-signature/pom.xml
+++ b/examples/saml/redirect-with-signature/pom.xml
@@ -2,9 +2,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
- org.keycloak.examples
+
+ keycloak-examples-saml-parent
+ org.keycloak
+ 1.7.0.Final-SNAPSHOT
+
+
saml-redirect-signatures
- 1.6.0.Final-SNAPSHOT
war
diff --git a/forms/common-themes/src/main/resources/theme/base/login/login-reset-password.ftl b/forms/common-themes/src/main/resources/theme/base/login/login-reset-password.ftl
index e19a266b9d..404de17ea2 100755
--- a/forms/common-themes/src/main/resources/theme/base/login/login-reset-password.ftl
+++ b/forms/common-themes/src/main/resources/theme/base/login/login-reset-password.ftl
@@ -11,7 +11,7 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/base/login/login-totp.ftl b/forms/common-themes/src/main/resources/theme/base/login/login-totp.ftl
index e472fff1ff..3f46b76ba1 100755
--- a/forms/common-themes/src/main/resources/theme/base/login/login-totp.ftl
+++ b/forms/common-themes/src/main/resources/theme/base/login/login-totp.ftl
@@ -12,7 +12,7 @@
-
+
diff --git a/forms/login-api/src/main/java/org/keycloak/login/LoginFormsProvider.java b/forms/login-api/src/main/java/org/keycloak/login/LoginFormsProvider.java
index cb5f2be8cd..fccfce160c 100755
--- a/forms/login-api/src/main/java/org/keycloak/login/LoginFormsProvider.java
+++ b/forms/login-api/src/main/java/org/keycloak/login/LoginFormsProvider.java
@@ -52,6 +52,8 @@ public interface LoginFormsProvider extends Provider {
public LoginFormsProvider setClientSessionCode(String accessCode);
+ public LoginFormsProvider setClientSession(ClientSessionModel clientSession);
+
public LoginFormsProvider setAccessRequest(List realmRolesRequested, MultivaluedMap resourceRolesRequested, List protocolMappers);
public LoginFormsProvider setAccessRequest(String message);
diff --git a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/FreeMarkerLoginFormsProvider.java b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/FreeMarkerLoginFormsProvider.java
index 7fc1bcddcb..6125d0b83b 100755
--- a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/FreeMarkerLoginFormsProvider.java
+++ b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/FreeMarkerLoginFormsProvider.java
@@ -47,6 +47,7 @@ import org.keycloak.login.freemarker.model.TotpBean;
import org.keycloak.login.freemarker.model.UrlBean;
import org.keycloak.models.ClientModel;
import org.keycloak.models.ClientSessionModel;
+import org.keycloak.models.Constants;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.ProtocolMapperModel;
import org.keycloak.models.RealmModel;
@@ -138,7 +139,8 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
case VERIFY_EMAIL:
try {
UriBuilder builder = Urls.loginActionEmailVerificationBuilder(uriInfo.getBaseUri());
- builder.queryParam("key", accessCode);
+ builder.queryParam(OAuth2Constants.CODE, accessCode);
+ builder.queryParam("key", clientSession.getNote(Constants.VERIFY_EMAIL_KEY));
String link = builder.build(realm.getName()).toString();
long expiration = TimeUnit.SECONDS.toMinutes(realm.getAccessCodeLifespanUserAction());
@@ -531,6 +533,12 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
return this;
}
+ @Override
+ public LoginFormsProvider setClientSession(ClientSessionModel clientSession) {
+ this.clientSession = clientSession;
+ return this;
+ }
+
@Override
public LoginFormsProvider setAccessRequest(List realmRolesRequested, MultivaluedMap resourceRolesRequested, List protocolMappersRequested) {
this.realmRolesRequested = realmRolesRequested;
diff --git a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/ClientBean.java b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/ClientBean.java
index f10d031d07..a29271895b 100755
--- a/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/ClientBean.java
+++ b/forms/login-freemarker/src/main/java/org/keycloak/login/freemarker/model/ClientBean.java
@@ -4,6 +4,7 @@ import org.keycloak.models.ClientModel;
import org.keycloak.services.util.ResolveRelative;
import java.net.URI;
+import java.util.Map;
/**
* @author Bill Burke
@@ -32,4 +33,11 @@ public class ClientBean {
return ResolveRelative.resolveRelativeUri(requestUri, client.getRootUrl(), client.getBaseUrl());
}
+ public Map getAttributes(){
+ return client.getAttributes();
+ }
+
+ public String getAttribute(String key){
+ return client.getAttribute(key);
+ }
}
diff --git a/integration/js/src/main/resources/keycloak.js b/integration/js/src/main/resources/keycloak.js
index d189a361f8..7b378de347 100755
--- a/integration/js/src/main/resources/keycloak.js
+++ b/integration/js/src/main/resources/keycloak.js
@@ -168,6 +168,10 @@
url += '&scope=' + options.scope;
}
+ if (options && options.locale) {
+ url += '&ui_locales=' + options.locale;
+ }
+
return url;
}
diff --git a/model/api/src/main/java/org/keycloak/models/Constants.java b/model/api/src/main/java/org/keycloak/models/Constants.java
index 43bdc7dc68..8977def5c3 100755
--- a/model/api/src/main/java/org/keycloak/models/Constants.java
+++ b/model/api/src/main/java/org/keycloak/models/Constants.java
@@ -22,4 +22,6 @@ public interface Constants {
// 30 days
int DEFAULT_OFFLINE_SESSION_IDLE_TIMEOUT = 2592000;
+
+ public static final String VERIFY_EMAIL_KEY = "VERIFY_EMAIL_KEY";
}
diff --git a/model/api/src/main/java/org/keycloak/models/utils/PostMigrationEvent.java b/model/api/src/main/java/org/keycloak/models/utils/PostMigrationEvent.java
new file mode 100644
index 0000000000..513836f3ba
--- /dev/null
+++ b/model/api/src/main/java/org/keycloak/models/utils/PostMigrationEvent.java
@@ -0,0 +1,11 @@
+package org.keycloak.models.utils;
+
+import org.keycloak.provider.ProviderEvent;
+
+/**
+ * Executed at startup after model migration is finished
+ *
+ * @author Marek Posolda
+ */
+public class PostMigrationEvent implements ProviderEvent {
+}
diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/session/JpaUserSessionPersisterProvider.java b/model/jpa/src/main/java/org/keycloak/models/jpa/session/JpaUserSessionPersisterProvider.java
index 6fc2960b84..5fa648ed36 100644
--- a/model/jpa/src/main/java/org/keycloak/models/jpa/session/JpaUserSessionPersisterProvider.java
+++ b/model/jpa/src/main/java/org/keycloak/models/jpa/session/JpaUserSessionPersisterProvider.java
@@ -188,32 +188,32 @@ public class JpaUserSessionPersisterProvider implements UserSessionPersisterProv
userSessionIds.add(entity.getUserSessionId());
}
- TypedQuery query2 = em.createNamedQuery("findClientSessionsByUserSessions", PersistentClientSessionEntity.class);
- query2.setParameter("userSessionIds", userSessionIds);
- query2.setParameter("offline", offlineStr);
- List clientSessions = query2.getResultList();
+ if (!userSessionIds.isEmpty()) {
+ TypedQuery query2 = em.createNamedQuery("findClientSessionsByUserSessions", PersistentClientSessionEntity.class);
+ query2.setParameter("userSessionIds", userSessionIds);
+ query2.setParameter("offline", offlineStr);
+ List clientSessions = query2.getResultList();
- // Assume both userSessions and clientSessions ordered by userSessionId
- int j=0;
- for (UserSessionModel ss : result) {
- PersistentUserSessionAdapter userSession = (PersistentUserSessionAdapter) ss;
- List currentClientSessions = userSession.getClientSessions(); // This is empty now and we want to fill it
+ // Assume both userSessions and clientSessions ordered by userSessionId
+ int j = 0;
+ for (UserSessionModel ss : result) {
+ PersistentUserSessionAdapter userSession = (PersistentUserSessionAdapter) ss;
+ List currentClientSessions = userSession.getClientSessions(); // This is empty now and we want to fill it
- boolean next = true;
- while (next && jeap6
+
+ migration-kc16
+
+ wildfly_kc16
+
+
migration-kc15
diff --git a/testsuite/integration-arquillian/servers/wildfly_kc16/assembly.xml b/testsuite/integration-arquillian/servers/wildfly_kc16/assembly.xml
new file mode 100644
index 0000000000..46782886cb
--- /dev/null
+++ b/testsuite/integration-arquillian/servers/wildfly_kc16/assembly.xml
@@ -0,0 +1,29 @@
+
+
+ auth-server-wildfly-kc16
+
+
+ zip
+
+
+ false
+
+
+
+ ${keycloak.server.home}
+ keycloak-1.6.0.Final
+
+ **/*.sh
+
+
+
+ ${keycloak.server.home}
+ keycloak-1.6.0.Final
+
+ **/*.sh
+
+ 0755
+
+
+
+
diff --git a/testsuite/integration-arquillian/servers/wildfly_kc16/pom.xml b/testsuite/integration-arquillian/servers/wildfly_kc16/pom.xml
new file mode 100644
index 0000000000..c5e8ac147c
--- /dev/null
+++ b/testsuite/integration-arquillian/servers/wildfly_kc16/pom.xml
@@ -0,0 +1,199 @@
+
+
+
+ org.keycloak.testsuite
+ integration-arquillian-servers
+ 1.7.0.Final-SNAPSHOT
+
+ 4.0.0
+
+ integration-arquillian-server-wildfly-kc16
+ pom
+ Keycloak 1.6.0.Final on Wildfly
+
+
+ ${project.build.directory}/unpacked/keycloak-1.6.0.Final
+ ${keycloak.server.home}/modules/system/layers/base/com/${jdbc.mvn.artifactId}/main
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 1.4
+
+
+ enforce-properties
+
+ enforce
+
+
+
+
+ jdbc.mvn.groupId
+
+
+ jdbc.mvn.artifactId
+
+
+ jdbc.mvn.version
+
+
+ keycloak.connectionsJpa.url
+
+
+ keycloak.connectionsJpa.user
+
+
+ keycloak.connectionsJpa.password
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ unpack-server
+ generate-resources
+
+ unpack
+
+
+
+
+ org.keycloak
+ keycloak-server-dist
+ 1.6.0.Final
+ zip
+ ${project.build.directory}/unpacked
+
+
+
+
+
+ jdbc-driver
+ process-resources
+
+ copy
+
+
+
+
+ ${jdbc.mvn.groupId}
+ ${jdbc.mvn.artifactId}
+ ${jdbc.mvn.version}
+ jar
+
+
+ ${jdbc.mvn.driver.deployment.dir}
+ true
+
+
+
+
+
+ org.codehaus.mojo
+ xml-maven-plugin
+
+
+ configure-wildfly-datasource
+ process-resources
+
+ transform
+
+
+
+
+
+ ${keycloak.server.home}/modules/system/layers/base/com/h2database/h2/main
+ src/main/xslt/module.xsl
+
+ module.xml
+
+ ${jdbc.mvn.driver.deployment.dir}
+
+
+ database
+ ${jdbc.mvn.artifactId}
+
+
+ version
+ ${jdbc.mvn.version}
+
+
+
+
+
+ ${keycloak.server.home}/standalone/configuration
+ src/main/xslt/datasource.xsl
+
+ standalone.xml
+
+ ${keycloak.server.home}/standalone/configuration
+
+
+ jdbc.url
+ ${keycloak.connectionsJpa.url}
+
+
+ driver
+ ${jdbc.mvn.artifactId}
+
+
+ username
+ ${keycloak.connectionsJpa.user}
+
+
+ password
+ ${keycloak.connectionsJpa.password}
+
+
+
+
+
+ ${keycloak.server.home}/standalone/configuration
+ src/main/xslt/add-dialect-logger.xsl
+
+ standalone.xml
+
+ ${keycloak.server.home}/standalone/configuration
+
+
+
+
+
+
+
+ maven-assembly-plugin
+
+
+ create-zip
+ package
+
+ single
+
+
+
+ assembly.xml
+
+ false
+
+
+
+
+
+
+
diff --git a/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/add-dialect-logger.xsl b/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/add-dialect-logger.xsl
new file mode 100644
index 0000000000..b5dc8c4e02
--- /dev/null
+++ b/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/add-dialect-logger.xsl
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/datasource.xsl b/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/datasource.xsl
new file mode 100644
index 0000000000..c06899fd74
--- /dev/null
+++ b/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/datasource.xsl
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/module.xsl b/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/module.xsl
new file mode 100644
index 0000000000..88ac56b86c
--- /dev/null
+++ b/testsuite/integration-arquillian/servers/wildfly_kc16/src/main/xslt/module.xsl
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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 1b6df1d5e1..bc82ac773c 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml
+++ b/testsuite/integration-arquillian/tests/base/src/test/resources/arquillian.xml
@@ -21,6 +21,17 @@
+
+
+ ${migration.kc16}
+ org.jboss.as.arquillian.container.managed.ManagedDeployableContainer
+ ${keycloak-1.6.0.Final.home}
+ -Djboss.socket.binding.port-offset=${auth.server.port.offset} -Xms64m -Xmx512m -XX:MaxPermSize=256m
+ ${auth.server.management.port}
+ ${startup.timeout.sec}
+
+
+
${migration.kc15}
diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml
index 2c9f13f5f0..cec51ebe6a 100644
--- a/testsuite/integration-arquillian/tests/pom.xml
+++ b/testsuite/integration-arquillian/tests/pom.xml
@@ -451,6 +451,57 @@
+
+ migration-kc16
+
+ ${containers.home}/keycloak-1.6.0.Final
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ unpack-previous
+ generate-test-resources
+
+ unpack
+
+
+
+
+ org.keycloak.testsuite
+ integration-arquillian-server-wildfly-kc16
+ ${project.version}
+ zip
+
+
+ ${containers.home}
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ true
+ true
+ ${keycloak-1.6.0.Final.home}
+ src/test/resources/migration-test/migration-realm-16.json
+
+
+
+
+
+
+
+
migration-kc15
diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java
index a9c0c58373..c7f075f4d6 100755
--- a/testsuite/integration/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java
@@ -26,7 +26,9 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
+import org.keycloak.common.util.KeycloakUriBuilder;
import org.keycloak.events.Details;
+import org.keycloak.events.Errors;
import org.keycloak.events.Event;
import org.keycloak.events.EventType;
import org.keycloak.models.RealmModel;
@@ -130,7 +132,7 @@ public class RequiredActionEmailVerificationTest {
String mailCodeId = sendEvent.getDetails().get(Details.CODE_ID);
- Assert.assertEquals(mailCodeId, verificationUrl.split("key=")[1].split("\\.")[1]);
+ Assert.assertEquals(mailCodeId, verificationUrl.split("code=")[1].split("\\&")[0].split("\\.")[1]);
driver.navigate().to(verificationUrl.trim());
@@ -223,7 +225,7 @@ public class RequiredActionEmailVerificationTest {
String mailCodeId = sendEvent.getDetails().get(Details.CODE_ID);
- Assert.assertEquals(mailCodeId, verificationUrl.split("key=")[1].split("\\.")[1]);
+ Assert.assertEquals(mailCodeId, verificationUrl.split("code=")[1].split("\\&")[0].split("\\.")[1]);
driver.manage().deleteAllCookies();
@@ -238,6 +240,42 @@ public class RequiredActionEmailVerificationTest {
assertTrue(loginPage.isCurrent());
}
+
+
+ @Test
+ public void verifyInvalidKeyOrCode() throws IOException, MessagingException {
+ loginPage.open();
+ loginPage.login("test-user@localhost", "password");
+
+ Assert.assertTrue(verifyEmailPage.isCurrent());
+ String resendEmailLink = verifyEmailPage.getResendEmailLink();
+ String keyInsteadCodeURL = resendEmailLink.replace("code=", "key=");
+
+ AssertEvents.ExpectedEvent emailEvent = events.expectRequiredAction(EventType.SEND_VERIFY_EMAIL).detail("email", "test-user@localhost");
+ Event sendEvent = emailEvent.assertEvent();
+ String sessionId = sendEvent.getSessionId();
+ String mailCodeId = sendEvent.getDetails().get(Details.CODE_ID);
+
+ driver.navigate().to(keyInsteadCodeURL);
+
+ events.expectRequiredAction(EventType.VERIFY_EMAIL_ERROR)
+ .error(Errors.INVALID_CODE)
+ .client((String)null)
+ .user((String)null)
+ .session((String)null)
+ .clearDetails()
+ .assertEvent();
+
+ String badKeyURL = KeycloakUriBuilder.fromUri(resendEmailLink).queryParam("key", "foo").build().toString();
+ driver.navigate().to(badKeyURL);
+
+ events.expectRequiredAction(EventType.VERIFY_EMAIL_ERROR)
+ .error(Errors.INVALID_USER_CREDENTIALS)
+ .session(sessionId)
+ .detail("email", "test-user@localhost")
+ .detail(Details.CODE_ID, mailCodeId)
+ .assertEvent();
+ }
private String getPasswordResetEmailLink(MimeMessage message) throws IOException, MessagingException {
Multipart multipart = (Multipart) message.getContent();
diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserSessionPersisterProviderTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserSessionPersisterProviderTest.java
index 8a6fc9dcb0..cbc8284c22 100644
--- a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserSessionPersisterProviderTest.java
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/UserSessionPersisterProviderTest.java
@@ -290,6 +290,14 @@ public class UserSessionPersisterProviderTest {
realmMgr.removeRealm(realmMgr.getRealm("foo"));
}
+ // KEYCLOAK-1999
+ @Test
+ public void testNoSessions() {
+ UserSessionPersisterProvider persister = session.getProvider(UserSessionPersisterProvider.class);
+ List sessions = persister.loadUserSessions(0, 1, true);
+ Assert.assertEquals(0, sessions.size());
+ }
+
private ClientSessionModel createClientSession(ClientModel client, UserSessionModel userSession, String redirect, String state, Set roles, Set protocolMappers) {
ClientSessionModel clientSession = session.sessions().createClientSession(realm, client);
diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java
index cfcfbb4fdb..9968ce1087 100644
--- a/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java
+++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java
@@ -50,4 +50,8 @@ public class VerifyEmailPage extends AbstractPage {
resendEmailLink.click();
}
+ public String getResendEmailLink() {
+ return resendEmailLink.getAttribute("href");
+ }
+
}