3 * Copyright 2010-2011, Roland Mas
4 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License,
11 * or (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once dirname(dirname(__FILE__)).'/Testing/SeleniumGforge.php';
25 class RBAC extends FForge_SeleniumTestCase
27 function testAnonymousProjectReadAccess()
31 $this->click("link=Admin");
32 $this->waitForPageToLoad("30000");
33 $this->assertTrue($this->isTextPresent("Project Information"));
34 $this->click("link=Users and permissions");
35 $this->waitForPageToLoad("30000");
36 $this->assertTrue($this->isTextPresent("Members of ProjectA"));
37 $this->click("//tr/td/form/div[contains(.,'Anonymous')]/../../../td/form/div/input[contains(@value,'Unlink Role')]");
38 $this->waitForPageToLoad("30000");
39 $this->assertTrue($this->isTextPresent("Role unlinked successfully"));
41 $this->createUser ('staffmember') ;
43 $this->assertFalse($this->isTextPresent("ProjectA"));
45 $this->open( ROOT . '/projects/projecta') ;
46 $this->waitForPageToLoad("30000");
47 $this->assertTrue($this->isLoginRequired());
48 $this->triggeredLogin('staffmember');
49 $this->assertTrue($this->isTextPresent("Project Members"));
52 function testGlobalRolesAndPermissions()
54 $this->login("admin");
56 $this->click("link=Site Admin");
57 $this->waitForPageToLoad("30000");
59 // Create "Project approvers" role
60 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Project approvers") ;
61 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
62 $this->waitForPageToLoad("30000");
64 // Grant it permissions
65 $this->select("//select[@name='data[approve_projects][-1]']", "label=Approve projects");
66 $this->select("//select[@name='data[approve_news][-1]']", "label=Approve news");
67 $this->click ("//input[@value='Submit']") ;
68 $this->waitForPageToLoad("30000");
70 // Check permissions were saved
71 $this->click("link=Site Admin");
72 $this->waitForPageToLoad("30000");
73 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
74 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
75 $this->waitForPageToLoad("30000");
77 $this->assertSelected("//select[@name='data[approve_projects][-1]']", "Approve projects");
78 $this->assertNotSelected("//select[@name='data[approve_projects][-1]']", "No access");
79 $this->assertSelected("//select[@name='data[approve_news][-1]']", "Approve news");
81 // Whoops, we don't actually want the news moderation bit, unset it
82 $this->select("//select[@name='data[approve_news][-1]']", "label=No access");
83 $this->click ("//input[@value='Submit']") ;
84 $this->waitForPageToLoad("30000");
85 $this->assertSelected("//select[@name='data[approve_projects][-1]']", "Approve projects");
86 $this->assertSelected("//select[@name='data[approve_news][-1]']", "No access");
88 // Create users for "Project approvers" and "News moderators" roles
89 $this->createUser ("projapp") ;
90 $this->createUser ("newsmod") ;
92 // Add them to their respective roles, check they're here
93 $this->click("link=Site Admin");
94 $this->waitForPageToLoad("30000");
95 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
96 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
97 $this->waitForPageToLoad("30000");
98 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "projapp") ;
99 $this->click ("//input[@value='Add User']") ;
100 $this->waitForPageToLoad("30000");
101 $this->assertTrue($this->isTextPresent("projapp Lastname"));
103 $this->click("link=Site Admin");
104 $this->waitForPageToLoad("30000");
105 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=News moderators") ;
106 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
107 $this->waitForPageToLoad("30000");
108 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "newsmod") ;
109 $this->click ("//input[@value='Add User']") ;
110 $this->waitForPageToLoad("30000");
111 $this->assertTrue($this->isTextPresent("newsmod Lastname"));
113 // Add a wrong user to the role, then remove it
114 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "projapp") ;
115 $this->click ("//input[@value='Add User']") ;
116 $this->waitForPageToLoad("30000");
117 $this->assertTrue($this->isTextPresent("projapp Lastname"));
118 $this->assertTrue($this->isTextPresent("newsmod Lastname"));
119 $this->click ("//a[contains(@href,'/users/projapp')]/../../td/input[@type='checkbox']") ;
120 $this->click ("//input[@name='reallyremove']") ;
121 $this->click ("//input[@name='dormusers']") ;
122 $this->waitForPageToLoad("30000");
123 $this->assertFalse($this->isTextPresent("projapp Lastname"));
124 $this->assertTrue($this->isTextPresent("newsmod Lastname"));
126 // Register unprivileged user
127 $this->createUser ("toto") ;
129 // Temporarily grant project approval rights to user
130 // (For cases where project_registration_restricted=true)
131 $this->click("link=Site Admin");
132 $this->waitForPageToLoad("30000");
133 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
134 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
135 $this->waitForPageToLoad("30000");
136 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
137 $this->click ("//input[@value='Add User']") ;
138 $this->waitForPageToLoad("30000");
139 $this->assertTrue($this->isTextPresent("toto Lastname"));
142 $this->registerProject ("TotoProject", "toto") ;
144 // Revoke project approval rights
145 $this->click("link=Site Admin");
146 $this->waitForPageToLoad("30000");
147 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
148 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
149 $this->waitForPageToLoad("30000");
150 $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
151 $this->click ("//input[@name='reallyremove']") ;
152 $this->click ("//input[@name='dormusers']") ;
153 $this->waitForPageToLoad("30000");
154 $this->assertFalse($this->isTextPresent("toto Lastname"));
156 // Try approving it as two users without the right to do so
157 $this->switchUser ("toto") ;
158 $this->open( ROOT . '/admin/approve-pending.php') ;
159 $this->waitForPageToLoad("30000");
160 $this->assertTrue ($this->isPermissionDenied()) ;
161 $this->switchUser ("newsmod") ;
162 $this->open( ROOT . '/admin/approve-pending.php') ;
163 $this->waitForPageToLoad("30000");
164 $this->assertTrue ($this->isPermissionDenied()) ;
166 // Approve it with a user that only has approve_projects
167 $this->approveProject ("TotoProject", "projapp") ;
169 // Submit a news in the project
170 $this->switchUser ("toto") ;
171 $this->gotoProject ("TotoProject") ;
172 $this->click("link=News") ;
173 $this->waitForPageToLoad("30000");
174 $this->click("link=Submit") ;
175 $this->waitForPageToLoad("30000");
176 $this->type("summary", "First TotoNews");
177 $this->type("details", "This is a simple news for Toto's project.");
178 $this->click("submit");
179 $this->waitForPageToLoad("30000");
181 // Try to push it to front page with user toto
182 $this->open( ROOT . '/admin/pending-news.php') ;
183 $this->waitForPageToLoad("30000");
184 $this->assertTrue ($this->isPermissionDenied()) ;
186 // Try to push it to front page with user projapp
187 $this->switchUser ("projapp") ;
188 $this->open( ROOT . '/admin/pending-news.php') ;
189 $this->waitForPageToLoad("30000");
190 $this->assertTrue ($this->isPermissionDenied()) ;
192 // Push it to front page with user newsmod
193 $this->switchUser ("newsmod") ;
194 $this->open( ROOT . '/admin/pending-news.php') ;
195 $this->waitForPageToLoad("30000");
196 $this->assertTrue ($this->isTextPresent("These items need to be approved")) ;
197 $this->assertTrue ($this->isTextPresent("First TotoNews")) ;
198 $this->click ("//a[contains(.,'First TotoNews')]") ;
199 $this->waitForPageToLoad("30000");
200 $this->click ("//input[@type='radio' and @value='1']") ;
201 $this->click ("submit") ;
202 $this->waitForPageToLoad("30000");
203 $this->assertTrue ($this->isTextPresent("These items were approved this past week")) ;
204 $this->open( ROOT ) ;
205 $this->waitForPageToLoad("30000");
206 $this->assertTrue ($this->isTextPresent("First TotoNews")) ;
208 // Non-regression test for #265
210 $this->open( ROOT ) ;
211 $this->waitForPageToLoad("30000");
212 $this->assertTrue ($this->isTextPresent("First TotoNews")) ;
213 $this->click("link=First TotoNews") ;
214 $this->waitForPageToLoad("30000");
215 $this->assertFalse ($this->isPermissionDenied()) ;
217 // Non-regression test for Adacore ticket K802-005
218 // (Deletion of global roles)
219 $this->switchUser("admin");
220 $this->click("link=Site Admin");
221 $this->waitForPageToLoad("30000");
222 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Temporary role") ;
223 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
224 $this->waitForPageToLoad("30000");
225 $this->click("link=Site Admin");
226 $this->waitForPageToLoad("30000");
227 $this->assertTrue($this->isElementPresent("//option[.='Temporary role']"));
228 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
229 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
230 $this->waitForPageToLoad("30000");
232 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
233 $this->click ("//input[@value='Add User']") ;
234 $this->waitForPageToLoad("30000");
235 $this->assertTrue($this->isTextPresent("toto Lastname"));
236 $this->click ("//input[@type='checkbox' and @name='sure']") ;
237 $this->click ("//input[@value='Delete role']") ;
238 $this->waitForPageToLoad("30000");
239 $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
240 $this->click("link=Site Admin");
241 $this->waitForPageToLoad("30000");
242 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
243 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
244 $this->waitForPageToLoad("30000");
245 $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
246 $this->click ("//input[@name='reallyremove']") ;
247 $this->click ("//input[@name='dormusers']") ;
248 $this->waitForPageToLoad("30000");
249 $this->click("link=Site Admin");
250 $this->waitForPageToLoad("30000");
251 $this->assertFalse($this->isElementPresent("//option[.='Temporary role']"));
254 function testProjectRolesAndPermissions()
256 $this->populateStandardTemplate('trackers');
258 $this->createUser ("bigboss") ;
259 $this->createUser ("guru") ;
260 $this->createUser ("docmaster") ;
261 $this->createUser ("trainee") ;
263 // Create "Project moderators" role
264 $this->click("link=Site Admin");
265 $this->waitForPageToLoad("30000");
266 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Project moderators") ;
267 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
268 $this->waitForPageToLoad("30000");
270 // Grant it permissions
271 $this->select("//select[@name='data[approve_projects][-1]']", "label=Approve projects");
272 $this->click ("//input[@value='Submit']") ;
273 $this->waitForPageToLoad("30000");
276 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "bigboss") ;
277 $this->click ("//input[@value='Add User']") ;
278 $this->waitForPageToLoad("30000");
279 $this->assertTrue($this->isTextPresent("bigboss Lastname"));
281 // Create "Documentation masters" role
282 $this->click("link=Site Admin");
283 $this->waitForPageToLoad("30000");
284 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Documentation masters") ;
285 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
286 $this->waitForPageToLoad("30000");
289 $this->click ("//input[@type='checkbox' and @name='public']") ;
290 $this->click ("//input[@value='Submit']") ;
291 $this->waitForPageToLoad("30000");
294 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "docmaster") ;
295 $this->click ("//input[@value='Add User']") ;
296 $this->waitForPageToLoad("30000");
297 $this->assertTrue($this->isTextPresent("docmaster Lastname"));
300 $this->switchUser ("bigboss") ;
301 $this->registerProject ("MetaProject", "bigboss") ;
302 $this->approveProject ("MetaProject", "bigboss") ;
303 $this->registerProject ("SubProject", "bigboss") ;
304 $this->approveProject ("SubProject", "bigboss") ;
307 $this->gotoProject ("MetaProject") ;
308 $this->click("link=Admin");
309 $this->waitForPageToLoad("30000");
310 $this->click("link=Users and permissions");
311 $this->waitForPageToLoad("30000");
312 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Senior Developer") ;
313 $this->click ("//input[@value='Create Role']") ;
314 $this->waitForPageToLoad("30000");
315 $this->click("link=Users and permissions");
316 $this->waitForPageToLoad("30000");
317 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Junior Developer") ;
318 $this->click ("//input[@value='Create Role']") ;
319 $this->waitForPageToLoad("30000");
320 $this->click("link=Users and permissions");
321 $this->waitForPageToLoad("30000");
322 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Doc Writer") ;
323 $this->click ("//input[@value='Create Role']") ;
324 $this->waitForPageToLoad("30000");
327 $this->gotoProject ("MetaProject") ;
328 $this->click("link=Admin");
329 $this->waitForPageToLoad("30000");
330 $this->click("link=Users and permissions");
331 $this->waitForPageToLoad("30000");
332 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
333 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
334 $this->click ("//input[@value='Add Member']") ;
335 $this->waitForPageToLoad("30000");
336 $this->assertTrue($this->isTextPresent("guru Lastname"));
337 $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Senior Developer')]")) ;
339 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
340 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
341 $this->click ("//input[@value='Add Member']") ;
342 $this->waitForPageToLoad("30000");
343 $this->assertTrue($this->isTextPresent("trainee Lastname"));
344 $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
346 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "docmaster") ;
347 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Doc Writer");
348 $this->click ("//input[@value='Add Member']") ;
349 $this->waitForPageToLoad("30000");
350 $this->assertTrue($this->isTextPresent("docmaster Lastname"));
351 $this->assertTrue($this->isElementPresent("//tr/td/a[.='docmaster Lastname']/../../td/div[contains(.,'Doc Writer')]")) ;
353 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "bigboss") ;
354 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
355 $this->click ("//input[@value='Add Member']") ;
356 $this->waitForPageToLoad("30000");
357 $this->assertTrue($this->isTextPresent("bigboss Lastname"));
358 $this->assertTrue($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/..//input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
360 // Oops, bigboss doesn't need the extra role after all
361 $this->click("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@name='username' and @value='bigboss']/../input[@value='Remove']") ;
362 $this->waitForPageToLoad("30000");
363 $this->assertFalse($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
365 // Remove/re-add a user
366 $this->click("//tr/td/div[contains(.,'Junior Developer')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
367 $this->waitForPageToLoad("30000");
368 $this->assertFalse($this->isTextPresent("trainee Lastname"));
370 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
371 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
372 $this->click ("//input[@value='Add Member']") ;
373 $this->waitForPageToLoad("30000");
374 $this->assertTrue($this->isTextPresent("trainee Lastname"));
375 $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
377 // Edit permissions of the JD role
378 $this->gotoProject ("MetaProject") ;
379 $this->click("link=Admin");
380 $this->waitForPageToLoad("30000");
381 $this->click("link=Users and permissions");
382 $this->waitForPageToLoad("30000");
384 $this->click ("//td/form/div[contains(.,'Junior Developer')]/../div/input[@value='Edit Permissions']") ;
385 $this->waitForPageToLoad("30000");
387 $this->select("//select[contains(@name,'data[frs]')]", "label=View public packages only");
388 $this->select("//select[contains(@name,'data[docman]')]", "label=Read only");
389 $this->click ("//input[@value='Submit']") ;
390 $this->waitForPageToLoad("30000");
391 $this->assertSelected("//select[contains(@name,'data[docman]')]", "Read only");
392 $this->assertSelected("//select[contains(@name,'data[frs]')]", "View public packages only");
393 $this->select("//select[contains(@name,'data[frs]')]", "label=View all packages");
394 $this->click ("//input[@value='Submit']") ;
395 $this->waitForPageToLoad("30000");
396 $this->assertSelected("//select[contains(@name,'data[frs]')]", "View all packages");
398 // Check that SD is technician on trackers but DM isn't
399 $this->click("link=Tracker");
400 $this->waitForPageToLoad("30000");
401 $this->click("link=Bugs");
402 $this->waitForPageToLoad("30000");
403 $this->click("link=Submit New");
404 $this->waitForPageToLoad("30000");
405 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
406 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']/option[.='guru Lastname']")) ;
407 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']/option[.='docmaster Lastname']")) ;
409 // Check that SD is a manager on trackers but JD isn't
410 $this->switchUser('guru');
411 $this->gotoProject ("MetaProject") ;
412 $this->click("link=Tracker");
413 $this->waitForPageToLoad("30000");
414 $this->click("link=Bugs");
415 $this->waitForPageToLoad("30000");
416 $this->click("link=Submit New");
417 $this->waitForPageToLoad("30000");
418 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
420 $this->switchUser('trainee');
421 $this->gotoProject ("MetaProject") ;
422 $this->click("link=Tracker");
423 $this->waitForPageToLoad("30000");
424 $this->click("link=Bugs");
425 $this->waitForPageToLoad("30000");
426 $this->click("link=Submit New");
427 $this->waitForPageToLoad("30000");
428 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']")) ;
430 // Also check that guru isn't a manager on SubProject yet
431 $this->switchUser('guru');
432 $this->gotoProject ("SubProject") ;
433 $this->click("link=Tracker");
434 $this->waitForPageToLoad("30000");
435 $this->click("link=Bugs");
436 $this->waitForPageToLoad("30000");
437 $this->click("link=Submit New");
438 $this->waitForPageToLoad("30000");
439 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']")) ;
441 // Mark SD role as shared
442 $this->switchUser('bigboss');
443 $this->gotoProject ("MetaProject") ;
444 $this->click("link=Admin");
445 $this->waitForPageToLoad("30000");
446 $this->click("link=Users and permissions");
447 $this->waitForPageToLoad("30000");
448 $this->click ("//td/form/div[contains(.,'Senior Developer')]/../div/input[@value='Edit Permissions']") ;
449 $this->waitForPageToLoad("30000");
450 $this->click ("//input[@type='checkbox' and @name='public']") ;
451 $this->click ("//input[@value='Submit']") ;
452 $this->waitForPageToLoad("30000");
454 // Link MetaProject/SD role into SubProject
455 $this->gotoProject ("SubProject") ;
456 $this->click("link=Admin");
457 $this->waitForPageToLoad("30000");
458 $this->click("link=Users and permissions");
459 $this->waitForPageToLoad("30000");
461 $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Senior Developer (in project MetaProject)']")) ;
462 $this->select("//input[@value='Link external role']/../../div/select", "label=Senior Developer (in project MetaProject)") ;
463 $this->click("//input[@value='Link external role']") ;
464 $this->waitForPageToLoad("30000");
465 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[contains(@value,'Unlink Role')]"));
467 // Grant it tracker manager permissions
468 $this->click ("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[@value='Edit Permissions']") ;
469 $this->waitForPageToLoad("30000");
470 $this->select("//select[contains(@name,'data[tracker]')]", "label=Manager");
471 $this->click ("//input[@value='Submit']") ;
472 $this->waitForPageToLoad("30000");
474 // Check that guru now has manager permissions on SubProject
475 $this->switchUser('guru');
476 $this->gotoProject ("SubProject") ;
477 $this->click("link=Tracker");
478 $this->waitForPageToLoad("30000");
479 $this->click("link=Bugs");
480 $this->waitForPageToLoad("30000");
481 $this->click("link=Submit New");
482 $this->waitForPageToLoad("30000");
483 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
485 // Link global "Documentation masters" role into SubProject
486 $this->switchUser ("bigboss") ;
487 $this->gotoProject ("SubProject") ;
488 $this->click("link=Admin");
489 $this->waitForPageToLoad("30000");
490 $this->click("link=Users and permissions");
491 $this->waitForPageToLoad("30000");
493 $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Documentation masters (global role)']")) ;
494 $this->assertFalse($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Project moderators (global role)']")) ;
495 $this->select("//input[@value='Link external role']/../../div/select", "label=Documentation masters (global role)") ;
496 $this->click("//input[@value='Link external role']") ;
497 $this->waitForPageToLoad("30000");
498 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Documentation masters (global role)')]/../div/input[contains(@value,'Unlink Role')]"));
500 // Check that a project admin (not forge admin) can create a new role
501 $this->gotoProject ("SubProject") ;
502 $this->click("link=Admin");
503 $this->waitForPageToLoad("30000");
504 $this->click("link=Users and permissions");
505 $this->waitForPageToLoad("30000");
506 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
507 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Admin");
508 $this->click ("//input[@value='Add Member']") ;
509 $this->waitForPageToLoad("30000");
510 $this->assertTrue($this->isTextPresent("guru Lastname"));
511 $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Admin')]")) ;
513 $this->switchUser('guru');
514 $this->gotoProject ("SubProject") ;
515 $this->click("link=Admin");
516 $this->waitForPageToLoad("30000");
517 $this->click("link=Users and permissions");
518 $this->waitForPageToLoad("30000");
519 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Role created by guru") ;
520 $this->click ("//input[@value='Create Role']") ;
521 $this->waitForPageToLoad("30000");
522 $this->assertFalse ($this->isPermissionDenied()) ;
523 $this->click("link=Users and permissions");
524 $this->waitForPageToLoad("30000");
525 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Role created by guru')]/../div/input[@value='Edit Permissions']")) ;
527 // Non-regression test for Adacore ticket K802-005
528 // (Deletion of project-wide roles)
529 $this->switchUser("admin");
530 $this->gotoProject ("MetaProject") ;
531 $this->click("link=Admin");
532 $this->waitForPageToLoad("30000");
533 $this->click("link=Users and permissions");
534 $this->waitForPageToLoad("30000");
535 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Temporary role") ;
536 $this->click ("//input[@value='Create Role']") ;
537 $this->waitForPageToLoad("30000");
538 $this->click("link=Users and permissions");
539 $this->waitForPageToLoad("30000");
540 $this->assertTrue($this->isTextPresent("Temporary role"));
541 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
542 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Temporary role");
543 $this->click ("//input[@value='Add Member']") ;
544 $this->waitForPageToLoad("30000");
545 $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
546 $this->waitForPageToLoad("30000");
547 $this->click ("//input[@type='checkbox' and @name='sure']") ;
548 $this->click ("//input[@value='Submit']") ;
549 $this->waitForPageToLoad("30000");
550 $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
551 $this->click("//tr/td/div[contains(.,'Temporary role')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
552 $this->waitForPageToLoad("30000");
553 $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
554 $this->waitForPageToLoad("30000");
555 $this->click ("//input[@type='checkbox' and @name='sure']") ;
556 $this->click ("//input[@value='Submit']") ;
557 $this->waitForPageToLoad("30000");
558 $this->assertFalse($this->isTextPresent("Temporary role"));