From eeb47f93747ddefa4812df7e39fbab79e9b4354d Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 12 Mar 2015 16:34:02 -0400 Subject: [PATCH] KEYCLOAK-982 --- .../keycloak/protocol/saml/SamlService.java | 1 - .../keycloak/testsuite/model/CacheTest.java | 55 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java diff --git a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java index a6a2330270..80420318ba 100755 --- a/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java +++ b/saml/saml-protocol/src/main/java/org/keycloak/protocol/saml/SamlService.java @@ -515,7 +515,6 @@ public class SamlService { /** */ @GET - @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response redirectBinding(@QueryParam(GeneralConstants.SAML_REQUEST_KEY) String samlRequest, @QueryParam(GeneralConstants.SAML_RESPONSE_KEY) String samlResponse, @QueryParam(GeneralConstants.RELAY_STATE) String relayState) { diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java new file mode 100755 index 0000000000..f56582560c --- /dev/null +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/model/CacheTest.java @@ -0,0 +1,55 @@ +package org.keycloak.testsuite.model; + +import org.junit.Assert; +import org.junit.ClassRule; +import org.junit.Test; +import org.keycloak.models.ApplicationModel; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.RealmModel; +import org.keycloak.testsuite.rule.KeycloakRule; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class CacheTest { + @ClassRule + public static KeycloakRule kc = new KeycloakRule(); + + @Test + public void testStaleCache() throws Exception { + String appId = null; + { + // load up cache + KeycloakSession session = kc.startSession(); + RealmModel realm = session.realms().getRealmByName("test"); + ApplicationModel testApp = realm.getApplicationByName("test-app"); + Assert.assertNotNull(testApp); + appId = testApp.getId(); + Assert.assertTrue(testApp.isEnabled()); + kc.stopSession(session, true); + } + { + // update realm, then get an AppModel and change it. The AppModel would not be a cache adapter + KeycloakSession session = kc.startSession(); + RealmModel realm = session.realms().getRealmByName("test"); + Assert.assertTrue(realm instanceof org.keycloak.models.cache.RealmAdapter); + realm.setAccessCodeLifespanLogin(200); + ApplicationModel testApp = realm.getApplicationByName("test-app"); + Assert.assertNotNull(testApp); + testApp.setEnabled(false); + kc.stopSession(session, true); + } + // make sure that app cache was flushed and enabled changed + { + KeycloakSession session = kc.startSession(); + RealmModel realm = session.realms().getRealmByName("test"); + ApplicationModel testApp = session.realms().getApplicationById(appId, realm); + Assert.assertFalse(testApp.isEnabled()); + kc.stopSession(session, true); + + } + + + } +}