/** * @expectedException \Datto\JsonRpc\Exception\MissingAuth */ public function testAuthorizingRequestWithNoValidHandler() { $handlerMock = $this->getMock('\\Datto\\JsonRpc\\Auth\\Handler'); $handlerMock->expects($this->once())->method('canHandle')->willReturn(false); $handlerMock->expects($this->never())->method('authenticate'); $auth = new Authenticator(); $auth->addHandler($handlerMock); $auth->authenticate("", array()); }
/** * Authenticate request and (if successful) map method name to callable * and run it with the given arguments. * * @param string $method Method name * @param array $arguments Positional or associative argument array * @return mixed Return value of the callable * @throws Exception\MissingAuth If the no credentials are given * @throws Exception\InvalidAuth If the given credentials are invalid */ public function evaluate($method, $arguments) { $this->authenticator->authenticate($method, $arguments); return $this->evaluator->evaluate($method, $arguments); }