diff --git a/testsuite/src/test/java/org/keycloak/testsuite/ApplicationServlet.java b/testsuite/src/test/java/org/keycloak/testsuite/ApplicationServlet.java index 46667ee772..4202cc1ff7 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/ApplicationServlet.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/ApplicationServlet.java @@ -22,12 +22,19 @@ package org.keycloak.testsuite; import java.io.IOException; +import java.io.PrintWriter; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.utils.URLEncodedUtils; + /** * @author Stian Thorgersen */ @@ -35,7 +42,32 @@ public class ApplicationServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - resp.getWriter().print("Hello world!"); + String title = ""; + String body = ""; + + StringBuffer sb = req.getRequestURL(); + sb.append("?"); + sb.append(req.getQueryString()); + + List 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")) { + title = "LOGOUT_REQUEST"; + } else { + title = "APP_REQUEST"; + } + + PrintWriter pw = resp.getWriter(); + pw.printf("%s%s", title, body); + pw.flush(); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java index 374b93487c..ba9104e4e3 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java @@ -36,7 +36,8 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.models.RealmModel; import org.keycloak.services.models.UserModel; import org.keycloak.services.models.UserModel.RequiredAction; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.RegisterPage; import org.keycloak.testsuite.rule.GreenMailRule; @@ -74,7 +75,7 @@ public class RequiredActionEmailVerificationTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -101,7 +102,7 @@ public class RequiredActionEmailVerificationTest { driver.navigate().to(verificationUrl.trim()); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } @Test @@ -124,7 +125,7 @@ public class RequiredActionEmailVerificationTest { driver.navigate().to(verificationUrl.trim()); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionMultipleActionsTest.java b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionMultipleActionsTest.java index b64f911332..da1b747c67 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionMultipleActionsTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionMultipleActionsTest.java @@ -29,7 +29,8 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.models.RealmModel; import org.keycloak.services.models.UserModel; import org.keycloak.services.models.UserModel.RequiredAction; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginPasswordUpdatePage; import org.keycloak.testsuite.pages.LoginUpdateProfilePage; @@ -63,7 +64,7 @@ public class RequiredActionMultipleActionsTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -93,7 +94,7 @@ public class RequiredActionMultipleActionsTest { Assert.fail("Expected to update password and profile before login"); } - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } public void updatePassword() { diff --git a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionResetPasswordTest.java b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionResetPasswordTest.java index 44f4c98843..77c881406a 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionResetPasswordTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionResetPasswordTest.java @@ -30,6 +30,8 @@ import org.keycloak.services.models.RealmModel; import org.keycloak.services.models.UserModel; import org.keycloak.services.models.UserModel.RequiredAction; import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginPasswordUpdatePage; import org.keycloak.testsuite.rule.GreenMailRule; @@ -69,6 +71,9 @@ public class RequiredActionResetPasswordTest { @WebResource protected OAuthClient oauth; + @WebResource + protected AppPage appPage; + @WebResource protected LoginPage loginPage; @@ -83,7 +88,7 @@ public class RequiredActionResetPasswordTest { changePasswordPage.assertCurrent(); changePasswordPage.changePassword("new-password", "new-password"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); oauth.openLogout(); diff --git a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionTotpSetupTest.java b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionTotpSetupTest.java index 5a95d6435d..e89125e33a 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionTotpSetupTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionTotpSetupTest.java @@ -30,7 +30,8 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.models.RealmModel; import org.keycloak.services.models.UserModel; import org.keycloak.services.models.UserModel.RequiredAction; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginConfigTotpPage; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.RegisterPage; @@ -67,7 +68,7 @@ public class RequiredActionTotpSetupTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -90,7 +91,7 @@ public class RequiredActionTotpSetupTest { totpPage.configure(totp.generate(totpPage.getTotpSecret())); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } @Test @@ -102,7 +103,7 @@ public class RequiredActionTotpSetupTest { totpPage.configure(totp.generate(totpPage.getTotpSecret())); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionUpdateProfileTest.java b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionUpdateProfileTest.java index b6890bbd98..c1fe766de8 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionUpdateProfileTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionUpdateProfileTest.java @@ -29,7 +29,8 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.models.RealmModel; import org.keycloak.services.models.UserModel; import org.keycloak.services.models.UserModel.RequiredAction; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginUpdateProfilePage; import org.keycloak.testsuite.rule.KeycloakRule; @@ -61,7 +62,7 @@ public class RequiredActionUpdateProfileTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -79,7 +80,7 @@ public class RequiredActionUpdateProfileTest { updateProfilePage.update("New first", "New last", "new@email.com"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/forms/AccountTest.java b/testsuite/src/test/java/org/keycloak/testsuite/forms/AccountTest.java index d00d9268b6..bcc0516583 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/forms/AccountTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/forms/AccountTest.java @@ -35,6 +35,8 @@ import org.keycloak.testsuite.OAuthClient; import org.keycloak.testsuite.pages.AccountPasswordPage; import org.keycloak.testsuite.pages.AccountTotpPage; import org.keycloak.testsuite.pages.AccountUpdateProfilePage; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.rule.KeycloakRule; import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup; @@ -60,6 +62,9 @@ public class AccountTest { @WebResource protected OAuthClient oauth; + @WebResource + protected AppPage appPage; + @WebResource protected LoginPage loginPage; @@ -108,7 +113,7 @@ public class AccountTest { loginPage.open(); loginPage.login("test-user@localhost", "new-password"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } @Test diff --git a/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTest.java b/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTest.java index d2a91e345f..d9628df5d4 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTest.java @@ -25,7 +25,8 @@ import org.junit.Assert; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.rule.KeycloakRule; import org.keycloak.testsuite.rule.WebResource; @@ -47,7 +48,7 @@ public class LoginTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -77,7 +78,7 @@ public class LoginTest { loginPage.open(); loginPage.login("test-user@localhost", "password"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTotpTest.java b/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTotpTest.java index e38e958388..6587cab874 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTotpTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/forms/LoginTotpTest.java @@ -33,7 +33,8 @@ import org.keycloak.services.managers.RealmManager; import org.keycloak.services.models.RealmModel; import org.keycloak.services.models.UserCredentialModel; import org.keycloak.services.models.UserModel; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginTotpPage; import org.keycloak.testsuite.rule.GreenMailRule; @@ -76,7 +77,7 @@ public class LoginTotpTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -113,7 +114,7 @@ public class LoginTotpTest { loginTotpPage.login(totp.generate("totpSecret")); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/forms/RegisterTest.java b/testsuite/src/test/java/org/keycloak/testsuite/forms/RegisterTest.java index dfff59c705..4862cf696d 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/forms/RegisterTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/forms/RegisterTest.java @@ -25,7 +25,8 @@ import org.junit.Assert; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; -import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.RegisterPage; import org.keycloak.testsuite.rule.KeycloakRule; @@ -48,7 +49,7 @@ public class RegisterTest { protected WebDriver driver; @WebResource - protected OAuthClient oauth; + protected AppPage appPage; @WebResource protected LoginPage loginPage; @@ -112,7 +113,7 @@ public class RegisterTest { registerPage.register("name", "email", "registerUserSuccess", "password", "password"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/forms/ResetPasswordTest.java b/testsuite/src/test/java/org/keycloak/testsuite/forms/ResetPasswordTest.java index 5ccc1bfdde..8dd56e34a1 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/forms/ResetPasswordTest.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/forms/ResetPasswordTest.java @@ -31,6 +31,8 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.pages.AppPage; +import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginPasswordResetPage; import org.keycloak.testsuite.pages.LoginPasswordUpdatePage; @@ -60,6 +62,9 @@ public class ResetPasswordTest { @WebResource protected OAuthClient oauth; + @WebResource + protected AppPage appPage; + @WebResource protected LoginPage loginPage; @@ -93,7 +98,7 @@ public class ResetPasswordTest { updatePasswordPage.changePassword("new-password", "new-password"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); oauth.openLogout(); @@ -101,7 +106,7 @@ public class ResetPasswordTest { loginPage.login("test-user@localhost", "new-password"); - Assert.assertTrue("Expected authorization response", oauth.isAuthorizationResponse()); + Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountPasswordPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountPasswordPage.java index c52d8f0e9c..b53e88ff9a 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountPasswordPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountPasswordPage.java @@ -22,8 +22,6 @@ package org.keycloak.testsuite.pages; import org.keycloak.testsuite.Constants; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -34,9 +32,6 @@ public class AccountPasswordPage extends Page { private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/test/account/password"; - @WebResource - private WebDriver browser; - @FindBy(id = "password") private WebElement passwordInput; @@ -58,11 +53,11 @@ public class AccountPasswordPage extends Page { } public boolean isCurrent() { - return browser.getPageSource().contains("Change Password"); + return driver.getPageSource().contains("Change Password"); } public void open() { - browser.navigate().to(PATH); + driver.navigate().to(PATH); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java index 77dc68267e..32cfb80689 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountTotpPage.java @@ -22,8 +22,6 @@ package org.keycloak.testsuite.pages; import org.keycloak.testsuite.Constants; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -34,9 +32,6 @@ public class AccountTotpPage extends Page { private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/test/account/totp"; - @WebResource - private WebDriver browser; - @FindBy(id = "totpSecret") private WebElement totpSecret; @@ -56,11 +51,11 @@ public class AccountTotpPage extends Page { } public boolean isCurrent() { - return browser.getPageSource().contains("Google Authenticator Setup"); + return driver.getPageSource().contains("Google Authenticator Setup"); } public void open() { - browser.navigate().to(PATH); + driver.navigate().to(PATH); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountUpdateProfilePage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountUpdateProfilePage.java index fb94414035..c890f2ff72 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountUpdateProfilePage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/AccountUpdateProfilePage.java @@ -22,8 +22,6 @@ package org.keycloak.testsuite.pages; import org.keycloak.testsuite.Constants; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -34,9 +32,6 @@ public class AccountUpdateProfilePage extends Page { private static String PATH = Constants.AUTH_SERVER_ROOT + "/rest/realms/test/account"; - @WebResource - private WebDriver browser; - @FindBy(id = "firstName") private WebElement firstNameInput; @@ -73,11 +68,11 @@ public class AccountUpdateProfilePage extends Page { } public boolean isCurrent() { - return browser.getPageSource().contains("Edit Account"); + return driver.getPageSource().contains("Edit Account"); } public void open() { - browser.navigate().to(PATH); + driver.navigate().to(PATH); } } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/AppPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/AppPage.java new file mode 100644 index 0000000000..4270640740 --- /dev/null +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/AppPage.java @@ -0,0 +1,50 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2012, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.keycloak.testsuite.pages; + + +/** + * @author Stian Thorgersen + */ +public class AppPage extends Page { + + private String baseUrl = "http://localhost:8081/app"; + + @Override + public void open() { + driver.navigate().to(baseUrl); + } + + @Override + public boolean isCurrent() { + return driver.getCurrentUrl().startsWith(baseUrl); + } + + public RequestType getRequestType() { + return RequestType.valueOf(driver.getTitle()); + } + + public enum RequestType { + AUTH_RESPONSE, LOGOUT_REQUEST, APP_REQUEST + } + +} diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginConfigTotpPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginConfigTotpPage.java index d1712c571f..3cfca03986 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginConfigTotpPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginConfigTotpPage.java @@ -21,8 +21,6 @@ */ package org.keycloak.testsuite.pages; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -31,9 +29,6 @@ import org.openqa.selenium.support.FindBy; */ public class LoginConfigTotpPage extends Page { - @WebResource - private WebDriver browser; - @FindBy(id = "totpSecret") private WebElement totpSecret; @@ -53,7 +48,7 @@ public class LoginConfigTotpPage extends Page { } public boolean isCurrent() { - return browser.getTitle().equals("Config TOTP"); + return driver.getTitle().equals("Config TOTP"); } public void open() { diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPage.java index a36ab3abc5..b23dd2bb02 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPage.java @@ -21,6 +21,8 @@ */ package org.keycloak.testsuite.pages; +import org.keycloak.testsuite.OAuthClient; +import org.keycloak.testsuite.rule.WebResource; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -29,6 +31,9 @@ import org.openqa.selenium.support.FindBy; */ public class LoginPage extends Page { + @WebResource + protected OAuthClient oauth; + @FindBy(id = "username") private WebElement usernameInput; diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordResetPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordResetPage.java index b2736f2686..94edee87cc 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordResetPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordResetPage.java @@ -21,8 +21,6 @@ */ package org.keycloak.testsuite.pages; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -31,9 +29,6 @@ import org.openqa.selenium.support.FindBy; */ public class LoginPasswordResetPage extends Page { - @WebResource - private WebDriver browser; - @FindBy(id = "username") private WebElement usernameInput; @@ -51,7 +46,7 @@ public class LoginPasswordResetPage extends Page { } public boolean isCurrent() { - return browser.getTitle().equals("Reset password"); + return driver.getTitle().equals("Reset password"); } public void open() { diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordUpdatePage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordUpdatePage.java index 0546417dd5..100b891c1f 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordUpdatePage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginPasswordUpdatePage.java @@ -21,8 +21,6 @@ */ package org.keycloak.testsuite.pages; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -31,9 +29,6 @@ import org.openqa.selenium.support.FindBy; */ public class LoginPasswordUpdatePage extends Page { - @WebResource - private WebDriver browser; - @FindBy(id = "password-new") private WebElement newPasswordInput; @@ -51,7 +46,7 @@ public class LoginPasswordUpdatePage extends Page { } public boolean isCurrent() { - return browser.getTitle().equals("Update password"); + return driver.getTitle().equals("Update password"); } public void open() { diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginTotpPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginTotpPage.java index 88f91fb251..67b3801c5f 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginTotpPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginTotpPage.java @@ -21,9 +21,7 @@ */ package org.keycloak.testsuite.pages; -import org.keycloak.testsuite.rule.WebResource; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -32,9 +30,6 @@ import org.openqa.selenium.support.FindBy; */ public class LoginTotpPage extends Page { - @WebResource - private WebDriver browser; - @FindBy(id = "totp") private WebElement totpInput; @@ -55,9 +50,9 @@ public class LoginTotpPage extends Page { } public boolean isCurrent() { - if (browser.getTitle().equals("Log in to test")) { + if (driver.getTitle().equals("Log in to test")) { try { - browser.findElement(By.id("totp")); + driver.findElement(By.id("totp")); return true; } catch (Throwable t) { } diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginUpdateProfilePage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginUpdateProfilePage.java index 2a53c0167c..88d41efaa4 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginUpdateProfilePage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/LoginUpdateProfilePage.java @@ -21,8 +21,6 @@ */ package org.keycloak.testsuite.pages; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -31,9 +29,6 @@ import org.openqa.selenium.support.FindBy; */ public class LoginUpdateProfilePage extends Page { - @WebResource - private WebDriver browser; - @FindBy(id = "firstName") private WebElement firstNameInput; @@ -65,7 +60,7 @@ public class LoginUpdateProfilePage extends Page { } public boolean isCurrent() { - return browser.getTitle().equals("Update profile"); + return driver.getTitle().equals("Update profile"); } @Override diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/Page.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/Page.java index 97d49b2539..cb56000a99 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/Page.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/Page.java @@ -22,7 +22,6 @@ package org.keycloak.testsuite.pages; import org.junit.Assert; -import org.keycloak.testsuite.OAuthClient; import org.keycloak.testsuite.rule.WebResource; import org.openqa.selenium.WebDriver; @@ -34,9 +33,6 @@ public abstract class Page { @WebResource protected WebDriver driver; - @WebResource - protected OAuthClient oauth; - public void assertCurrent() { String name = getClass().getSimpleName(); Assert.assertTrue("Exptected " + name + " but was " + driver.getTitle() + " (" + driver.getCurrentUrl() + ")", diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/RegisterPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/RegisterPage.java index 47183315f4..8970704075 100644 --- a/testsuite/src/test/java/org/keycloak/testsuite/pages/RegisterPage.java +++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/RegisterPage.java @@ -21,8 +21,6 @@ */ package org.keycloak.testsuite.pages; -import org.keycloak.testsuite.rule.WebResource; -import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -31,9 +29,6 @@ import org.openqa.selenium.support.FindBy; */ public class RegisterPage extends Page { - @WebResource - private WebDriver browser; - @FindBy(id = "name") private WebElement nameInput; @@ -84,7 +79,7 @@ public class RegisterPage extends Page { } public boolean isCurrent() { - return browser.getTitle().equals("Register with test"); + return driver.getTitle().equals("Register with test"); } @Override