コード例 #1
0
 /**
  * @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);
         };
     };
 }
コード例 #3
0
 /**
  * @param RequestInterface $request
  *
  * @return bool
  */
 protected function reauthenticate(RequestInterface $request)
 {
     return $this->signer->signRequest($request, true);
 }