]> source.dussan.org Git - archiva.git/commitdiff
add selenium test for create/delete user
authorOlivier Lamy <olamy@apache.org>
Thu, 29 Dec 2011 13:53:39 +0000 (13:53 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 29 Dec 2011 13:53:39 +0000 (13:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225531 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/resources/testng.properties
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/UserManagementTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java

index 57efad36c79b67e13905bf2e1170579372d92e57..3fd59794e576f55c48cc883d8b6d3bcc27005d65 100644 (file)
@@ -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>
index 2863603cdfcd04a7936d25ab52fcffb7bc887ca0..c7ea281a284653d5d6c3034a90b5fffb42e272c2 100644 (file)
@@ -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 (file)
index 0000000..61136ca
--- /dev/null
@@ -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() );
+    }
+}
index 72a49b6a7475d23b2cb7591fc958d0b751eb80f5..b4adefc83a3ad2e41704e73a60563dbac46bae03 100644 (file)
@@ -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 )