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); }
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; }