/**
  * @test
  * @expectedException \GuzzleHttp\Exception\ClientException
  */
 public function it_throws_exception_on_invalid_token()
 {
     $pool = $this->getMockBuilder(TokenPool::class)->disableOriginalConstructor()->setMethods(['getToken', 'getEndpointUrl', 'getTokenId'])->getMock();
     $pool->expects($this->once())->method('getToken')->willThrowException(new TokenException());
     $signer = new RequestSigner($pool);
     $signer->signRequest(new Request('GET', 'foo'), true);
 }
예제 #2
0
 /**
  * @param RequestSigner $signer
  *
  * @return \Closure
  */
 public static function signRequest(RequestSigner $signer)
 {
     return function (callable $handler) use($signer) {
         return function (RequestInterface $request, array $options) use($handler, $signer) {
             return $handler($signer->signRequest($request), $options);
         };
     };
 }
 /**
  * @param RequestInterface $request
  *
  * @return bool
  */
 protected function reauthenticate(RequestInterface $request)
 {
     return $this->signer->signRequest($request, true);
 }