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("Current Project Members"));
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(FORGE_ADMIN_USERNAME);
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(FORGE_ADMIN_USERNAME);
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");
231 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
232 $this->click ("//input[@value='Add User']") ;
233 $this->waitForPageToLoad("30000");
234 $this->assertTrue($this->isTextPresent("toto Lastname"));
235 $this->click ("//input[@type='checkbox' and @name='sure']") ;
236 $this->click ("//input[@value='Delete role']") ;
237 $this->waitForPageToLoad("30000");
238 $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
239 $this->click("link=Site Admin");
240 $this->waitForPageToLoad("30000");
241 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
242 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
243 $this->waitForPageToLoad("30000");
244 $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
245 $this->click ("//input[@name='reallyremove']") ;
246 $this->click ("//input[@name='dormusers']") ;
247 $this->waitForPageToLoad("30000");
248 $this->click("link=Site Admin");
249 $this->waitForPageToLoad("30000");
250 $this->assertTrue($this->isElementPresent("//option[.='Temporary role']"));
251 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
252 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
253 $this->waitForPageToLoad("30000");
254 $this->click ("//input[@type='checkbox' and @name='sure']") ;
255 $this->click ("//input[@value='Delete role']") ;
256 $this->waitForPageToLoad("30000");
257 $this->assertFalse($this->isElementPresent("//option[.='Temporary role']"));
260 function testProjectRolesAndPermissions()
262 $this->populateStandardTemplate('trackers');
264 $this->createUser ("bigboss") ;
265 $this->createUser ("guru") ;
266 $this->createUser ("docmaster") ;
267 $this->createUser ("trainee") ;
269 // Create "Project moderators" role
270 $this->click("link=Site Admin");
271 $this->waitForPageToLoad("30000");
272 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Project moderators") ;
273 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
274 $this->waitForPageToLoad("30000");
276 // Grant it permissions
277 $this->select("//select[@name='data[approve_projects][-1]']", "label=Approve projects");
278 $this->click ("//input[@value='Submit']") ;
279 $this->waitForPageToLoad("30000");
282 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "bigboss") ;
283 $this->click ("//input[@value='Add User']") ;
284 $this->waitForPageToLoad("30000");
285 $this->assertTrue($this->isTextPresent("bigboss Lastname"));
287 // Create "Documentation masters" role
288 $this->click("link=Site Admin");
289 $this->waitForPageToLoad("30000");
290 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Documentation masters") ;
291 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
292 $this->waitForPageToLoad("30000");
295 $this->click ("//input[@type='checkbox' and @name='public']") ;
296 $this->click ("//input[@value='Submit']") ;
297 $this->waitForPageToLoad("30000");
300 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "docmaster") ;
301 $this->click ("//input[@value='Add User']") ;
302 $this->waitForPageToLoad("30000");
303 $this->assertTrue($this->isTextPresent("docmaster Lastname"));
306 $this->switchUser ("bigboss") ;
307 $this->registerProject ("MetaProject", "bigboss") ;
308 $this->approveProject ("MetaProject", "bigboss") ;
309 $this->registerProject ("SubProject", "bigboss") ;
310 $this->approveProject ("SubProject", "bigboss") ;
313 $this->gotoProject ("MetaProject") ;
314 $this->click("link=Admin");
315 $this->waitForPageToLoad("30000");
316 $this->click("link=Users and permissions");
317 $this->waitForPageToLoad("30000");
318 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Senior Developer") ;
319 $this->click ("//input[@value='Create Role']") ;
320 $this->waitForPageToLoad("30000");
321 $this->click("link=Users and permissions");
322 $this->waitForPageToLoad("30000");
323 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Junior Developer") ;
324 $this->click ("//input[@value='Create Role']") ;
325 $this->waitForPageToLoad("30000");
326 $this->click("link=Users and permissions");
327 $this->waitForPageToLoad("30000");
328 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Doc Writer") ;
329 $this->click ("//input[@value='Create Role']") ;
330 $this->waitForPageToLoad("30000");
333 $this->gotoProject ("MetaProject") ;
334 $this->click("link=Admin");
335 $this->waitForPageToLoad("30000");
336 $this->click("link=Users and permissions");
337 $this->waitForPageToLoad("30000");
338 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
339 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
340 $this->click ("//input[@value='Add Member']") ;
341 $this->waitForPageToLoad("30000");
342 $this->assertTrue($this->isTextPresent("guru Lastname"));
343 $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Senior Developer')]")) ;
345 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
346 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
347 $this->click ("//input[@value='Add Member']") ;
348 $this->waitForPageToLoad("30000");
349 $this->assertTrue($this->isTextPresent("trainee Lastname"));
350 $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
352 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "docmaster") ;
353 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Doc Writer");
354 $this->click ("//input[@value='Add Member']") ;
355 $this->waitForPageToLoad("30000");
356 $this->assertTrue($this->isTextPresent("docmaster Lastname"));
357 $this->assertTrue($this->isElementPresent("//tr/td/a[.='docmaster Lastname']/../../td/div[contains(.,'Doc Writer')]")) ;
359 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "bigboss") ;
360 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
361 $this->click ("//input[@value='Add Member']") ;
362 $this->waitForPageToLoad("30000");
363 $this->assertTrue($this->isTextPresent("bigboss Lastname"));
364 $this->assertTrue($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/..//input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
366 // Oops, bigboss doesn't need the extra role after all
367 $this->click("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@name='username' and @value='bigboss']/../input[@value='Remove']") ;
368 $this->waitForPageToLoad("30000");
369 $this->assertFalse($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
371 // Remove/re-add a user
372 $this->click("//tr/td/div[contains(.,'Junior Developer')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
373 $this->waitForPageToLoad("30000");
374 $this->assertFalse($this->isTextPresent("trainee Lastname"));
376 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
377 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
378 $this->click ("//input[@value='Add Member']") ;
379 $this->waitForPageToLoad("30000");
380 $this->assertTrue($this->isTextPresent("trainee Lastname"));
381 $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
383 // Edit permissions of the JD role
384 $this->gotoProject ("MetaProject") ;
385 $this->click("link=Admin");
386 $this->waitForPageToLoad("30000");
387 $this->click("link=Users and permissions");
388 $this->waitForPageToLoad("30000");
390 $this->click ("//td/form/div[contains(.,'Junior Developer')]/../div/input[@value='Edit Permissions']") ;
391 $this->waitForPageToLoad("30000");
393 $this->select("//select[contains(@name,'data[frs]')]", "label=View public packages only");
394 $this->select("//select[contains(@name,'data[docman]')]", "label=Read only");
395 $this->click ("//input[@value='Submit']") ;
396 $this->waitForPageToLoad("30000");
397 $this->assertSelected("//select[contains(@name,'data[docman]')]", "Read only");
398 $this->assertSelected("//select[contains(@name,'data[frs]')]", "View public packages only");
399 $this->select("//select[contains(@name,'data[frs]')]", "label=View all packages");
400 $this->click ("//input[@value='Submit']") ;
401 $this->waitForPageToLoad("30000");
402 $this->assertSelected("//select[contains(@name,'data[frs]')]", "View all packages");
404 // Check that SD is technician on trackers but DM isn't
405 $this->click("link=Tracker");
406 $this->waitForPageToLoad("30000");
407 $this->click("link=Bugs");
408 $this->waitForPageToLoad("30000");
409 $this->click("link=Submit New");
410 $this->waitForPageToLoad("30000");
411 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
412 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']/option[.='guru Lastname']")) ;
413 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']/option[.='docmaster Lastname']")) ;
415 // Check that SD is a manager on trackers but JD isn't
416 $this->switchUser('guru');
417 $this->gotoProject ("MetaProject") ;
418 $this->click("link=Tracker");
419 $this->waitForPageToLoad("30000");
420 $this->click("link=Bugs");
421 $this->waitForPageToLoad("30000");
422 $this->click("link=Submit New");
423 $this->waitForPageToLoad("30000");
424 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
426 $this->switchUser('trainee');
427 $this->gotoProject ("MetaProject") ;
428 $this->click("link=Tracker");
429 $this->waitForPageToLoad("30000");
430 $this->click("link=Bugs");
431 $this->waitForPageToLoad("30000");
432 $this->click("link=Submit New");
433 $this->waitForPageToLoad("30000");
434 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']")) ;
436 // Also check that guru isn't a manager on SubProject yet
437 $this->switchUser('guru');
438 $this->gotoProject ("SubProject") ;
439 $this->click("link=Tracker");
440 $this->waitForPageToLoad("30000");
441 $this->click("link=Bugs");
442 $this->waitForPageToLoad("30000");
443 $this->click("link=Submit New");
444 $this->waitForPageToLoad("30000");
445 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']")) ;
447 // Mark SD role as shared
448 $this->switchUser('bigboss');
449 $this->gotoProject ("MetaProject") ;
450 $this->click("link=Admin");
451 $this->waitForPageToLoad("30000");
452 $this->click("link=Users and permissions");
453 $this->waitForPageToLoad("30000");
454 $this->click ("//td/form/div[contains(.,'Senior Developer')]/../div/input[@value='Edit Permissions']") ;
455 $this->waitForPageToLoad("30000");
456 $this->click ("//input[@type='checkbox' and @name='public']") ;
457 $this->click ("//input[@value='Submit']") ;
458 $this->waitForPageToLoad("30000");
460 // Link MetaProject/SD role into SubProject
461 $this->gotoProject ("SubProject") ;
462 $this->click("link=Admin");
463 $this->waitForPageToLoad("30000");
464 $this->click("link=Users and permissions");
465 $this->waitForPageToLoad("30000");
467 $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Senior Developer (in project MetaProject)']")) ;
468 $this->select("//input[@value='Link external role']/../../div/select", "label=Senior Developer (in project MetaProject)") ;
469 $this->click("//input[@value='Link external role']") ;
470 $this->waitForPageToLoad("30000");
471 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[contains(@value,'Unlink Role')]"));
473 // Grant it tracker manager permissions
474 $this->click ("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[@value='Edit Permissions']") ;
475 $this->waitForPageToLoad("30000");
476 $this->select("//select[contains(@name,'data[tracker]')]", "label=Manager");
477 $this->click ("//input[@value='Submit']") ;
478 $this->waitForPageToLoad("30000");
480 // Check that guru now has manager permissions on SubProject
481 $this->switchUser('guru');
482 $this->gotoProject ("SubProject") ;
483 $this->click("link=Tracker");
484 $this->waitForPageToLoad("30000");
485 $this->click("link=Bugs");
486 $this->waitForPageToLoad("30000");
487 $this->click("link=Submit New");
488 $this->waitForPageToLoad("30000");
489 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
491 // Link global "Documentation masters" role into SubProject
492 $this->switchUser ("bigboss") ;
493 $this->gotoProject ("SubProject") ;
494 $this->click("link=Admin");
495 $this->waitForPageToLoad("30000");
496 $this->click("link=Users and permissions");
497 $this->waitForPageToLoad("30000");
499 $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Documentation masters (global role)']")) ;
500 $this->assertFalse($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Project moderators (global role)']")) ;
501 $this->select("//input[@value='Link external role']/../../div/select", "label=Documentation masters (global role)") ;
502 $this->click("//input[@value='Link external role']") ;
503 $this->waitForPageToLoad("30000");
504 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Documentation masters (global role)')]/../div/input[contains(@value,'Unlink Role')]"));
506 // Check that a project admin (not forge admin) can create a new role
507 $this->gotoProject ("SubProject") ;
508 $this->click("link=Admin");
509 $this->waitForPageToLoad("30000");
510 $this->click("link=Users and permissions");
511 $this->waitForPageToLoad("30000");
512 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
513 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Admin");
514 $this->click ("//input[@value='Add Member']") ;
515 $this->waitForPageToLoad("30000");
516 $this->assertTrue($this->isTextPresent("guru Lastname"));
517 $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Admin')]")) ;
519 $this->switchUser('guru');
520 $this->gotoProject ("SubProject") ;
521 $this->click("link=Admin");
522 $this->waitForPageToLoad("30000");
523 $this->click("link=Users and permissions");
524 $this->waitForPageToLoad("30000");
525 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Role created by guru") ;
526 $this->click ("//input[@value='Create Role']") ;
527 $this->waitForPageToLoad("30000");
528 $this->assertFalse ($this->isPermissionDenied()) ;
529 $this->click("link=Users and permissions");
530 $this->waitForPageToLoad("30000");
531 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Role created by guru')]/../div/input[@value='Edit Permissions']")) ;
533 // Non-regression test for Adacore ticket K802-005
534 // (Deletion of project-wide roles)
535 $this->switchUser(FORGE_ADMIN_USERNAME);
536 $this->gotoProject ("MetaProject") ;
537 $this->click("link=Admin");
538 $this->waitForPageToLoad("30000");
539 $this->click("link=Users and permissions");
540 $this->waitForPageToLoad("30000");
541 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Temporary role") ;
542 $this->click ("//input[@value='Create Role']") ;
543 $this->waitForPageToLoad("30000");
544 $this->click("link=Users and permissions");
545 $this->waitForPageToLoad("30000");
546 $this->assertTrue($this->isTextPresent("Temporary role"));
547 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
548 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Temporary role");
549 $this->click ("//input[@value='Add Member']") ;
550 $this->waitForPageToLoad("30000");
551 $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
552 $this->waitForPageToLoad("30000");
553 $this->click ("//input[@type='checkbox' and @name='sure']") ;
554 $this->click ("//input[@value='Submit']") ;
555 $this->waitForPageToLoad("30000");
556 $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
557 $this->click("//tr/td/div[contains(.,'Temporary role')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
558 $this->waitForPageToLoad("30000");
559 $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
560 $this->waitForPageToLoad("30000");
561 $this->click ("//input[@type='checkbox' and @name='sure']") ;
562 $this->click ("//input[@value='Submit']") ;
563 $this->waitForPageToLoad("30000");
564 $this->assertFalse($this->isTextPresent("Temporary role"));
566 // Non-regression test
567 $this->click("link=Site Admin");
568 $this->waitForPageToLoad("30000");
569 $this->click("link=Display Full Project List/Edit Projects");
570 $this->waitForPageToLoad("30000");
571 $this->click("link=SubProject");
572 $this->waitForPageToLoad("30000");
573 $this->click("link=Permanently Delete Project");
574 $this->waitForPageToLoad("30000");
575 $this->click("sure");
576 $this->click("reallysure");
577 $this->click("reallyreallysure");
578 $this->click("submit");
579 $this->waitForPageToLoad("30000");
580 $this->click("link=Home");
581 $this->waitForPageToLoad("30000");
582 $this->assertFalse($this->isTextPresent("SubProject"));