<?php
/*
- * Copyright 2010, Roland Mas
+ * Copyright 2010-2011, Roland Mas
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
*
* This file is part of FusionForge.
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
- *
+ *
* FusionForge is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
$this->assertTrue($this->isTextPresent("Project Information"));
$this->click("link=Users and permissions");
$this->waitForPageToLoad("30000");
- $this->assertTrue($this->isTextPresent("Members of ProjectA"));
+ $this->assertTrue($this->isTextPresent("Current Project Members"));
$this->click("//tr/td/form/div[contains(.,'Anonymous')]/../../../td/form/div/input[contains(@value,'Unlink Role')]");
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("Role unlinked successfully"));
function testGlobalRolesAndPermissions()
{
- $this->login("admin");
+ $this->login(FORGE_ADMIN_USERNAME);
$this->click("link=Site Admin");
$this->waitForPageToLoad("30000");
$this->assertSelected("//select[@name='data[approve_projects][-1]']", "Approve projects");
$this->assertNotSelected("//select[@name='data[approve_projects][-1]']", "No access");
$this->assertSelected("//select[@name='data[approve_news][-1]']", "Approve news");
-
+
// Whoops, we don't actually want the news moderation bit, unset it
$this->select("//select[@name='data[approve_news][-1]']", "label=No access");
$this->click ("//input[@value='Submit']") ;
$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->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->click ("//a[contains(@href,'/users/projapp')]/../../td/input[@type='checkbox']") ;
+ $this->click ("//input[@name='reallyremove']") ;
+ $this->click ("//input[@name='dormusers']") ;
$this->waitForPageToLoad("30000");
$this->assertFalse($this->isTextPresent("projapp Lastname"));
$this->assertTrue($this->isTextPresent("newsmod Lastname"));
$this->click ("//input[@value='Add User']") ;
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("toto Lastname"));
-
+
// Register project
$this->registerProject ("TotoProject", "toto") ;
$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->click ("//a[contains(@href,'/users/toto')]/../input[@name='rmuser']") ;
+ $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
+ $this->click ("//input[@name='reallyremove']") ;
+ $this->click ("//input[@name='dormusers']") ;
$this->waitForPageToLoad("30000");
$this->assertFalse($this->isTextPresent("toto Lastname"));
$this->click("link=First TotoNews") ;
$this->waitForPageToLoad("30000");
$this->assertFalse ($this->isPermissionDenied()) ;
+
+ // Non-regression test for Adacore ticket K802-005
+ // (Deletion of global roles)
+ $this->switchUser(FORGE_ADMIN_USERNAME);
+ $this->click("link=Site Admin");
+ $this->waitForPageToLoad("30000");
+ $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Temporary role") ;
+ $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Site Admin");
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isElementPresent("//option[.='Temporary role']"));
+ $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
+ $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']", "toto") ;
+ $this->click ("//input[@value='Add User']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isTextPresent("toto Lastname"));
+ $this->click ("//input[@type='checkbox' and @name='sure']") ;
+ $this->click ("//input[@value='Delete role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
+ $this->click("link=Site Admin");
+ $this->waitForPageToLoad("30000");
+ $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
+ $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
+ $this->click ("//input[@name='reallyremove']") ;
+ $this->click ("//input[@name='dormusers']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Site Admin");
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isElementPresent("//option[.='Temporary role']"));
+ $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
+ $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click ("//input[@type='checkbox' and @name='sure']") ;
+ $this->click ("//input[@value='Delete role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertFalse($this->isElementPresent("//option[.='Temporary role']"));
}
function testProjectRolesAndPermissions()
$this->click ("//input[@value='Add Member']") ;
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("guru Lastname"));
- $this->assertTrue($this->isElementPresent("
-//input[@value=
- //tr/td/a[.='guru Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Senior Developer']")) ;
+ $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Senior Developer')]")) ;
$this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
$this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
$this->click ("//input[@value='Add Member']") ;
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("trainee Lastname"));
- $this->assertTrue($this->isElementPresent("
-//input[@value=
- //tr/td/a[.='trainee Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Junior Developer']")) ;
+ $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
$this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "docmaster") ;
$this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Doc Writer");
$this->click ("//input[@value='Add Member']") ;
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("docmaster Lastname"));
- $this->assertTrue($this->isElementPresent("
-//input[@value=
- //tr/td/a[.='docmaster Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Doc Writer']")) ;
+ $this->assertTrue($this->isElementPresent("//tr/td/a[.='docmaster Lastname']/../../td/div[contains(.,'Doc Writer')]")) ;
$this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "bigboss") ;
$this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
$this->click ("//input[@value='Add Member']") ;
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("bigboss Lastname"));
- $this->assertTrue($this->isElementPresent("
-//input[@value=
- //tr/td/a[.='bigboss Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Senior Developer']")) ;
+ $this->assertTrue($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/..//input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
// Oops, bigboss doesn't need the extra role after all
- $this->click ("
-//input[@value=
- //tr/td/a[.='bigboss Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Senior Developer']/../td/input[@value='Remove']") ;
- $this->waitForPageToLoad("30000");
- $this->assertFalse($this->isElementPresent("
-//input[@value=
- //tr/td/a[.='bigboss Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Senior Developer']")) ;
+ $this->click("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@name='username' and @value='bigboss']/../input[@value='Remove']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertFalse($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
// Remove/re-add a user
- $this->click ("
-//input[@value=
- //tr/td/a[.='trainee Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Junior Developer']/../td/input[@value='Remove']") ;
+ $this->click("//tr/td/div[contains(.,'Junior Developer')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
$this->waitForPageToLoad("30000");
$this->assertFalse($this->isTextPresent("trainee Lastname"));
$this->click ("//input[@value='Add Member']") ;
$this->waitForPageToLoad("30000");
$this->assertTrue($this->isTextPresent("trainee Lastname"));
- $this->assertTrue($this->isElementPresent("
-//input[@value=
- //tr/td/a[.='trainee Lastname']/../..//input[@name='user_id']/@value
-]
-/../td[.='Junior Developer']")) ;
+ $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
// Edit permissions of the JD role
$this->gotoProject ("MetaProject") ;
$this->click("link=Users and permissions");
$this->waitForPageToLoad("30000");
- $this->click ("//td[.='Junior Developer']/../td/input[@value='Edit Permissions']") ;
+ $this->click ("//td/form/div[contains(.,'Junior Developer')]/../div/input[@value='Edit Permissions']") ;
$this->waitForPageToLoad("30000");
$this->select("//select[contains(@name,'data[frs]')]", "label=View public packages only");
$this->waitForPageToLoad("30000");
$this->click("link=Users and permissions");
$this->waitForPageToLoad("30000");
- $this->click ("//td[.='Senior Developer']/../td/input[@value='Edit Permissions']") ;
+ $this->click ("//td/form/div[contains(.,'Senior Developer')]/../div/input[@value='Edit Permissions']") ;
$this->waitForPageToLoad("30000");
$this->click ("//input[@type='checkbox' and @name='public']") ;
$this->click ("//input[@value='Submit']") ;
$this->click("link=Users and permissions");
$this->waitForPageToLoad("30000");
- $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../td/select/option[.='Senior Developer (in project MetaProject)']")) ;
- $this->select("//input[@value='Link external role']/../../td/select", "label=Senior Developer (in project MetaProject)") ;
+ $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Senior Developer (in project MetaProject)']")) ;
+ $this->select("//input[@value='Link external role']/../../div/select", "label=Senior Developer (in project MetaProject)") ;
$this->click("//input[@value='Link external role']") ;
$this->waitForPageToLoad("30000");
- $this->assertTrue($this->isElementPresent("//tr/td[.='Senior Developer (in project MetaProject)']/../td/input[contains(@value,'Unlink Role')]"));
+ $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[contains(@value,'Unlink Role')]"));
// Grant it tracker manager permissions
- $this->click ("//td[.='Senior Developer (in project MetaProject)']/../td/input[@value='Edit Permissions']") ;
+ $this->click ("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[@value='Edit Permissions']") ;
$this->waitForPageToLoad("30000");
$this->select("//select[contains(@name,'data[tracker]')]", "label=Manager");
$this->click ("//input[@value='Submit']") ;
$this->click("link=Users and permissions");
$this->waitForPageToLoad("30000");
- $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../td/select/option[.='Documentation masters (global role)']")) ;
- $this->assertFalse($this->isElementPresent("//input[@value='Link external role']/../../td/select/option[.='Project moderators (global role)']")) ;
- $this->select("//input[@value='Link external role']/../../td/select", "label=Documentation masters (global role)") ;
+ $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Documentation masters (global role)']")) ;
+ $this->assertFalse($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Project moderators (global role)']")) ;
+ $this->select("//input[@value='Link external role']/../../div/select", "label=Documentation masters (global role)") ;
$this->click("//input[@value='Link external role']") ;
$this->waitForPageToLoad("30000");
- $this->assertTrue($this->isElementPresent("//tr/td[.='Documentation masters (global role)']/../td/input[contains(@value,'Unlink Role')]"));
+ $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Documentation masters (global role)')]/../div/input[contains(@value,'Unlink Role')]"));
+
+ // Check that a project admin (not forge admin) can create a new role
+ $this->gotoProject ("SubProject") ;
+ $this->click("link=Admin");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Users and permissions");
+ $this->waitForPageToLoad("30000");
+ $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
+ $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Admin");
+ $this->click ("//input[@value='Add Member']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isTextPresent("guru Lastname"));
+ $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Admin')]")) ;
+ $this->switchUser('guru');
+ $this->gotoProject ("SubProject") ;
+ $this->click("link=Admin");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Users and permissions");
+ $this->waitForPageToLoad("30000");
+ $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Role created by guru") ;
+ $this->click ("//input[@value='Create Role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertFalse ($this->isPermissionDenied()) ;
+ $this->click("link=Users and permissions");
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Role created by guru')]/../div/input[@value='Edit Permissions']")) ;
+
+ // Non-regression test for Adacore ticket K802-005
+ // (Deletion of project-wide roles)
+ $this->switchUser(FORGE_ADMIN_USERNAME);
+ $this->gotoProject ("MetaProject") ;
+ $this->click("link=Admin");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Users and permissions");
+ $this->waitForPageToLoad("30000");
+ $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Temporary role") ;
+ $this->click ("//input[@value='Create Role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Users and permissions");
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isTextPresent("Temporary role"));
+ $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
+ $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Temporary role");
+ $this->click ("//input[@value='Add Member']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click ("//input[@type='checkbox' and @name='sure']") ;
+ $this->click ("//input[@value='Submit']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
+ $this->click("//tr/td/div[contains(.,'Temporary role')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
+ $this->waitForPageToLoad("30000");
+ $this->click ("//input[@type='checkbox' and @name='sure']") ;
+ $this->click ("//input[@value='Submit']") ;
+ $this->waitForPageToLoad("30000");
+ $this->assertFalse($this->isTextPresent("Temporary role"));
+
+ // Non-regression test
+ $this->click("link=Site Admin");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Display Full Project List/Edit Projects");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=SubProject");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Permanently Delete Project");
+ $this->waitForPageToLoad("30000");
+ $this->click("sure");
+ $this->click("reallysure");
+ $this->click("reallyreallysure");
+ $this->click("submit");
+ $this->waitForPageToLoad("30000");
+ $this->click("link=Home");
+ $this->waitForPageToLoad("30000");
+ $this->assertFalse($this->isTextPresent("SubProject"));
}
}
-?>