ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilRBACTest Class Reference

Unit tests for tree table needsInstalledILIAS. More...

+ Inheritance diagram for ilRBACTest:
+ Collaboration diagram for ilRBACTest:

Public Member Functions

 testRbacFA ()
 RBAC FA tests IL_Init. More...
 
 testRbacUA ()
 test rbac_ua IL_Init More...
 
 testRbacTA ()
 rbac ta test IL_Init More...
 
 testRbacPA ()
 test rbac_pa IL_Init More...
 
 testConditions ()
 test preconditions IL_Init More...
 
 testCache ()
 IL_Init More...
 
 testAssignUser ()
 Test Assign User Method DB: rbac_ua. More...
 
 testDeassignUser ()
 Test deassign user Method DB: rbac_ua. More...
 
 testGrantPermission ()
 Test grant Permission Method DB: rbac_pa. More...
 
 testRevokePermission ()
 Test revoke Permission Method DB: rbac_pa. More...
 
 testRevokeSubtreePermissions ()
 Test revokeSubtreePermissions Method DB: rbac_pa. More...
 
 testRevokePermissionList ()
 Test revokePermissionList Method DB: rbac_pa. More...
 
 testSetRolePermission ()
 Test Set Role Permission Method DB: rbac_template. More...
 
 testDeleteRolePermission ()
 Test Delete Role Permission Method DB: rbac_template. More...
 
 testCopyRoleTemplatePermissions ()
 Test Copy Role Template Permission Method DB: rbac_template. More...
 
 testCopyRolePermissions ()
 Test Method DB: rbac_template DB: rbac_pa. More...
 
 testCopyRolePermissionIntersection ()
 Test Copy Role Permission Intersection Method DB: rbac_template. More...
 
 testCopyRolePermissionUnion ()
 Test Copy Role Permission Union Method DB: rbac_template. More...
 
 testCopyRolePermissionSubtract ()
 Test Copy Role Permission Subtract Method DB: rbac_template. More...
 
 testAssignOperationToObject ()
 Test assignOperationToObject Method DB: rbac_ta. More...
 
 testDeassignOperationFromObject ()
 Test deassignOperationFromObject Method ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testAssignOperationToObject. More...
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests for tree table needsInstalledILIAS.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file ilRBACTest.php.

Member Function Documentation

◆ setUp()

ilRBACTest::setUp ( )
protected

Definition at line 38 of file ilRBACTest.php.

39  {
40  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
41  ilUnitUtil::performInitialisation();
42  }

◆ testAssignOperationToObject()

ilRBACTest::testAssignOperationToObject ( )

Test assignOperationToObject Method DB: rbac_ta.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 645 of file ilRBACTest.php.

References array.

646  {
647  global $rbacreview, $rbacadmin;
648 
649  $rbacadmin->assignOperationToObject(1001, 10);
650  $rbacadmin->assignOperationToObject(1001, 20);
651 
652  $this->assertEquals($rbacreview->getOperationsOnType(1001), array(10,20));
653  }
Create styles array
The data for the language used.

◆ testAssignUser()

ilRBACTest::testAssignUser ( )

Test Assign User Method DB: rbac_ua.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 186 of file ilRBACTest.php.

187  {
188  global $rbacreview, $rbacadmin;
189  //assign User 15 to role 10
190  $rbacadmin->assignUser(10, 15);
191 
192  $this->assertTrue($rbacreview->isAssigned(15, 10));
193 
194  //Test double assign
195  $rbacadmin->assignUser(10, 15);
196  }

◆ testCache()

ilRBACTest::testCache ( )

IL_Init

Definition at line 166 of file ilRBACTest.php.

References $handler, $res, and array.

167  {
168  include_once './Services/AccessControl/classes/class.ilAccessHandler.php';
169 
170  $handler = new ilAccessHandler();
171  $handler->setResults(array(1,2,3));
172  $handler->storeCache();
173  $handler->readCache();
174  $res = $handler->getResults();
175 
176  $this->assertEquals(array(1,2,3), $res);
177  }
Interface ilAccessHandler.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
$handler

◆ testConditions()

ilRBACTest::testConditions ( )

test preconditions IL_Init

Parameters

Definition at line 130 of file ilRBACTest.php.

References $handler, ilConditionHandler\_deleteTargetConditionsByRefId(), ilConditionHandler\_getCondition(), ilConditionHandler\_getConditionsOfTarget(), ilConditionHandler\_getConditionsOfTrigger(), and ilConditionHandler\_getDistinctTargetRefIds().

131  {
132  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
133 
136 
138  $handler->setTargetRefId(99999);
139  $handler->setTargetObjId(99998);
140  $handler->setTargetType('xxx');
141  $handler->setTriggerRefId(99997);
142  $handler->setTriggerObjId(99996);
143  $handler->setTriggerType('yyy');
144  $handler->setReferenceHandlingType(0);
145  $handler->enableAutomaticValidation(false);
146  $suc = $handler->storeCondition();
147  $this->assertEquals($suc, true);
148 
149  $suc = $handler->checkExists();
150  $this->assertEquals($suc, false);
151 
152  $suc = $handler->delete(99999);
153  $this->assertEquals($suc, true);
154 
155  // syntax check
156  $handler->deleteByObjId(-1);
157  $handler->deleteCondition(-1);
161  }
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
static _getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
static _getDistinctTargetRefIds()
Get all target ref ids.
static _deleteTargetConditionsByRefId($a_target_ref_id)
Delete conditions by target ref id Note: only conditions on the target type are deleted Conditions on...
Handles conditions for accesses to different ILIAS objects.
$handler
+ Here is the call graph for this function:

◆ testCopyRolePermissionIntersection()

ilRBACTest::testCopyRolePermissionIntersection ( )

Test Copy Role Permission Intersection Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 528 of file ilRBACTest.php.

References array.

529  {
530  global $rbacreview, $rbacadmin;
531  $rbacadmin->deleteTemplate(1010);
532  $rbacadmin->deleteTemplate(2020);
533  $rbacadmin->deleteTemplate(3030);
534 
535  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
536  $rbacadmin->setRolePermission(2020, "a", array(11,12,13,16), 2200);
537 
538  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
539  $rbacadmin->setRolePermission(2020, "b", array(20,23,24,26), 2200);
540 
541  $rbacadmin->setRolePermission(3030, "c", array(30,33), 3300);
542  $rbacadmin->setRolePermission(3030, "a", array(30,33), 3300);
543  $rbacadmin->setRolePermission(3030, "b", array(30,33), 3300);
544 
545  $rbacadmin->copyRolePermissionIntersection(1010, 1100, 2020, 2200, 3300, 3030);
546 
547  $intersect = array("a" => array(11,13), "b" => array(20,23));
548  $dest = $rbacreview->getAllOperationsOfRole(3030, 3300);
549 
550  //sort
551  sort($dest["a"]);
552  sort($dest["b"]);
553 
554  $this->assertEquals($intersect, $dest);
555 
556  $rbacadmin->deleteTemplate(1010);
557  $rbacadmin->deleteTemplate(2020);
558  $rbacadmin->deleteTemplate(3030);
559  }
Create styles array
The data for the language used.

◆ testCopyRolePermissions()

ilRBACTest::testCopyRolePermissions ( )

Test Method DB: rbac_template DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission testRevokePermission testSetRolePermission

Definition at line 462 of file ilRBACTest.php.

References $ilDB, $req, $row, $type, and array.

463  {
464  global $rbacreview, $rbacadmin, $ilDB;
465 
466  $req = $ilDB->query("SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='seas';");
467 
468  $seas = 0;
469 
470  while ($row = $ilDB->fetchAssoc($req)) {
471  $seas = $row["ref_id"];
472  }
473 
474  $req = $ilDB->query("SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='mail';");
475 
476  $mail = 0;
477 
478  while ($row = $ilDB->fetchAssoc($req)) {
479  $mail = $row["ref_id"];
480  }
481 
482  $req = $ilDB->query("SELECT obj_id FROM object_data WHERE type='role';");
483  $ilDB->fetchAssoc($req);//First role is protected. Dont use it!
484  $role = $ilDB->fetchAssoc($req)["obj_id"];
485 
486  //save normal operations
487  $opt_mail = $rbacreview->getActiveOperationsOfRole($mail, $role);
488  $opt_seas = $rbacreview->getActiveOperationsOfRole($seas, $role);
489  $opt_temp_seas = $rbacreview->getAllOperationsOfRole($role, $seas);
490  $opt_temp_mail = $rbacreview->getAllOperationsOfRole($role, $mail);
491 
492  //set values
493  $rbacadmin->setRolePermission($role, "mail", array(1,2,3,4,5), $mail);
494  $rbacadmin->grantPermission($role, array(1,2,3,4,5), $mail);
495  $rbacadmin->setRolePermission($role, "seas", array(5,6,7,8,9), $seas);
496  $rbacadmin->grantPermission($role, array(5,6,7,8,9), $seas);
497 
498  $rbacadmin->copyRolePermissions($role, $seas, $mail, $role);
499  $this->assertEquals(
500  $rbacreview->getActiveOperationsOfRole($seas, $role),
501  $rbacreview->getActiveOperationsOfRole($mail, $role)
502  );
503 
504  //set normal operations
505  $rbacadmin->grantPermission($role, $opt_seas, $seas);
506  $rbacadmin->grantPermission($role, $opt_mail, $mail);
507 
508  $rbacadmin->deleteRolePermission($role, $mail);
509  $rbacadmin->deleteRolePermission($role, $seas);
510 
511  foreach ($opt_temp_seas as $type => $opt) {
512  $rbacadmin->setRolePermission($role, $type, $opt, $seas);
513  }
514 
515  foreach ($opt_temp_mail as $type => $opt) {
516  $rbacadmin->setRolePermission($role, $type, $opt, $mail);
517  }
518  }
$type
$req
Definition: getUserInfo.php:20
Create styles array
The data for the language used.
global $ilDB

◆ testCopyRolePermissionSubtract()

ilRBACTest::testCopyRolePermissionSubtract ( )

Test Copy Role Permission Subtract Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 609 of file ilRBACTest.php.

References array.

610  {
611  global $rbacreview, $rbacadmin;
612  $rbacadmin->deleteTemplate(1010);
613  $rbacadmin->deleteTemplate(2020);
614 
615  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
616  $rbacadmin->setRolePermission(2020, "a", array(11,12,13,16), 2200);
617 
618  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
619  $rbacadmin->setRolePermission(2020, "b", array(20,23,24,26), 2200);
620 
621  $rbacadmin->setRolePermission(2020, "c", array(30,33,34,35), 2200);
622 
623  $rbacadmin->copyRolePermissionSubtract(1010, 1100, 2020, 2200);
624 
625  $subtract = array("a" => array(12,16), "b" => array(24,26), "c" => array(30,33,34,35));
626  $dest = $rbacreview->getAllOperationsOfRole(2020, 2200);
627 
628  sort($dest["a"]);
629  sort($dest["b"]);
630  sort($dest["c"]);
631 
632  $this->assertEquals($subtract, $dest);
633 
634  $rbacadmin->deleteTemplate(1010);
635  $rbacadmin->deleteTemplate(2020);
636  }
Create styles array
The data for the language used.

◆ testCopyRolePermissionUnion()

ilRBACTest::testCopyRolePermissionUnion ( )

Test Copy Role Permission Union Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testCopyRoleTemplatePermissions testSetRolePermission

Definition at line 570 of file ilRBACTest.php.

References array.

571  {
572  global $rbacreview, $rbacadmin;
573  $rbacadmin->deleteTemplate(1010);
574  $rbacadmin->deleteTemplate(2020);
575  $rbacadmin->deleteTemplate(3030);
576 
577  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
578  $rbacadmin->setRolePermission(2020, "a", array(11,12,13,16), 2200);
579 
580  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
581  $rbacadmin->setRolePermission(2020, "b", array(20,23,24,26), 2200);
582 
583  $rbacadmin->setRolePermission(1010, "c", array(30,33,34,35), 1100);
584 
585  $rbacadmin->copyRolePermissionUnion(1010, 1100, 2020, 2200, 3030, 3300);
586 
587  $union = array("a" => array(10,11,12,13,15,16), "b" => array(20,22,23,24,25,26), "c" => array(30,33,34,35));
588  $dest = $rbacreview->getAllOperationsOfRole(3030, 3300);
589 
590  sort($dest["a"]);
591  sort($dest["b"]);
592  sort($dest["c"]);
593 
594  $this->assertEquals($union, $dest);
595 
596  $rbacadmin->deleteTemplate(1010);
597  $rbacadmin->deleteTemplate(2020);
598  $rbacadmin->deleteTemplate(3030);
599  }
Create styles array
The data for the language used.

◆ testCopyRoleTemplatePermissions()

ilRBACTest::testCopyRoleTemplatePermissions ( )

Test Copy Role Template Permission Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 431 of file ilRBACTest.php.

References array.

432  {
433  global $rbacreview, $rbacadmin;
434  $rbacadmin->deleteTemplate(1010);
435  $rbacadmin->deleteTemplate(2020);
436 
437  $rbacadmin->setRolePermission(1010, "blub", array(10,11), 1100);
438  $rbacadmin->setRolePermission(2020, "bulb", array(20,22), 2200);
439 
440  $rbacadmin->copyRoleTemplatePermissions(1010, 1100, 2200, 2020);
441 
442  $one = $rbacreview->getAllOperationsOfRole(1010, 1100);
443  $two = $rbacreview->getAllOperationsOfRole(2020, 2200);
444  sort($one["blub"]);
445  sort($two["blub"]);
446  $this->assertEquals($one, $two);
447  $rbacadmin->deleteTemplate(1010);
448  $rbacadmin->deleteTemplate(2020);
449  }
Create styles array
The data for the language used.

◆ testDeassignOperationFromObject()

ilRBACTest::testDeassignOperationFromObject ( )

Test deassignOperationFromObject Method ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testAssignOperationToObject.

Definition at line 661 of file ilRBACTest.php.

References array.

662  {
663  global $rbacreview, $rbacadmin;
664  $rbacadmin->deassignOperationFromObject(1001, 10);
665 
666  $this->assertEquals($rbacreview->getOperationsOnType(1001), array(20));
667 
668  $rbacadmin->deassignOperationFromObject(1001, 20);
669 
670  $this->assertEmpty($rbacreview->getOperationsOnType(1001));
671  }
Create styles array
The data for the language used.

◆ testDeassignUser()

ilRBACTest::testDeassignUser ( )

Test deassign user Method DB: rbac_ua.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testAssignUser

Definition at line 206 of file ilRBACTest.php.

207  {
208  global $rbacreview, $rbacadmin;
209  //deassign User 15 from role 10
210  $rbacadmin->deassignUser(10, 15);
211 
212  $this->assertFalse($rbacreview->isAssigned(15, 10));
213  }

◆ testDeleteRolePermission()

ilRBACTest::testDeleteRolePermission ( )

Test Delete Role Permission Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 396 of file ilRBACTest.php.

References array.

397  {
398  global $rbacreview, $rbacadmin;
399  $rbacadmin->deleteTemplate(1010);
400 
401  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
402  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
403 
404  $rbacadmin->deleteRolePermission(1010, 1100);
405 
406  $this->assertEmpty($rbacreview->getAllOperationsOfRole(1010, 1100));
407 
408  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
409  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
410 
411  $rbacadmin->deleteRolePermission(1010, 1100, "a");
412 
413  $assert = array("b" => array(20,22,23,25));
414  $dest = $rbacreview->getAllOperationsOfRole(1010, 1100);
415 
416  sort($dest["b"]);
417 
418  $this->assertEquals($assert, $dest);
419 
420  $rbacadmin->deleteTemplate(1010);
421  }
Create styles array
The data for the language used.

◆ testGrantPermission()

ilRBACTest::testGrantPermission ( )

Test grant Permission Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 222 of file ilRBACTest.php.

References array.

223  {
224  global $rbacreview, $rbacadmin;
225  //grant permissions 10,20 and 30 for role 10 on object 60
226  $rbacadmin->grantPermission(10, array(10,20,30), 60);
227 
228  $this->assertEquals($rbacreview->getActiveOperationsOfRole(60, 10), array(10,20,30));
229  }
Create styles array
The data for the language used.

◆ testRbacFA()

ilRBACTest::testRbacFA ( )

RBAC FA tests IL_Init.

Parameters

Definition at line 50 of file ilRBACTest.php.

51  {
52  global $rbacreview,$rbacadmin;
53 
54  // Protected
55  #$rbacadmin->setProtected(1,4,'y');
56  #$prot = $rbacreview->isProtected(8,4);
57  #$this->assertEquals($prot,true);
58  #$rbacadmin->setProtected(1,4,'n');
59  #$prot = $rbacreview->isProtected(8,4);
60  #$this->assertEquals($prot,false);
61 
62  $rbacreview->getRoleListByObject(8);
63  $rbacreview->getAssignableRoles();
64 
65 
66  $ass = $rbacreview->isAssignable(4, 8);
67  $this->assertEquals($ass, true);
68 
69  $roles = $rbacreview->getRolesOfObject(8);
70 
71  $obj = $rbacreview->getObjectOfRole(4);
72  $this->assertEquals(8, $obj);
73  }

◆ testRbacPA()

ilRBACTest::testRbacPA ( )

test rbac_pa IL_Init

Definition at line 114 of file ilRBACTest.php.

References array.

115  {
116  global $rbacreview,$rbacadmin;
117 
118  $sess_ops = $rbacreview->getOperationsOnTypeString('cat');
119 
120  $rbacadmin->revokePermission(1, 4);
121  $rbacadmin->grantPermission(4, array(2,3), 1);
122  }
Create styles array
The data for the language used.

◆ testRbacTA()

ilRBACTest::testRbacTA ( )

rbac ta test IL_Init

Parameters

Definition at line 95 of file ilRBACTest.php.

96  {
97  global $rbacreview,$rbacadmin;
98 
99  $sess_ops = $rbacreview->getOperationsOnTypeString('sess');
100 
101  $rbacadmin->assignOperationToObject($rbacreview->getTypeId('sess'), '7');
102  //$new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
103  //$this->assertEquals(array_merge($sess_ops,array(7)),$new_sess_ops);
104 
105  $rbacadmin->deassignOperationFromObject($rbacreview->getTypeId('sess'), '7');
106  $new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
107  $this->assertEquals($sess_ops, $new_sess_ops);
108  }

◆ testRbacUA()

ilRBACTest::testRbacUA ( )

test rbac_ua IL_Init

Definition at line 79 of file ilRBACTest.php.

References ilUtil\_getObjectsByOperations().

80  {
81  global $rbacreview,$rbacadmin;
82 
83  $obj = ilUtil::_getObjectsByOperations('crs', 'join');
84 
85  $rbacreview->assignedUsers(4);
86  $rbacreview->assignedRoles(6);
87  }
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
+ Here is the call graph for this function:

◆ testRevokePermission()

ilRBACTest::testRevokePermission ( )

Test revoke Permission Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission

Definition at line 240 of file ilRBACTest.php.

References $ilDB, $req, $row, and array.

241  {
242  global $rbacreview, $rbacadmin, $ilDB;
243 
244  $req = $ilDB->query("SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='seas';");
245 
246  $ref_id = 0;
247 
248  while ($row = $ilDB->fetchAssoc($req)) {
249  $ref_id = $row["ref_id"];
250  }
251 
252  $req = $ilDB->query("SELECT obj_id FROM object_data WHERE type='role';");
253  $ilDB->fetchAssoc($req);//First role is protected. Dont use it!
254  $role1 = $ilDB->fetchAssoc($req)["obj_id"];
255  $role2 = $ilDB->fetchAssoc($req)["obj_id"];
256  $role3 = $ilDB->fetchAssoc($req)["obj_id"];
257 
258  //save normal operations
259  $opt1 = $rbacreview->getActiveOperationsOfRole($ref_id, $role1);
260  $opt2 = $rbacreview->getActiveOperationsOfRole($ref_id, $role2);
261  $opt3 = $rbacreview->getActiveOperationsOfRole($ref_id, $role3);
262 
263  $rbacadmin->grantPermission($role1, array(1,2,3,4,5), $ref_id);
264  $rbacadmin->grantPermission($role2, array(1,2,3,4,5), $ref_id);
265  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role1), array(1,2,3,4,5));
266  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role2), array(1,2,3,4,5));
267  $rbacadmin->revokePermission($ref_id);
268  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role1));
269  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role2));
270 
271 
272  $rbacadmin->grantPermission($role1, array(1,2,3,4,5), $ref_id);
273  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role1), array(1,2,3,4,5));
274  $rbacadmin->revokePermission($ref_id, $role1);
275  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role1));
276 
277 
278  $rbacadmin->grantPermission($role2, array(1,2,3,4,5), $ref_id);
279  $rbacadmin->grantPermission($role3, array(1,2,3,4,5), $ref_id);
280  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role2), array(1,2,3,4,5));
281  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role3), array(1,2,3,4,5));
282  $rbacadmin->revokePermission($ref_id, 0, false);
283  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role2));
284  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role3));
285 
286  $rbacadmin->grantPermission($role3, array(1,2,3,4,5), $ref_id);
287  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role3), array(1,2,3,4,5));
288  $rbacadmin->revokePermission($ref_id, $role3, false);
289  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role3));
290 
291  //set normal operations
292  $rbacadmin->grantPermission($role1, $opt1, $ref_id);
293  $rbacadmin->grantPermission($role2, $opt2, $ref_id);
294  $rbacadmin->grantPermission($role3, $opt3, $ref_id);
295  }
$req
Definition: getUserInfo.php:20
Create styles array
The data for the language used.
global $ilDB

◆ testRevokePermissionList()

ilRBACTest::testRevokePermissionList ( )

Test revokePermissionList Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission

Definition at line 346 of file ilRBACTest.php.

References $id, $list, and array.

347  {
348  global $rbacreview, $rbacadmin;
349  $list = array(1001, 1003, 1005, 1007);
350 
351  foreach ($list as $id) {
352  $rbacadmin->grantPermission(123, array(1,2,3,4,5), $id);
353  }
354 
355  $rbacadmin->revokePermissionList($list, 123);
356 
357  foreach ($list as $id) {
358  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id, 123));
359  }
360  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.

◆ testRevokeSubtreePermissions()

ilRBACTest::testRevokeSubtreePermissions ( )

Test revokeSubtreePermissions Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission

Definition at line 305 of file ilRBACTest.php.

References $id, $ilDB, $req, $row, and array.

306  {
307  global $rbacreview, $rbacadmin, $tree, $ilDB;
308  $req = $ilDB->query("SELECT ref.ref_id FROM object_reference AS ref LEFT JOIN object_data AS data ON data.obj_id = ref.obj_id WHERE data.type='adm';");
309 
310  $ref_id = 0;
311 
312  while ($row = $ilDB->fetchAssoc($req)) {
313  $ref_id = $row["ref_id"];
314  }
315 
316  $childs = $tree->getChildIds($ref_id);
317 
318  $req = $ilDB->query("SELECT obj_id FROM object_data WHERE type='role';");
319  $ilDB->fetchAssoc($req);//First role is protected. Dont use it!
320  $role = $ilDB->fetchAssoc($req)["obj_id"];
321 
322  $ops = array();
323 
324  foreach ($childs as $id) {
325  $ops[$id] = $rbacreview->getActiveOperationsOfRole($id, $role);//save normal operations
326  $rbacadmin->grantPermission($role, array(1,2,3,4,5), $id);
327  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($id,$role), array(1,2,3,4,5));
328  }
329 
330  $rbacadmin->revokeSubtreePermissions($ref_id, $role);
331 
332  foreach ($childs as $id) {
333  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id, $role));
334  $rbacadmin->grantPermission($role, $ops[$id], $id);//set normal operations
335  }
336  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$req
Definition: getUserInfo.php:20
Create styles array
The data for the language used.
global $ilDB

◆ testSetRolePermission()

ilRBACTest::testSetRolePermission ( )

Test Set Role Permission Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 369 of file ilRBACTest.php.

References array.

370  {
371  global $rbacreview, $rbacadmin;
372  $rbacadmin->deleteTemplate(1010);
373 
374  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
375  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
376 
377  $assert = array("a" => array(10,11,13,15),"b" => array(20,22,23,25));
378  $dest = $rbacreview->getAllOperationsOfRole(1010, 1100);
379 
380  sort($dest["a"]);
381  sort($dest["b"]);
382 
383  $this->assertEquals($assert, $dest);
384 
385  $rbacadmin->deleteTemplate(1010);
386  }
Create styles array
The data for the language used.

Field Documentation

◆ $backupGlobals

ilRBACTest::$backupGlobals = false
protected

Definition at line 36 of file ilRBACTest.php.


The documentation for this class was generated from the following file: