Exemplo n.º 1
0
 public static function create(callable $handler = null) : self
 {
     $stack = new self($handler ?: choose_handler());
     $stack->push(Middleware::httpErrors());
     $stack->push(Middleware::prepareBody());
     return $stack;
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 private function getStack(callable $authHandler, Token $token = null) : HandlerStack
 {
     $stack = HandlerStack::create();
     $stack->push(Middleware::authHandler($authHandler, $token));
     return $stack;
 }
 /**
  * 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;
 }