ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 700 of file ilRBACTest.php.

References $DIC.

701  {
702  global $DIC;
703 
704  $rbacreview = $DIC['rbacreview'];
705  $rbacadmin = $DIC['rbacadmin'];
706 
707  $rbacadmin->assignOperationToObject(1001, 10);
708  $rbacadmin->assignOperationToObject(1001, 20);
709 
710  $this->assertEquals($rbacreview->getOperationsOnType(1001), array(10,20));
711  }
global $DIC
Definition: saml.php:7

◆ testAssignUser()

ilRBACTest::testAssignUser ( )

Test Assign User Method DB: rbac_ua.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 198 of file ilRBACTest.php.

References $DIC.

199  {
200  global $DIC;
201 
202  $rbacreview = $DIC['rbacreview'];
203  $rbacadmin = $DIC['rbacadmin'];
204  //assign User 15 to role 10
205  $rbacadmin->assignUser(10, 15);
206 
207  $this->assertTrue($rbacreview->isAssigned(15, 10));
208 
209  //Test double assign
210  $rbacadmin->assignUser(10, 15);
211  }
global $DIC
Definition: saml.php:7

◆ testCache()

ilRBACTest::testCache ( )

IL_Init

Definition at line 178 of file ilRBACTest.php.

References $handler, and $res.

179  {
180  include_once './Services/AccessControl/classes/class.ilAccessHandler.php';
181 
182  $handler = new ilAccessHandler();
183  $handler->setResults(array(1,2,3));
184  $handler->storeCache();
185  $handler->readCache();
186  $res = $handler->getResults();
187 
188  $this->assertEquals(array(1,2,3), $res);
189  }
Interface ilAccessHandler.
foreach($_POST as $key=> $value) $res
$handler

◆ testConditions()

ilRBACTest::testConditions ( )

test preconditions IL_Init

Parameters

Definition at line 142 of file ilRBACTest.php.

References $handler, ilConditionHandler\_deleteTargetConditionsByRefId(), ilConditionHandler\_getCondition(), ilConditionHandler\_getDistinctTargetRefIds(), ilConditionHandler\_getPersistedConditionsOfTarget(), and ilConditionHandler\_getPersistedConditionsOfTrigger().

143  {
144  include_once './Services/Conditions/classes/class.ilConditionHandler.php';
145 
148 
150  $handler->setTargetRefId(99999);
151  $handler->setTargetObjId(99998);
152  $handler->setTargetType('xxx');
153  $handler->setTriggerRefId(99997);
154  $handler->setTriggerObjId(99996);
155  $handler->setTriggerType('yyy');
156  $handler->setReferenceHandlingType(0);
157  $handler->enableAutomaticValidation(false);
158  $suc = $handler->storeCondition();
159  $this->assertEquals($suc, true);
160 
161  $suc = $handler->checkExists();
162  $this->assertEquals($suc, false);
163 
164  $suc = $handler->delete(99999);
165  $this->assertEquals($suc, true);
166 
167  // syntax check
168  $handler->deleteByObjId(-1);
169  $handler->deleteCondition(-1);
173  }
static _getPersistedConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
Get all persisted conditions of trigger object Note: This only gets persisted conditions NOT (dynamic...
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...
INTERNAL CLASS: Please do not use in consumer code.
static _getPersistedConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all persisted conditions of target object
$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 574 of file ilRBACTest.php.

References $DIC.

575  {
576  global $DIC;
577 
578  $rbacreview = $DIC['rbacreview'];
579  $rbacadmin = $DIC['rbacadmin'];
580  $rbacadmin->deleteTemplate(1010);
581  $rbacadmin->deleteTemplate(2020);
582  $rbacadmin->deleteTemplate(3030);
583 
584  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
585  $rbacadmin->setRolePermission(2020, "a", array(11,12,13,16), 2200);
586 
587  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
588  $rbacadmin->setRolePermission(2020, "b", array(20,23,24,26), 2200);
589 
590  $rbacadmin->setRolePermission(3030, "c", array(30,33), 3300);
591  $rbacadmin->setRolePermission(3030, "a", array(30,33), 3300);
592  $rbacadmin->setRolePermission(3030, "b", array(30,33), 3300);
593 
594  $rbacadmin->copyRolePermissionIntersection(1010, 1100, 2020, 2200, 3300, 3030);
595 
596  $intersect = array("a" => array(11,13), "b" => array(20,23));
597  $dest = $rbacreview->getAllOperationsOfRole(3030, 3300);
598 
599  //sort
600  sort($dest["a"]);
601  sort($dest["b"]);
602 
603  $this->assertEquals($intersect, $dest);
604 
605  $rbacadmin->deleteTemplate(1010);
606  $rbacadmin->deleteTemplate(2020);
607  $rbacadmin->deleteTemplate(3030);
608  }
global $DIC
Definition: saml.php:7

◆ testCopyRolePermissions()

ilRBACTest::testCopyRolePermissions ( )

Test Method DB: rbac_template DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission testRevokePermission testSetRolePermission

Definition at line 504 of file ilRBACTest.php.

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

505  {
506  global $DIC;
507 
508  $rbacreview = $DIC['rbacreview'];
509  $rbacadmin = $DIC['rbacadmin'];
510  $ilDB = $DIC['ilDB'];
511 
512  $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';");
513 
514  $seas = 0;
515 
516  while ($row = $ilDB->fetchAssoc($req)) {
517  $seas = $row["ref_id"];
518  }
519 
520  $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';");
521 
522  $mail = 0;
523 
524  while ($row = $ilDB->fetchAssoc($req)) {
525  $mail = $row["ref_id"];
526  }
527 
528  $req = $ilDB->query("SELECT obj_id FROM object_data WHERE type='role';");
529  $ilDB->fetchAssoc($req);//First role is protected. Dont use it!
530  $role = $ilDB->fetchAssoc($req)["obj_id"];
531 
532  //save normal operations
533  $opt_mail = $rbacreview->getActiveOperationsOfRole($mail, $role);
534  $opt_seas = $rbacreview->getActiveOperationsOfRole($seas, $role);
535  $opt_temp_seas = $rbacreview->getAllOperationsOfRole($role, $seas);
536  $opt_temp_mail = $rbacreview->getAllOperationsOfRole($role, $mail);
537 
538  //set values
539  $rbacadmin->setRolePermission($role, "mail", array(1,2,3,4,5), $mail);
540  $rbacadmin->grantPermission($role, array(1,2,3,4,5), $mail);
541  $rbacadmin->setRolePermission($role, "seas", array(5,6,7,8,9), $seas);
542  $rbacadmin->grantPermission($role, array(5,6,7,8,9), $seas);
543 
544  $rbacadmin->copyRolePermissions($role, $seas, $mail, $role);
545  $this->assertEquals(
546  $rbacreview->getActiveOperationsOfRole($seas, $role),
547  $rbacreview->getActiveOperationsOfRole($mail, $role)
548  );
549 
550  //set normal operations
551  $rbacadmin->grantPermission($role, $opt_seas, $seas);
552  $rbacadmin->grantPermission($role, $opt_mail, $mail);
553 
554  $rbacadmin->deleteRolePermission($role, $mail);
555  $rbacadmin->deleteRolePermission($role, $seas);
556 
557  foreach ($opt_temp_seas as $type => $opt) {
558  $rbacadmin->setRolePermission($role, $type, $opt, $seas);
559  }
560 
561  foreach ($opt_temp_mail as $type => $opt) {
562  $rbacadmin->setRolePermission($role, $type, $opt, $mail);
563  }
564  }
$type
global $DIC
Definition: saml.php:7
$req
Definition: getUserInfo.php:20
$row
global $ilDB

◆ testCopyRolePermissionSubtract()

ilRBACTest::testCopyRolePermissionSubtract ( )

Test Copy Role Permission Subtract Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 661 of file ilRBACTest.php.

References $DIC.

662  {
663  global $DIC;
664 
665  $rbacreview = $DIC['rbacreview'];
666  $rbacadmin = $DIC['rbacadmin'];
667  $rbacadmin->deleteTemplate(1010);
668  $rbacadmin->deleteTemplate(2020);
669 
670  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
671  $rbacadmin->setRolePermission(2020, "a", array(11,12,13,16), 2200);
672 
673  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
674  $rbacadmin->setRolePermission(2020, "b", array(20,23,24,26), 2200);
675 
676  $rbacadmin->setRolePermission(2020, "c", array(30,33,34,35), 2200);
677 
678  $rbacadmin->copyRolePermissionSubtract(1010, 1100, 2020, 2200);
679 
680  $subtract = array("a" => array(12,16), "b" => array(24,26), "c" => array(30,33,34,35));
681  $dest = $rbacreview->getAllOperationsOfRole(2020, 2200);
682 
683  sort($dest["a"]);
684  sort($dest["b"]);
685  sort($dest["c"]);
686 
687  $this->assertEquals($subtract, $dest);
688 
689  $rbacadmin->deleteTemplate(1010);
690  $rbacadmin->deleteTemplate(2020);
691  }
global $DIC
Definition: saml.php:7

◆ testCopyRolePermissionUnion()

ilRBACTest::testCopyRolePermissionUnion ( )

Test Copy Role Permission Union Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testCopyRoleTemplatePermissions testSetRolePermission

Definition at line 619 of file ilRBACTest.php.

References $DIC.

620  {
621  global $DIC;
622 
623  $rbacreview = $DIC['rbacreview'];
624  $rbacadmin = $DIC['rbacadmin'];
625  $rbacadmin->deleteTemplate(1010);
626  $rbacadmin->deleteTemplate(2020);
627  $rbacadmin->deleteTemplate(3030);
628 
629  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
630  $rbacadmin->setRolePermission(2020, "a", array(11,12,13,16), 2200);
631 
632  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
633  $rbacadmin->setRolePermission(2020, "b", array(20,23,24,26), 2200);
634 
635  $rbacadmin->setRolePermission(1010, "c", array(30,33,34,35), 1100);
636 
637  $rbacadmin->copyRolePermissionUnion(1010, 1100, 2020, 2200, 3030, 3300);
638 
639  $union = array("a" => array(10,11,12,13,15,16), "b" => array(20,22,23,24,25,26), "c" => array(30,33,34,35));
640  $dest = $rbacreview->getAllOperationsOfRole(3030, 3300);
641 
642  sort($dest["a"]);
643  sort($dest["b"]);
644  sort($dest["c"]);
645 
646  $this->assertEquals($union, $dest);
647 
648  $rbacadmin->deleteTemplate(1010);
649  $rbacadmin->deleteTemplate(2020);
650  $rbacadmin->deleteTemplate(3030);
651  }
global $DIC
Definition: saml.php:7

◆ testCopyRoleTemplatePermissions()

ilRBACTest::testCopyRoleTemplatePermissions ( )

Test Copy Role Template Permission Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 470 of file ilRBACTest.php.

References $DIC.

471  {
472  global $DIC;
473 
474  $rbacreview = $DIC['rbacreview'];
475  $rbacadmin = $DIC['rbacadmin'];
476  $rbacadmin->deleteTemplate(1010);
477  $rbacadmin->deleteTemplate(2020);
478 
479  $rbacadmin->setRolePermission(1010, "blub", array(10,11), 1100);
480  $rbacadmin->setRolePermission(2020, "bulb", array(20,22), 2200);
481 
482  $rbacadmin->copyRoleTemplatePermissions(1010, 1100, 2200, 2020);
483 
484  $one = $rbacreview->getAllOperationsOfRole(1010, 1100);
485  $two = $rbacreview->getAllOperationsOfRole(2020, 2200);
486  sort($one["blub"]);
487  sort($two["blub"]);
488  $this->assertEquals($one, $two);
489  $rbacadmin->deleteTemplate(1010);
490  $rbacadmin->deleteTemplate(2020);
491  }
global $DIC
Definition: saml.php:7

◆ testDeassignOperationFromObject()

ilRBACTest::testDeassignOperationFromObject ( )

Test deassignOperationFromObject Method ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testAssignOperationToObject.

Definition at line 719 of file ilRBACTest.php.

References $DIC.

720  {
721  global $DIC;
722 
723  $rbacreview = $DIC['rbacreview'];
724  $rbacadmin = $DIC['rbacadmin'];
725  $rbacadmin->deassignOperationFromObject(1001, 10);
726 
727  $this->assertEquals($rbacreview->getOperationsOnType(1001), array(20));
728 
729  $rbacadmin->deassignOperationFromObject(1001, 20);
730 
731  $this->assertEmpty($rbacreview->getOperationsOnType(1001));
732  }
global $DIC
Definition: saml.php:7

◆ testDeassignUser()

ilRBACTest::testDeassignUser ( )

Test deassign user Method DB: rbac_ua.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testAssignUser

Definition at line 221 of file ilRBACTest.php.

References $DIC.

222  {
223  global $DIC;
224 
225  $rbacreview = $DIC['rbacreview'];
226  $rbacadmin = $DIC['rbacadmin'];
227  //deassign User 15 from role 10
228  $rbacadmin->deassignUser(10, 15);
229 
230  $this->assertFalse($rbacreview->isAssigned(15, 10));
231  }
global $DIC
Definition: saml.php:7

◆ testDeleteRolePermission()

ilRBACTest::testDeleteRolePermission ( )

Test Delete Role Permission Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testSetRolePermission

Definition at line 432 of file ilRBACTest.php.

References $DIC.

433  {
434  global $DIC;
435 
436  $rbacreview = $DIC['rbacreview'];
437  $rbacadmin = $DIC['rbacadmin'];
438  $rbacadmin->deleteTemplate(1010);
439 
440  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
441  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
442 
443  $rbacadmin->deleteRolePermission(1010, 1100);
444 
445  $this->assertEmpty($rbacreview->getAllOperationsOfRole(1010, 1100));
446 
447  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
448  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
449 
450  $rbacadmin->deleteRolePermission(1010, 1100, "a");
451 
452  $assert = array("b" => array(20,22,23,25));
453  $dest = $rbacreview->getAllOperationsOfRole(1010, 1100);
454 
455  sort($dest["b"]);
456 
457  $this->assertEquals($assert, $dest);
458 
459  $rbacadmin->deleteTemplate(1010);
460  }
global $DIC
Definition: saml.php:7

◆ testGrantPermission()

ilRBACTest::testGrantPermission ( )

Test grant Permission Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 240 of file ilRBACTest.php.

References $DIC.

241  {
242  global $DIC;
243 
244  $rbacreview = $DIC['rbacreview'];
245  $rbacadmin = $DIC['rbacadmin'];
246  //grant permissions 10,20 and 30 for role 10 on object 60
247  $rbacadmin->grantPermission(10, array(10,20,30), 60);
248 
249  $this->assertEquals($rbacreview->getActiveOperationsOfRole(60, 10), array(10,20,30));
250  }
global $DIC
Definition: saml.php:7

◆ testRbacFA()

ilRBACTest::testRbacFA ( )

RBAC FA tests IL_Init.

Parameters

Definition at line 50 of file ilRBACTest.php.

References $DIC.

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

◆ testRbacPA()

ilRBACTest::testRbacPA ( )

test rbac_pa IL_Init

Definition at line 123 of file ilRBACTest.php.

References $DIC.

124  {
125  global $DIC;
126 
127  $rbacreview = $DIC['rbacreview'];
128  $rbacadmin = $DIC['rbacadmin'];
129 
130  $sess_ops = $rbacreview->getOperationsOnTypeString('cat');
131 
132  $rbacadmin->revokePermission(1, 4);
133  $rbacadmin->grantPermission(4, array(2,3), 1);
134  }
global $DIC
Definition: saml.php:7

◆ testRbacTA()

ilRBACTest::testRbacTA ( )

rbac ta test IL_Init

Parameters

Definition at line 101 of file ilRBACTest.php.

References $DIC.

102  {
103  global $DIC;
104 
105  $rbacreview = $DIC['rbacreview'];
106  $rbacadmin = $DIC['rbacadmin'];
107 
108  $sess_ops = $rbacreview->getOperationsOnTypeString('sess');
109 
110  $rbacadmin->assignOperationToObject($rbacreview->getTypeId('sess'), '7');
111  //$new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
112  //$this->assertEquals(array_merge($sess_ops,array(7)),$new_sess_ops);
113 
114  $rbacadmin->deassignOperationFromObject($rbacreview->getTypeId('sess'), '7');
115  $new_sess_ops = $rbacreview->getOperationsOnTypeString('sess');
116  $this->assertEquals($sess_ops, $new_sess_ops);
117  }
global $DIC
Definition: saml.php:7

◆ testRbacUA()

ilRBACTest::testRbacUA ( )

test rbac_ua IL_Init

Definition at line 82 of file ilRBACTest.php.

References $DIC, and ilUtil\_getObjectsByOperations().

83  {
84  global $DIC;
85 
86  $rbacreview = $DIC['rbacreview'];
87  $rbacadmin = $DIC['rbacadmin'];
88 
89  $obj = ilUtil::_getObjectsByOperations('crs', 'join');
90 
91  $rbacreview->assignedUsers(4);
92  $rbacreview->assignedRoles(6);
93  }
global $DIC
Definition: saml.php:7
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 261 of file ilRBACTest.php.

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

262  {
263  global $DIC;
264 
265  $rbacreview = $DIC['rbacreview'];
266  $rbacadmin = $DIC['rbacadmin'];
267  $ilDB = $DIC['ilDB'];
268 
269  $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';");
270 
271  $ref_id = 0;
272 
273  while ($row = $ilDB->fetchAssoc($req)) {
274  $ref_id = $row["ref_id"];
275  }
276 
277  $req = $ilDB->query("SELECT obj_id FROM object_data WHERE type='role';");
278  $ilDB->fetchAssoc($req);//First role is protected. Dont use it!
279  $role1 = $ilDB->fetchAssoc($req)["obj_id"];
280  $role2 = $ilDB->fetchAssoc($req)["obj_id"];
281  $role3 = $ilDB->fetchAssoc($req)["obj_id"];
282 
283  //save normal operations
284  $opt1 = $rbacreview->getActiveOperationsOfRole($ref_id, $role1);
285  $opt2 = $rbacreview->getActiveOperationsOfRole($ref_id, $role2);
286  $opt3 = $rbacreview->getActiveOperationsOfRole($ref_id, $role3);
287 
288  $rbacadmin->grantPermission($role1, array(1,2,3,4,5), $ref_id);
289  $rbacadmin->grantPermission($role2, array(1,2,3,4,5), $ref_id);
290  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role1), array(1,2,3,4,5));
291  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role2), array(1,2,3,4,5));
292  $rbacadmin->revokePermission($ref_id);
293  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role1));
294  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role2));
295 
296 
297  $rbacadmin->grantPermission($role1, array(1,2,3,4,5), $ref_id);
298  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role1), array(1,2,3,4,5));
299  $rbacadmin->revokePermission($ref_id, $role1);
300  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role1));
301 
302 
303  $rbacadmin->grantPermission($role2, array(1,2,3,4,5), $ref_id);
304  $rbacadmin->grantPermission($role3, array(1,2,3,4,5), $ref_id);
305  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role2), array(1,2,3,4,5));
306  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role3), array(1,2,3,4,5));
307  $rbacadmin->revokePermission($ref_id, 0, false);
308  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role2));
309  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role3));
310 
311  $rbacadmin->grantPermission($role3, array(1,2,3,4,5), $ref_id);
312  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($ref_id,$role3), array(1,2,3,4,5));
313  $rbacadmin->revokePermission($ref_id, $role3, false);
314  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($ref_id, $role3));
315 
316  //set normal operations
317  $rbacadmin->grantPermission($role1, $opt1, $ref_id);
318  $rbacadmin->grantPermission($role2, $opt2, $ref_id);
319  $rbacadmin->grantPermission($role3, $opt3, $ref_id);
320  }
global $DIC
Definition: saml.php:7
$req
Definition: getUserInfo.php:20
$row
global $ilDB

◆ testRevokePermissionList()

ilRBACTest::testRevokePermissionList ( )

Test revokePermissionList Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission

Definition at line 376 of file ilRBACTest.php.

References $DIC, $id, and $list.

377  {
378  global $DIC;
379 
380  $rbacreview = $DIC['rbacreview'];
381  $rbacadmin = $DIC['rbacadmin'];
382  $list = array(1001, 1003, 1005, 1007);
383 
384  foreach ($list as $id) {
385  $rbacadmin->grantPermission(123, array(1,2,3,4,5), $id);
386  }
387 
388  $rbacadmin->revokePermissionList($list, 123);
389 
390  foreach ($list as $id) {
391  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id, 123));
392  }
393  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id

◆ testRevokeSubtreePermissions()

ilRBACTest::testRevokeSubtreePermissions ( )

Test revokeSubtreePermissions Method DB: rbac_pa.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin testGrantPermission

Definition at line 330 of file ilRBACTest.php.

References $DIC, $id, $ilDB, $req, $row, and $tree.

331  {
332  global $DIC;
333 
334  $rbacreview = $DIC['rbacreview'];
335  $rbacadmin = $DIC['rbacadmin'];
336  $tree = $DIC['tree'];
337  $ilDB = $DIC['ilDB'];
338  $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';");
339 
340  $ref_id = 0;
341 
342  while ($row = $ilDB->fetchAssoc($req)) {
343  $ref_id = $row["ref_id"];
344  }
345 
346  $childs = $tree->getChildIds($ref_id);
347 
348  $req = $ilDB->query("SELECT obj_id FROM object_data WHERE type='role';");
349  $ilDB->fetchAssoc($req);//First role is protected. Dont use it!
350  $role = $ilDB->fetchAssoc($req)["obj_id"];
351 
352  $ops = array();
353 
354  foreach ($childs as $id) {
355  $ops[$id] = $rbacreview->getActiveOperationsOfRole($id, $role);//save normal operations
356  $rbacadmin->grantPermission($role, array(1,2,3,4,5), $id);
357  //$this->assertEquals($rbacreview->getActiveOperationsOfRole($id,$role), array(1,2,3,4,5));
358  }
359 
360  $rbacadmin->revokeSubtreePermissions($ref_id, $role);
361 
362  foreach ($childs as $id) {
363  $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id, $role));
364  $rbacadmin->grantPermission($role, $ops[$id], $id);//set normal operations
365  }
366  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
$req
Definition: getUserInfo.php:20
$row
global $ilDB

◆ testSetRolePermission()

ilRBACTest::testSetRolePermission ( )

Test Set Role Permission Method DB: rbac_template.

ilRbacReview $rbacreview ilRbacAdmin $rbacadmin

Definition at line 402 of file ilRBACTest.php.

References $DIC.

403  {
404  global $DIC;
405 
406  $rbacreview = $DIC['rbacreview'];
407  $rbacadmin = $DIC['rbacadmin'];
408  $rbacadmin->deleteTemplate(1010);
409 
410  $rbacadmin->setRolePermission(1010, "a", array(10,11,13,15), 1100);
411  $rbacadmin->setRolePermission(1010, "b", array(20,22,23,25), 1100);
412 
413  $assert = array("a" => array(10,11,13,15),"b" => array(20,22,23,25));
414  $dest = $rbacreview->getAllOperationsOfRole(1010, 1100);
415 
416  sort($dest["a"]);
417  sort($dest["b"]);
418 
419  $this->assertEquals($assert, $dest);
420 
421  $rbacadmin->deleteTemplate(1010);
422  }
global $DIC
Definition: saml.php:7

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: