Пример #1
0
 public function it_can_execute_a_request(RequestInterface $request, Token $token)
 {
     $tokenUuid = Uuid::uuid4()->toString();
     $passCode = bin2hex(random_bytes(20));
     $request->getAcceptContentType()->willReturn('*/*');
     $request->offsetGet('token')->willReturn($tokenUuid);
     $request->offsetGet('pass_code')->willReturn($passCode);
     $this->tokenService->getToken(Uuid::fromString($tokenUuid), $passCode)->willReturn($token);
     $this->tokenService->remove($token)->shouldBeCalled();
     $response = $this->executeRequest($request);
     $response->shouldHaveType(ResponseInterface::class);
     $response->getResponseName()->shouldReturn(LogoutHandler::MESSAGE);
 }
Пример #2
0
 public function executeRequest(RequestInterface $request) : ResponseInterface
 {
     try {
         $token = $this->tokenService->getToken(Uuid::fromString($request['token']), $request['pass_code']);
         $this->tokenService->remove($token);
         return new Response(self::MESSAGE, [], $request);
     } catch (AuthException $exception) {
         return new Response($exception->getMessage(), [], $request);
     } catch (\Throwable $exception) {
         $this->log(LogLevel::ERROR, $exception->getMessage());
         throw new ResponseException('An error occurred during LogoutHandler.', new ServerErrorResponse([], $request));
     }
 }
Пример #3
0
 public function logout(Token $token)
 {
     $this->tokenService->remove($token);
 }
 public function it_can_logout(Token $token)
 {
     $this->tokenService->remove($token)->shouldBeCalled();
     $this->logout($token);
 }