// regular users should only be able to act for themselves
if($actor==$affected){
$this->assertTrue(Data::$user->authorize($affected,"userExists"),"User $actor acted properly for $affected, but the action was denied.");
$this->assertTrue(Data::$user->authorize($affected,"userRemove"),"User $actor acted properly for $affected, but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($affected,"userExists"),"User $actor acted improperly for $affected, but the action was allowed.");
$this->assertFalse(Data::$user->authorize($affected,"userRemove"),"User $actor acted improperly for $affected, but the action was allowed.");
}
// they should never be able to set rights
foreach(self::LEVELSas$level){
$this->assertFalse(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted improperly for $affected settings rights level $level, but the action was allowed.");
}
}
// they should not be able to list users
foreach(self::DOMAINSas$domain){
$this->assertFalse(Data::$user->authorize($domain,"userList"),"User $actor improperly checked user list for domain '$domain', but the action was allowed.");
$this->assertTrue(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted properly for $affected settings rights level $level, but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted improperly for $affected settings rights level $level, but the action was allowed.");
}
}
}
// they should also be able to list all users on their own domain
foreach(self::DOMAINSas$domain){
if($domain=="@".$actorDomain){
$this->assertTrue(Data::$user->authorize($domain,"userList"),"User $actor properly checked user list for domain '$domain', but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($domain,"userList"),"User $actor improperly checked user list for domain '$domain', but the action was allowed.");
$this->assertTrue(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted properly for $affected settings rights level $level, but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted improperly for $affected settings rights level $level, but the action was allowed.");
}
}
}
// they should also be able to list all users on their own domain
foreach(self::DOMAINSas$domain){
if($domain=="@".$actorDomain){
$this->assertTrue(Data::$user->authorize($domain,"userList"),"User $actor properly checked user list for domain '$domain', but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($domain,"userList"),"User $actor improperly checked user list for domain '$domain', but the action was allowed.");
$this->assertTrue(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted properly for $affected settings rights level $level, but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted improperly for $affected settings rights level $level, but the action was allowed.");
}
}
}
// they should also be able to list all users
foreach(self::DOMAINSas$domain){
$this->assertTrue(Data::$user->authorize($domain,"userList"),"User $actor properly checked user list for domain '$domain', but the action was denied.");
$this->assertTrue(Data::$user->authorize($affected,"userExists"),"User $actor acted properly for $affected, but the action was denied.");
$this->assertTrue(Data::$user->authorize($affected,"userRemove"),"User $actor acted properly for $affected, but the action was denied.");
foreach(self::LEVELSas$level){
$this->assertTrue(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted properly for $affected settings rights level $level, but the action was denied.");
}
}
foreach(self::DOMAINSas$domain){
$this->assertTrue(Data::$user->authorize($domain,"userList"),"User $actor properly checked user list for domain '$domain', but the action was denied.");
// users with unknown/invalid rights should be treated just like regular users and only be able to act for themselves
if($actor==$affected){
$this->assertTrue(Data::$user->authorize($affected,"userExists"),"User $actor acted properly for $affected, but the action was denied.");
$this->assertTrue(Data::$user->authorize($affected,"userRemove"),"User $actor acted properly for $affected, but the action was denied.");
}else{
$this->assertFalse(Data::$user->authorize($affected,"userExists"),"User $actor acted improperly for $affected, but the action was allowed.");
$this->assertFalse(Data::$user->authorize($affected,"userRemove"),"User $actor acted improperly for $affected, but the action was allowed.");
}
// they should never be able to set rights
foreach(self::LEVELSas$level){
$this->assertFalse(Data::$user->authorize($affected,"userRightsSet",$level),"User $actor acted improperly for $affected settings rights level $level, but the action was allowed.");
}
}
// they should not be able to list users
foreach(self::DOMAINSas$domain){
$this->assertFalse(Data::$user->authorize($domain,"userList"),"User $actor improperly checked user list for domain '$domain', but the action was allowed.");