mirror of
https://github.com/ysoftdevs/oauth-playground-server.git
synced 2026-03-28 20:11:56 +01:00
refactor tests - bad creds
This commit is contained in:
@@ -59,6 +59,17 @@ public class AuthCodeGrantTest {
|
|||||||
assertThat(accessTokenResponse.accessToken(), is(notNullValue()));
|
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
|
@Test
|
||||||
public void authCodeGrant_invalidResponseType() throws IOException {
|
public void authCodeGrant_invalidResponseType() throws IOException {
|
||||||
AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT)
|
AuthorizationCodeFlow flow = new AuthorizationCodeFlow(authUrl, CLIENT)
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
|||||||
public class LoginScreen {
|
public class LoginScreen {
|
||||||
|
|
||||||
private final FormElement form;
|
private final FormElement form;
|
||||||
|
private final Document document;
|
||||||
|
|
||||||
public LoginScreen(Document doc) {
|
public LoginScreen(Document document) {
|
||||||
this.form = doc.expectForm("form");
|
this.form = document.expectForm("form");
|
||||||
|
this.document = document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result submit(String username, String password) throws IOException {
|
public Result submit(String username, String password) throws IOException {
|
||||||
@@ -36,7 +38,7 @@ public class LoginScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LoginScreen expectError(String error) {
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user