public function setUp() { $streamClient = new Client\StreamClient(); $streamClient->setTimeout(3); $curlClient = new Client\CurlClient(); $curlClient->setTimeout(3); $this->clients[] = $streamClient; $this->clients[] = $curlClient; }
protected function getServiceFactory() { if (static::$serviceFactory instanceof ServiceFactory === false) { static::$serviceFactory = new ServiceFactory(); $httpClient = null; if (function_exists('curl_version') === true) { $httpClient = new CurlClient(); $httpClient->setCurlParameters([CURLOPT_CAINFO => __DIR__ . '/../../cert/cacert.pem']); } static::$serviceFactory->setHttpClient($httpClient); } return static::$serviceFactory; }
public function register() { $this->app->bind('oauth/factory/service', function ($app, $params = array()) { $factory = new ServiceFactory(); $factory->setHttpClient($client = new CurlClient()); $client->setCurlParameters((array) $params); return $factory; }); $this->app->bindShared('oauth/factory/extractor', function () { return new ExtractorFactory(); }); $this->app->bind('oauth_extractor', function ($app, $params = array()) { if (!is_array($params)) { $params = array($params); } if (!($service = head($params))) { throw new \InvalidArgumentException('No Service given.'); } $extractor_factory = $app->make('oauth/factory/extractor'); return $extractor_factory->get($service); }); \Route::register('/ccm/system/authentication/oauth2/{type}/{action}', function ($type, $action) { try { $type = \AuthenticationType::getByHandle($type); if ($type && is_object($type) && !$type->isError()) { /** @var GenericOauthTypeController $controller */ $controller = $type->getController(); if ($controller instanceof GenericOauthTypeController) { switch ($action) { case 'attempt_auth': return $controller->handle_authentication_attempt(); break; case 'callback': return $controller->handle_authentication_callback(); break; case 'attempt_attach': return $controller->handle_attach_attempt(); break; case 'attach_callback': return $controller->handle_attach_callback(); break; } } } } catch (\Exception $e) { \Log::addNotice('OAUTH ERROR: ' . $e->getMessage()); } }); }
public function testAdditionalParameters() { $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); $endPoint->expects($this->any())->method('getHost')->will($this->returnValue('httpbin.org')); $endPoint->expects($this->any())->method('getAbsoluteUri')->will($this->returnValue('http://httpbin.org/gzip')); $client = new CurlClient(); $client->setCurlParameters(array(CURLOPT_ENCODING => 'gzip')); $response = $client->retrieveResponse($endPoint, '', array(), 'get'); $response = json_decode($response, true); $this->assertNotNull($response); $this->assertSame('gzip', $response['headers']['Accept-Encoding']); $this->assertTrue($response['gzipped']); }
/** * {@inheritdoc} */ public function retrieveResponse(UriInterface $endpoint, $requestBody, array $extraHeaders = [], $method = 'POST') { $this->setCurlParameters([CURLOPT_FAILONERROR => true]); return parent::retrieveResponse($endpoint, $requestBody, $extraHeaders, $method); }