protected function createRequest() { $request = new \Galmi\Xacml\Request(); $request->set('WorkingTime', true); $request->set('Subject.role', 'Manager'); $request->set('Object.type', 'Document'); $request->set('Action', 'edit'); return $request; }
public function testSet() { $resource = ['id' => 1, 'role' => 'Manager']; $request = new \Galmi\Xacml\Request(); $request->set('Resource', $resource); $this->assertEquals($resource, $request->get('Resource')); }
public function testEvaluate() { $request = new \Galmi\Xacml\Request(); $request->set('Subject.role', 'Manager'); $attributeFinder = $this->getMockBuilder('stdClass')->setMethods(['getValue'])->getMock(); $attributeFinder->method('getValue')->will($this->returnCallback(function () { /** @var \Galmi\Xacml\Request $request */ $request = func_get_arg(0); $attributeId = func_get_arg(1); return $request->get($attributeId); })); \Galmi\Xacml\Config::set(\Galmi\Xacml\Config::ATTRIBUTE_FINDER, $attributeFinder); $match = new \Galmi\Xacml\Match('Subject.role', 'Manager'); $this->assertTrue($match->evaluate($request), 'Test match evaluation'); }