aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-12-29 13:53:39 +0000
committerOlivier Lamy <olamy@apache.org>2011-12-29 13:53:39 +0000
commit49be96fe11d1cd64722cfd8302048d8933a3b315 (patch)
treec99f145a19425811dbed11aa3cef8a87698ec9f3
parent1c218dc40f3fb13f32d9bdb3d4ace35eb4441db0 (diff)
downloadarchiva-49be96fe11d1cd64722cfd8302048d8933a3b315.tar.gz
archiva-49be96fe11d1cd64722cfd8302048d8933a3b315.zip
add selenium test for create/delete user
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225531 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html8
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test-js/src/test/resources/testng.properties2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/UserManagementTest.java41
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java79
4 files changed, 90 insertions, 40 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
index 57efad36c..3fd59794e 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
@@ -1,7 +1,11 @@
<div class='well' id="main-menu" redback-permissions="{permissions: ['archiva-manage-users']}" style="display: none">
<ul class="navigation">
- <li style="display: none" redback-permissions="{permissions: ['archiva-manage-users']}"><a href="#" onclick="displayUsersGrid()">${$.i18n.prop('users.list')}</a></li>
- <li style="display: none" redback-permissions="{permissions: ['archiva-manage-users']}"><a href="#" onclick="displayRolesGrid()">${$.i18n.prop('roles.list')}</a></li>
+ <li style="display: none" redback-permissions="{permissions: ['archiva-manage-users']}">
+ <a href="#" id="menu-users-list-a" onclick="displayUsersGrid()">${$.i18n.prop('users.list')}</a>
+ </li>
+ <li style="display: none" redback-permissions="{permissions: ['archiva-manage-users']}">
+ <a href="#" id="menu-roles-list-a" onclick="displayRolesGrid()">${$.i18n.prop('roles.list')}</a>
+ </li>
</ul>
</div>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/resources/testng.properties b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/resources/testng.properties
index 2863603cd..c7ea281a2 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/resources/testng.properties
+++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/resources/testng.properties
@@ -53,7 +53,7 @@ END_DATE=05/30/2009
# User Management
# For password and new password
-USERROLE_EMAIL=admin@localhost
+USERROLE_EMAIL=admin@localhost.fr
USERROLE_PASSWORD=password1
NEW_USERROLE_PASSWORD=password123
diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/UserManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/UserManagementTest.java
new file mode 100644
index 000000000..61136caa3
--- /dev/null
+++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/UserManagementTest.java
@@ -0,0 +1,41 @@
+package org.apache.archiva.web.test;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author Olivier Lamy
+ */
+@Test( groups = { "usermanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class UserManagementTest
+ extends AbstractArchivaTest
+{
+ public void testBasicAddDeleteUser()
+ {
+ username = getProperty( "GUEST_USERNAME" );
+ fullname = getProperty( "GUEST_FULLNAME" );
+
+ createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
+ deleteUser( username, fullname, getUserEmail() );
+ logout();
+ login( getAdminUsername(), getAdminPassword() );
+ }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
index 72a49b6a7..b4adefc83 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
@@ -1,6 +1,5 @@
package org.apache.archiva.web.test.parent;
-import org.apache.archiva.web.test.XPathExpressionUtil;
import org.testng.Assert;
import java.io.File;
@@ -222,27 +221,30 @@ public abstract class AbstractArchivaTest
private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword,
boolean valid )
{
- // login( getAdminUsername() , getAdminPassword() );
- getSelenium().open( "/archiva/security/userlist.action" );
- clickButtonWithLocator( "userCreateButton", true );
- //clickButtonWithValue( "Create New User" );
+
+ clickLinkWithLocator( "menu-users-list-a", true );
+ clickLinkWithLocator( "users-view-tabs-li-user-edit-a", true );
+
assertCreateUserPage();
- setFieldValue( "user.username", userName );
- setFieldValue( "user.fullName", fullName );
- setFieldValue( "user.email", emailAd );
- setFieldValue( "user.password", password );
- setFieldValue( "user.confirmPassword", confirmPassword );
- submit();
+ setFieldValue( "username", userName );
+ setFieldValue( "fullname", fullName );
+ setFieldValue( "email", emailAd );
+ setFieldValue( "password", password );
+ setFieldValue( "confirmPassword", confirmPassword );
- assertUserRolesPage();
+ clickLinkWithLocator( "user-create-form-register-button", true );
- //clickButtonWithValue( "Submit" );
- clickButtonWithName( "submitRolesButton", true );
+ assertTextPresent( "user created:guest_user" );
+
+ //assertUserRolesPage();
+
+ //clickButtonWithName( "submitRolesButton", true );
if ( valid )
{
- String[] columnValues = { userName, fullName, emailAd };
- assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) );
+ //String[] columnValues = { userName, fullName, emailAd };
+ //assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) );
+
}
else
{
@@ -257,12 +259,18 @@ public abstract class AbstractArchivaTest
public void deleteUser( String userName, String fullName, String emailAd, boolean validated, boolean locked )
{
- String[] columnValues = { userName, fullName, emailAd };
- // clickLinkWithText( "userlist" );
- clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" );
- assertDeleteUserPage( userName );
- submit();
- assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) );
+ clickLinkWithLocator( "menu-users-list-a", true );
+ assertTextPresent( userName );
+ assertTextPresent( fullName );
+
+ clickLinkWithLocator( "users-grid-delete-" + userName );
+
+ assertTextPresent( "user " + userName + " deleted" );
+
+ assertTextNotPresent( userName );
+ assertTextNotPresent( fullName );
+
+
}
public void login( String username, String password )
@@ -371,21 +379,18 @@ public abstract class AbstractArchivaTest
public void assertCreateUserPage()
{
- //assertPage( "Apache Archiva \\ [Admin] User Create" );
- //assertTextPresent( "[Admin] User Create" );
- assertTextPresent( "Username*:", "Nom d'utilisateur*:" );
- assertElementPresent( "user.username" );
- assertTextPresent( "Full Name*:", "Nom complet*:" );
- assertElementPresent( "user.fullName" );
- assertTextPresent( "Email Address*:", "Adresse email*:" );
- assertElementPresent( "user.email" );
- assertTextPresent( "Password*:", "Mot de passe*:" );
- assertElementPresent( "user.password" );
- assertTextPresent( "Confirm Password*:", "Confirmer le mot de passe*" );
- assertElementPresent( "user.confirmPassword" );
- //assertButtonWithValuePresent( "Create User" );
- assertButtonWithIdPresent( "userCreateSubmit" );
-// assertElementNotPresent( "userCreateSubmit" );
+ assertTextPresent( "Username" );
+ assertElementPresent( "username" );
+ assertTextPresent( "Full Name" );
+ assertElementPresent( "fullname" );
+ assertTextPresent( "Email Address" );
+ assertElementPresent( "email" );
+ assertTextPresent( "Password" );
+ assertElementPresent( "password" );
+ assertTextPresent( "Confirm Password" );
+ assertElementPresent( "confirmPassword" );
+ assertButtonWithIdPresent( "user-create-form-register-button" );
+
}
public void assertLeftNavMenuWithRole( String role )