Author: mposolda(a)redhat.com
Date: 2009-07-09 07:00:44 -0400 (Thu, 09 Jul 2009)
New Revision: 13532
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
Log:
LdapIdentityAdminTestCase added and IdentityAdminTestCase refactored for usage with
LdapIdentityAdminTestCase.
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-09
08:00:21 UTC (rev 13531)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-09
11:00:44 UTC (rev 13532)
@@ -21,7 +21,7 @@
private final String INP_USER_SEARCH_NEXT = getProp(casePfx +
"inp.user.search.next",
"//input[contains(@id,'search-user-form1:next-page')]");
private final String SEL_SEARCHUSER_LIMIT = getProp(casePfx +
"sel.searchuser.limit",
"//select[contains(@id,'search-user-form:limit')]");
- private final String SUB_EDIT_PROF = getProp(casePfx + "sub.edit.prof",
"//input[contains(@id,'profile-form:submit')]");
+ final String SUB_EDIT_PROF = getProp(casePfx + "sub.edit.prof",
"//input[contains(@id,'profile-form:submit')]");
private final String SUB_PAGIN_LEFT = getProp(casePfx + "sub.pagin.left",
INP_USER_SEARCH_PREV);
private final String SUB_PAGIN_RIGHT = getProp(casePfx + "sub.pagin.right",
INP_USER_SEARCH_NEXT);
@@ -90,7 +90,7 @@
return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
}
- private String butUsrRol_id(String userName) {
+ String butUsrRol_id(String userName) {
String table = TBL_USERLIST;
int r = findTableRow(table, userName, 0);
return MessageFormat.format(LNK_T_USRLIST_ROLES, r - 1);
@@ -435,7 +435,16 @@
createUser("user0" + i + "", "useruser",
"user0" + i + "" + "(a)portal.com");
}
}
+
+ void goToEdit(String userName, String userMail) {
+ searchUser(userName, userMail);
+ int r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
+
@Test(enabled = true, description = "Altering the number of rows in user
search")
public void testSearchUserCount() {
@@ -640,7 +649,7 @@
}
- private void deleteUser(String username, String email) {
+ void deleteUser(String username, String email) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
@@ -680,7 +689,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
- private void createRole(String roleName, String roleDisplayName) {
+ void createRole(String roleName, String roleDisplayName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
@@ -707,7 +716,7 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly
created role is missing.");
}
- private void deleteRole(String roleName) {
+ void deleteRole(String roleName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
===================================================================
---
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
(rev 0)
+++
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java 2009-07-09
11:00:44 UTC (rev 13532)
@@ -0,0 +1,145 @@
+package org.jboss.portal.test.selenium;
+
+import java.text.MessageFormat;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * <p>The Class LdapIdentityAdminTestCase is used for testing of admin gui of
JBoss Portal, especially the users and roles part.
+ * And this is the reason while it is derived from IdentityAdminTestCase.
+ *
+ * <p>The assumption is that JBoss Portal identity is configured with Ldap and
users <i>ldap1</i> and <i>ldap2</i> are stored in Ldap directory
with <i>Ldap</i> role too.
+ * The users <i>admin</i>, <i>user</i> and roles
<i>Admins</i>, <i>Users</i> should be also in Ldap directory.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "admin_ui_ldap" }, enabled = true)
+public class LdapIdentityAdminTestCase extends IdentityAdminTestCase {
+
+ private final String LDAP1_USER = "ldap1";
+ private final String LDAP1_USER_PASSWORD = "password";
+ private final String LDAP1_USER_MAIL = "ldap1(a)portal.com";
+ private final String LDAP1_FIRST_NAME = "Joseph";
+ private final String LDAP1_SURNAME = "Berry";
+
+ private final String LDAP2_USER = "ldap2";
+ private final String LDAP2_USER_PASSWORD = "password";
+ private final String LDAP2_USER_MAIL = "ldap2(a)portal.com";
+ private final String LDAP2_FIRST_NAME = "Cyril";
+ private final String LDAP2_SURNAME = "Berry";
+
+ private final String LDAP_ROLE_NAME = "Ldap";
+
+ /**
+ * <p>User (tempUser, tempPassword, tempUser(a)redhat.com) and role (tempRole,
+ * tempRoleDisplay) are created. The role is assigned to the user and it is
+ * asserted by the checked button in user roles.
+ *
+ * <p>First deassignation is not successfull because each role in Ldap should have
at least one user. So
+ * another user (tempUser2) is created and assigned to the tempRole. Then user tempUser
is deassigned successfully
+ * from tempRole.
+ *
+ * <p>At the end of the test both the user and the role are deleted.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testCreateUser",
"testCreateRole" }, description = "Assigning and deassigning of the role to
the user.")
+ public void testAssignRole2User() {
+ String user = "tempUser";
+ String userMail = "tempUser(a)redhat.com";
+ String user2 = "tempUser2";
+ String userMail2 = "tempUser2(a)redhat.com";
+ String role = "tempRole";
+ final String roleDisplayName = "tempRoleDisplay";
+ final String userPass = "tempPassword";
+
+ createUser(user, userPass, userMail);
+ createRole(role, roleDisplayName);
+ assignRole(user, userMail, role, roleDisplayName);
+
+ createUser(user2, userPass, userMail2);
+ assignRole(user2, userMail2, role, roleDisplayName);
+
+ deassignRole(user, userMail, role, roleDisplayName);
+ deleteRole(role);
+ deleteUser(user, userMail);
+ deleteUser(user2, userMail2);
+ }
+
+ /**
+ * This method searches for users 'ldap1' and 'ldap2'. Assumption is
that these users are stored in Ldap directory
+ * with correct settings of their attributes.
+ */
+ @Test(enabled = true, description = "Searching for users from ldap and testing his
roles.")
+ public void testSearchLdapUsers() {
+ // user 'ldap1'
+ searchUser(LDAP1_USER, LDAP1_USER_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_FIRST_NAME), "Name " +
LDAP1_FIRST_NAME + " of user " + LDAP1_USER + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_SURNAME), "Surname " +
LDAP1_SURNAME + " of user " + LDAP1_USER + " was not found on the
page.");
+ final String CHECK_ROLE = MessageFormat.format(CHK_ROLE, LDAP_ROLE_NAME);
+ selenium.click(butUsrRol_id(LDAP1_USER));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role LdapRole is not
correctly assigned to user " + LDAP1_USER + ".");
+ Assert.assertTrue(selenium.isChecked(MessageFormat.format(CHK_ROLE, "User")),
"The role Users is not correctly assigned to user " + LDAP1_USER +
".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"Admin")), "The role Admins is not correctly assigned to user " +
LDAP1_USER + ".");
+
+ // user 'ldap2'
+ searchUser(LDAP2_USER, LDAP2_USER_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_FIRST_NAME), "Name " +
LDAP2_FIRST_NAME + " of user " + LDAP2_USER + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_SURNAME), "Surname " +
LDAP2_SURNAME + " of user " + LDAP2_USER + " was not found on the
page.");
+ selenium.click(butUsrRol_id(LDAP2_USER));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role LdapRoleDisplay is not
correctly assigned to user " + LDAP2_USER + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"User")), "The role Users is not correctly assigned to user " +
LDAP2_USER + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"Admin")), "The role Admins is not correctly assigned to user " +
LDAP2_USER + ".");
+ }
+
+ /**
+ * This method searches for users 'ldap1' and 'ldap2'. Then check and
edit their user profiles.
+ * Both attributes from Ldap directory and from database are changed. Assumption is that
these users are stored in
+ * Ldap directory with correct settings of their attributes.
+ */
+ @Test(enabled = true, description = "Searching for users from Ldap and checking
their user profiles.")
+ public void testUserProfilesOfLdapUsers() {
+ // Go to edit page and check user profile
+ goToEdit(LDAP1_USER, LDAP1_USER_MAIL);
+ // TODO: add localizators while they will be added to IdentityAdminTestCase.
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:givenname')]").equals(LDAP1_FIRST_NAME),
"First name should be " + LDAP1_FIRST_NAME + " but is " +
selenium.getValue("//input[contains(@id,'profile-form:givenname')]"));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:lastname')]").equals(LDAP1_SURNAME),
"Surname should be " + LDAP1_SURNAME + " but is " +
selenium.getValue("//input[contains(@id,'profile-form:lastname')]"));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:location')]").contains("Brno,
Czechue Republic"), "Location should contains Brno,Czechue Republic but is
" +
selenium.getValue("//input[contains(@id,'profile-form:location')]"));
+ Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:extra')]").contains("This
is content of ldap attribute \"description\""), "Description has value
" +
selenium.getValue("//textarea[contains(@id,'profile-form:extra')]"));
+
+ // fill some attributes (homepage should be DB attribute and givenname should be LDAP
attribute) and check them.
+ selenium.type("//input[contains(@id,'profile-form:givenname')]",
"Jack");
+ selenium.type("//input[contains(@id,'profile-form:homepage')]",
"http://www.jboss.org/jbossportal");
+ clickAndWait(SUB_EDIT_PROF);
+ goToEdit(LDAP1_USER, LDAP1_USER_MAIL);
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:givenname')]").equals("Jack"),
"First name should be Jack but is " +
selenium.getValue("//input[contains(@id,'profile-form:givenname')]"));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:homepage')]").equals("http://www.jboss.org/jbossportal"),
"Homepage should be
http://www.jboss.org/jbossportal but is " +
selenium.getValue("//input[contains(@id,'profile-form:homepage')]"));
+ // Change name to the original value
+ selenium.type("//input[contains(@id,'profile-form:givenname')]",
LDAP1_FIRST_NAME);
+ clickAndWait(SUB_EDIT_PROF);
+ }
+
+ /**
+ * This method tries to login as user 'ldap1' and as user 'ldap2'.
Assumption is that these users are stored in Ldap directory
+ * with correct settings of their attributes including user passwords.
+ */
+ @Test(enabled = true, description = "Trying to login as user from Ldap.")
+ public void testLoginAsLdapUsers() {
+ logoutIfPossible();
+ // user 'ldap1'
+ login(LDAP1_USER, LDAP1_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_USER_MAIL), "Mail " +
LDAP1_USER_MAIL + " of user " + LDAP1_USER + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_FIRST_NAME), "Name " +
LDAP1_FIRST_NAME + " of user " + LDAP1_USER + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_SURNAME), "Surname " +
LDAP1_SURNAME + " of user " + LDAP1_USER + " was not found on the
page.");
+ logoutIfPossible();
+
+ // user 'ldap2'
+ login(LDAP2_USER, LDAP2_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_USER_MAIL), "Mail " +
LDAP2_USER_MAIL + " of user " + LDAP2_USER + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_FIRST_NAME), "Name " +
LDAP2_FIRST_NAME + " of user " + LDAP2_USER + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_SURNAME), "Surname " +
LDAP2_SURNAME + " of user " + LDAP2_USER + " was not found on the
page.");
+ logoutIfPossible();
+ }
+
+}