public function testRemoveTargetAllOf() { $target = new \Galmi\Xacml\TargetAnyOf(); $this->assertEquals([], $target->getTargetAllOf(), 'Empty list of AllOf'); $allOf1 = new \Galmi\Xacml\TargetAllOf(); $target->addTargetAllOf($allOf1); $allOf2 = new \Galmi\Xacml\TargetAllOf(); $match = new \Galmi\Xacml\Match('Attribute.test', 'test'); $allOf2->addMatch($match); $target->addTargetAllOf($allOf2); $this->assertEquals([$allOf1, $allOf2], $target->getTargetAllOf(), 'Two item array of AllOf'); $target->removeTargetAllOf($allOf1); $this->assertEquals([$allOf2], $target->getTargetAllOf(), 'One item array of AllOf2'); $this->assertEquals($target, $target->removeTargetAllOf($allOf1), 'Remove not existed item will return this'); }
public function testEvaluate() { $request = new \Galmi\Xacml\Request(); $target = new \Galmi\Xacml\TargetAllOf(); $this->assertEquals(\Galmi\Xacml\Match::INDETERMINATE, $target->evaluate($request)); }
/** * Test 8 * * Subject.role == Array() * * Result = Indeterminate * */ public function testEvaluate8() { $request = $this->createRequest(); \Galmi\Xacml\Config::set(\Galmi\Xacml\Config::ATTRIBUTE_FINDER, $this->createAttributeFinder()); $matchMock = $this->getMockBuilder('\\Galmi\\Xacml\\Match')->setConstructorArgs(array('Subject.role', 'Manager'))->getMock(); $matchMock->method('evaluate')->willReturn(\Galmi\Xacml\Match::INDETERMINATE); $allOf = new \Galmi\Xacml\TargetAllOf(); $allOf->addMatch($matchMock); $anyOf = new \Galmi\Xacml\TargetAnyOf(); $anyOf->addTargetAllOf($allOf); $target = new \Galmi\Xacml\Target(); $target->addTargetAnyOf($anyOf); $this->assertEquals(\Galmi\Xacml\Match::INDETERMINATE, $target->evaluate($request), 'Test 8 is Indeterminate'); }
/** * ----------------------------------------------------------------------------------------- * | Target | Condition | Rule Value | * ----------------------------------------------------------------------------------------- * | “Indeterminate” | Don’t care | “Indeterminate{P}” if the Effect is Permit, | * | | | or “Indeterminate{D}” if the Effect is Deny | * ----------------------------------------------------------------------------------------- */ public function testEvaluate4() { $request = $this->createRequest(); $matchMock = $this->getMockBuilder('\\Galmi\\Xacml\\Match')->setConstructorArgs(array('Subject.role', 'Manager'))->getMock(); $matchMock->method('evaluate')->willReturn(\Galmi\Xacml\Match::INDETERMINATE); $allOf = new \Galmi\Xacml\TargetAllOf(); $allOf->addMatch($matchMock); $anyOf = new \Galmi\Xacml\TargetAnyOf(); $anyOf->addTargetAllOf($allOf); $target = new \Galmi\Xacml\Target(); $target->addTargetAnyOf($anyOf); $rule = new \Galmi\Xacml\Rule(); $rule->setEffect(\Galmi\Xacml\Decision::PERMIT); $rule->setTarget($target); $this->assertEquals(\Galmi\Xacml\Decision::INDETERMINATE_P, $rule->evaluate($request)); $rule = new \Galmi\Xacml\Rule(); $rule->setEffect(\Galmi\Xacml\Decision::DENY); $rule->setTarget($target); $this->assertEquals(\Galmi\Xacml\Decision::INDETERMINATE_D, $rule->evaluate($request)); }