Hi...
I have only recently got back from holiday and have been looking to forward to reviving this thread. Random comments since my last post...
I think building the Security class was a good idea even though it isn't within the requirements. It has forced us to think about the interfaces again.
I think the way forward though is either sample client code or test cases. I am not sure how the UML code clarified anything. UML is great stuff when requirements are clear, but it is really easy to create castles in the air.
I am happy with either PHP5 or PHP4, but it is harder for me to run PHP5 stuff.
What is wrong with this test case...?
PHP Code:
class RoleBasedPermissionsTest extends UnitTestCase {
function RoleBasedPermissionsTest() {
$this->UnitTestCase();
}
function setUp() {
$authoriser = &new Authoriser();
$authoriser->addPrincipal('fred');
$authoriser->assign('fred', 'pleb');
$authoriser->permit('pleb', 'do_stuff');
}
function tearDown() {
$authoriser = &new Authoriser();
$authoriser->dropPrincipal('fred');
$authoriser->dropRole('pleb');
}
function testNonUserHasNothingAllowed() {
$authoriser = &new Authoriser();
$permissions = &$authoriser->getPermissions('nobody');
$this->assertFalse($permissions->can('do_stuff'));
}
function testLegitimateUserHasActionAllowed() {
$authoriser = &new Authoriser();
$permissions = &$authoriser->getPermissions('fred');
$this->assertTrue($permissions->can('do_stuff'));
}
function testUserCannotDoNonAction() {
$authoriser = &new Authoriser();
$permissions = &$authoriser->getPermissions('fred');
$this->assertFalse($permissions->can('do_unknown'));
}
}
I have removed the storage flexibility for now (it can be put in later if needed) and assumed that the editing methods will fill out needed data automatically. This is the simplest starting point I can come up with.
yours, Marcus