KEYCLOAK-181
Link back to application from account management pages
This commit is contained in:
1 parent
2059283e99
commit
85eeb415e1
25 files changed
+256
-148
No files matched your search
@@ -39,23 +39,11 @@ import java.util.List;
|
||||
*/
|
||||
public class ApplicationServlet extends HttpServlet {
|
||||
|
||||
private static final String LINK = "<a href=\"%s\" id=\"%s\">%s</a>";
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String title = "";
|
||||
String body = "";
|
||||
|
||||
StringBuffer sb = req.getRequestURL();
|
||||
sb.append("?");
|
||||
sb.append(req.getQueryString());
|
||||
|
||||
List<NameValuePair> query = null;
|
||||
|
||||
try {
|
||||
query = URLEncodedUtils.parse(new URI(sb.toString()), "UTF-8");
|
||||
} catch (URISyntaxException e) {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
|
||||
if (req.getRequestURI().endsWith("auth")) {
|
||||
title = "AUTH_RESPONSE";
|
||||
} else if (req.getRequestURI().endsWith("logout")) {
|
||||
@@ -65,7 +53,11 @@ public class ApplicationServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
PrintWriter pw = resp.getWriter();
|
||||
pw.printf("<html><head><title>%s</title></head><body>%s</body>", title, body);
|
||||
pw.printf("<html><head><title>%s</title></head><body>", title);
|
||||
|
||||
pw.printf(LINK, "http://localhost:8081/auth-server/rest/realms/test/account", "account", "account");
|
||||
|
||||
pw.print("</body></html>");
|
||||
pw.flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,28 @@ public class AccountTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnToAppFromHeader() {
|
||||
appPage.open();
|
||||
appPage.openAccount();
|
||||
loginPage.login("test-user@localhost", "password");
|
||||
|
||||
Assert.assertTrue(profilePage.isCurrent());
|
||||
profilePage.backToApplication();
|
||||
|
||||
Assert.assertTrue(appPage.isCurrent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnToAppFromQueryParam() {
|
||||
driver.navigate().to(AccountUpdateProfilePage.PATH + "?referrer=test-app");
|
||||
loginPage.login("test-user@localhost", "password");
|
||||
Assert.assertTrue(profilePage.isCurrent());
|
||||
profilePage.backToApplication();
|
||||
|
||||
Assert.assertTrue(appPage.isCurrent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changePassword() {
|
||||
changePasswordPage.open();
|
||||
|
||||
+9
-1
@@ -30,7 +30,7 @@ import org.openqa.selenium.support.FindBy;
|
||||
*/
|
||||
public class AccountUpdateProfilePage extends AbstractAccountPage {
|
||||
|
||||
private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/test/account";
|
||||
public static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/test/account";
|
||||
|
||||
@FindBy(id = "firstName")
|
||||
private WebElement firstNameInput;
|
||||
@@ -41,6 +41,10 @@ public class AccountUpdateProfilePage extends AbstractAccountPage {
|
||||
@FindBy(id = "email")
|
||||
private WebElement emailInput;
|
||||
|
||||
|
||||
@FindBy(linkText = "Back to application")
|
||||
private WebElement backToApplicationLink;
|
||||
|
||||
@FindBy(css = "button[type=\"submit\"]")
|
||||
private WebElement submitButton;
|
||||
|
||||
@@ -78,6 +82,10 @@ public class AccountUpdateProfilePage extends AbstractAccountPage {
|
||||
driver.navigate().to(PATH);
|
||||
}
|
||||
|
||||
public void backToApplication() {
|
||||
backToApplicationLink.click();
|
||||
}
|
||||
|
||||
public boolean isSuccess(){
|
||||
return feedbackMessage != null && "Success!".equals(feedbackMessage.getText());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
package org.keycloak.testsuite.pages;
|
||||
|
||||
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||
*/
|
||||
@@ -29,6 +32,9 @@ public class AppPage extends AbstractPage {
|
||||
|
||||
private String baseUrl = "http://localhost:8081/app";
|
||||
|
||||
@FindBy(id = "account")
|
||||
private WebElement accountLink;
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
driver.navigate().to(baseUrl);
|
||||
@@ -43,6 +49,10 @@ public class AppPage extends AbstractPage {
|
||||
return RequestType.valueOf(driver.getTitle());
|
||||
}
|
||||
|
||||
public void openAccount() {
|
||||
accountLink.click();
|
||||
}
|
||||
|
||||
public enum RequestType {
|
||||
AUTH_RESPONSE, LOGOUT_REQUEST, APP_REQUEST
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
{
|
||||
"name": "test-app",
|
||||
"enabled": true,
|
||||
"baseUrl": "http://localhost:8081/app",
|
||||
"adminUrl": "http://localhost:8081/app/logout",
|
||||
"credentials": [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user