Migration of OAuthDanceClientSessionExtensionTest
This commit is contained in:
parent
49dc5363bb
commit
2a60f65229
1 changed files with 31 additions and 27 deletions
|
@ -17,40 +17,44 @@
|
||||||
|
|
||||||
package org.keycloak.testsuite.oauth;
|
package org.keycloak.testsuite.oauth;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.OAuth2Constants;
|
import org.keycloak.OAuth2Constants;
|
||||||
import org.keycloak.events.Details;
|
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.AssertEvents;
|
||||||
import org.keycloak.testsuite.OAuthClient;
|
import org.keycloak.testsuite.util.OAuthClient;
|
||||||
import org.keycloak.testsuite.rule.KeycloakRule;
|
|
||||||
import org.keycloak.testsuite.rule.WebResource;
|
import java.util.List;
|
||||||
import org.keycloak.testsuite.rule.WebRule;
|
|
||||||
|
import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sebastian Rose, AOE on 02.06.15.
|
* @author Sebastian Rose, AOE on 02.06.15.
|
||||||
*/
|
*/
|
||||||
public class OAuthDanceClientSessionExtensionTest {
|
public class OAuthDanceClientSessionExtensionTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static KeycloakRule keycloakRule = new KeycloakRule();
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public WebRule webRule = new WebRule(this);
|
public AssertEvents events = new AssertEvents(this);
|
||||||
|
|
||||||
@WebResource
|
@Override
|
||||||
protected OAuthClient oauth;
|
public void beforeAbstractKeycloakTest() throws Exception {
|
||||||
|
super.beforeAbstractKeycloakTest();
|
||||||
|
}
|
||||||
|
|
||||||
@Rule
|
@Override
|
||||||
public AssertEvents events = new AssertEvents(keycloakRule);
|
public void addTestRealms(List<RealmRepresentation> testRealms) {
|
||||||
|
RealmRepresentation realmRepresentation = loadJson(getClass().getResourceAsStream("/testrealm.json"), RealmRepresentation.class);
|
||||||
|
testRealms.add(realmRepresentation);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void doOauthDanceWithClientSessionStateAndHost() throws Exception {
|
public void doOauthDanceWithClientSessionStateAndHost() throws Exception {
|
||||||
oauth.doLogin("test-user@localhost", "password");
|
oauth.doLogin("test-user@localhost", "password");
|
||||||
|
|
||||||
Event loginEvent = events.expectLogin().assertEvent();
|
EventRepresentation loginEvent = events.expectLogin().assertEvent();
|
||||||
|
|
||||||
String sessionId = loginEvent.getSessionId();
|
String sessionId = loginEvent.getSessionId();
|
||||||
String codeId = loginEvent.getDetails().get(Details.CODE_ID);
|
String codeId = loginEvent.getDetails().get(Details.CODE_ID);
|
||||||
|
@ -66,7 +70,7 @@ public class OAuthDanceClientSessionExtensionTest {
|
||||||
|
|
||||||
String refreshTokenString = tokenResponse.getRefreshToken();
|
String refreshTokenString = tokenResponse.getRefreshToken();
|
||||||
|
|
||||||
Event tokenEvent = events.expectCodeToToken(codeId, sessionId)
|
EventRepresentation tokenEvent = events.expectCodeToToken(codeId, sessionId)
|
||||||
.detail(Details.CLIENT_SESSION_STATE, clientSessionState)
|
.detail(Details.CLIENT_SESSION_STATE, clientSessionState)
|
||||||
.detail(Details.CLIENT_SESSION_HOST, clientSessionHost)
|
.detail(Details.CLIENT_SESSION_HOST, clientSessionHost)
|
||||||
.assertEvent();
|
.assertEvent();
|
Loading…
Reference in a new issue