Author: mposolda(a)redhat.com
Date: 2009-07-07 10:33:27 -0400 (Tue, 07 Jul 2009)
New Revision: 13527
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
Log:
LdapIdentityAdminTestCase added.
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-06
21:44:41 UTC (rev 13526)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-07
14:33:27 UTC (rev 13527)
@@ -30,7 +30,7 @@
private final String INP_USER_SEARCH_NEXT = getLoc(casePfx +
"inp.user.search.next",
"//input[contains(@id,'search-user-form1:next-page')]");
private final String SEL_SEARCHUSER_LIMIT = getLoc(casePfx +
"sel.searchuser.limit",
"//select[contains(@id,'search-user-form:limit')]");
- private final String SUB_EDIT_PROF = getLoc(casePfx + "sub.edit.prof",
"//input[contains(@id,'profile-form:submit')]");
+ final String SUB_EDIT_PROF = getLoc(casePfx + "sub.edit.prof",
"//input[contains(@id,'profile-form:submit')]");
private final String SUB_PAGIN_LEFT = getLoc(casePfx + "sub.pagin.left",
INP_USER_SEARCH_PREV);
private final String SUB_PAGIN_RIGHT = getLoc(casePfx + "sub.pagin.right",
INP_USER_SEARCH_NEXT);
@@ -89,7 +89,7 @@
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}'']");
+ final String CHK_ROLE = getLoc(casePfx + "chk.role",
"//input[contains(@name,''assign-roles-form:roles'') and
@value=''{0}'']");
private final String MSG_CREATE_ROLE = getMess(casePfx + "chk.role",
"Create role");
@@ -102,20 +102,20 @@
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);
}
@BeforeMethod(groups = { "log" })
- private void loginBeforeTest() {
+ void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- private void logoutAfterTest() {
+ void logoutAfterTest() {
}
@@ -723,7 +723,7 @@
Assert.assertTrue(selenium.isTextPresent("is an invalid"),"validation
message missing or other than expected");
}
- private void goToEdit(String userName, String userMail) {
+ void goToEdit(String userName, String userMail) {
searchUser(userName, userMail);
int r = findTableRow(TBL_USERLIST, userName, 0);
@@ -957,7 +957,7 @@
}
- private void deleteUser(String username, String email) {
+ void deleteUser(String username, String email) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
@@ -998,7 +998,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(LNK_ADMIN);
@@ -1025,7 +1025,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(LNK_ADMIN);
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java 2009-07-07
14:33:27 UTC (rev 13527)
@@ -0,0 +1,146 @@
+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 ldap1User = "ldap1";
+ private final String ldap1UserPassword = "password";
+ private final String ldap1UserMail = "ldap1(a)portal.com";
+ private final String ldap1Firstname = "Joseph";
+ private final String ldap1Surname = "Berry";
+
+ private final String ldap2User = "ldap2";
+ private final String ldap2UserPassword = "password";
+ private final String ldap2UserMail = "ldap2(a)portal.com";
+ private final String ldap2Firstname = "Cyril";
+ private final String ldap2Surname = "Berry";
+
+ private final String ldapRoleName = "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(ldap1User, ldap1UserMail);
+ Assert.assertTrue(selenium.isTextPresent(ldap1Firstname), "Name " +
ldap1Firstname + " of user " + ldap1User + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(ldap1Surname), "Surname " +
ldap1Surname + " of user " + ldap1User + " was not found on the
page.");
+ final String CHECK_ROLE = MessageFormat.format(CHK_ROLE, ldapRoleName);
+ selenium.click(butUsrRol_id(ldap1User));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role LdapRole is not
correctly assigned to user " + ldap1User + ".");
+ Assert.assertTrue(selenium.isChecked(MessageFormat.format(CHK_ROLE, "User")),
"The role Users is not correctly assigned to user " + ldap1User +
".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"Admin")), "The role Admins is not correctly assigned to user " +
ldap1User + ".");
+
+ // user 'ldap2'
+ searchUser(ldap2User, ldap2UserMail);
+ Assert.assertTrue(selenium.isTextPresent(ldap2Firstname), "Name " +
ldap2Firstname + " of user " + ldap2User + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(ldap2Surname), "Surname " +
ldap2Surname + " of user " + ldap2User + " was not found on the
page.");
+ selenium.click(butUsrRol_id(ldap2User));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role LdapRoleDisplay is not
correctly assigned to user " + ldap2User + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"User")), "The role Users is not correctly assigned to user " +
ldap2User + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"Admin")), "The role Admins is not correctly assigned to user " +
ldap2User + ".");
+ }
+
+ /**
+ * 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(ldap1User, ldap1UserMail);
+ // TODO: add localizators while they will be added to IdentityAdminTestCase.
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:givenname')]").equals(ldap1Firstname));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:familyname')]").equals(ldap1Surname));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:location')]").contains("Brno,
Czechue Republic"));
+ Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:signature')]").equals("This
is signature"));
+ Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:extra')]").contains("This
is content of ldap attribute \"description\""));
+
+ // fill some attributes (homepage should be DB attribute and signature should be LDAP
attribute) and check them.
+ selenium.type("//input[contains(@id,'profile-form:homepage')]",
"http://www.jboss.org/jbossportal");
+ selenium.type("//textarea[contains(@id,'profile-form:signature')]",
"This is updated signature");
+ clickAndWait(SUB_EDIT_PROF);
+ goToEdit(ldap1User, ldap1UserMail);
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:homepage')]").equals("http://www.jboss.org/jbossportal"));
+ Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:signature')]").equals("This
is updated signature"));
+ // Change signature to the original value
+ selenium.type("//textarea[contains(@id,'profile-form:signature')]",
"This is signature");
+ 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(ldap1User, ldap1UserPassword);
+ Assert.assertTrue(selenium.isTextPresent(ldap1UserMail), "Mail " +
ldap1UserMail + " of user " + ldap1User + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(ldap1Firstname), "Name " +
ldap1Firstname + " of user " + ldap1User + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(ldap1Surname), "Surname " +
ldap1Surname + " of user " + ldap1User + " was not found on the
page.");
+ logoutIfPossible();
+
+ // user 'ldap2'
+ login(ldap2User, ldap2UserPassword);
+ Assert.assertTrue(selenium.isTextPresent(ldap2UserMail), "Mail " +
ldap2UserMail + " of user " + ldap2User + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(ldap2Firstname), "Name " +
ldap2Firstname + " of user " + ldap2User + " was not found on the
page.");
+ Assert.assertTrue(selenium.isTextPresent(ldap2Surname), "Surname " +
ldap2Surname + " of user " + ldap2User + " was not found on the
page.");
+ logoutIfPossible();
+ }
+
+}