Merge pull request #3540 from mhajas/KEYCLOAK-3671

KEYCLOAK-3671
This commit is contained in:
Bill Burke 2016-11-22 14:48:59 -05:00 committed by GitHub
commit 2da9986717

View file

@ -18,11 +18,16 @@
package org.keycloak.testsuite.client;
import org.junit.Test;
import org.keycloak.OAuth2Constants;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.TestRealmKeycloakTest;
import org.keycloak.testsuite.util.ClientBuilder;
import org.keycloak.testsuite.util.RealmBuilder;
import javax.ws.rs.client.Client;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
/**
@ -55,4 +60,17 @@ public class ClientRedirectTest extends TestRealmKeycloakTest {
driver.get(getAuthServerRoot().toString() + "realms/test/clients/account/redirect");
assertEquals(getAuthServerRoot().toString() + "realms/test/account", driver.getCurrentUrl());
}
@Test
public void testRedirectStatusCode() {
oauth.doLogin("test-user@localhost", "password");
String code = oauth.getCurrentQuery().get(OAuth2Constants.CODE);
String token = oauth.doAccessTokenRequest(code, "password").getAccessToken();
Client client = javax.ws.rs.client.ClientBuilder.newClient();
String redirectUrl = getAuthServerRoot().toString() + "realms/test/clients/launchpad-test/redirect";
Response response = client.target(redirectUrl).request().header(HttpHeaders.AUTHORIZATION, "Bearer " + token).get();
assertEquals(303, response.getStatus());
client.close();
}
}