]> source.dussan.org Git - archiva.git/commitdiff
check user is logged in at end of test
authorBrett Porter <brett@apache.org>
Tue, 16 Feb 2010 03:57:37 +0000 (03:57 +0000)
committerBrett Porter <brett@apache.org>
Tue, 16 Feb 2010 03:57:37 +0000 (03:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@910389 13f79535-47bb-0310-9956-ffa450edef68

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

index 4b3bc18250ebbc27f145f06d946fed85058db1d2..e5a02bd721f787c368113a1178becce194b21b0f 100644 (file)
@@ -62,8 +62,8 @@ public class ArchivaAdminTest
             String username = getProperty( "ADMIN_USERNAME" );
             String mail = getProperty( "ADMIN_EMAIL" );
             String password = getProperty( "ADMIN_PASSWORD" );
-            submitAdminData( fullname, mail, password );            
-            assertAuthenticatedPage( username );
+            submitAdminData( fullname, mail, password );
+            assertUserLoggedIn( username );
             submit();
             clickLinkWithText( "Logout" );
        }
index a1ad6d5ec61d82e0873135cf0849e6174c37e02f..1f984fbc7a6843b27121d872c9d4371d7f0267e2 100644 (file)
@@ -34,8 +34,8 @@ public class UserRolesTest
                
                createUser( username, fullname, getUserEmail(), getUserRolePassword(), true);
                deleteUser( username, fullname, getUserEmail() );
-               clickLinkWithText( "Logout" );
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        @Test (dependsOnMethods = { "testBasicAddDeleteUser" } )
@@ -49,20 +49,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        @Test (dependsOnMethods = { "testUserWithGuestRole" } )
@@ -76,20 +76,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        @Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } )
@@ -103,20 +103,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        @Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } )
@@ -130,20 +130,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        @Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } )
@@ -157,20 +157,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
 
        @Test (dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
@@ -184,20 +184,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkUserRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        @Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
@@ -211,20 +211,20 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkResourceRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
        
        /*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
@@ -265,46 +265,46 @@ public class UserRolesTest
                clickLinkWithText( "Edit Roles" );
                checkResourceRoleWithValue( fullname );
                clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
+
+        logout();
+        login(username, getUserRolePassword());
                changePassword( getUserRolePassword(), getUserRoleNewPassword());
                
                // this section will be removed if issue from redback after changing password will be fixed.
                getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
+        logout();
+        //assertTextPresent("You are already logged in.");
                
                login(username, getUserRoleNewPassword());
                assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
+        logout();
+        login( getAdminUsername() , getAdminPassword() );
        }
-       
-       /*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
-       public void testUserWithRepoObserverSnapshotsRole()
-       {
-               username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
-               fullname = getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
-               
-               createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
-               clickLinkWithText( username );
-               clickLinkWithText( "Edit Roles" );
-               checkResourceRoleWithValue( fullname );
-               clickButtonWithValue( "Submit" );
-               
-               clickLinkWithText("Logout");
-               login(username, getUserRolePassword());
-               changePassword( getUserRolePassword(), getUserRoleNewPassword());
-               
-               // this section will be removed if issue from redback after changing password will be fixed.
-               getSelenium().goBack();
-               clickLinkWithText("Logout");
-               //assertTextPresent("You are already logged in.");
-               
-               login(username, getUserRoleNewPassword());
-               assertLeftNavMenuWithRole( fullname );
-               clickLinkWithText("Logout");
-               login( getAdminUsername() , getAdminPassword() );
-       }*/
+
+    /*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } )
+     public void testUserWithRepoObserverSnapshotsRole()
+     {
+         username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" );
+         fullname = getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" );
+
+         createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
+         clickLinkWithText( username );
+         clickLinkWithText( "Edit Roles" );
+         checkResourceRoleWithValue( fullname );
+         clickButtonWithValue( "Submit" );
+
+         clickLinkWithText("Logout");
+         login(username, getUserRolePassword());
+         changePassword( getUserRolePassword(), getUserRoleNewPassword());
+
+         // this section will be removed if issue from redback after changing password will be fixed.
+         getSelenium().goBack();
+         clickLinkWithText("Logout");
+         //assertTextPresent("You are already logged in.");
+
+         login(username, getUserRoleNewPassword());
+         assertLeftNavMenuWithRole( fullname );
+         clickLinkWithText("Logout");
+         login( getAdminUsername() , getAdminPassword() );
+     }*/
 }
index 356caf9666dcffd287c75481dac32aeb6a8573f3..f9612d79553627aba2c3e7d91a2100fde94fc045 100644 (file)
@@ -118,8 +118,8 @@ public abstract class AbstractArchivaTest
                submit();
                if ( success )
                {
-                       assertAuthenticatedPage( username );
-               }
+                assertUserLoggedIn( username );
+            }
                else
                {
                    assertLoginPage();
@@ -142,18 +142,8 @@ public abstract class AbstractArchivaTest
                assertTextPresent( "Need an Account? Register!" );
                assertTextPresent( "Forgot your Password? Request a password reset." );
        }
-       
-       public void assertAuthenticatedPage( String username )
-       {
-               assertTextPresent( "Current User" );
-               assertTextPresent( "Edit Details" );
-               assertTextPresent( "Logout" );
-               assertTextNotPresent( "Login" );
-               assertTextPresent( username );
-       }
-       
-       
-       //User Management
+
+    //User Management
        public void goToUserManagementPage()
        {
                clickLinkWithText( "User Management" );
@@ -278,6 +268,10 @@ public abstract class AbstractArchivaTest
 
             submitLoginPage( username, password, false, valid, assertReturnPage );
         }
+        if ( valid )
+        {
+            assertUserLoggedIn( username );
+        }
     }
     
     public void submitLoginPage( String username, String password )
@@ -304,10 +298,7 @@ public abstract class AbstractArchivaTest
 
         if ( validUsernamePassword )
         {
-            assertTextPresent( "Current User:" );
-            assertTextPresent( username );
-            assertLinkPresent( "Edit Details" );
-            assertLinkPresent( "Logout" );
+            assertUserLoggedIn( username );
         }
         else
         {
@@ -321,8 +312,17 @@ public abstract class AbstractArchivaTest
             }
         }
     }
-    
-        // User Roles
+
+    protected void assertUserLoggedIn( String username )
+    {
+        assertTextPresent( "Current User:" );
+        assertTextPresent( username );
+        assertLinkPresent( "Edit Details" );
+        assertLinkPresent( "Logout" );
+        assertTextNotPresent( "Login" );
+    }
+
+    // User Roles
        public void assertUserRoleCheckBoxPresent(String value) 
        {
                getSelenium()   .isElementPresent("xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='"   + value + "']");
@@ -553,4 +553,13 @@ public abstract class AbstractArchivaTest
        //TODO  
        clickButtonWithValue( "Add Repository" );
     }
+
+    protected void logout()
+    {
+        clickLinkWithText("Logout");
+        assertTextNotPresent( "Current User:" );
+        assertLinkNotPresent( "Edit Details" );
+        assertLinkNotPresent( "Logout" );
+        assertLinkPresent( "Login" );
+    }
 }