Files
oauth-playground-server/src/test/java/com/ysoft/geecon/helpers/LoginScreen.java
2023-09-18 16:25:54 +02:00

34 lines
967 B
Java

package com.ysoft.geecon.helpers;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;
import java.io.IOException;
public class LoginScreen {
private final FormElement form;
public LoginScreen(Document doc) {
this.form = doc.expectForm("form");
;
}
public Document submit(String username, String password) throws IOException {
form.getElementsByAttributeValue("name", "username").val(username);
form.getElementsByAttributeValue("name", "password").val(password);
return form.submit().post();
}
public ConsentScreen submitCorrect(String username, String password) throws IOException {
Document posted = submit(username, password);
return new ConsentScreen(posted);
}
public LoginScreen submitWrong(String username, String password) throws IOException {
Document posted = submit(username, password);
return new LoginScreen(posted);
}
}