コード例 #1
0
 public function test_auth_handler_is_returned()
 {
     $generator = function () {
     };
     $middleware = Middleware::authHandler($generator);
     $handler = new MockHandler([new Response(204)]);
     $fn = $middleware($handler);
     $this->assertInstanceOf(AuthHandler::class, $fn);
 }
コード例 #2
0
ファイル: Builder.php プロジェクト: php-opencloud/common
 private function getStack(callable $authHandler, Token $token = null) : HandlerStack
 {
     $stack = HandlerStack::create();
     $stack->push(Middleware::authHandler($authHandler, $token));
     return $stack;
 }
コード例 #3
0
 /**
  * Load a token for the Compute Service
  *
  * @param String $opt serialized token
  *
  * @return void
  */
 public function loadComputeBackup($opt)
 {
     $options = $this->optionsGlobal['Common'];
     $options['catalogName'] = 'nova';
     $options['catalogType'] = 'compute';
     $options['region'] = 'RegionOne';
     $this->backup['Compute'] = $opt;
     $token = $this->unserializeToken($this->backup['Compute']['token']);
     $baseUrl = $this->backup['Compute']['baseUrl'];
     $stack = HandlerStack::create();
     $stack->push(Middleware::authHandler($options['authHandler'], $token));
     $this->addDebugMiddleware($options, $stack);
     $options['httpClient'] = new Client(['base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack]);
     $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl));
     $this->optionsGlobal['Compute'] = $options;
 }