Author: mposolda(a)redhat.com
Date: 2009-07-09 11:41:36 -0400 (Thu, 09 Jul 2009)
New Revision: 13533
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
Log:
SSO selenium test classes merged to the epp branch.
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,246 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class CASSeleniumTestCase is reponsible for testing of the JBoss Portal with
cooperation of CAS (Central Authentication Service).
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "CAS
selenium test case.")
+public class CASSeleniumTestCase extends SSOSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.cas.";
+
+ private final String PORTAL_ADMIN_USERNAME = "admin";
+ private final String PORTAL_ADMIN_PASSWORD = "admin";
+ private final String PORTAL_USER_USERNAME = "user";
+ private final String PORTAL_USER_PASSWORD = "user";
+ private final String PORTAL_CYRIL_USERNAME = "cyril";
+ private final String PORTAL_CYRIL_PASSWORD = "password";
+ private final String PORTAL_CYRIL_MAIL = "cyril(a)redhat.com";
+ private final String PORTAL_CYRIL_ROLE = "Cyril";
+
+ // TODO: uncomment and remove getProp part
+
+ /*private final String ADR_PORTAL =
getLoc(casePfx+"adr.portal","/portal");
+ private final String ADR_PORTAL_ADMIN =
getLoc(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
+ private final String ADR_PORTAL_DEFAULT =
getLoc(casePfx+"adr.portal.default","/portal/auth/portal/default");
+
+ private final String LINK_LOGIN = getLoc(casePfx+"lnk.login",
"link=Login");
+ private final String LINK_ADMIN = getLoc(casePfx+"lnk.admin",
"link=Admin");
+ private final String LINK_WEATHER = getLoc(casePfx+"lnk.weather",
"link=Weather");
+ private final String LINK_COPY_DASHBOARD = getLoc(casePfx+"lnk.cp.dashboard",
"link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD =
getLoc(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getLoc(casePfx+"lnk.dashboard",
"link=Dashboard");
+ private final String LINK_LOGOUT = getLoc(casePfx+"lnk.logout",
"link=Logout");
+ private final String FORBIDDEN_ELEMENT = getLoc(casePfx+"forbidden.element",
"//h1");
+
+ private final String CAS_INPUT_USERNAME = getLoc(casePfx +
"cas.input.username", "username");
+ private final String CAS_INPUT_PASSWORD = getLoc(casePfx +
"cas.input.password", "password");
+ private final String CAS_SUBMIT_LOGIN = getLoc(casePfx + "cas.submit.login",
"//input[@value='LOGIN']");
+ private final String CAS_IMAGE = getLoc(casePfx + "cas.image",
"//img[@alt='Central Authentication Service']");
+
+ private final String CAS_INVALID_AUTH = getMess(casePfx +
"cas.invalid.auth", "The credentials you provided cannot be determined to
be authentic.");
+ private final String CAS_LOGIN_MESSAGE = getMess(casePfx +
"cas.login.mess", "Enter your JA-SIG NetID and Password.");
+ private final String CAS_LOGOUT_SUCCESSFULL = getMess(casePfx +
"cas.logout.succ", "Logout successful");
+
+ private final String PORTAL_LOGGED_IN_AS_MESSAGE = getMess(casePfx +
"logged.in.mess", "Logged in as: ");
+ private final String PORTAL_FORBIDDEN_MESS = getMess(casePfx +
"forbidden.mess", "HTTP Status 403 -");*/
+
+ private final String ADR_PORTAL =
getProp(casePfx+"adr.portal","/portal");
+ private final String ADR_PORTAL_ADMIN =
getProp(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
+ private final String ADR_PORTAL_DEFAULT =
getProp(casePfx+"adr.portal.default","/portal/auth/portal/default");
+
+ private final String LINK_LOGIN = getProp(casePfx+"lnk.login",
"link=Login");
+ private final String LINK_ADMIN = getProp(casePfx+"lnk.admin",
"link=Admin");
+ private final String LINK_WEATHER = getProp(casePfx+"lnk.weather",
"link=Weather");
+ private final String LINK_COPY_DASHBOARD = getProp(casePfx+"lnk.cp.dashboard",
"link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD =
getProp(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getProp(casePfx+"lnk.dashboard",
"link=Dashboard");
+ private final String LINK_LOGOUT = getProp(casePfx+"lnk.logout",
"link=Logout");
+ private final String FORBIDDEN_ELEMENT = getProp(casePfx+"forbidden.element",
"//h1");
+
+ private final String CAS_INPUT_USERNAME = getProp(casePfx +
"cas.input.username", "username");
+ private final String CAS_INPUT_PASSWORD = getProp(casePfx +
"cas.input.password", "password");
+ private final String CAS_SUBMIT_LOGIN = getProp(casePfx +
"cas.submit.login", "//input[@value='LOGIN']");
+ private final String CAS_IMAGE = getProp(casePfx + "cas.image",
"//img[@alt='Central Authentication Service']");
+
+ private final String CAS_INVALID_AUTH = getProp(casePfx +
"cas.invalid.auth", "The credentials you provided cannot be determined to
be authentic.");
+ private final String CAS_LOGIN_MESSAGE = getProp(casePfx +
"cas.login.mess", "Enter your JA-SIG NetID and Password.");
+ private final String CAS_LOGOUT_SUCCESSFULL = getProp(casePfx +
"cas.logout.succ", "Logout successful");
+
+ private final String PORTAL_LOGGED_IN_AS_MESSAGE = getProp(casePfx +
"logged.in.mess", "Logged in as: ");
+ private final String PORTAL_FORBIDDEN_MESS = getProp(casePfx +
"forbidden.mess", "HTTP Status 403 -");
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * This method tests couple of bad login attempts with usage of CAS.
+ * After click to "Login" link from portal, the user is redirected to CAS
login screen and then he tries to login with credentials:
+ * "admin:adminadmin" , "cyril:cyril", "cyril:password"
+ */
+ @Test(enabled = true)
+ public void badLoginsToCAS() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, "adminadmin");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH), "Message about invalid
credentials should be shown.");
+ tryToLogin(PORTAL_CYRIL_USERNAME, "cyril");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH), "Message about invalid
credentials should be shown.");
+ tryToLogin(PORTAL_CYRIL_USERNAME, "password");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH), "Message about invalid
credentials should be shown.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of CAS.
+ * After click to "Login" link from portal, the user is redirected to CAS
login screen and then he tries to login with credentials:
+ * "user:user". He is logged in and then he goes to some page. He tries the
admin portal, but he ends with 403 error. Then he is logged out. After
+ * logging out, he should be redirected to default portal page.
+ */
+ @Test(enabled = true)
+ public void loginAsUserAndLoggedOut() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_USER_USERNAME), "Message about 'Logged in as:' should be shown. But
it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be
shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link
'configure dashboard' should be shown.");
+ // try to go to "admin" portal. This must end with 403 error, because user
doesn't have permission to go to this portal.
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT),
"Forbidden message should be shown while trying to go to 'admin'
portal.");
+ // go to default portal and logout
+ openAndWait(ADR_PORTAL_DEFAULT);
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown
after logout from JBoss Portal.");
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout
successfull message should be shown on CAS page.");
+ }
+
+ /**
+ * After opening URL like:
http://localhost:8080/portal/auth/portal/admin the user
should be redirected to CAS login page.
+ * The User "user" should have 403 error while trying to go to admin portal,
but he should be able to go to
http://localhost:8080/portal/auth/portal/default
+ */
+ @Test(enabled = true)
+ public void loginAsUserWhileGoingToAuthURL() {
+ // 403 error after trying to go to admin portal as user
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown
while trying to access admin portal.");
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT),
"Forbidden message should be shown while trying to go to 'admin'
portal.");
+ // going to default portal. Everythink should be ok.
+ openAndWait(ADR_PORTAL_DEFAULT);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_USER_USERNAME), "Message about 'Logged in as:' should be shown. But
it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be
shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link
'configure dashboard' should be shown.");
+ // logout (redirected to CAS page)
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown
after logout from JBoss Portal.");
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout
successfull message should be shown on CAS page.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of CAS.
+ * After clicks to "Login" link from portal, the user is redirected to CAS
login screen and then he tries to login with credentials:
+ * "admin:admin". He is logged in and then he goes to admin portal, and he
creates role "Cyril" and user "cyril" with password
"password". Then admin logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "badLoginsToCAS" })
+ public void loginAsAdminAndCreateNewRoleAndUser() {
+ loginToPortalAsAdmin();
+ createRole(PORTAL_CYRIL_ROLE, PORTAL_CYRIL_ROLE);
+ createUser(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_PASSWORD, PORTAL_CYRIL_MAIL,
PORTAL_CYRIL_ROLE);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown.
But it's not here.");
+ logoutIfPossible();
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout
successfull message should be shown on CAS page.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of CAS.
+ * After clicks to "Login" link from portal the user is redirected to CAS
login screen and then he tries to login with credentials:
+ * "cyril:cyril", which is bad and then "cyril:password" which is
good. Then cyril tries to do some dashboard operations and then logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = {
"loginAsAdminAndCreateNewRoleAndUser" })
+ public void loginAsCyrilAndPlayWithDashboard() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_CYRIL_USERNAME), "Message about 'Logged in as: cyril' should be shown.
But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be
shown after successfull login.");
+ // TODO: uncomment this after fixing the CMS bug with Access denied
+ // Assert.assertFalse(selenium.isTextPresent("Access Denied"));
+ waitFor(3000);
+ clickAndWait(LINK_WEATHER);
+ Assert.assertTrue(selenium.isElementPresent(LINK_COPY_DASHBOARD), "Link 'copy
to dashboard' should be shown.");
+ clickAndWait(LINK_COPY_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link
'configure dashboard' should be shown.");
+ logoutIfPossible();
+ }
+
+ /**
+ * This test loggs admin in and then admin deletes Cyril role and cyril user. Then
logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "loginAsCyrilAndPlayWithDashboard"
})
+ public void deleteCyrilRoleAndUser() {
+ loginToPortalAsAdmin();
+ deleteRole(PORTAL_CYRIL_ROLE);
+ deleteUser(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown.
But it's not here.");
+ logoutIfPossible();
+ }
+
+ /**
+ * Loggs into portal as admin with usage of CAS.
+ */
+ private void loginToPortalAsAdmin() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown.
But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be
shown after successfull login.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_ADMIN), "Link to admin portal
should be shown when admin is logged to JBoss Portal.");
+ }
+
+ /**
+ * This helper method is used to open portal page (
http://localhost:8080/portal) then
click to 'Login' link and verifies if
+ * CAS login page is shown. Method shouldn't be called when some user is logged into
portal.
+ */
+ private void openPortalAndClickToLogin() {
+ openAndWait(ADR_PORTAL);
+ clickAndWait(LINK_LOGIN);
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGIN_MESSAGE), "CAS page should be
shown after click to 'login' link in JBoss Portal.");
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown
after click to 'login' link in JBoss Portal.");
+ }
+
+ /**
+ * This method tries to login into CAS. The condition is, that CAS login page is shown
when this method is called.
+ * Any test (whether login was success or not) are not performed during this method.
+ * @param username
+ * @param password
+ */
+ private void tryToLogin(String username, String password) {
+ selenium.type(CAS_INPUT_USERNAME, username);
+ selenium.type(CAS_INPUT_PASSWORD, password);
+ clickAndWait(CAS_SUBMIT_LOGIN);
+ }
+
+ /**
+ * Overriden method. Because after click to logout, the CAS page is shown.
+ */
+ @Test(enabled = false)
+ public void logoutIfPossible() {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (selenium.isElementPresent(LINK_LOGOUT)) {
+ selenium.click(LINK_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown
after logout from JBoss Portal.");
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout
successfull message should be shown on CAS page.");
+ }
+ }
+
+}
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,347 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class JOSSOSeleniumTestCase is reponsible for testing of the JBoss Portal with
cooperation of JOSSO (Java Open Single Sign On).
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "JOSSO
selenium test case.")
+public class JOSSOSeleniumTestCase extends SSOSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.josso.";
+
+ private final String PORTAL_ADMIN_USERNAME = "admin";
+ private final String PORTAL_ADMIN_PASSWORD = "admin";
+ private final String PORTAL_USER_USERNAME = "user";
+ private final String PORTAL_USER_PASSWORD = "user";
+ private final String PORTAL_JOSEPH_USERNAME = "joseph";
+ private final String PORTAL_JOSEPH_PASSWORD = "password";
+ private final String PORTAL_JOSEPH_MAIL = "joseph(a)redhat.com";
+ private final String PORTAL_JOSEPH_ROLE = "Joseph";
+
+ // TODO: uncomment and remove getProp part
+
+ /*private final String ADR_PORTAL =
getLoc(casePfx+"adr.portal","/portal");
+ private final String ADR_PORTAL_ADMIN =
getLoc(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
+ private final String ADR_PORTAL_DEFAULT =
getLoc(casePfx+"adr.portal.default","/portal/auth/portal/default");
+ private final String ADR_PORTAL_SESSION_TEST =
getLoc(casePfx+"adr.portal.test.session","/portal/auth/portal/default/Test/Session+test");
+
+ private final String LINK_LOGIN = getLoc(casePfx+"lnk.login",
"link=Login");
+ private final String LINK_ADMIN = getLoc(casePfx+"lnk.admin",
"link=Admin");
+ private final String LINK_WEATHER = getLoc(casePfx+"lnk.weather",
"link=Weather");
+ private final String LINK_COPY_DASHBOARD = getLoc(casePfx+"lnk.cp.dashboard",
"link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD =
getLoc(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getLoc(casePfx+"lnk.dashboard",
"link=Dashboard");
+ private final String LINK_LOGOUT = getLoc(casePfx+"lnk.logout",
"link=Logout");
+ private final String FORBIDDEN_ELEMENT = getLoc(casePfx+"forbidden.element",
"//h1");
+
+ private final String JOSSO_INPUT_USERNAME = getLoc(casePfx +
"josso.input.username", "josso_username");
+ private final String JOSSO_INPUT_PASSWORD = getLoc(casePfx +
"josso.input.password", "josso_password");
+ private final String JOSSO_SUBMIT_LOGIN = getLoc(casePfx +
"josso.submit.login", "//input[@value='Login']");
+ private final String JOSSO_IMAGE = getLoc(casePfx + "josso.image",
"//img[@alt='Java Open Single SignOn']");
+
+ private final String JOSSO_INVALID_AUTH = getMess(casePfx +
"josso.invalid.auth", "Invalid Authentication Information");
+
+ private final String PORTAL_LOGGED_IN_AS_MESSAGE = getMess(casePfx +
"logged.in.mess", "Logged in as: ");
+ private final String PORTAL_FORBIDDEN_MESS = getMess(casePfx +
"forbidden.mess", "HTTP Status 403 -");
+ private final String PORTAL_SESSION_TEST_NO_SESSION =
getMess("samples.ses.no", "No session");
+ private final String PORTAL_SESSION_TEST_ID = getMess("samples.ses.id",
"Session id");
+
+ public final String TBL_CMS_FILE = getLoc("cms.file.tbl.cms.file",
"//div[@id='center']/div/div/div[3]/table");
+
+ private final long SESSION_TIMEOUT = 60000;
+ private final long SESSION_TIMEOUT_WAITING = SESSION_TIMEOUT + 30000; // It's
session timeout and some additional time to wait for session timeout
+ private final String SES_SUB_PSCOPE = getLoc("samples.ses.sub.pscope",
"portlet");
+ private final String SES_INP_VAL = getLoc("samples.ses.inp.val",
"value");
+ private final String SES_INP_NAM = getLoc("samples.ses.inp.nam",
"name");
+ */
+
+ private final String ADR_PORTAL =
getProp(casePfx+"adr.portal","/portal");
+ private final String ADR_PORTAL_ADMIN =
getProp(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
+ private final String ADR_PORTAL_DEFAULT =
getProp(casePfx+"adr.portal.default","/portal/auth/portal/default");
+ private final String ADR_PORTAL_SESSION_TEST =
getProp(casePfx+"adr.portal.test.session","/portal/auth/portal/default/Test/Session+test");
+
+ private final String LINK_LOGIN = getProp(casePfx+"lnk.login",
"link=Login");
+ private final String LINK_ADMIN = getProp(casePfx+"lnk.admin",
"link=Admin");
+ private final String LINK_WEATHER = getProp(casePfx+"lnk.weather",
"link=Weather");
+ private final String LINK_COPY_DASHBOARD = getProp(casePfx+"lnk.cp.dashboard",
"link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD =
getProp(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getProp(casePfx+"lnk.dashboard",
"link=Dashboard");
+ private final String LINK_LOGOUT = getProp(casePfx+"lnk.logout",
"link=Logout");
+ private final String FORBIDDEN_ELEMENT = getProp(casePfx+"forbidden.element",
"//h1");
+
+ private final String JOSSO_INPUT_USERNAME = getProp(casePfx +
"josso.input.username", "josso_username");
+ private final String JOSSO_INPUT_PASSWORD = getProp(casePfx +
"josso.input.password", "josso_password");
+ private final String JOSSO_SUBMIT_LOGIN = getProp(casePfx +
"josso.submit.login", "//input[@value='Login']");
+ private final String JOSSO_IMAGE = getProp(casePfx + "josso.image",
"//img[@alt='Java Open Single SignOn']");
+
+ private final String JOSSO_INVALID_AUTH = getProp(casePfx +
"josso.invalid.auth", "Invalid Authentication Information");
+
+ private final String PORTAL_LOGGED_IN_AS_MESSAGE = getProp(casePfx +
"logged.in.mess", "Logged in as: ");
+ private final String PORTAL_FORBIDDEN_MESS = getProp(casePfx +
"forbidden.mess", "HTTP Status 403 -");
+ private final String PORTAL_SESSION_TEST_NO_SESSION =
getProp("samples.ses.no", "No session");
+ private final String PORTAL_SESSION_TEST_ID = getProp("samples.ses.id",
"Session id");
+
+ public final String TBL_CMS_FILE = getProp("cms.file.tbl.cms.file",
"//div[@id='center']/div/div/div[3]/table");
+
+ private final long SESSION_TIMEOUT = 60000;
+ private final long SESSION_TIMEOUT_WAITING = SESSION_TIMEOUT + 30000; // It's
session timeout and some additional time to wait for session timeout
+ private final String SES_SUB_PSCOPE = getProp("samples.ses.sub.pscope",
"portlet");
+ private final String SES_INP_VAL = getProp("samples.ses.inp.val",
"value");
+ private final String SES_INP_NAM = getProp("samples.ses.inp.nam",
"name");
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * This method tests couple of bad login attempts with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO
login screen and then he tries to login with credentials:
+ * "admin:adminadmin" , "joseph:joseph",
"joseph:password"
+ */
+ @Test(enabled = true)
+ public void badLoginsToJOSSO() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, "adminadmin");
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH), "Message about
invalid credentials should be shown.");
+ tryToLogin(PORTAL_JOSEPH_USERNAME, "joseph");
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH), "Message about
invalid credentials should be shown.");
+ // Joseph is not created right now, so authentication can't be good
+ tryToLogin(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH), "Message about
invalid credentials should be shown.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO
login screen and then he tries to login with credentials:
+ * "user:user". He is logged in and then he goes to some page. He tries the
admin portal, but he ends with 403 error. Then he is logged out. After
+ * logging out, he should be redirected to default portal page.
+ */
+ @Test(enabled = true)
+ public void loginAsUserAndLoggedOut() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_USER_USERNAME), "Message about 'Logged in as: user' should be shown.
But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link
'configure dashboard' should be shown.");
+ // try to go to "admin" portal. This must end with 403 error, because user
doesn't have permission to go to this portal.
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT),
"Forbidden message should be shown while trying to go to 'admin'
portal.");
+ // go to default portal and logout
+ openAndWait(ADR_PORTAL_DEFAULT);
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull logout.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGIN), "Link 'login'
should be shown on JBoss Portal while user logges out.");
+ }
+
+ /**
+ * After opening URL like:
http://localhost:8080/portal/auth/portal/admin the user
should be redirected to JOSSO login page.
+ * The User "user" should have 403 error while trying to go to admin portal,
but he should be able to go to
http://localhost:8080/portal/auth/portal/default
+ */
+ @Test(enabled = true)
+ public void loginAsUserWhileGoingToAuthURL() {
+ // 403 error after trying to go to admin portal as user
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull login.");
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT),
"Forbidden message should be shown while trying to go to 'admin'
portal.");
+ // going to default portal. Everythink should be ok.
+ openAndWait(ADR_PORTAL_DEFAULT);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_USER_USERNAME), "Message about 'Logged in as: user' should be shown.
But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link
'configure dashboard' should be shown.");
+ // logout
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull logout.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGIN), "Link 'login'
should be shown on JBoss Portal while user logges out.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO
login screen and then he tries to login with credentials:
+ * "admin:admin". He is logged in and then he goes to admin portal, and he
creates role "Joseph" and user "joseph" with password
"password". Then admin logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "badLoginsToJOSSO" })
+ public void loginAsAdminAndCreateNewRoleAndUser() {
+ loginToPortalAsAdmin();
+ createRole(PORTAL_JOSEPH_ROLE, PORTAL_JOSEPH_ROLE);
+ createUser(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD, PORTAL_JOSEPH_MAIL,
PORTAL_JOSEPH_ROLE);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: joseph' should be
shown. But it's not here.");
+ logout();
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull logout.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO
login screen and then he tries to login with credentials:
+ * "joseph:joseph", which is bad and then "joseph:password" which is
good. Then joseph tries to do some dashboard stuff and then logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = {
"loginAsAdminAndCreateNewRoleAndUser" })
+ public void loginAsJosephAndPlayWithDashboard() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_JOSEPH_USERNAME), "Message about 'Logged in as: joseph' should be
shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull login.");
+ // TODO: uncomment this after fixing the CMS bug with Access denied
+ // Assert.assertFalse(selenium.isTextPresent("Access Denied"));
+ waitFor(3000);
+ clickAndWait(LINK_WEATHER);
+ Assert.assertTrue(selenium.isElementPresent(LINK_COPY_DASHBOARD), "Link 'copy
dashboard' should be present.");
+ clickAndWait(LINK_COPY_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link
'configure dashboard' should be present.");
+ logout();
+ }
+
+ /**
+ * This test loggs admin in and then admin deletes Joseph role and joseph user. Then
logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "loginAsJosephAndPlayWithDashboard"
})
+ public void deleteJosephRoleAndUser() {
+ loginToPortalAsAdmin();
+ deleteRole(PORTAL_JOSEPH_ROLE);
+ deleteUser(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown.
But it's not here.");
+ logout();
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull logout.");
+ }
+
+ /**
+ * This test loggs admin and then wait for 90 seconds. The session invalidates because
portal is configured to Session timeout
+ * for only one minute.
+ * The user should be directly logged in even if session invalidates, because of JOSSO
cookie (JOSSO_SESSIONID).
+ */
+ @Test(enabled = true)
+ public void loginAfterSessionTimeout() {
+ loginToPortalAsAdmin();
+ // Go to session test and put some attribute to portlet scope
+ openAndWait(ADR_PORTAL_SESSION_TEST);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_SESSION_TEST_NO_SESSION), "Sign
'No session' should be in session test, but it isn't.");
+ selenium.type(SES_INP_NAM, "scope1");
+ selenium.type(SES_INP_VAL, "scopeval1");
+ selenium.click(SES_SUB_PSCOPE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_SESSION_TEST_ID), "Sign about
session should be in session test, but it isn't. Session should be present.");
+
+ // waiting 90 seconds until session timeout occurs
+ waitFor(SESSION_TIMEOUT_WAITING);
+ // Session is invalidated but user is automatically logged in without need of coming to
JOSSO console
+ openAndWait(ADR_PORTAL_SESSION_TEST);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_SESSION_TEST_NO_SESSION), "Sign
'No session' should be in session test, but it isn't.");
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be still
here after session timeout. But it's not here.");
+ }
+
+ /**
+ * Simple file creation. File named "newFile" is created in the root directory
of CMS module with main action selector.
+ * This test is used for testing CMS file creation while portal is configured for
integration with JOSSO
+ *
+ */
+ @Test(enabled = true, description = "Simple file creation.")
+ public void testCreateFile() {
+ loginToPortalAsAdmin();
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type("filename", "newFile");
+ selenium.type("description", "newFile description");
+ selenium.type("title", "newFile title");
+ //elenium.select("language", "label=Czech");
+ selenium.click("save");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals("newFile", selenium.getText("link=newFile"),
"newFile should be created and shown in CMS directory.");
+ }
+
+ /**
+ * File creation and copying to default directory. File named "file2copy" is
created in the root directory. Then the file is copied into the default directory.
+ * It's tested that creation and copying of file is good with JOSSO integration.
+ */
+ @Test(enabled = true, description = "File creation and copying to default
directory.")
+ public void testCopyFile() {
+ loginToPortalAsAdmin();
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select("//div[@id='center']/div/div/div[1]/div/select",
"label=Create File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type("filename", "file2copy");
+ selenium.type("description", "file2copy description");
+ selenium.type("title", "file2copy title");
+ selenium.click("save");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertEquals("text/plain",
selenium.getText("link=text/plain"), "Link text/plain should be
here.");
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals("file2copy",
selenium.getText("link=file2copy"), "File file2copy should be
here.");
+
+ int row = findTableRow(TBL_CMS_FILE, "file2copy", 0) + 1;
+
+ selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr["
+ row + "]/td[2]/form/select", "label=Copy");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[" +
row + "]/td[2]/form/select/option[3]");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[" +
row + "]/td[2]/form/input");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=default");
+ selenium.click("submit");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=default");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent("link=file2copy"), "Link
'file2copy' should be her but it isn't.");
+
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent("link=file2copy"), "Link
file2copy should be here but it isn't.");
+ }
+
+ /**
+ * Loggs into portal as admin with usage of JOSSO.
+ */
+ private void loginToPortalAsAdmin() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should be shown. But
it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not
be shown after successfull login to JBoss Portal.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_ADMIN), "Link 'admin'
should be present when user is logged as admin.");
+ }
+
+ /**
+ * This helper method is used to open portal page (
http://localhost:8080/portal) then
click to 'Login' link and verifies if
+ * JOSSO login page is shown. Method shouldn't be called when some user is logged
into portal.
+ */
+ private void openPortalAndClickToLogin() {
+ openAndWait(ADR_PORTAL);
+ clickAndWait(LINK_LOGIN);
+ Assert.assertTrue(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should be
shown after click to 'login' link on JBoss Portal.");
+ }
+
+ /**
+ * This method tries to login into JOSSO. The condition is, that JOSSO login page is
shown when this method is called.
+ * Any test (whether login was success or not) are not performed during this method.
+ * @param username
+ * @param password
+ */
+ private void tryToLogin(String username, String password) {
+ selenium.type(JOSSO_INPUT_USERNAME, username);
+ selenium.type(JOSSO_INPUT_PASSWORD, password);
+ clickAndWait(JOSSO_SUBMIT_LOGIN);
+ }
+
+}
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,226 @@
+package org.jboss.portal.test.selenium.sso;
+
+import java.text.MessageFormat;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+/**
+ * The class is used for inheritance by other SSO test cases (CASSeleniumTestCase,
JOSSOSeleniumTestCase, ...) It contains helper methods
+ * for manipulation with users and roles (creating new user, creating role, delete user,
etc.) nad other stuff which is
+ * shared by all SSO test cases.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+class SSOSeleniumTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "iden.man.";
+
+ // TODO: uncomment and remove getProp part
+
+ /*private final String TBL_ROLELIST = getLoc(casePfx + "tbl.rolelist",
"//table[contains(@id,'roles-form:userlist')]");
+
+ private final String LNK_T_ROLLIST_DEL = getLoc(casePfx + "lnk.t.rollist.del",
"//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
+
+ private final String SUB_CONF_CREATE_USER = getLoc(casePfx +
"sub.conf.create.user",
"//input[contains(@id,'confirm-form:admin')]");
+ private final String SUB_DELETE_ROLE = getLoc(casePfx + "sub.delete.role",
"//input[contains(@id,'delete-role-form:confirm')]");
+ private final String SUB_ROLE_CREATE = getLoc(casePfx + "sub.role.create",
"//input[contains(@id,'create-role-form:submit')]");
+ private final String INP_ROLEDISNAME = getLoc(casePfx + "inp.roledisname",
"//input[contains(@id,'create-role-form:roledisplayname')]");
+ private final String INP_ROLENAME = getLoc(casePfx + "inp.rolename",
"//input[contains(@id,'create-role-form:rolename')]");
+ private final String TBL_USERLIST = getLoc(casePfx + "tbl.userlist",
"//table[contains(@id,'search-user-form1:userlist')]");
+ private final String LNK_ROLE_CREATE = getLoc(casePfx + "lnk.role.create",
"//a[contains(@id, 'create-role-form:create-role-link')]");
+ private final String SUB_DEL_USER = getLoc(casePfx + "sub.del.user",
"//input[contains(@id,'delete-user-form:submit')]");
+
+ private final String SUB_USER_ROLE = getLoc(casePfx + "sub.user.role",
"//input[contains(@id,'register-role-form:submit')]");
+ private final String SUB_CREATE_USER = getLoc(casePfx + "sub.create.user",
"//input[contains(@id,'register-form:submit')]");
+ private final String INP_PASSWORD_CHK = getLoc(casePfx + "inp.password.chk",
"//input[contains(@id,'register-form:passwordCheck')]");
+ private final String INP_PASSWORD = getLoc(casePfx + "inp.password",
"//input[contains(@id,'register-form:password')]");
+ private final String INP_USEREMAIL = getLoc(casePfx + "inp.useremail",
"//input[contains(@id,'register-form:email')]");
+ private final String INP_USERNAME = getLoc(casePfx + "inp.username",
"//input[contains(@id,'register-form:username')]");
+ private final String SUB_SEARCH_USER = getLoc(casePfx + "sub.search.user",
"//input[contains(@id,'search-user-form:search') and
@type='submit']");
+ private final String INP_SEARCH_USER = getLoc(casePfx + "inp.search.user",
"//input[contains(@id,'search-user-form:searchString')]");
+ private final String LNK_SEARCH_USER = getLoc(casePfx + "lnk.search.user",
"//a[contains(@id,'user-form:search-user-link')]");
+ private final String LNK_USERTAB = getLoc(casePfx + "lnk.usertab",
"//a[contains(@id,'role-temp-form:manage-users')]");
+ private final String LNK_USERMAIN = getLoc(casePfx + "lnk.usermain",
"//a[contains(@id,'user-temp-form1:user-adm-link')]");
+ private final String LNK_T_USRLIST_DEL = getLoc(casePfx + "lnk.t.usrlist.del",
"//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
+ private final String LNK_ROLETAB = getLoc(casePfx + "lnk.roletab",
"//a[contains(@id,'user-temp-form:role-mgm-link')]");
+
+ private final String LNK_ROLEMAIN = getLoc(casePfx + "lnk.rolemain",
"//a[contains(@id, 'role-temp-form1:role-admin-link')]");
+ private final String LNK_USERMANG_MAIN = getLoc(casePfx + "lnk.usermang.main",
"//a[contains(@id,'user-temp-form1:assign-role-link')]");
+ private final String LNK_USERMANG_MAIN2 = getLoc(casePfx +
"lnk.usermang.main2",
"//a[contains(@id,'user-temp-form1:user-mgm-link')]");
+ private final String LNK_CREATE_USER = getLoc(casePfx + "lnk.create.user",
"//a[contains(@id,':user-form:create-user-link')]");
+
+ //private final String CHK_ROLE = getLoc(casePfx + "chk.role",
"//input[contains(@name,''assign-roles-form:roles'') and
@value=''{0}'']");
+ private final String CHK_REGISTER_ROLE = getLoc(casePfx + "chk.reg.role",
"//input[contains(@name,''register-role-form:roles'') and
@value=''{0}'']");*/
+
+ private final String TBL_ROLELIST = getProp(casePfx + "tbl.rolelist",
"//table[contains(@id,'roles-form:userlist')]");
+
+ private final String LNK_T_ROLLIST_DEL = getProp(casePfx +
"lnk.t.rollist.del",
"//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
+
+ private final String SUB_CONF_CREATE_USER = getProp(casePfx +
"sub.conf.create.user",
"//input[contains(@id,'confirm-form:admin')]");
+ private final String SUB_DELETE_ROLE = getProp(casePfx + "sub.delete.role",
"//input[contains(@id,'delete-role-form:confirm')]");
+ private final String SUB_ROLE_CREATE = getProp(casePfx + "sub.role.create",
"//input[contains(@id,'create-role-form:submit')]");
+ private final String INP_ROLEDISNAME = getProp(casePfx + "inp.roledisname",
"//input[contains(@id,'create-role-form:roledisplayname')]");
+ private final String INP_ROLENAME = getProp(casePfx + "inp.rolename",
"//input[contains(@id,'create-role-form:rolename')]");
+ private final String TBL_USERLIST = getProp(casePfx + "tbl.userlist",
"//table[contains(@id,'search-user-form1:userlist')]");
+ private final String LNK_ROLE_CREATE = getProp(casePfx + "lnk.role.create",
"//a[contains(@id, 'create-role-form:create-role-link')]");
+ private final String SUB_DEL_USER = getProp(casePfx + "sub.del.user",
"//input[contains(@id,'delete-user-form:submit')]");
+
+ private final String SUB_USER_ROLE = getProp(casePfx + "sub.user.role",
"//input[contains(@id,'register-role-form:submit')]");
+ private final String SUB_CREATE_USER = getProp(casePfx + "sub.create.user",
"//input[contains(@id,'register-form:submit')]");
+ private final String INP_PASSWORD_CHK = getProp(casePfx + "inp.password.chk",
"//input[contains(@id,'register-form:passwordCheck')]");
+ private final String INP_PASSWORD = getProp(casePfx + "inp.password",
"//input[contains(@id,'register-form:password')]");
+ private final String INP_USEREMAIL = getProp(casePfx + "inp.useremail",
"//input[contains(@id,'register-form:email')]");
+ private final String INP_USERNAME = getProp(casePfx + "inp.username",
"//input[contains(@id,'register-form:username')]");
+ private final String SUB_SEARCH_USER = getProp(casePfx + "sub.search.user",
"//input[contains(@id,'search-user-form:search') and
@type='submit']");
+ private final String INP_SEARCH_USER = getProp(casePfx + "inp.search.user",
"//input[contains(@id,'search-user-form:searchString')]");
+ private final String LNK_SEARCH_USER = getProp(casePfx + "lnk.search.user",
"//a[contains(@id,'user-form:search-user-link')]");
+ private final String LNK_USERTAB = getProp(casePfx + "lnk.usertab",
"//a[contains(@id,'role-temp-form:manage-users')]");
+ private final String LNK_USERMAIN = getProp(casePfx + "lnk.usermain",
"//a[contains(@id,'user-temp-form1:user-adm-link')]");
+ private final String LNK_T_USRLIST_DEL = getProp(casePfx +
"lnk.t.usrlist.del",
"//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
+ private final String LNK_ROLETAB = getProp(casePfx + "lnk.roletab",
"//a[contains(@id,'user-temp-form:role-mgm-link')]");
+
+ private final String LNK_ROLEMAIN = getProp(casePfx + "lnk.rolemain",
"//a[contains(@id, 'role-temp-form1:role-admin-link')]");
+ private final String LNK_USERMANG_MAIN = getProp(casePfx +
"lnk.usermang.main",
"//a[contains(@id,'user-temp-form1:assign-role-link')]");
+ private final String LNK_USERMANG_MAIN2 = getProp(casePfx +
"lnk.usermang.main2",
"//a[contains(@id,'user-temp-form1:user-mgm-link')]");
+ private final String LNK_CREATE_USER = getProp(casePfx + "lnk.create.user",
"//a[contains(@id,':user-form:create-user-link')]");
+
+ //private final String CHK_ROLE = getProp(casePfx + "chk.role",
"//input[contains(@name,''assign-roles-form:roles'') and
@value=''{0}'']");
+ private final String CHK_REGISTER_ROLE = getProp(casePfx + "chk.reg.role",
"//input[contains(@name,''register-role-form:roles'') and
@value=''{0}'']");
+
+ private final long SEARCH_TIMEOUT = 10000;
+
+ protected void createRole(String roleName, String roleDisplayName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_ROLE_CREATE), "Button for role
creating has wrong id or doesn't exist.");
+ //Assert.assertEquals(selenium.getText(LNK_ROLE_CREATE), "Create role",
"Button for role creating has wrong label.");
+ selenium.click(LNK_ROLE_CREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("Role"), "Label for role name
not present or incorrect.");
+ selenium.type(INP_ROLENAME, roleName);
+ Assert.assertTrue(selenium.isTextPresent("Display name"), "Label for
display role name not present or incorrect.");
+ selenium.type(INP_ROLEDISNAME, roleDisplayName);
+ selenium.click(SUB_ROLE_CREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(roleName), "Name of newly created role is
missing.");
+ Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly
created role is missing.");
+ }
+
+ protected void deleteRole(String roleName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ Assert.assertTrue(selenium.isTextPresent(roleName), "Role name is missing");
+
+ int r = findTableRow(TBL_ROLELIST, roleName, 0);
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_DEL, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Warning! You are about to delete the
role '" + roleName + "'"),
+ "Confirmation text for role deletion missing missing.");
+ selenium.click(SUB_DELETE_ROLE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
+
+ protected void createUser(String userName, String userPass, String userMail, String
roleToRegister) {
+ selenium.open("/portal/auth/portal/default");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_USERTAB);
+ clickIfVisible(LNK_USERMAIN);
+ selenium.click(LNK_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("Username *"), "Label for
username input is wrong or missing.");
+ selenium.type(INP_USERNAME, userName);
+ Assert.assertTrue(selenium.isTextPresent("E-Mail *"), "Label for e-mail
input is wrong or missing.");
+ selenium.type(INP_USEREMAIL, userMail);
+ Assert.assertTrue(selenium.isTextPresent("Password *"), "Label for
password input is wrong or missing.");
+ selenium.type(INP_PASSWORD, userPass);
+ Assert.assertTrue(selenium.isTextPresent("Confirm Password *"), "Label
for password confirm input is wrong or missing.");
+ selenium.type(INP_PASSWORD_CHK, userPass);
+
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent("This username is already taken.
tempUser"), "User already exists.");
+ Assert.assertTrue(selenium.isTextPresent(roleToRegister), "Role " +
roleToRegister + " is not present.");
+ // register Cyril (or Joseph) role
+ String checkRole = MessageFormat.format(CHK_REGISTER_ROLE , roleToRegister);
+ selenium.click(checkRole);
+ // deregister User role
+ checkRole = MessageFormat.format(CHK_REGISTER_ROLE , "User");
+ selenium.click(checkRole);
+ clickAndWait(SUB_USER_ROLE);
+
+ Assert.assertTrue(selenium.isTextPresent("Confirmation"), "Confirmation
screen is missing or corrupted.");
+ selenium.click(SUB_CONF_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("User created"), "User was not
created (\"User created\" text missing).");
+
+ }
+
+ protected void deleteUser(String username, String email) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_USERTAB);
+ // user home page
+ clickIfVisible(LNK_USERMAIN);
+ clickIfVisible(LNK_USERMANG_MAIN);
+ clickIfVisible(LNK_USERMANG_MAIN2);
+
+ selenium.click(LNK_SEARCH_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_SEARCH_USER, username);
+ selenium.click(SUB_SEARCH_USER);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(SEARCH_TIMEOUT);
+ Assert.assertTrue(selenium.isTextPresent(username), "Username was not
found.");
+ Assert.assertTrue(selenium.isTextPresent(email), "User e-mail adress was not
found.");
+
+ selenium.click(butDelUsr_id(username));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_DEL_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("User deleted"), "user was not
deleted (\"User deleted\" text missing).");
+ }
+
+ private String butDelUsr_id(String userName) {
+ String table = TBL_USERLIST;
+ int r = findTableRow(table, userName, 0);
+ return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
+ }
+}
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,116 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TomcatSSOValveDisabledTestCase is reponsible for testing of the Tomcat SSO
Valve when the valve is disabled.
+ * It uses JBoss Portal with TomcatSSOValveExampleApp (sample third-party web
application) and jmx-console application. Various scenarios of tests are performed.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "Tomcat SSO
valve disabled test case.")
+public class TomcatSSOValveDisabledTestCase extends TomcatSSOValveTestCase {
+
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ logoutFromExampleIfPossible();
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApplication and then check if nobody is logged into
portal.
+ * After login to JBoss Portal and logout from it, the user is still logged in
TomcatSSOValveExampleApplication.
+ */
+ @Test(enabled = true)
+ public void loginInExampleAndCheckPortalNotLogged() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in
JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN_USERNAME, EXAMPLE_ADMIN_PASSWORD);
+ Assert.assertTrue("false".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)),
"User 'admin' shouldn't be in role 'Authorized' but it seems that
he is in this role.");
+
+ // going to portal. 'logged in as:' page is not shown, because user still not
logged in portal. Only to example app
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE), "'Logged in
as' sign is shown which is bad. User shouldn't be logged to JBoss Portal but it
seems that he is logged in.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Link 'login'
should be present in JBoss Portal.");
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ADMIN), "Link 'admin'
should be in the portal page while user 'admin' is logged.");
+ // logout from portal
+ logout();
+ // Going to example app. User is still logged in even if not logged in the portal.
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"User should be still logged to example application but it seems that he is not
logged.");
+ Assert.assertTrue(EXAMPLE_ADMIN_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)),
"User 'admin' should be logged to example application but it seems that he is
not logged.");
+ }
+
+ /**
+ * Login to JBoss Portal and then check if nobody is logged into
TomcatSSOValveExampleApp.
+ * After login to example application as "user", the "admin" is
still logged in JBOss Portal.
+ */
+ @Test(enabled = true)
+ public void loginIntoPortalAndCheckExample() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME));
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ // Going to example app. User is not logged in even if logged in the portal.
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"Nobody should be logged in TomcatSSOValveExampleApp but it seems that user is logged
in.");
+ // login to example app as user
+ logIntoExampleApp(EXAMPLE_USER_USERNAME, EXAMPLE_USER_PASSWORD);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"User 'user' should be logged in example app, but it seems that he is not
logged.");
+ Assert.assertTrue(EXAMPLE_USER_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)),
"User 'user' should be logged in example app, but it seems that he is not
logged.");
+
+ // Check portal. 'admin' is still logged in. Not user.
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME),
"User 'admin' should be logged in JBoss Portal, but it seems that he is not
logged.");
+ // go to example and logout
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_USER_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)),
"User 'user' should be logged in example app, but it seems that he is not
logged.");
+ clickAndWait(EXAMPLE_LOGOUT);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"Nobody should be logged in TomcatSSOValveExampleApp but it seems that user is logged
in.");
+
+ // Check portal. 'admin' is still logged in.
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME),
"User 'admin' should be logged in JBoss Portal, but it seems that he is not
logged.");
+ }
+
+ /**
+ * Login to jmx-console and then check if nobody is logged in JBoss Portal.
+ * After login and logour from JBoss Portal, the user is still logged in jmx-console
web application.
+ */
+ @Test(enabled = true)
+ public void loginToJMXConsoleAndCheckPortal() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "admin should not be logged in JBoss Portal but it seems that
he is logged in.");
+
+ // login to jmx console
+ loginToJMXConsole(JMX_ADMIN_USERNAME, JMX_ADMIN_PASSWORD);
+
+ // going to portal. 'logged in as:' page is not shown, because user still not
logged in portal. Only to example app
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE), "Nobody should be
logged in JBoss Portal but it seems that user is logged in.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Nobody should be logged
in JBoss Portal but it seems that user is logged in.");
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ADMIN), "Link 'admin'
should be in the portal page while user 'admin' is logged.");
+ // logout from portal
+ logout();
+ // Going to example app. User is still logged in even if not logged in the portal.
+ openAndWait(ADR_JMX_CONSOLE);
+ Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE), "User should be logged to
JMX console but it seems that he is not logged.");
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW),
"User should be logged to JMX console but it seems that he is not logged.");
+ }
+
+}
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,128 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+/**
+ *
+ * Helper class which is used for inheritance by other TomcatSSOValve test classes. This
class contains constants and some basic functions like login
+ * to JMX console via selenium, login to TomcatSSOValveExampleApp etc.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+class TomcatSSOValveTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.tomcatvalve.";
+
+ // TODO: uncomment and remove getProp part
+
+ /*
+ protected final String ADR_PORTAL =
getLoc(casePfx+"adr.portal","/portal");
+ protected final String ADR_EXAMPLE =
getLoc(casePfx+"adr.example","/TomcatSSOValveExampleApp");
+ protected final String ADR_JMX_CONSOLE =
getLoc(casePfx+"adr.jmx","/jmx-console/");
+ protected final String EXAMPLE_TITLE_ELEMENT =
getLoc(casePfx+"ex.title","//h1");
+ protected final String EXAMPLE_INP_USERNAME =
getLoc(casePfx+"ex.inp.username","j_username");
+ protected final String EXAMPLE_INP_PASSWORD =
getLoc(casePfx+"ex.inp.password","j_password");
+ protected final String EXAMPLE_LOGIN =
getLoc(casePfx+"ex.login","//input[@value='Login']");
+ protected final String EXAMPLE_LOGOUT =
getLoc(casePfx+"ex.logout","//input[@value='Logout']");
+ protected final String EXAMPLE_LOGGED_USER_OUTPUT =
getLoc(casePfx+"ex.logged.user.label","//tr[1]/td[2]/b");
+ protected final String EXAMPLE_AUTHORIZED_ROLE_OUTPUT =
getLoc(casePfx+"ex.logged.role.auth.label","//tr[4]/td[2]/b");
+ protected final String JMX_TITLE_ELEMENT = getLoc(casePfx+"jmx.title.element",
"//h1");
+ protected final String JMX_IMAGE = getLoc(casePfx+"jmx.image",
"//img[@alt='JBoss']");
+
+ protected final String LNK_LOGIN =
getLoc(casePfx+"lnk.login","link=Login");
+ protected final String LNK_LOGOUT =
getLoc(casePfx+"lnk.logout","link=Logout");
+ protected final String LNK_DEFAULT =
getLoc(casePfx+"lnk.default","link=default");
+ protected final String LNK_ADMIN =
getLoc(casePfx+"lnk.admin","link=Admin");
+ protected final String LNK_WSRP =
getLoc(casePfx+"lnk.wsrp","link=WSRP");
+ protected final String LNK_DASHBOARD =
getLoc(casePfx+"lnk.default.dashboard","link=Dashboard");
+
+ protected final String EXAMPLE_LOGIN_FORM =
getMess(casePfx+"example.login.form", "Login form");
+ protected final String EXAMPLE_TITLE_OUTPUT =
getMess(casePfx+"example.title.output", "Tomcat SSO valve example
servlet");
+ protected final String LOGGED_IN_AS_MESSAGE =
getMess(casePfx+"logged.in.mess", "Logged in as: ");
+ protected final String JMX_AGENT_VIEW = getMess(casePfx+"jmx.agnview",
"JMX Agent View");
+ protected final String PORTAL_FORBIDDEN_MESS = getMess(casePfx +
"forbidden.mess", "HTTP Status 403 -");
+ */
+
+ protected final String ADR_PORTAL =
getProp(casePfx+"adr.portal","/portal");
+ protected final String ADR_EXAMPLE =
getProp(casePfx+"adr.example","/TomcatSSOValveExampleApp");
+ protected final String ADR_JMX_CONSOLE =
getProp(casePfx+"adr.jmx","/jmx-console/");
+ protected final String EXAMPLE_TITLE_ELEMENT =
getProp(casePfx+"ex.title","//h1");
+ protected final String EXAMPLE_INP_USERNAME =
getProp(casePfx+"ex.inp.username","j_username");
+ protected final String EXAMPLE_INP_PASSWORD =
getProp(casePfx+"ex.inp.password","j_password");
+ protected final String EXAMPLE_LOGIN =
getProp(casePfx+"ex.login","//input[@value='Login']");
+ protected final String EXAMPLE_LOGOUT =
getProp(casePfx+"ex.logout","//input[@value='Logout']");
+ protected final String EXAMPLE_LOGGED_USER_OUTPUT =
getProp(casePfx+"ex.logged.user.label","//tr[1]/td[2]/b");
+ protected final String EXAMPLE_AUTHORIZED_ROLE_OUTPUT =
getProp(casePfx+"ex.logged.role.auth.label","//tr[4]/td[2]/b");
+ protected final String JMX_TITLE_ELEMENT =
getProp(casePfx+"jmx.title.element", "//h1");
+ protected final String JMX_IMAGE = getProp(casePfx+"jmx.image",
"//img[@alt='JBoss']");
+
+ protected final String LNK_LOGIN =
getProp(casePfx+"lnk.login","link=Login");
+ protected final String LNK_LOGOUT =
getProp(casePfx+"lnk.logout","link=Logout");
+ protected final String LNK_DEFAULT =
getProp(casePfx+"lnk.default","link=default");
+ protected final String LNK_ADMIN =
getProp(casePfx+"lnk.admin","link=Admin");
+ protected final String LNK_WSRP =
getProp(casePfx+"lnk.wsrp","link=WSRP");
+ protected final String LNK_DASHBOARD =
getProp(casePfx+"lnk.default.dashboard","link=Dashboard");
+
+ protected final String EXAMPLE_LOGIN_FORM =
getProp(casePfx+"example.login.form", "Login form");
+ protected final String EXAMPLE_TITLE_OUTPUT =
getProp(casePfx+"example.title.output", "Tomcat SSO valve example
servlet");
+ protected final String LOGGED_IN_AS_MESSAGE =
getProp(casePfx+"logged.in.mess", "Logged in as: ");
+ protected final String JMX_AGENT_VIEW = getProp(casePfx+"jmx.agnview",
"JMX Agent View");
+ protected final String PORTAL_FORBIDDEN_MESS = getProp(casePfx +
"forbidden.mess", "HTTP Status 403 -");
+
+ protected final String EXAMPLE_ADMIN_USERNAME = "admin";
+ protected final String EXAMPLE_ADMIN_PASSWORD = "password";
+ protected final String EXAMPLE_ADMIN2_USERNAME = "admin2";
+ protected final String EXAMPLE_ADMIN2_PASSWORD = "password";
+ protected final String EXAMPLE_USER_USERNAME = "user";
+ protected final String EXAMPLE_USER_PASSWORD = "password";
+ protected final String PORTAL_ADMIN_USERNAME = "admin";
+ protected final String PORTAL_ADMIN_PASSWORD = "admin";
+ protected final String JMX_ADMIN_USERNAME = "admin";
+ protected final String JMX_ADMIN_PASSWORD = "admin";
+ protected final String PORTAL_USER_USERNAME = "user";
+ protected final String PORTAL_USER_PASSWORD = "user";
+
+ /**
+ * Login to jmx-console web application with usage of selenium framework.
+ *
+ * @param user
+ * @param password
+ */
+ protected void loginToJMXConsole(String user, String password) {
+ // TODO: this probably doesn't work in IE. So disable test while working with IE.
+ openAndWait("http://" + user + ":" + password +
"@localhost:8080" + ADR_JMX_CONSOLE);
+ Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE), "User should be logged to
JMX console but it seems that he is not logged.");
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW),
"User should be logged to JMX console but it seems that he is not logged.");
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApp (sample third-party application)
+ *
+ * @param username
+ * @param password
+ */
+ protected void logIntoExampleApp(String username, String password) {
+ openAndWait(ADR_EXAMPLE);
+ selenium.type(EXAMPLE_INP_USERNAME, username);
+ selenium.type(EXAMPLE_INP_PASSWORD, password);
+ clickAndWait(EXAMPLE_LOGIN);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"User should be logged to TomcatSSOValveExampleApp but it seems that he is not
logged.");
+ Assert.assertTrue(username.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)),
"User should be logged to TomcatSSOValveExampleApp but it seems that he is not
logged.");
+ }
+
+ /**
+ * Logout from TomcatSSOValveExampleApp
+ */
+ protected void logoutFromExampleIfPossible() {
+ selenium.open(ADR_EXAMPLE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (selenium.isElementPresent(EXAMPLE_LOGOUT)) {
+ selenium.click(EXAMPLE_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"User should be logged out from TomcatSSOValveExampleApp.");
+ }
+ }
+
+}
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,95 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TomcatSSOValveWithExampleTestCase is reponsible for testing of the Tomcat
SSO Valve. This class is responsible for testing
+ * with Tomcat SSO valve enabled and uses JBoss Portal with TomcatSSOValveExampleApp
(sample third-party web application)
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "Tomcat SSO
valve success test case.")
+public class TomcatSSOValveWithExampleTestCase extends TomcatSSOValveTestCase {
+
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApp and then going to JBoss Portal. The user
"admin", who loggs in TomcatSSOValveExampleApp is logged
+ * in JBoss Portal too. After logout from JBoss Portal, the user is signed-off also in
TomcatSSOValveExampleApp.
+ * This testCase uses "admin" user, who have only role "Admin" but
not "Authenticated" in TomcatSSOValveExampleApp and so he is not enable to do
everythink
+ * in JBoss Portal (After going to some page, the user should have 'Forbidden'
error).
+ */
+ @Test(enabled = true)
+ public void loginInExampleAndCheckPortalUnauthorized() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in
JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN_USERNAME, EXAMPLE_ADMIN_PASSWORD);
+ // user should not be in Authorized role
+ Assert.assertTrue("false".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)),
"User 'admin' shouldn't be in role 'Authorized' but it seems that
he is in this role.");
+
+ // going to portal. 'logged in as: admin' page is shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME),
"User 'admin' should be logged in JBoss Portal.");
+
+ // The error 403 - forbidden should be thrown by portal when user clicks to some link
on the page
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS), "Page 403 -
forbidden should be shown but it seems that it isn't.");
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApp and then going to JBoss Portal. The user
"admin2", who loggs in TomcatSSOValveExampleApp is logged
+ * in JBoss Portal too. After logout from JBoss Portal, the user is signed-off also in
TomcatSSOValveExampleApp.
+ * This testCase uses "admin2" user, who have both roles "Admin" and
"Authenticated" in TomcatSSOValveExampleApp and so he is enable to do
everythink
+ * in JBoss Portal (This user has admin privileges in JBoss Portal).
+ */
+ @Test(enabled = true)
+ public void loginInExampleAndCheckPortalAuthorized() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in
JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN2_USERNAME, EXAMPLE_ADMIN2_PASSWORD);
+ // user should be in Authorized role
+ Assert.assertTrue("true".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)),
"User 'admin2' should be in role 'Authorized' but it seems that he
isn't.");
+
+ // going to portal. 'logged in as: admin' is shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
EXAMPLE_ADMIN2_USERNAME), "User 'admin2' should be logged in JBoss
Portal.");
+ clickAndWait(LNK_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(LNK_WSRP), "Link to 'wsrp'
page should be shown on admin portal. But this link is not here.");
+
+ // logout from portal and check if logout from example app
+ clickAndWait(LNK_LOGOUT);
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)),
"User should not be logged in TomcatSSOValveExampleApp, but it seems that he is still
logged.");
+ }
+
+ /**
+ * After login in JBoss Portal as "admin", the user should be logged in
TomcatSSOValveExampleApp too.
+ */
+ @Test(enabled = true)
+ public void loginInPortalAndCheckExample() {
+ // login to portal as admin
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ // open example app and chek if login and check Authorized role. Then logout
+ selenium.open(ADR_EXAMPLE);
+ Assert.assertTrue("true".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)),
"User 'admin' should be in 'Authorized' role but it seems that he
isn't.");
+ clickAndWait(EXAMPLE_LOGOUT);
+
+ // Check if logout from portal
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Nobody should be logged
in JBoss Portal but it seems that user is still logged in.");
+ }
+
+}
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java 2009-07-09
15:41:36 UTC (rev 13533)
@@ -0,0 +1,62 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TomcatSSOValveWithJMXConsoleTestCase is reponsible for testing of the Tomcat
SSO Valve. This class is responsible for testing
+ * with Tomcat SSO valve enabled and uses JBoss Portal with jmx-console application.
Various scenarios of tests are performed.
+ *
+ * JMX Console is configured to roles JBossAdmin and Admin can see it (so authentication
in portal enables access to JMX Console)
+ * roles.properties of JMX console looks like: admin=JBossAdmin,HttpInvoker,Admin
+ * Authenticated role is missing, so login to JMX Console doesn't enable full access
to JBoss portal (after click to something in JBoss portal, 403 is thrown)
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "Tomcat SSO
valve success test case.")
+public class TomcatSSOValveWithJMXConsoleTestCase extends TomcatSSOValveTestCase {
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * Login to portal as admin and then see jmx-console application. Admin from JBoss
Portal is authorized to see jmx-console application.
+ * After logout from portal and login as "user", then access to jmx-console is
forbidden.
+ */
+ @Test(enabled = true)
+ public void loginInPortalAndCheckConsole() {
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in
JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ openAndWait("http://localhost:8080" + ADR_JMX_CONSOLE);
+ Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE), "User should be logged to
JMX console but it seems that he is not logged.");
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW),
"User should be logged to JMX console but it seems that he is not logged.");
+ // logout from portal and login as user
+ logout();
+ login(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ openAndWait("http://localhost:8080" + ADR_JMX_CONSOLE);
+ // user is not authorized to see JMX console
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS), "Page 403 -
forbidden should be shown but it seems that it isn't.");
+ }
+
+ /**
+ * Login to jmx-console and then user should be logged in JBoss Portal too.
+ */
+ @Test(enabled = true)
+ public void loginInConsoleAndCheckPortal() {
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in
JBoss Portal. Admin shouldn't be logged in, but it seems that he is
logged.");
+ // TODO: this probably doesn't work in IE. So disable test while working with IE.
+ loginToJMXConsole(JMX_ADMIN_USERNAME, JMX_ADMIN_PASSWORD);
+
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME),
"Message 'Logged in as: admin' should be shown in JBoss Portal. Admin should
be logged in, but it seems that he is not logged.");
+ // The error 403 - forbidden should be thrown by portal when user clicks to some link
on the page
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS), "Page 403 -
forbidden should be shown but it seems that it isn't.");
+ }
+}