Author: vrockai
Date: 2009-05-11 09:19:01 -0400 (Mon, 11 May 2009)
New Revision: 13338
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java
Log:
[selenium] mposolda sso tests
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -0,0 +1,219 @@
+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 UserRolesHelperTestCase {
+
+ /** 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";
+
+ 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 -");
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * This method tests couple of bad login attempts 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:adminadmin" , "cyril:cyril", "cyril:password"
+ */
+ @Test(enabled = true)
+ public void badLoginsToCAS() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, "adminadmin");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH));
+ tryToLogin(PORTAL_CYRIL_USERNAME, "cyril");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH));
+ tryToLogin(PORTAL_CYRIL_USERNAME, "password");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH));
+ }
+
+ /**
+ * 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:
+ * "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));
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE));
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD));
+ // 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));
+ // go to default portal and logout
+ openAndWait(ADR_PORTAL_DEFAULT);
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE));
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL));
+ }
+
+ /**
+ * 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));
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT));
+ // going to default portal. Everythink should be ok.
+ openAndWait(ADR_PORTAL_DEFAULT);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_USER_USERNAME));
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE));
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD));
+ // logout (redirected to CAS page)
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE));
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL));
+ }
+
+ /**
+ * 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);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME));
+ logoutIfPossible();
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL));
+ }
+
+ /**
+ * 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 stuff 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));
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE));
+ // 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));
+ clickAndWait(LINK_COPY_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD));
+ 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));
+ 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));
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE));
+ Assert.assertTrue(selenium.isElementPresent(LINK_ADMIN));
+ }
+
+ /**
+ * 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));
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE));
+ }
+
+ /**
+ * 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(ADDR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (selenium.isElementPresent(LINK_LOGOUT)) {
+ selenium.click(LINK_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE));
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL));
+ }
+ }
+
+}
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -0,0 +1,206 @@
+package org.jboss.portal.test.selenium.sso;
+
+import java.text.MessageFormat;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+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 UserRolesHelperTestCase {
+
+ /** 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";
+
+ 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 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 -");
+
+ @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));
+ tryToLogin(PORTAL_JOSEPH_USERNAME, "joseph");
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH));
+ // 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));
+ }
+
+ /**
+ * 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));
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD));
+ // 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));
+ // go to default portal and logout
+ openAndWait(ADR_PORTAL_DEFAULT);
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGIN));
+ }
+
+ /**
+ * 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));
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT));
+ // going to default portal. Everythink should be ok.
+ openAndWait(ADR_PORTAL_DEFAULT);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_USER_USERNAME));
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD));
+ // logout
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGIN));
+ }
+
+ /**
+ * 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);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME));
+ logout();
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ }
+
+ /**
+ * 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));
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ // 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));
+ clickAndWait(LINK_COPY_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD));
+ 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));
+ logout();
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ }
+
+ /**
+ * 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));
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
+ Assert.assertTrue(selenium.isElementPresent(LINK_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));
+ }
+
+ /**
+ * 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/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -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));
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN_USERNAME, EXAMPLE_ADMIN_PASSWORD);
+ Assert.assertTrue("false".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)));
+
+ // 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));
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN));
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ADMIN));
+ // 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)));
+ Assert.assertTrue(EXAMPLE_ADMIN_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)));
+ }
+
+ /**
+ * 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)));
+ // login to example app as user
+ logIntoExampleApp(EXAMPLE_USER_USERNAME, EXAMPLE_USER_PASSWORD);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)));
+ Assert.assertTrue(EXAMPLE_USER_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)));
+
+ // Check portal. 'admin' is still logged in. Not user.
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME));
+ // go to example and logout
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_USER_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)));
+ clickAndWait(EXAMPLE_LOGOUT);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)));
+
+ // Check portal. 'admin' is still logged in.
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME));
+ }
+
+ /**
+ * 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));
+
+ // 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));
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN));
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ADMIN));
+ // 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));
+ Assert.assertEquals(JMX_AGENT_VIEW, selenium.getText(JMX_TITLE_ELEMENT));
+ }
+
+}
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -0,0 +1,91 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+class TomcatSSOValveTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.tomcat.";
+
+ 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.user.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","link=Dashboard");
+
+ 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";
+
+ 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 -");
+
+ /**
+ * 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));
+ Assert.assertEquals(JMX_AGENT_VIEW, selenium.getText(JMX_TITLE_ELEMENT));
+ }
+
+ /**
+ * 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)));
+ Assert.assertTrue(username.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)));
+ }
+
+ /**
+ * 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)));
+ }
+ }
+
+}
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -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));
+
+ // 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)));
+
+ // going to portal. 'logged in as: admin' page is shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
PORTAL_ADMIN_USERNAME));
+
+ // 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));
+ }
+
+ /**
+ * 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));
+
+ // 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)));
+
+ // going to portal. 'logged in as: admin' is shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE +
EXAMPLE_ADMIN2_USERNAME));
+ clickAndWait(LNK_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(LNK_WSRP));
+
+ // 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)));
+ }
+
+ /**
+ * 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)));
+ clickAndWait(EXAMPLE_LOGOUT);
+
+ // Check if logout from portal
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN));
+ }
+
+}
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -0,0 +1,63 @@
+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));
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ openAndWait("http://localhost:8080" + ADR_JMX_CONSOLE);
+ Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE));
+ Assert.assertEquals(JMX_AGENT_VIEW, selenium.getText(JMX_TITLE_ELEMENT));
+ // 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));
+ Assert.assertFalse(JMX_AGENT_VIEW.equals(selenium.getText(JMX_TITLE_ELEMENT)));
+ }
+
+ /**
+ * 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));
+ // 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));
+ // 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));
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java 2009-05-11
13:19:01 UTC (rev 13338)
@@ -0,0 +1,178 @@
+package org.jboss.portal.test.selenium.sso;
+
+import java.text.MessageFormat;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+class UserRolesHelperTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "iden.man.";
+
+ 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 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) {
+ 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.");
+
+ // TODO: refactor this
+ // Assert.assertTrue(selenium.isTextPresent("Joseph"), "Role Joseph is
not present.");
+ selenium.click("_jbpnsIdentityAdminPortletWindowsnpbj:j_id28:register-role-form:roles:2");
+ selenium.click("_jbpnsIdentityAdminPortletWindowsnpbj:j_id28:register-role-form:roles:1");
+ 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);
+ }
+}