diff --git a/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java b/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java index 478f3b0..81c82e1 100644 --- a/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java +++ b/src/test/java/com/ysoft/geecon/AuthCodeGrantTest.java @@ -59,6 +59,17 @@ public class AuthCodeGrantTest { assertThat(accessTokenResponse.accessToken(), is(notNullValue())); } + @Test + public void badCredentials() throws IOException { + AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT) + .scope("scope1 scope2"); + LoginScreen loginScreen = flow.start().expectLogin(); + + loginScreen.submit("x", "bbb").expectError("Invalid credentials") + .submit("bob", "bbb").expectError("Invalid credentials") + .submit("bob", "password").expectSuccess(); + } + @Test public void authCodeGrant_invalidResponseType() throws IOException { AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT) diff --git a/src/test/java/com/ysoft/geecon/helpers/LoginScreen.java b/src/test/java/com/ysoft/geecon/helpers/LoginScreen.java index aa75775..f157efe 100644 --- a/src/test/java/com/ysoft/geecon/helpers/LoginScreen.java +++ b/src/test/java/com/ysoft/geecon/helpers/LoginScreen.java @@ -12,9 +12,11 @@ import static org.hamcrest.MatcherAssert.assertThat; public class LoginScreen { private final FormElement form; + private final Document document; - public LoginScreen(Document doc) { - this.form = doc.expectForm("form"); + public LoginScreen(Document document) { + this.form = document.expectForm("form"); + this.document = document; } public Result submit(String username, String password) throws IOException { @@ -36,7 +38,7 @@ public class LoginScreen { } private LoginScreen expectError(String error) { - assertThat(Objects.requireNonNull(form.getElementById("error-popup")).text(), containsString(error)); + assertThat(Objects.requireNonNull(document.getElementById("error-popup")).text(), containsString(error)); return this; }