diff --git a/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java b/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java index 4359912..fdc57d6 100644 --- a/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java +++ b/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java @@ -50,10 +50,23 @@ public class AuthCodeGrantTest { flow.parseAndValidateRedirect(submit.connection().response()); assertThat(flow.getCode(), is(notNullValue())); - assertThat(flow.getToken(), is(nullValue())); + assertThat(flow.getAccessToken(), is(nullValue())); flow.exchangeCode(); - assertThat(flow.getToken(), is(notNullValue())); + assertThat(flow.getAccessToken(), is(notNullValue())); } + @Test + public void implicitGrant() throws IOException { + AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT); + LoginScreen loginScreen = flow.start(Map.of("response_type", "token", "scope", "scope1 scope2")); + + ConsentScreen consentScreen = loginScreen.submitCorrect("bob", "password"); + assertThat(consentScreen.getScopes(), is(List.of("scope1", "scope2"))); + + Document submit = consentScreen.submit(); + flow.parseAndValidateRedirect(submit.connection().response()); + + assertThat(flow.getAccessToken(), is(notNullValue())); + } } \ No newline at end of file diff --git a/src/test/java/com/ysoft/geecon/helpers/AuthorizationCodeFlow.java b/src/test/java/com/ysoft/geecon/helpers/AuthorizationCodeFlow.java index 1baf6c5..9c86d04 100644 --- a/src/test/java/com/ysoft/geecon/helpers/AuthorizationCodeFlow.java +++ b/src/test/java/com/ysoft/geecon/helpers/AuthorizationCodeFlow.java @@ -26,7 +26,7 @@ public class AuthorizationCodeFlow { private final OAuthClient client; private String state = "testStateIsNotRandom"; private String code; - private String token; + private String accessToken; private String idToken; public AuthorizationCodeFlow(String authUrl, OAuthClient client) { @@ -64,10 +64,9 @@ public class AuthorizationCodeFlow { .stream().collect(Collectors.toMap(NameValuePair::getName, NameValuePair::getValue)); assertThat(query.get("state"), is(state)); - assertThat(query.get("code"), is(notNullValue())); code = query.get("code"); - token = query.get("token"); + accessToken = query.get("access_token"); idToken = query.get("id_token"); } @@ -87,7 +86,7 @@ public class AuthorizationCodeFlow { .body("access_token", is(notNullValue())) .body("refresh_token", is(notNullValue())) .extract().body().as(AccessTokenResponse.class); - token = accessTokenResponse.accessToken(); + accessToken = accessTokenResponse.accessToken(); idToken = accessTokenResponse.idToken(); return accessTokenResponse; } @@ -100,8 +99,8 @@ public class AuthorizationCodeFlow { return code; } - public String getToken() { - return token; + public String getAccessToken() { + return accessToken; } public String getIdToken() {