KEYCLOAK-3671

This commit is contained in:
mhajas 2016-11-22 16:32:39 +01:00
parent 33cd261d83
commit b2d48c86a6

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();
}
}