diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthDanceClientSessionExtensionTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/OAuthDanceClientSessionExtensionTest.java similarity index 52% rename from testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthDanceClientSessionExtensionTest.java rename to testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/OAuthDanceClientSessionExtensionTest.java index 5c62c98fb1..5ddef6e35b 100644 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthDanceClientSessionExtensionTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oauth/OAuthDanceClientSessionExtensionTest.java @@ -17,40 +17,44 @@ package org.keycloak.testsuite.oauth; -import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.keycloak.OAuth2Constants; import org.keycloak.events.Details; -import org.keycloak.events.Event; +import org.keycloak.representations.idm.EventRepresentation; +import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.testsuite.AbstractKeycloakTest; import org.keycloak.testsuite.AssertEvents; -import org.keycloak.testsuite.OAuthClient; -import org.keycloak.testsuite.rule.KeycloakRule; -import org.keycloak.testsuite.rule.WebResource; -import org.keycloak.testsuite.rule.WebRule; +import org.keycloak.testsuite.util.OAuthClient; + +import java.util.List; + +import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson; /** * @author Sebastian Rose, AOE on 02.06.15. */ -public class OAuthDanceClientSessionExtensionTest { - - @ClassRule - public static KeycloakRule keycloakRule = new KeycloakRule(); +public class OAuthDanceClientSessionExtensionTest extends AbstractKeycloakTest { @Rule - public WebRule webRule = new WebRule(this); + public AssertEvents events = new AssertEvents(this); - @WebResource - protected OAuthClient oauth; + @Override + public void beforeAbstractKeycloakTest() throws Exception { + super.beforeAbstractKeycloakTest(); + } - @Rule - public AssertEvents events = new AssertEvents(keycloakRule); + @Override + public void addTestRealms(List testRealms) { + RealmRepresentation realmRepresentation = loadJson(getClass().getResourceAsStream("/testrealm.json"), RealmRepresentation.class); + testRealms.add(realmRepresentation); + } @Test public void doOauthDanceWithClientSessionStateAndHost() throws Exception { oauth.doLogin("test-user@localhost", "password"); - Event loginEvent = events.expectLogin().assertEvent(); + EventRepresentation loginEvent = events.expectLogin().assertEvent(); String sessionId = loginEvent.getSessionId(); String codeId = loginEvent.getDetails().get(Details.CODE_ID); @@ -61,27 +65,27 @@ public class OAuthDanceClientSessionExtensionTest { String clientSessionHost = "test-client-host"; OAuthClient.AccessTokenResponse tokenResponse = oauth.clientSessionState(clientSessionState) - .clientSessionHost(clientSessionHost) - .doAccessTokenRequest(code, "password"); + .clientSessionHost(clientSessionHost) + .doAccessTokenRequest(code, "password"); String refreshTokenString = tokenResponse.getRefreshToken(); - Event tokenEvent = events.expectCodeToToken(codeId, sessionId) - .detail(Details.CLIENT_SESSION_STATE, clientSessionState) - .detail(Details.CLIENT_SESSION_HOST, clientSessionHost) - .assertEvent(); + EventRepresentation tokenEvent = events.expectCodeToToken(codeId, sessionId) + .detail(Details.CLIENT_SESSION_STATE, clientSessionState) + .detail(Details.CLIENT_SESSION_HOST, clientSessionHost) + .assertEvent(); String updatedClientSessionState = "5678"; oauth.clientSessionState(updatedClientSessionState) - .clientSessionHost(clientSessionHost) - .doRefreshTokenRequest(refreshTokenString, "password"); + .clientSessionHost(clientSessionHost) + .doRefreshTokenRequest(refreshTokenString, "password"); events.expectRefresh(tokenEvent.getDetails().get(Details.REFRESH_TOKEN_ID), sessionId) - .detail(Details.CLIENT_SESSION_STATE, updatedClientSessionState) - .detail(Details.CLIENT_SESSION_HOST, clientSessionHost) - .assertEvent(); + .detail(Details.CLIENT_SESSION_STATE, updatedClientSessionState) + .detail(Details.CLIENT_SESSION_HOST, clientSessionHost) + .assertEvent(); }