From de1f3020478a471e0041c1030231bb5462640fd8 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 31 Jan 2016 02:38:05 +0100 Subject: Test Authentification --- server/core/LibOverride/Test.php | 69 +++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 30 deletions(-) mode change 100644 => 100755 server/core/LibOverride/Test.php (limited to 'server/core/LibOverride/Test.php') diff --git a/server/core/LibOverride/Test.php b/server/core/LibOverride/Test.php old mode 100644 new mode 100755 index a1c8023..09f08d5 --- a/server/core/LibOverride/Test.php +++ b/server/core/LibOverride/Test.php @@ -1,24 +1,56 @@ Utils::normalizeUrl($options['authUrl']), + // 'handler' => HandlerStack::create(), + //]); + + $httpClient = new Client([ + 'base_uri' => Utils::normalizeUrl($options['authUrl']), + 'handler' => $stack, + ]); + + $options['identityService'] = Service::factory($httpClient); //AuthHadler? // + $options['authHandler'] = function () use ($options) { + return $options['identityService']->generateToken($options); + }; //StockClient? // creer $options['httpClient'] instance de ClientInterface // token, baseUrl = identity->authenticate // stack = getStack authhandler token // addDebug?? // $options['httpClient'] = httpCLient baseurl stack - + $baseUrl = $options['authUrl']; + + //$stack = HandlerStack::create(); + $stack->push(Middleware::authHandler($options['authHandler'], $token)); + + $this->addDebugMiddleware($options, $stack); + + $options['httpClient'] = $httpClient; + + $this->optionsGlobal = $options; } /** @@ -33,31 +65,8 @@ class genTokenOptions $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); } } - /** - * @param array $options - * @codeCoverageIgnore - */ - private function stockAuthHandler(array &$options) - { - if (!isset($options['authHandler'])) { - $options['authHandler'] = function () use ($options) { - return $options['identityService']->generateToken($options); - }; - } - } - - private function getStack(callable $authHandler, Token $token = null) - { - $stack = HandlerStack::create(); - $stack->push(Middleware::authHandler($authHandler, $token)); - return $stack; - } - - private function httpClient($baseUrl, HandlerStack $stack) - { - return new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); - } + + public function getOptions(){ + return $this->optionsGlobal; + } } -- cgit v1.2.3