]> source.dussan.org Git - archiva.git/commitdiff
allow user tests to be re-run
authorBrett Porter <brett@apache.org>
Tue, 28 Jan 2014 00:57:51 +0000 (00:57 +0000)
committerBrett Porter <brett@apache.org>
Tue, 28 Jan 2014 00:57:51 +0000 (00:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1561917 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AuditLogsReportTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/UserRolesTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java

index 0bf98d022bf09ed7b1485e5e53407237cce2d614..fe71ece1a05ff5225a56cf5fa968f3120c504f1f 100644 (file)
@@ -147,8 +147,8 @@ public class AuditLogsReportTest
         assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version +
                                "' was successfully deployed to repository '" + repo + "'" );
 
-        goToUserManagementPage();
         String username = "testAuditUser";
+        goToUserManagementPage();
         if ( !isLinkPresent( username ) )
         {
             createUserWithRole( username, "Repository Manager - internal", getUserEmail(), getUserRolePassword() );
index df074304bcd163a452f7d09bb81ae398f92e706b..14e0e585d9096332d96cbdbc6f3a57e21dde6bfc 100644 (file)
@@ -20,11 +20,12 @@ package org.apache.archiva.web.test;
  */
 
 import org.apache.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 @Test( groups = { "userroles" })
-public class UserRolesTest 
+public class UserRolesTest
        extends AbstractArchivaTest
 {
     @BeforeTest
@@ -33,23 +34,40 @@ public class UserRolesTest
         loginAsAdmin();
     }
 
+    @AfterSuite
+    public void tearDown()
+    {
+        goToUserManagementPage();
+        String[] usernameProperties =
+            new String[]{ "GUEST_USERNAME", "REGISTERED_USERNAME", "SYSAD_USERNAME", "USERADMIN_USERNAME",
+                "GLOBALREPOMANAGER_USERNAME", "GLOBALREPOOBSERVER_USERNAME", "REPOMANAGER_INTERNAL_USERNAME",
+                "REPOOBSERVER_INTERNAL_USERNAME" };
+        for ( String p : usernameProperties )
+        {
+            String username = getProperty( p );
+
+            if ( isLinkPresent( username ) )
+            {
+                deleteUser( username );
+            }
+        }
+    }
+
     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() );
+               deleteUser( username );
        }
-       
+
        @Test (dependsOnMethods = { "testBasicAddDeleteUser" } )
        public void testUserWithGuestRole()
        {
                username = getProperty("GUEST_USERNAME");
                fullname = getProperty("GUEST_FULLNAME");
-               
+
                createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
                clickLinkWithText( username );
                clickLinkWithText( "Edit Roles" );
@@ -59,26 +77,26 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
         login( getAdminUsername() , getAdminPassword() );
        }
-       
+
        @Test (dependsOnMethods = { "testUserWithGuestRole" } )
        public void testUserWithRegisteredUserRole()
        {
                username = getProperty("REGISTERED_USERNAME");
                fullname = getProperty("REGISTERED_FULLNAME");
-               
+
                createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
-               clickLinkWithText( username );  
+               clickLinkWithText( username );
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
@@ -86,24 +104,24 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
         login( getAdminUsername() , getAdminPassword() );
        }
-       
+
        @Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } )
        public void testUserWithSysAdminUserRole()
        {
                username = getProperty("SYSAD_USERNAME");
                fullname = getProperty("SYSAD_FULLNAME");
-               
+
                createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
                clickLinkWithText( username );
                clickLinkWithText( "Edit Roles" );
@@ -113,24 +131,24 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
         login( getAdminUsername() , getAdminPassword() );
        }
-       
+
        @Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } )
        public void testUserWithUserAdminUserRole()
        {
                username = getProperty("USERADMIN_USERNAME");
                fullname = getProperty("USERADMIN_FULLNAME");
-               
+
                createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
                clickLinkWithText( username );
                clickLinkWithText( "Edit Roles" );
@@ -140,24 +158,24 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
         login( getAdminUsername() , getAdminPassword() );
        }
-       
+
        @Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } )
        public void testUserWithGlobalRepoManagerRole()
        {
                username = getProperty("GLOBALREPOMANAGER_USERNAME");
                fullname = getProperty("GLOBALREPOMANAGER_FULLNAME");
-               
+
                createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
                clickLinkWithText( username );
                clickLinkWithText( "Edit Roles" );
@@ -167,12 +185,12 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
@@ -184,7 +202,7 @@ public class UserRolesTest
        {
                username = getProperty("GLOBALREPOOBSERVER_USERNAME");
                fullname = getProperty("GLOBALREPOOBSERVER_FULLNAME");
-               
+
                createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
                clickLinkWithText( username );
                clickLinkWithText( "Edit Roles" );
@@ -194,18 +212,18 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
         login( getAdminUsername() , getAdminPassword() );
        }
-       
+
        @Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
        public void testUserWithRepoManagerInternalRole()
        {
@@ -217,12 +235,12 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
@@ -255,7 +273,7 @@ public class UserRolesTest
                clickLinkWithText("Logout");
                login( getAdminUsername() , getAdminPassword() );
        }*/
-       
+
        @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
        public void testUserWithRepoObserverInternalRole()
        {
@@ -267,12 +285,12 @@ public class UserRolesTest
         logout();
         login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
+
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
         logout();
         //assertTextPresent("You are already logged in.");
-               
+
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
         logout();
index 6051dae63b24d96bb046f7e470010366be20dd30..af956ae5ded4c8d30e3898d59cc47ab3fe99b5f5 100644 (file)
@@ -275,19 +275,12 @@ public abstract class AbstractArchivaTest
         }
     }
 
-    public void deleteUser( String userName, String fullName, String emailAdd )
+    public void deleteUser( String userName )
     {
-        deleteUser( userName, fullName, emailAdd, false, false );
-    }
-
-    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" );
+        clickLinkWithXPath( "//tr[.//a[text()='" + userName + "']]/td/a[@title='delete user']" );
         assertDeleteUserPage( userName );
         submit();
-        assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) );
+        assertLinkNotPresent( userName );
     }
 
     public void login( String username, String password )