mirror of
https://github.com/ysoftdevs/oauth-playground-server.git
synced 2026-01-17 00:57:16 +01:00
refactor tests - bad creds
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user