[Fusionforge-commits] r11229 - in trunk: src/www/admin tests/func/RBAC

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Oct 28 14:34:05 CEST 2010


Author: lolando
Date: 2010-10-28 14:34:05 +0200 (Thu, 28 Oct 2010)
New Revision: 11229

Modified:
   trunk/src/www/admin/globalroleedit.php
   trunk/tests/func/RBAC/rbacTests.php
Log:
RBAC testsuite: creation of global roles, adding/removing users to them, setting/unsetting permissions

Modified: trunk/src/www/admin/globalroleedit.php
===================================================================
--- trunk/src/www/admin/globalroleedit.php	2010-10-28 12:19:51 UTC (rev 11228)
+++ trunk/src/www/admin/globalroleedit.php	2010-10-28 12:34:05 UTC (rev 11229)
@@ -141,7 +141,7 @@
 		
 		foreach ($users as $user) {
 			echo '
-		<form action="'.getStringFromServer('PHP_SELF').'" method="post">
+		<form action="'.util_make_url('/admin/globalroleedit.php').'" method="post">
 		<input type="hidden" name="role_id" value="'.$role_id.'">
                         <tr>
                         <td style="white-space: nowrap;">
@@ -167,7 +167,7 @@
 
 			?>
 		<form
-			action="<?php echo getStringFromServer('PHP_SELF'); ?>"
+			action="<?php echo util_make_url('/admin/globalroleedit.php'); ?>"
 			method="post">
 		<p><input type="text"
 			name="form_unix_name" size="10" value="" />
@@ -181,7 +181,7 @@
 		
 echo '
 <p>
-<form action="'.getStringFromServer('PHP_SELF').'" method="post">';
+<form action="'.util_make_url('/admin/globalroleedit.php').'" method="post">';
 echo '<input type="hidden" name="role_id" value="'.$role_id.'">' ;
 		
 if ($role instanceof RoleExplicit) {

Modified: trunk/tests/func/RBAC/rbacTests.php
===================================================================
--- trunk/tests/func/RBAC/rbacTests.php	2010-10-28 12:19:51 UTC (rev 11228)
+++ trunk/tests/func/RBAC/rbacTests.php	2010-10-28 12:34:05 UTC (rev 11229)
@@ -24,7 +24,7 @@
 
 class RBAC extends FForge_SeleniumTestCase
 {
-	function testRBAC()
+	function testAnonymousProjectReadAccess()
 	{
 		$this->init();
 
@@ -52,5 +52,80 @@
 		$this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
 	}
 
+	function testGlobalRoles()
+	{
+		$this->login("admin");
+
+		$this->open( ROOT );
+		$this->waitForPageToLoad("30000");
+		$this->click("link=Site Admin");
+		$this->waitForPageToLoad("30000");
+
+		// Create "Project approvers" role
+		$this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Project approvers") ;
+		$this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
+		$this->waitForPageToLoad("30000");
+
+		// Grant it permissions
+		$this->select("//select[@id='tracker-data[approve_projects][-1]']", "label=Approve projects");
+		$this->select("//select[@id='tracker-data[approve_news][-1]']", "label=Approve news");
+		$this->click ("//input[@value='Submit']") ;
+		$this->waitForPageToLoad("30000");
+
+		// Check permissions were saved
+		$this->click("link=Site Admin");
+		$this->waitForPageToLoad("30000");
+		$this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
+		$this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
+		$this->waitForPageToLoad("30000");
+
+		$this->assertSelected("//select[@id='tracker-data[approve_projects][-1]']", "Approve projects");
+		$this->assertNotSelected("//select[@id='tracker-data[approve_projects][-1]']", "No access");
+		$this->assertSelected("//select[@id='tracker-data[approve_news][-1]']", "Approve news");
+		
+		// Whoops, we don't actually want the news moderation bit, unset it
+		$this->select("//select[@id='tracker-data[approve_news][-1]']", "label=No access");
+		$this->click ("//input[@value='Submit']") ;
+		$this->waitForPageToLoad("30000");
+		$this->assertSelected("//select[@id='tracker-data[approve_projects][-1]']", "Approve projects");
+		$this->assertSelected("//select[@id='tracker-data[approve_news][-1]']", "No access");
+
+		// Create users for "Project approvers" and "News moderators" roles
+		$this->createUser ("projapp") ;
+		$this->createUser ("newsmod") ;
+
+		// Add them to their respective roles, check they're here
+		$this->click("link=Site Admin");
+		$this->waitForPageToLoad("30000");
+		$this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
+		$this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
+		$this->waitForPageToLoad("30000");
+		$this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "projapp") ;
+		$this->click ("//input[@value='Add User']") ;
+		$this->waitForPageToLoad("30000");
+		$this->assertTrue($this->isTextPresent("projapp Lastname"));
+		
+		$this->click("link=Site Admin");
+		$this->waitForPageToLoad("30000");
+		$this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=News moderators") ;
+		$this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
+		$this->waitForPageToLoad("30000");
+		$this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "newsmod") ;
+		$this->click ("//input[@value='Add User']") ;
+		$this->waitForPageToLoad("30000");
+		$this->assertTrue($this->isTextPresent("newsmod Lastname"));
+
+		// Add a wrong user to the role, then remove it
+		$this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "projapp") ;
+		$this->click ("//input[@value='Add User']") ;
+		$this->waitForPageToLoad("30000");
+		$this->assertTrue($this->isTextPresent("projapp Lastname"));
+		$this->assertTrue($this->isTextPresent("newsmod Lastname"));
+		$this->click ("//a[contains(@href,'/users/projapp')]/../input[@name='rmuser']") ;
+		$this->waitForPageToLoad("30000");
+		$this->assertFalse($this->isTextPresent("projapp Lastname"));
+		$this->assertTrue($this->isTextPresent("newsmod Lastname"));
+		
+	}
 }
 ?>




More information about the Fusionforge-commits mailing list