3 * Copyright 2010-2011, Roland Mas
4 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
5 * Copyright 2013, Franck Villaume - TrivialDev
7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2 of the License,
12 * or (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once dirname(dirname(__FILE__)).'/Testing/SeleniumGforge.php';
26 class RBAC extends FForge_SeleniumTestCase
28 function testAnonymousProjectReadAccess()
32 $this->click("link=Admin");
33 $this->waitForPageToLoad("30000");
34 $this->assertTrue($this->isTextPresent("Project Information"));
35 $this->click("link=Users and permissions");
36 $this->waitForPageToLoad("30000");
37 $this->assertTrue($this->isTextPresent("Current Project Members"));
38 $this->click("//tr/td/form/div[contains(.,'Anonymous')]/../../../td/form/div/input[contains(@value,'Unlink Role')]");
39 $this->waitForPageToLoad("30000");
40 $this->assertTrue($this->isTextPresent("Role unlinked successfully"));
42 $this->createUser ('staffmember') ;
44 $this->assertFalse($this->isTextPresent("ProjectA"));
46 $this->open( ROOT . '/projects/projecta') ;
47 $this->waitForPageToLoad("30000");
48 $this->assertTrue($this->isLoginRequired());
49 $this->triggeredLogin('staffmember');
50 $this->assertTrue($this->isTextPresent("Project Members"));
53 function testGlobalRolesAndPermissions()
55 $this->login(FORGE_ADMIN_USERNAME);
57 $this->click("link=Site Admin");
58 $this->waitForPageToLoad("30000");
60 // Create "Project approvers" role
61 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Project approvers") ;
62 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
63 $this->waitForPageToLoad("30000");
65 // Grant it permissions
66 $this->select("//select[@name='data[approve_projects][-1]']", "label=Approve projects");
67 $this->select("//select[@name='data[approve_news][-1]']", "label=Approve news");
68 $this->click ("//input[@value='Submit']") ;
69 $this->waitForPageToLoad("30000");
71 // Check permissions were saved
72 $this->click("link=Site Admin");
73 $this->waitForPageToLoad("30000");
74 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
75 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
76 $this->waitForPageToLoad("30000");
78 $this->assertSelected("//select[@name='data[approve_projects][-1]']", "Approve projects");
79 $this->assertNotSelected("//select[@name='data[approve_projects][-1]']", "No access");
80 $this->assertSelected("//select[@name='data[approve_news][-1]']", "Approve news");
82 // Whoops, we don't actually want the news moderation bit, unset it
83 $this->select("//select[@name='data[approve_news][-1]']", "label=No access");
84 $this->click ("//input[@value='Submit']") ;
85 $this->waitForPageToLoad("30000");
86 $this->assertSelected("//select[@name='data[approve_projects][-1]']", "Approve projects");
87 $this->assertSelected("//select[@name='data[approve_news][-1]']", "No access");
89 // Create users for "Project approvers" and "News moderators" roles
90 $this->createUser ("projapp") ;
91 $this->createUser ("newsmod") ;
93 // Add them to their respective roles, check they're here
94 $this->click("link=Site Admin");
95 $this->waitForPageToLoad("30000");
96 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
97 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
98 $this->waitForPageToLoad("30000");
99 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "projapp") ;
100 $this->click ("//input[@value='Add User']") ;
101 $this->waitForPageToLoad("30000");
102 $this->assertTrue($this->isTextPresent("projapp Lastname"));
104 $this->click("link=Site Admin");
105 $this->waitForPageToLoad("30000");
106 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=News moderators") ;
107 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
108 $this->waitForPageToLoad("30000");
109 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "newsmod") ;
110 $this->click ("//input[@value='Add User']") ;
111 $this->waitForPageToLoad("30000");
112 $this->assertTrue($this->isTextPresent("newsmod Lastname"));
114 // Add a wrong user to the role, then remove it
115 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "projapp") ;
116 $this->click ("//input[@value='Add User']") ;
117 $this->waitForPageToLoad("30000");
118 $this->assertTrue($this->isTextPresent("projapp Lastname"));
119 $this->assertTrue($this->isTextPresent("newsmod Lastname"));
120 $this->click ("//a[contains(@href,'/users/projapp')]/../../td/input[@type='checkbox']") ;
121 $this->click ("//input[@name='reallyremove']") ;
122 $this->click ("//input[@name='dormusers']") ;
123 $this->waitForPageToLoad("30000");
124 $this->assertFalse($this->isTextPresent("projapp Lastname"));
125 $this->assertTrue($this->isTextPresent("newsmod Lastname"));
127 // Register unprivileged user
128 $this->createUser ("toto") ;
130 // Temporarily grant project approval rights to user
131 // (For cases where project_registration_restricted=true)
132 $this->click("link=Site Admin");
133 $this->waitForPageToLoad("30000");
134 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
135 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
136 $this->waitForPageToLoad("30000");
137 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
138 $this->click ("//input[@value='Add User']") ;
139 $this->waitForPageToLoad("30000");
140 $this->assertTrue($this->isTextPresent("toto Lastname"));
143 $this->registerProject ("TotoProject", "toto") ;
145 // Revoke project approval rights
146 $this->click("link=Site Admin");
147 $this->waitForPageToLoad("30000");
148 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Project approvers") ;
149 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
150 $this->waitForPageToLoad("30000");
151 $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
152 $this->click ("//input[@name='reallyremove']") ;
153 $this->click ("//input[@name='dormusers']") ;
154 $this->waitForPageToLoad("30000");
155 $this->assertFalse($this->isTextPresent("toto Lastname"));
157 // Try approving it as two users without the right to do so
158 $this->switchUser ("toto") ;
159 $this->open( ROOT . '/admin/approve-pending.php') ;
160 $this->waitForPageToLoad("30000");
161 $this->assertTrue ($this->isPermissionDenied()) ;
162 $this->switchUser ("newsmod") ;
163 $this->open( ROOT . '/admin/approve-pending.php') ;
164 $this->waitForPageToLoad("30000");
165 $this->assertTrue ($this->isPermissionDenied()) ;
167 // Submit a news in the project
168 $this->switchUser ("toto") ;
169 $this->gotoProject ("TotoProject") ;
170 $this->click("link=News") ;
171 $this->waitForPageToLoad("30000");
172 $this->click("link=Submit") ;
173 $this->waitForPageToLoad("30000");
174 $this->type("summary", "First TotoNews");
175 $this->type("details", "This is a simple news for Toto's project.");
176 $this->click("submit");
177 $this->waitForPageToLoad("30000");
179 // Try to push it to front page with user toto
180 $this->open( ROOT . '/admin/pending-news.php') ;
181 $this->waitForPageToLoad("30000");
182 $this->assertTrue ($this->isPermissionDenied()) ;
184 // Try to push it to front page with user projapp
185 $this->switchUser ("projapp") ;
186 $this->open( ROOT . '/admin/pending-news.php') ;
187 $this->waitForPageToLoad("30000");
188 $this->assertTrue ($this->isPermissionDenied()) ;
190 // Push it to front page with user newsmod
191 $this->switchUser ("newsmod") ;
192 $this->open( ROOT . '/admin/pending-news.php') ;
193 $this->waitForPageToLoad("30000");
194 $this->assertTrue ($this->isTextPresent("These items need to be approved")) ;
195 $this->assertTrue ($this->isTextPresent("First TotoNews")) ;
196 $this->click ("//a[contains(.,'First TotoNews')]") ;
197 $this->waitForPageToLoad("30000");
198 $this->click ("//input[@type='radio' and @value='1']") ;
199 $this->click ("submit") ;
200 $this->waitForPageToLoad("30000");
201 $this->assertTrue ($this->isTextPresent("These items were approved this past week")) ;
202 $this->open( ROOT ) ;
203 $this->waitForPageToLoad("30000");
204 $this->assertTrue ($this->isTextPresent("First TotoNews")) ;
206 // Non-regression test for #265
208 $this->open( ROOT ) ;
209 $this->waitForPageToLoad("30000");
210 $this->assertTrue ($this->isTextPresent("First TotoNews")) ;
211 $this->click("link=First TotoNews") ;
212 $this->waitForPageToLoad("30000");
213 $this->assertFalse ($this->isPermissionDenied()) ;
215 // Non-regression test for Adacore ticket K802-005
216 // (Deletion of global roles)
217 $this->switchUser(FORGE_ADMIN_USERNAME);
218 $this->click("link=Site Admin");
219 $this->waitForPageToLoad("30000");
220 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Temporary role") ;
221 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
222 $this->waitForPageToLoad("30000");
223 $this->click("link=Site Admin");
224 $this->waitForPageToLoad("30000");
225 $this->assertTrue($this->isElementPresent("//option[.='Temporary role']"));
226 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
227 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
228 $this->waitForPageToLoad("30000");
229 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
230 $this->click ("//input[@value='Add User']") ;
231 $this->waitForPageToLoad("30000");
232 $this->assertTrue($this->isTextPresent("toto Lastname"));
233 $this->click ("//input[@type='checkbox' and @name='sure']") ;
234 $this->click ("//input[@value='Delete role']") ;
235 $this->waitForPageToLoad("30000");
236 $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
237 $this->click("link=Site Admin");
238 $this->waitForPageToLoad("30000");
239 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
240 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
241 $this->waitForPageToLoad("30000");
242 $this->click ("//a[contains(@href,'/users/toto')]/../../td/input[@type='checkbox']") ;
243 $this->click ("//input[@name='reallyremove']") ;
244 $this->click ("//input[@name='dormusers']") ;
245 $this->waitForPageToLoad("30000");
246 $this->click("link=Site Admin");
247 $this->waitForPageToLoad("30000");
248 $this->assertTrue($this->isElementPresent("//option[.='Temporary role']"));
249 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Temporary role") ;
250 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
251 $this->waitForPageToLoad("30000");
252 $this->click ("//input[@type='checkbox' and @name='sure']") ;
253 $this->click ("//input[@value='Delete role']") ;
254 $this->waitForPageToLoad("30000");
255 $this->assertFalse($this->isElementPresent("//option[.='Temporary role']"));
258 function testProjectRolesAndPermissions()
260 $this->populateStandardTemplate('all');
262 $this->createUser ("bigboss") ;
263 $this->createUser ("guru") ;
264 $this->createUser ("docmaster") ;
265 $this->createUser ("trainee") ;
267 // Create "Project moderators" role
268 $this->click("link=Site Admin");
269 $this->waitForPageToLoad("30000");
270 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Project moderators") ;
271 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
272 $this->waitForPageToLoad("30000");
274 // Grant it permissions
275 $this->select("//select[@name='data[approve_projects][-1]']", "label=Approve projects");
276 $this->click ("//input[@value='Submit']") ;
277 $this->waitForPageToLoad("30000");
280 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "bigboss") ;
281 $this->click ("//input[@value='Add User']") ;
282 $this->waitForPageToLoad("30000");
283 $this->assertTrue($this->isTextPresent("bigboss Lastname"));
285 // Create "Documentation masters" role
286 $this->click("link=Site Admin");
287 $this->waitForPageToLoad("30000");
288 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='role_name']", "Documentation masters") ;
289 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Create Role']") ;
290 $this->waitForPageToLoad("30000");
293 $this->click ("//input[@type='checkbox' and @name='public']") ;
294 $this->click ("//input[@value='Submit']") ;
295 $this->waitForPageToLoad("30000");
298 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "docmaster") ;
299 $this->click ("//input[@value='Add User']") ;
300 $this->waitForPageToLoad("30000");
301 $this->assertTrue($this->isTextPresent("docmaster Lastname"));
304 $this->switchUser ("bigboss") ;
305 $this->registerProject ("MetaProject", "bigboss") ;
306 $this->approveProject ("MetaProject", "bigboss") ;
307 $this->registerProject ("SubProject", "bigboss") ;
308 $this->approveProject ("SubProject", "bigboss") ;
311 $this->gotoProject ("MetaProject") ;
312 $this->click("link=Admin");
313 $this->waitForPageToLoad("30000");
314 $this->click("link=Users and permissions");
315 $this->waitForPageToLoad("30000");
316 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Senior Developer") ;
317 $this->click ("//input[@value='Create Role']") ;
318 $this->waitForPageToLoad("30000");
319 $this->click("link=Users and permissions");
320 $this->waitForPageToLoad("30000");
321 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Junior Developer") ;
322 $this->click ("//input[@value='Create Role']") ;
323 $this->waitForPageToLoad("30000");
324 $this->click("link=Users and permissions");
325 $this->waitForPageToLoad("30000");
326 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Doc Writer") ;
327 $this->click ("//input[@value='Create Role']") ;
328 $this->waitForPageToLoad("30000");
331 $this->gotoProject ("MetaProject") ;
332 $this->click("link=Admin");
333 $this->waitForPageToLoad("30000");
334 $this->click("link=Users and permissions");
335 $this->waitForPageToLoad("30000");
336 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
337 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
338 $this->click ("//input[@value='Add Member']") ;
339 $this->waitForPageToLoad("30000");
340 $this->assertTrue($this->isTextPresent("guru Lastname"));
341 $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Senior Developer')]")) ;
343 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
344 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
345 $this->click ("//input[@value='Add Member']") ;
346 $this->waitForPageToLoad("30000");
347 $this->assertTrue($this->isTextPresent("trainee Lastname"));
348 $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
350 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "docmaster") ;
351 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Doc Writer");
352 $this->click ("//input[@value='Add Member']") ;
353 $this->waitForPageToLoad("30000");
354 $this->assertTrue($this->isTextPresent("docmaster Lastname"));
355 $this->assertTrue($this->isElementPresent("//tr/td/a[.='docmaster Lastname']/../../td/div[contains(.,'Doc Writer')]")) ;
357 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "bigboss") ;
358 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Senior Developer");
359 $this->click ("//input[@value='Add Member']") ;
360 $this->waitForPageToLoad("30000");
361 $this->assertTrue($this->isTextPresent("bigboss Lastname"));
362 $this->assertTrue($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/..//input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
364 // Oops, bigboss doesn't need the extra role after all
365 $this->click("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@name='username' and @value='bigboss']/../input[@value='Remove']") ;
366 $this->waitForPageToLoad("30000");
367 $this->assertFalse($this->isElementPresent("//tr/td/div[contains(.,'Senior Developer')]/../div/form/input[@value='Remove']/../input[@name='username' and @value='bigboss']")) ;
369 // Remove/re-add a user
370 $this->click("//tr/td/div[contains(.,'Junior Developer')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
371 $this->waitForPageToLoad("30000");
372 $this->assertFalse($this->isTextPresent("trainee Lastname"));
374 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
375 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Junior Developer");
376 $this->click ("//input[@value='Add Member']") ;
377 $this->waitForPageToLoad("30000");
378 $this->assertTrue($this->isTextPresent("trainee Lastname"));
379 $this->assertTrue($this->isElementPresent("//tr/td/a[.='trainee Lastname']/../../td/div[contains(.,'Junior Developer')]")) ;
381 // Edit permissions of the JD role
382 $this->gotoProject ("MetaProject") ;
383 $this->click("link=Admin");
384 $this->waitForPageToLoad("30000");
385 $this->click("link=Users and permissions");
386 $this->waitForPageToLoad("30000");
388 $this->click ("//td/form/div[contains(.,'Junior Developer')]/../div/input[@value='Edit Permissions']") ;
389 $this->waitForPageToLoad("30000");
391 $this->select("//select[contains(@name,'data[frs]')]", "label=View public packages only");
392 $this->select("//select[contains(@name,'data[docman]')]", "label=Read only");
393 $this->click ("//input[@value='Submit']") ;
394 $this->waitForPageToLoad("30000");
395 $this->assertSelected("//select[contains(@name,'data[docman]')]", "Read only");
396 $this->assertSelected("//select[contains(@name,'data[frs]')]", "View public packages only");
397 $this->select("//select[contains(@name,'data[frs]')]", "label=View all packages");
398 $this->click ("//input[@value='Submit']") ;
399 $this->waitForPageToLoad("30000");
400 $this->assertSelected("//select[contains(@name,'data[frs]')]", "View all packages");
402 // Check that SD is technician on trackers but DM isn't
403 $this->click("link=Tracker");
404 $this->waitForPageToLoad("30000");
405 $this->click("link=Bugs");
406 $this->waitForPageToLoad("30000");
407 $this->click("link=Submit New");
408 $this->waitForPageToLoad("30000");
409 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
410 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']/option[.='guru Lastname']")) ;
411 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']/option[.='docmaster Lastname']")) ;
413 // Check that SD is a manager on trackers but JD isn't
414 $this->switchUser('guru');
415 $this->gotoProject ("MetaProject") ;
416 $this->click("link=Tracker");
417 $this->waitForPageToLoad("30000");
418 $this->click("link=Bugs");
419 $this->waitForPageToLoad("30000");
420 $this->click("link=Submit New");
421 $this->waitForPageToLoad("30000");
422 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
424 $this->switchUser('trainee');
425 $this->gotoProject ("MetaProject") ;
426 $this->click("link=Tracker");
427 $this->waitForPageToLoad("30000");
428 $this->click("link=Bugs");
429 $this->waitForPageToLoad("30000");
430 $this->click("link=Submit New");
431 $this->waitForPageToLoad("30000");
432 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']")) ;
434 // Also check that guru isn't a manager on SubProject yet
435 $this->switchUser('guru');
436 $this->gotoProject ("SubProject") ;
437 $this->click("link=Tracker");
438 $this->waitForPageToLoad("30000");
439 $this->click("link=Bugs");
440 $this->waitForPageToLoad("30000");
441 $this->click("link=Submit New");
442 $this->waitForPageToLoad("30000");
443 $this->assertFalse($this->isElementPresent("//select[@name='assigned_to']")) ;
445 // Mark SD role as shared
446 $this->switchUser('bigboss');
447 $this->gotoProject ("MetaProject") ;
448 $this->click("link=Admin");
449 $this->waitForPageToLoad("30000");
450 $this->click("link=Users and permissions");
451 $this->waitForPageToLoad("30000");
452 $this->click ("//td/form/div[contains(.,'Senior Developer')]/../div/input[@value='Edit Permissions']") ;
453 $this->waitForPageToLoad("30000");
454 $this->click ("//input[@type='checkbox' and @name='public']") ;
455 $this->click ("//input[@value='Submit']") ;
456 $this->waitForPageToLoad("30000");
458 // Link MetaProject/SD role into SubProject
459 $this->gotoProject ("SubProject") ;
460 $this->click("link=Admin");
461 $this->waitForPageToLoad("30000");
462 $this->click("link=Users and permissions");
463 $this->waitForPageToLoad("30000");
465 $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Senior Developer (in project MetaProject)']")) ;
466 $this->select("//input[@value='Link external role']/../../div/select", "label=Senior Developer (in project MetaProject)") ;
467 $this->click("//input[@value='Link external role']") ;
468 $this->waitForPageToLoad("30000");
469 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[contains(@value,'Unlink Role')]"));
471 // Grant it tracker manager permissions
472 $this->click ("//td/form/div[contains(.,'Senior Developer (in project MetaProject)')]/../div/input[@value='Edit Permissions']") ;
473 $this->waitForPageToLoad("30000");
474 $this->select("//select[contains(@name,'data[tracker]')]", "label=Manager");
475 $this->click ("//input[@value='Submit']") ;
476 $this->waitForPageToLoad("30000");
478 // Check that guru now has manager permissions on SubProject
479 $this->switchUser('guru');
480 $this->gotoProject ("SubProject") ;
481 $this->click("link=Tracker");
482 $this->waitForPageToLoad("30000");
483 $this->click("link=Bugs");
484 $this->waitForPageToLoad("30000");
485 $this->click("link=Submit New");
486 $this->waitForPageToLoad("30000");
487 $this->assertTrue($this->isElementPresent("//select[@name='assigned_to']")) ;
489 // Link global "Documentation masters" role into SubProject
490 $this->switchUser ("bigboss") ;
491 $this->gotoProject ("SubProject") ;
492 $this->click("link=Admin");
493 $this->waitForPageToLoad("30000");
494 $this->click("link=Users and permissions");
495 $this->waitForPageToLoad("30000");
497 $this->assertTrue($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Documentation masters (global role)']")) ;
498 $this->assertFalse($this->isElementPresent("//input[@value='Link external role']/../../div/select/option[.='Project moderators (global role)']")) ;
499 $this->select("//input[@value='Link external role']/../../div/select", "label=Documentation masters (global role)") ;
500 $this->click("//input[@value='Link external role']") ;
501 $this->waitForPageToLoad("30000");
502 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Documentation masters (global role)')]/../div/input[contains(@value,'Unlink Role')]"));
504 // Check that a project admin (not forge admin) can create a new role
505 $this->gotoProject ("SubProject") ;
506 $this->click("link=Admin");
507 $this->waitForPageToLoad("30000");
508 $this->click("link=Users and permissions");
509 $this->waitForPageToLoad("30000");
510 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "guru") ;
511 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Admin");
512 $this->click ("//input[@value='Add Member']") ;
513 $this->waitForPageToLoad("30000");
514 $this->assertTrue($this->isTextPresent("guru Lastname"));
515 $this->assertTrue($this->isElementPresent("//tr/td/a[.='guru Lastname']/../../td/div[contains(.,'Admin')]")) ;
517 $this->switchUser('guru');
518 $this->gotoProject ("SubProject") ;
519 $this->click("link=Admin");
520 $this->waitForPageToLoad("30000");
521 $this->click("link=Users and permissions");
522 $this->waitForPageToLoad("30000");
523 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Role created by guru") ;
524 $this->click ("//input[@value='Create Role']") ;
525 $this->waitForPageToLoad("30000");
526 $this->assertFalse ($this->isPermissionDenied()) ;
527 $this->click("link=Users and permissions");
528 $this->waitForPageToLoad("30000");
529 $this->assertTrue($this->isElementPresent("//td/form/div[contains(.,'Role created by guru')]/../div/input[@value='Edit Permissions']")) ;
531 // Non-regression test for Adacore ticket K802-005
532 // (Deletion of project-wide roles)
533 $this->switchUser(FORGE_ADMIN_USERNAME);
534 $this->gotoProject ("MetaProject") ;
535 $this->click("link=Admin");
536 $this->waitForPageToLoad("30000");
537 $this->click("link=Users and permissions");
538 $this->waitForPageToLoad("30000");
539 $this->type ("//form[contains(@action,'roleedit.php')]/..//input[@name='role_name']", "Temporary role") ;
540 $this->click ("//input[@value='Create Role']") ;
541 $this->waitForPageToLoad("30000");
542 $this->click("link=Users and permissions");
543 $this->waitForPageToLoad("30000");
544 $this->assertTrue($this->isTextPresent("Temporary role"));
545 $this->type ("//form[contains(@action,'users.php')]//input[@name='form_unix_name' and @type='text']", "trainee") ;
546 $this->select("//input[@value='Add Member']/../select[@name='role_id']", "label=Temporary role");
547 $this->click ("//input[@value='Add Member']") ;
548 $this->waitForPageToLoad("30000");
549 $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
550 $this->waitForPageToLoad("30000");
551 $this->click ("//input[@type='checkbox' and @name='sure']") ;
552 $this->click ("//input[@value='Submit']") ;
553 $this->waitForPageToLoad("30000");
554 $this->assertTrue($this->isTextPresent("Cannot remove a non empty role"));
555 $this->click("//tr/td/div[contains(.,'Temporary role')]/../div/form/input[@name='username' and @value='trainee']/../input[@value='Remove']") ;
556 $this->waitForPageToLoad("30000");
557 $this->click ("//td/form/div[contains(.,'Temporary role')]/../../form/div/input[@value='Delete role']") ;
558 $this->waitForPageToLoad("30000");
559 $this->click ("//input[@type='checkbox' and @name='sure']") ;
560 $this->click ("//input[@value='Submit']") ;
561 $this->waitForPageToLoad("30000");
562 $this->assertFalse($this->isTextPresent("Temporary role"));
564 // Non-regression test
565 $this->click("link=Site Admin");
566 $this->waitForPageToLoad("30000");
567 $this->click("link=Display Full Project List/Edit Projects");
568 $this->waitForPageToLoad("30000");
569 $this->click("link=SubProject");
570 $this->waitForPageToLoad("30000");
571 $this->click("link=Permanently Delete Project");
572 $this->waitForPageToLoad("30000");
573 $this->click("sure");
574 $this->click("reallysure");
575 $this->click("reallyreallysure");
576 $this->click("submit");
577 $this->waitForPageToLoad("30000");
578 $this->click("link=Home");
579 $this->waitForPageToLoad("30000");
580 $this->assertFalse($this->isTextPresent("SubProject"));
582 // Make sure permissions are saved for news-related forums
583 $this->switchUser(FORGE_ADMIN_USERNAME);
584 $this->gotoProject ("MetaProject") ;
586 $this->click("link=News");
587 $this->waitForPageToLoad("30000");
588 $this->click("link=Submit");
589 $this->waitForPageToLoad("30000");
590 $this->type("summary", "First news");
591 $this->type("details", "This is a simple news.");
592 $this->click("submit");
593 $this->waitForPageToLoad("30000");
594 $this->click("link=News");
595 $this->waitForPageToLoad("30000");
596 $this->assertTrue($this->isTextPresent("First news"));
597 $this->click("link=First news");
598 $this->waitForPageToLoad("30000");
599 $this->assertTrue($this->isTextPresent("First news"));
600 $this->assertTrue($this->isTextPresent("This is a simple news."));
602 $this->click("link=Admin");
603 $this->waitForPageToLoad("30000");
604 $this->click("link=Users and permissions");
605 $this->waitForPageToLoad("30000");
606 $this->click ("//td/form/div[contains(.,'Anonymous')]/../div/input[@value='Edit Permissions']") ;
607 $this->waitForPageToLoad("30000");
609 $this->select("//tr/td[contains(.,'first-news')]/../td/select", "label=Read only");
610 $this->click ("//input[@value='Submit']") ;
611 $this->waitForPageToLoad("30000");
612 $this->assertSelected("//tr/td[contains(.,'first-news')]/../td/select", "Read only");
614 $this->select("//tr/td[contains(.,'first-news')]/../td/select", "label=Moderated post");
615 $this->click ("//input[@value='Submit']") ;
616 $this->waitForPageToLoad("30000");
617 $this->assertSelected("//tr/td[contains(.,'first-news')]/../td/select", "Moderated post");
619 $this->select("//tr/td[contains(.,'first-news')]/../td/select", "label=Unmoderated post");
620 $this->click ("//input[@value='Submit']") ;
621 $this->waitForPageToLoad("30000");
622 $this->assertSelected("//tr/td[contains(.,'first-news')]/../td/select", "Unmoderated post");