-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. unit tests for domain resource roles 2. unit tests for resource roles 3. init filter support $filter = []; // the filter for policy to load $adapter = new AdapterFiltered(‘table_name’, $filter); $god = new God(‘path_to_model.conf’, $adapter);
- Loading branch information
Showing
9 changed files
with
194 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[request_definition] | ||
r = sub, dom, obj, act | ||
|
||
[policy_definition] | ||
p = sub, dom, obj, act | ||
|
||
[role_definition] | ||
g = _, _, _ | ||
g2 = _, _ | ||
|
||
[policy_effect] | ||
e = some(where (p.eft == allow)) | ||
|
||
[matchers] | ||
m = g(r.sub, p.sub, r.dom) && g2(r.obj, p.obj) && r.act == p.act |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
p, alice, domain1, data1, read | ||
p, bob, domain1, data2, write | ||
p, data_group_admin, domain1, data_group, write | ||
g, alice, data_group_admin, domain1 | ||
g2, data1, data_group | ||
g2, data2, data_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php namespace GodTests; | ||
|
||
use God\God; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* ------------------------------------------------------------------------------------ | ||
* God Test RBAC | ||
* ------------------------------------------------------------------------------------ | ||
* | ||
* @author lanlin | ||
* @change 2018/06/28 | ||
*/ | ||
class RbacAPIWithDomainResourceRolesUnitTest extends TestCase | ||
{ | ||
|
||
// ------------------------------------------------------------------------------ | ||
|
||
public function testDomainResourceRoles() | ||
{ | ||
$e = new God( | ||
TestUtil::$path.'rbac_with_domain_resource_roles_model.conf', | ||
TestUtil::$path.'rbac_with_domain_resource_roles_policy.csv' | ||
); | ||
|
||
TestUtil::testDomainEnforce($e, 'alice', 'domain1', 'data1', 'read', true); | ||
TestUtil::testDomainEnforce($e, 'alice', 'domain1', 'data1', 'write', true); | ||
TestUtil::testDomainEnforce($e, 'alice', 'domain1', 'data2', 'read', false); | ||
TestUtil::testDomainEnforce($e, 'alice', 'domain1', 'data2', 'write', true); | ||
} | ||
|
||
// ------------------------------------------------------------------------------ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php namespace GodTests; | ||
|
||
use God\God; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* ------------------------------------------------------------------------------------ | ||
* God Test RBAC | ||
* ------------------------------------------------------------------------------------ | ||
* | ||
* @author lanlin | ||
* @change 2018/06/28 | ||
*/ | ||
class RbacAPIWithResourceRolesUnitTest extends TestCase | ||
{ | ||
|
||
// ------------------------------------------------------------------------------ | ||
|
||
public function testResourceRoles() | ||
{ | ||
$e = new God(TestUtil::$path.'rbac_with_resource_roles_model.conf', TestUtil::$path.'rbac_with_resource_roles_policy.csv'); | ||
|
||
TestUtil::testEnforce($e, 'alice', 'data1', 'read', true); | ||
TestUtil::testEnforce($e, 'alice', 'data1', 'write', true); | ||
TestUtil::testEnforce($e, 'alice', 'data2', 'read', false); | ||
TestUtil::testEnforce($e, 'alice', 'data2', 'write', true); | ||
TestUtil::testEnforce($e, 'alice', 'data3', 'write', true); | ||
} | ||
|
||
// ------------------------------------------------------------------------------ | ||
|
||
} |