continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r826891 - in /continuum/trunk/continuum-webapp-test/src/test: resources/ testng/config/ testng/org/apache/continuum/web/test/ testng/org/apache/continuum/web/test/parent/
Date Mon, 19 Oct 2009 23:47:01 GMT
Author: ctan
Date: Mon Oct 19 23:47:00 2009
New Revision: 826891

URL: http://svn.apache.org/viewvc?rev=826891&view=rev
Log:
added test for CONTINUUM-2127

Added:
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SecurityTest.java
Modified:
    continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties
    continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java

Modified: continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties?rev=826891&r1=826890&r2=826891&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties (original)
+++ continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties Mon Oct 19
23:47:00 2009
@@ -275,3 +275,12 @@
 BUILD_AGENT_NAME3 =Third_Agent
 BUILD_AGENT_DESCRIPTION3 =Agent_description3
 BUILD_AGENT_GROUPNAME =agent_groupname
+
+########################
+# security
+########################
+PROJECT_ADMIN_USERNAME=project_admin
+PROJECT_ADMIN_NAME=project_admin_name
+PROJECT_ADMIN_EMAIL=project_admin@something.com
+PROJECT_ADMIN_OLD_PASSWORD=password123
+PROJECT_ADMIN_NEW_PASSWORD=projectadmin123
\ No newline at end of file

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml?rev=826891&r1=826890&r2=826891&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml (original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml Mon Oct 19 23:47:00
2009
@@ -61,6 +61,7 @@
 				<include name="buildDefinitionTemplate" />
 				<include name="userroles"/>
 				<include name="agent"/>
+				<include name="security" />
 			</run>
 		</groups>
 		<packages>

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java?rev=826891&r1=826890&r2=826891&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java
Mon Oct 19 23:47:00 2009
@@ -78,7 +78,74 @@
         assertTextPresent( "You have entered an incorrect username and/or password" );
     }
 
-    @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun
= true )
+    @Test( dependsOnMethods = { "testWithEmptyPassword" } )
+    public void testWithCreatedProjectAdminUser()
+    {
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+        getSelenium().type( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+
+        clickLinkWithText( "Configuration" );
+        clickLinkWithLocator( "configuration_distributedBuildEnabled", false );
+
+        String username = getProperty( "PROJECT_ADMIN_USERNAME" );
+        String name = getProperty( "PROJECT_ADMIN_NAME" );
+        String email = getProperty( "PROJECT_ADMIN_EMAIL" );
+        String oldPassword = getProperty( "PROJECT_ADMIN_OLD_PASSWORD" );
+        String newPassword = getProperty( "PROJECT_ADMIN_NEW_PASSWORD" );
+
+        createNewUser( username, name, email, oldPassword );
+        assignContinuumRoleToUser( "Continuum Group Project Administrator" );
+        clickButtonWithValue( "Submit" );
+        assertUserCreatedPage();
+        assertLinkPresent( username );
+        assertTextPresent( name );
+        assertTextPresent( email );
+
+        clickLinkWithText( username );
+        assertUserEditPage( username, name, email );
+        assertTextNotPresent( "Last Login:" );
+        assertTextPresent( "Continuum Group Project User" );
+        assertTextPresent( "Continuum Group Project Developer" );
+        assertTextPresent( "Continuum Group Project Administrator" );
+        clickLinkWithText( "Logout" );
+        goToLoginPage();
+
+        getSelenium().type( "loginForm_username", username );
+        getSelenium().type( "loginForm_password", oldPassword );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertChangePasswordPage();
+        
+        getSelenium().type( "passwordForm_existingPassword", oldPassword );
+        getSelenium().type( "passwordForm_newPassword", newPassword );
+        getSelenium().type( "passwordForm_newPasswordConfirm", newPassword );
+        getSelenium().click( "passwordForm__submit" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "Password successfully changed" );
+
+        assertLinkPresent( "Edit Details" );
+        assertLinkPresent( "Logout" );
+
+        assertProjectAdministratorAccess();
+
+        clickLinkWithText( "Logout" );
+
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+        getSelenium().type( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+
+        clickLinkWithText( "Configuration" );
+        clickLinkWithLocator( "configuration_distributedBuildEnabled", false );
+
+        clickLinkWithText( "Logout" );
+    }
+
+    @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithCreatedProjectAdminUser"
}, alwaysRun = true )
     public void testWithCorrectUsernamePassword()
     {
         goToLoginPage();

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SecurityTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SecurityTest.java?rev=826891&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SecurityTest.java
(added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/SecurityTest.java
Mon Oct 19 23:47:00 2009
@@ -0,0 +1,67 @@
+package org.apache.continuum.web.test;
+
+import org.apache.continuum.web.test.parent.AbstractContinuumTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "security" } )
+public class SecurityTest
+    extends AbstractContinuumTest
+{
+    public void testProjectAdminAccess()
+    {
+        String username = getProperty( "PROJECT_ADMIN_USERNAME" );
+        String password = getProperty( "PROJECT_ADMIN_NEW_PASSWORD" );
+        String name = getProperty( "PROJECT_ADMIN_NAME" );
+
+        // enable distributed build
+        clickLinkWithText( "Configuration" );
+        clickLinkWithLocator( "configuration_distributedBuildEnabled", false );
+        clickButtonWithValue( "Save" );
+
+        // logout admin
+        clickLinkWithText( "Logout" );
+
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", username );
+        getSelenium().type( "loginForm_password", password );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+
+        assertTextPresent( "Current User: " + name + " (" + username + ")" );
+        assertLinkPresent( "Edit Details" );
+        assertLinkPresent( "Logout" );
+
+        assertProjectAdministratorAccess();
+
+        clickLinkWithText( "Logout" );
+
+        // login as admin again
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
+        getSelenium().type( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+
+        // disable distributed build
+        clickLinkWithText( "Configuration" );
+        clickLinkWithLocator( "configuration_distributedBuildEnabled", false );
+        clickButtonWithValue( "Save" );
+
+        // logout admin
+        clickLinkWithText( "Logout" );
+
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", username );
+        getSelenium().type( "loginForm_password", password );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+
+        assertTextPresent( "Current User: " + name + " (" + username + ")" );
+        assertLinkPresent( "Edit Details" );
+        assertLinkPresent( "Logout" );
+
+        assertProjectAdministratorAccess();
+
+        clickLinkWithText( "Logout" );
+    }
+}

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java?rev=826891&r1=826890&r2=826891&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
Mon Oct 19 23:47:00 2009
@@ -133,6 +133,38 @@
         assertTextPresent( username );
     }
 
+    public void assertChangePasswordPage()
+    {
+        assertPage( "Change Password" );
+        assertTextPresent( "Change Password" );
+        assertTextPresent( "Existing Password*:" );
+        assertElementPresent( "existingPassword" );
+        assertTextPresent( "New Password*:" );
+        assertElementPresent( "newPassword" );
+        assertTextPresent( "Confirm New Password*:" );
+        assertElementPresent( "newPasswordConfirm" );
+    }
+
+    public void assertUserEditPage( String username, String name, String email )
+    {
+        assertPage( "[Admin] User Edit" );
+        assertTextPresent( "[Admin] User Edit" );
+        assertTextPresent( "Username" );
+        assertTextPresent( username );
+        assertTextPresent( "Full Name*:" );
+        assertFieldValue( name, "userEditForm_user_fullName" );
+        assertTextPresent( "Email Address*:" );
+        assertFieldValue( email, "userEditForm_user_email" );
+        assertTextPresent( "Password*:" );
+        assertFieldValue( "", "userEditForm_user_password" );
+        assertTextPresent( "Confirm Password*:" );
+        assertElementPresent( "userEditForm_user_confirmPassword" );
+        assertTextPresent( "Account Creation:" );
+        assertTextPresent( "Last Password Change:" );
+        assertTextPresent( "Effective Roles" );
+        assertLinkPresent( "Edit Roles" );
+    }
+
     // ////////////////////////////////////
     // Configuration
     // ////////////////////////////////////
@@ -787,7 +819,7 @@
         setFieldValue( "user.confirmPassword", password );
         clickButtonWithValue( "Create User" );
         assertPage( "[Admin] User Edit" );
-        clickLinkWithXPath( "//input[@name='addDSelectedRoles' and @value='Project Developer
- " + groupName + "']", false );
+        assignContinuumResourceRoleToUser( "Project Developer", groupName );
         clickButtonWithValue( "Submit" );
         assertPage( "[Admin] User List" );
         assertTextPresent( username );
@@ -836,4 +868,61 @@
         }
         Thread.sleep( 10000 );
     }
+
+    public void createNewUser( String username, String name, String email, String password
)
+    {
+        clickLinkWithText( "Users" );
+        assertPage( "[Admin] User List" );
+        assertTextNotPresent( username );
+        clickButtonWithValue( "Create New User" );
+        assertPage( "[Admin] User Create" );
+        setFieldValue( "user.fullName", name );
+        setFieldValue( "user.username", username );
+        setFieldValue( "user.email", email );
+        setFieldValue( "user.password", password );
+        setFieldValue( "user.confirmPassword", password );
+        clickButtonWithValue( "Create User" );
+        assertPage( "[Admin] User Edit" );
+    }
+
+    public void assignContinuumRoleToUser( String role )
+    {
+        clickLinkWithXPath( "//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles'
and @value='" + role + "']", false );
+    }
+
+    public void assignContinuumResourceRoleToUser( String resourceRole, String groupName
)
+    {
+        clickLinkWithXPath( "//input[@name='addDSelectedRoles' and @value='" + resourceRole
+ " - " + groupName + "']", false );
+    }
+
+    public void assertUserCreatedPage()
+    {
+        assertPage( "[Admin] User List" );
+        assertTextPresent( "[Admin] List of Users in Role: Any" );
+        assertLinkPresent( "admin" );
+        assertLinkPresent( "guest" );
+    }
+
+    public void assertProjectAdministratorAccess()
+    {
+        assertLinkPresent( "About" );
+        assertLinkPresent( "Show Project Groups" );
+        assertLinkPresent( "Maven 2.0.x Project" );
+        assertLinkPresent( "Maven 1.x Project" );
+        assertLinkPresent( "Ant Project" );
+        assertLinkPresent( "Shell Project" );
+        assertLinkPresent( "Schedules" );
+        assertLinkPresent( "Queues" );
+        assertLinkPresent( "Users" );
+        assertLinkPresent( "Roles" );
+        assertLinkNotPresent( "Local Repositories" );
+        assertLinkNotPresent( "Purge Configurations" );
+        assertLinkNotPresent( "Installations" );
+        assertLinkNotPresent( "Build Environments" );
+        assertLinkNotPresent( "Build Definition Templates" );
+        assertLinkNotPresent( "Configuration" );
+        assertLinkNotPresent( "Appearance" );
+        assertLinkNotPresent( "Build Queue" );
+        assertLinkNotPresent( "Build Agent" );
+    }
 }



Mime
View raw message