39 include_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
40 ilUnitUtil::performInitialisation();
51 global $rbacreview,$rbacadmin;
54 #$rbacadmin->setProtected(1,4,'y');
55 #$prot = $rbacreview->isProtected(8,4);
56 #$this->assertEquals($prot,true);
57 #$rbacadmin->setProtected(1,4,'n');
58 #$prot = $rbacreview->isProtected(8,4);
59 #$this->assertEquals($prot,false);
61 $rbacreview->getRoleListByObject(8);
62 $rbacreview->getAssignableRoles();
65 $ass = $rbacreview->isAssignable(4,8);
66 $this->assertEquals($ass,
true);
68 $roles = $rbacreview->getRolesOfObject(8);
70 $obj = $rbacreview->getObjectOfRole(4);
71 $this->assertEquals(8,$obj);
80 global $rbacreview,$rbacadmin;
84 $rbacreview->assignedUsers(4);
85 $rbacreview->assignedRoles(6);
96 global $rbacreview,$rbacadmin;
98 $sess_ops = $rbacreview->getOperationsOnTypeString(
'sess');
100 $rbacadmin->assignOperationToObject($rbacreview->getTypeId(
'sess'),
'7');
104 $rbacadmin->deassignOperationFromObject($rbacreview->getTypeId(
'sess'),
'7');
105 $new_sess_ops = $rbacreview->getOperationsOnTypeString(
'sess');
106 $this->assertEquals($sess_ops,$new_sess_ops);
115 global $rbacreview,$rbacadmin;
117 $sess_ops = $rbacreview->getOperationsOnTypeString(
'cat');
119 $rbacadmin->revokePermission(1,4);
120 $rbacadmin->grantPermission(4,array(2,3),1);
132 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
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);
149 $suc = $handler->checkExists();
150 $this->assertEquals($suc,
false);
152 $suc = $handler->delete(99999);
153 $this->assertEquals($suc,
true);
156 $handler->deleteByObjId(-1);
157 $handler->deleteCondition(-1);
168 include_once
'./Services/AccessControl/classes/class.ilAccessHandler.php';
171 $handler->setResults(array(1,2,3));
172 $handler->storeCache();
173 $handler->readCache();
174 $res = $handler->getResults();
176 $this->assertEquals(array(1,2,3),
$res);
188 global $rbacreview, $rbacadmin;
190 $rbacadmin->assignUser(10,15);
192 $this->assertTrue($rbacreview->isAssigned(15,10));
195 $rbacadmin->assignUser(10,15);
208 global $rbacreview, $rbacadmin;
210 $rbacadmin->deassignUser(10,15);
212 $this->assertFalse($rbacreview->isAssigned(15,10));
224 global $rbacreview, $rbacadmin;
226 $rbacadmin->grantPermission(10,array(10,20,30),60);
228 $this->assertEquals($rbacreview->getActiveOperationsOfRole(60,10), array(10,20,30));
242 global $rbacreview, $rbacadmin,
$ilDB;
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';");
248 while(
$row = $ilDB->fetchAssoc($req))
253 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
254 $ilDB->fetchAssoc($req);
255 $role1 = $ilDB->fetchAssoc($req)[
"obj_id"];
256 $role2 = $ilDB->fetchAssoc($req)[
"obj_id"];
257 $role3 = $ilDB->fetchAssoc($req)[
"obj_id"];
260 $opt1 = $rbacreview->getActiveOperationsOfRole(
$ref_id,$role1);
261 $opt2 = $rbacreview->getActiveOperationsOfRole(
$ref_id,$role2);
262 $opt3 = $rbacreview->getActiveOperationsOfRole(
$ref_id,$role3);
264 $rbacadmin->grantPermission($role1, array(1,2,3,4,5),
$ref_id);
265 $rbacadmin->grantPermission($role2, array(1,2,3,4,5),
$ref_id);
268 $rbacadmin->revokePermission(
$ref_id);
269 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role1));
270 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role2));
273 $rbacadmin->grantPermission($role1, array(1,2,3,4,5),
$ref_id);
275 $rbacadmin->revokePermission(
$ref_id, $role1);
276 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role1));
279 $rbacadmin->grantPermission($role2, array(1,2,3,4,5),
$ref_id);
280 $rbacadmin->grantPermission($role3, array(1,2,3,4,5),
$ref_id);
283 $rbacadmin->revokePermission(
$ref_id,0,
false);
284 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role2));
285 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role3));
287 $rbacadmin->grantPermission($role3, array(1,2,3,4,5),
$ref_id);
289 $rbacadmin->revokePermission(
$ref_id, $role3,
false);
290 $this->assertEmpty($rbacreview->getActiveOperationsOfRole(
$ref_id,$role3));
293 $rbacadmin->grantPermission($role1, $opt1,
$ref_id);
294 $rbacadmin->grantPermission($role2, $opt2,
$ref_id);
295 $rbacadmin->grantPermission($role3, $opt3,
$ref_id);
308 global $rbacreview, $rbacadmin, $tree,
$ilDB;
309 $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';");
313 while(
$row = $ilDB->fetchAssoc($req))
318 $childs = $tree->getChildIds(
$ref_id);
320 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
321 $ilDB->fetchAssoc($req);
322 $role = $ilDB->fetchAssoc($req)[
"obj_id"];
326 foreach($childs as $id)
328 $ops[$id] = $rbacreview->getActiveOperationsOfRole($id,$role);
329 $rbacadmin->grantPermission($role, array(1,2,3,4,5),$id);
333 $rbacadmin->revokeSubtreePermissions(
$ref_id,$role);
335 foreach($childs as $id)
337 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id,$role));
338 $rbacadmin->grantPermission($role, $ops[$id],$id);
352 global $rbacreview, $rbacadmin;
353 $list = array(1001, 1003, 1005, 1007);
355 foreach($list as $id)
357 $rbacadmin->grantPermission(123, array(1,2,3,4,5),$id);
360 $rbacadmin->revokePermissionList($list, 123);
362 foreach($list as $id)
364 $this->assertEmpty($rbacreview->getActiveOperationsOfRole($id,123));
377 global $rbacreview, $rbacadmin;
378 $rbacadmin->deleteTemplate(1010);
380 $rbacadmin->setRolePermission(1010,
"a",array(10,11,13,15),1100);
381 $rbacadmin->setRolePermission(1010,
"b",array(20,22,23,25),1100);
383 $assert = array(
"a" => array(10,11,13,15),
"b" => array(20,22,23,25));
384 $dest = $rbacreview->getAllOperationsOfRole(1010,1100);
389 $this->assertEquals($assert, $dest);
391 $rbacadmin->deleteTemplate(1010);
404 global $rbacreview, $rbacadmin;
405 $rbacadmin->deleteTemplate(1010);
407 $rbacadmin->setRolePermission(1010,
"a",array(10,11,13,15),1100);
408 $rbacadmin->setRolePermission(1010,
"b",array(20,22,23,25),1100);
410 $rbacadmin->deleteRolePermission(1010,1100);
412 $this->assertEmpty($rbacreview->getAllOperationsOfRole(1010,1100));
414 $rbacadmin->setRolePermission(1010,
"a",array(10,11,13,15),1100);
415 $rbacadmin->setRolePermission(1010,
"b",array(20,22,23,25),1100);
417 $rbacadmin->deleteRolePermission(1010,1100,
"a");
419 $assert = array(
"b" => array(20,22,23,25));
420 $dest = $rbacreview->getAllOperationsOfRole(1010,1100);
424 $this->assertEquals($assert, $dest);
426 $rbacadmin->deleteTemplate(1010);
439 global $rbacreview, $rbacadmin;
440 $rbacadmin->deleteTemplate(1010);
441 $rbacadmin->deleteTemplate(2020);
443 $rbacadmin->setRolePermission(1010,
"blub",array(10,11),1100);
444 $rbacadmin->setRolePermission(2020,
"bulb",array(20,22),2200);
446 $rbacadmin->copyRoleTemplatePermissions(1010,1100,2200,2020);
448 $one = $rbacreview->getAllOperationsOfRole(1010,1100);
449 $two = $rbacreview->getAllOperationsOfRole(2020,2200);
452 $this->assertEquals($one, $two);
453 $rbacadmin->deleteTemplate(1010);
454 $rbacadmin->deleteTemplate(2020);
470 global $rbacreview, $rbacadmin,
$ilDB;
472 $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';");
476 while(
$row = $ilDB->fetchAssoc($req))
478 $seas =
$row[
"ref_id"];
481 $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';");
485 while(
$row = $ilDB->fetchAssoc($req))
487 $mail =
$row[
"ref_id"];
490 $req = $ilDB->query(
"SELECT obj_id FROM object_data WHERE type='role';");
491 $ilDB->fetchAssoc($req);
492 $role = $ilDB->fetchAssoc($req)[
"obj_id"];
495 $opt_mail = $rbacreview->getActiveOperationsOfRole($mail, $role);
496 $opt_seas = $rbacreview->getActiveOperationsOfRole($seas, $role);
497 $opt_temp_seas = $rbacreview->getAllOperationsOfRole($role, $seas);
498 $opt_temp_mail = $rbacreview->getAllOperationsOfRole($role, $mail);
501 $rbacadmin->setRolePermission($role,
"mail", array(1,2,3,4,5),$mail);
502 $rbacadmin->grantPermission($role, array(1,2,3,4,5), $mail);
503 $rbacadmin->setRolePermission($role,
"seas", array(5,6,7,8,9),$seas);
504 $rbacadmin->grantPermission($role, array(5,6,7,8,9), $seas);
506 $rbacadmin->copyRolePermissions($role,$seas,$mail, $role);
507 $this->assertEquals($rbacreview->getActiveOperationsOfRole($seas, $role),
508 $rbacreview->getActiveOperationsOfRole($mail, $role));
511 $rbacadmin->grantPermission($role,$opt_seas,$seas);
512 $rbacadmin->grantPermission($role,$opt_mail,$mail);
514 $rbacadmin->deleteRolePermission($role,$mail);
515 $rbacadmin->deleteRolePermission($role,$seas);
517 foreach($opt_temp_seas as $type => $opt)
519 $rbacadmin->setRolePermission($role, $type, $opt,$seas);
522 foreach($opt_temp_mail as $type => $opt)
524 $rbacadmin->setRolePermission($role, $type, $opt,$mail);
539 global $rbacreview, $rbacadmin;
540 $rbacadmin->deleteTemplate(1010);
541 $rbacadmin->deleteTemplate(2020);
542 $rbacadmin->deleteTemplate(3030);
544 $rbacadmin->setRolePermission(1010,
"a",array(10,11,13,15),1100);
545 $rbacadmin->setRolePermission(2020,
"a",array(11,12,13,16),2200);
547 $rbacadmin->setRolePermission(1010,
"b",array(20,22,23,25),1100);
548 $rbacadmin->setRolePermission(2020,
"b",array(20,23,24,26),2200);
550 $rbacadmin->setRolePermission(3030,
"c",array(30,33),3300);
551 $rbacadmin->setRolePermission(3030,
"a",array(30,33),3300);
552 $rbacadmin->setRolePermission(3030,
"b",array(30,33),3300);
554 $rbacadmin->copyRolePermissionIntersection(1010,1100,2020,2200,3300,3030);
556 $intersect = array(
"a" => array(11,13),
"b" => array(20,23));
557 $dest = $rbacreview->getAllOperationsOfRole(3030,3300);
563 $this->assertEquals($intersect, $dest);
565 $rbacadmin->deleteTemplate(1010);
566 $rbacadmin->deleteTemplate(2020);
567 $rbacadmin->deleteTemplate(3030);
581 global $rbacreview, $rbacadmin;
582 $rbacadmin->deleteTemplate(1010);
583 $rbacadmin->deleteTemplate(2020);
584 $rbacadmin->deleteTemplate(3030);
586 $rbacadmin->setRolePermission(1010,
"a",array(10,11,13,15),1100);
587 $rbacadmin->setRolePermission(2020,
"a",array(11,12,13,16),2200);
589 $rbacadmin->setRolePermission(1010,
"b",array(20,22,23,25),1100);
590 $rbacadmin->setRolePermission(2020,
"b",array(20,23,24,26),2200);
592 $rbacadmin->setRolePermission(1010,
"c",array(30,33,34,35),1100);
594 $rbacadmin->copyRolePermissionUnion(1010,1100,2020,2200,3030,3300);
596 $union = array(
"a" => array(10,11,12,13,15,16),
"b" => array(20,22,23,24,25,26),
"c" => array(30,33,34,35));
597 $dest = $rbacreview->getAllOperationsOfRole(3030,3300);
603 $this->assertEquals($union, $dest);
605 $rbacadmin->deleteTemplate(1010);
606 $rbacadmin->deleteTemplate(2020);
607 $rbacadmin->deleteTemplate(3030);
620 global $rbacreview, $rbacadmin;
621 $rbacadmin->deleteTemplate(1010);
622 $rbacadmin->deleteTemplate(2020);
624 $rbacadmin->setRolePermission(1010,
"a",array(10,11,13,15),1100);
625 $rbacadmin->setRolePermission(2020,
"a",array(11,12,13,16),2200);
627 $rbacadmin->setRolePermission(1010,
"b",array(20,22,23,25),1100);
628 $rbacadmin->setRolePermission(2020,
"b",array(20,23,24,26),2200);
630 $rbacadmin->setRolePermission(2020,
"c",array(30,33,34,35),2200);
632 $rbacadmin->copyRolePermissionSubtract(1010,1100,2020,2200);
634 $subtract = array(
"a" => array(12,16),
"b" => array(24,26),
"c" => array(30,33,34,35));
635 $dest = $rbacreview->getAllOperationsOfRole(2020,2200);
641 $this->assertEquals($subtract, $dest);
643 $rbacadmin->deleteTemplate(1010);
644 $rbacadmin->deleteTemplate(2020);
656 global $rbacreview, $rbacadmin;
658 $rbacadmin->assignOperationToObject(1001,10);
659 $rbacadmin->assignOperationToObject(1001,20);
661 $this->assertEquals($rbacreview->getOperationsOnType(1001), array(10,20));
672 global $rbacreview, $rbacadmin;
673 $rbacadmin->deassignOperationFromObject(1001,10);
675 $this->assertEquals($rbacreview->getOperationsOnType(1001), array(20));
677 $rbacadmin->deassignOperationFromObject(1001,20);
679 $this->assertEmpty($rbacreview->getOperationsOnType(1001));