diff options
Diffstat (limited to 'vendor/lusitanian/oauth')
173 files changed, 0 insertions, 21699 deletions
diff --git a/vendor/lusitanian/oauth/.gitignore b/vendor/lusitanian/oauth/.gitignore deleted file mode 100644 index 1721c572..00000000 --- a/vendor/lusitanian/oauth/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.idea -vendor -.DS_Store -composer.lock -examples/init.php -atlassian-ide-plugin.xml diff --git a/vendor/lusitanian/oauth/.scrutinizer.yml b/vendor/lusitanian/oauth/.scrutinizer.yml deleted file mode 100644 index 5a274c98..00000000 --- a/vendor/lusitanian/oauth/.scrutinizer.yml +++ /dev/null @@ -1,37 +0,0 @@ -before_commands: - - "composer install --dev --prefer-source" - -tools: - php_code_coverage: - enabled: true - test_command: phpunit -c phpunit.xml.dist - filter: - paths: ["src/*"] - php_code_sniffer: - enabled: true - config: - standard: PSR2 - filter: - paths: ["src/*"] - php_cpd: - enabled: true - excluded_dirs: ["examples", "tests", "vendor"] - php_cs_fixer: - enabled: true - config: - level: all - filter: - paths: ["src/*", "tests/*"] - php_loc: - enabled: true - php_mess_detector: - enabled: true - filter: - paths: ["src/*"] - php_pdepend: - enabled: true - excluded_dirs: ["tests", "examples", "vendor"] - php_analyzer: - filter: - paths: ["src/*", "tests/*"] - sensiolabs_security_checker: true diff --git a/vendor/lusitanian/oauth/.travis.yml b/vendor/lusitanian/oauth/.travis.yml deleted file mode 100644 index fe927478..00000000 --- a/vendor/lusitanian/oauth/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm - -matrix: - allow_failures: - - php: hhvm - -before_script: - - composer self-update - - composer install - - pyrus install pear/PHP_CodeSniffer - - phpenv rehash - -script: - - phpcs --standard=psr2 src/ - - phpunit --coverage-text diff --git a/vendor/lusitanian/oauth/LICENSE b/vendor/lusitanian/oauth/LICENSE deleted file mode 100644 index cea529be..00000000 --- a/vendor/lusitanian/oauth/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -(c) 2013 David Desberg <david@daviddesberg.com> -Contributions (c) 2013 Pieter Hordijk <info@pieterhordijk.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/lusitanian/oauth/README.md b/vendor/lusitanian/oauth/README.md deleted file mode 100644 index e7c2f792..00000000 --- a/vendor/lusitanian/oauth/README.md +++ /dev/null @@ -1,102 +0,0 @@ -PHPoAuthLib -=========== -PHPoAuthLib provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client. - -[![Build Status](https://travis-ci.org/Lusitanian/PHPoAuthLib.png?branch=master)](https://travis-ci.org/Lusitanian/PHPoAuthLib) -[![Code Coverage](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/badges/coverage.png?s=a0a15bebfda49e79f9ce289b00c6dfebd18fc98e)](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/) -[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/badges/quality-score.png?s=c5976d2fefceb501f0d886c1a5bf087e69b44533)](https://scrutinizer-ci.com/g/Lusitanian/PHPoAuthLib/) -[![Latest Stable Version](https://poser.pugx.org/lusitanian/oauth/v/stable.png)](https://packagist.org/packages/lusitanian/oauth) -[![Total Downloads](https://poser.pugx.org/lusitanian/oauth/downloads.png)](https://packagist.org/packages/lusitanian/oauth) - -Installation ------------- -This library can be found on [Packagist](https://packagist.org/packages/lusitanian/oauth). -The recommended way to install this is through [composer](http://getcomposer.org). - -Edit your `composer.json` and add: - -```json -{ - "require": { - "lusitanian/oauth": "~0.3" - } -} -``` - -And install dependencies: - -```bash -$ curl -sS https://getcomposer.org/installer | php -$ php composer.phar install -``` - -Features --------- -- PSR-0 compliant for easy interoperability -- Fully extensible in every facet. - - You can implement any service with any custom requirements by extending the protocol version's `AbstractService` implementation. - - You can use any HTTP client you desire, just create a class utilizing it which implements `OAuth\Common\Http\ClientInterface` (two implementations are included) - - You can use any storage mechanism for tokens. By default, session, in-memory and Redis.io (requires PHPRedis) storage mechanisms are included. Implement additional mechanisms by implementing `OAuth\Common\Token\TokenStorageInterface`. - -Service support ---------------- -The library supports both oAuth 1.x and oAuth 2.0 compliant services. A list of currently implemented services can be found below. - -Included service implementations --------------------------------- -- OAuth1 - - BitBucket - - Etsy - - FitBit - - Flickr - - Scoop.it! - - Tumblr - - Twitter - - Xing - - Yahoo -- OAuth2 - - Amazon - - BitLy - - Box - - Dailymotion - - Dropbox - - Facebook - - Foursquare - - GitHub - - Google - - Harvest - - Heroku - - Instagram - - LinkedIn - - Mailchimp - - Microsoft - - PayPal - - Pocket - - Reddit - - RunKeeper - - SoundCloud - - Ustream - - Vkontakte - - Yammer -- more to come! - -Examples --------- -Examples of basic usage are located in the examples/ directory. - -Usage ------- -For usage with complete auth flow, please see the examples. More in-depth documentation will come with release 1.0. - -Framework Integration ---------------------- -* Lithium: Sébastien Charrier has written [an adapter](https://github.com/scharrier/li3_socialauth) for the library. -* Laravel 4: Dariusz PrzÄ…da has written [a service provider](https://github.com/artdarek/oauth-4-laravel) for the library. - -Extensions ----------- -* Extract normalized user data from OAuth Services with the library [PHPoAuthUserData](https://github.com/Oryzone/PHPoAuthUserData) by Luciano Mammino - -Tests ------- -To run the tests, you must install dependencies with `composer install --dev` diff --git a/vendor/lusitanian/oauth/composer.json b/vendor/lusitanian/oauth/composer.json deleted file mode 100644 index cc0bdcf2..00000000 --- a/vendor/lusitanian/oauth/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "lusitanian/oauth", - "description": "PHP 5.3+ oAuth 1/2 Library", - "keywords": ["oauth", "authentication", "authorization", "security"], - "license": "MIT", - "authors": [ - { - "name": "David Desberg", - "email": "david@daviddesberg.com" - }, - { - "name": "Pieter Hordijk", - "email": "info@pieterhordijk.com" - } - ], - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "symfony/http-foundation": "~2.1", - "predis/predis": "0.8.*@dev", - "phpunit/phpunit": "3.7.*" - }, - "suggest": { - "symfony/http-foundation": "Allows using the Symfony Session storage backend.", - "predis/predis": "Allows using the Redis storage backend.", - "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client." - }, - "autoload": { - "psr-0": { - "OAuth": "src", - "OAuth\\Unit": "tests" - } - }, - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" - } - } -} diff --git a/vendor/lusitanian/oauth/examples/amazon.php b/vendor/lusitanian/oauth/examples/amazon.php deleted file mode 100644 index 0798eafc..00000000 --- a/vendor/lusitanian/oauth/examples/amazon.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Amazon service - * - * PHP version 5.4 - * - * @author Flávio Heleno <flaviohbatista@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Amazon; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['amazon']['key'], - $servicesCredentials['amazon']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Amazon service using the credentials, http client, storage mechanism for the token and profile scope -/** @var $amazonService Amazon */ -$amazonService = $serviceFactory->createService('amazon', $credentials, $storage, array('profile')); - -if (!empty($_GET['code'])) { - // This was a callback request from Amazon, get the token - $token = $amazonService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($amazonService->request('/user/profile'), true); - - // Show some of the resultant data - echo 'Your unique Amazon user id is: ' . $result['user_id'] . ' and your name is ' . $result['name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $amazonService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Amazon!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/bitbucket.php b/vendor/lusitanian/oauth/examples/bitbucket.php deleted file mode 100644 index d9330961..00000000 --- a/vendor/lusitanian/oauth/examples/bitbucket.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token from the BitBucket service - * - * PHP version 5.4 - * @author Ændrew Rininsland <me@aendrew.com> - * - * Shamelessly cribbed from work by: - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\BitBucket; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// We need to use a persistent storage to save the token, because oauth1 requires the token secret received before' -// the redirect (request token request) in the access token request. -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['bitbucket']['key'], - $servicesCredentials['bitbucket']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the BitBucket service using the credentials, http client and storage mechanism for the token -/** @var $bbService BitBucket */ -$bbService = $serviceFactory->createService('BitBucket', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('BitBucket'); - - // This was a callback request from BitBucket, get the token - $bbService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($bbService->request('user/repositories')); - - echo('The first repo in the list is ' . $result[0]->name); - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // extra request needed for oauth1 to request a request token :-) - $token = $bbService->requestRequestToken(); - - $url = $bbService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with BitBucket!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/bitly.php b/vendor/lusitanian/oauth/examples/bitly.php deleted file mode 100644 index 9cd27e34..00000000 --- a/vendor/lusitanian/oauth/examples/bitly.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Bitly service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Bitly; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['bitly']['key'], - $servicesCredentials['bitly']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Bitly service using the credentials, http client and storage mechanism for the token -/** @var $bitlyService Bitly */ -$bitlyService = $serviceFactory->createService('bitly', $credentials, $storage); - -if (!empty($_GET['code'])) { - // This was a callback request from bitly, get the token - $bitlyService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($bitlyService->request('user/info'), true); - - // Show some of the resultant data - echo 'Your unique user id is: ' . $result['data']['login'] . ' and your name is ' . $result['data']['display_name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $bitlyService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Bitly!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/bootstrap.php b/vendor/lusitanian/oauth/examples/bootstrap.php deleted file mode 100644 index f02da414..00000000 --- a/vendor/lusitanian/oauth/examples/bootstrap.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -/** - * Bootstrap the library - */ -require_once __DIR__ . '/../vendor/autoload.php'; - -/** - * Setup error reporting - */ -error_reporting(E_ALL); -ini_set('display_errors', 1); - -/** - * Setup the timezone - */ -ini_set('date.timezone', 'Europe/Amsterdam'); - -/** - * Create a new instance of the URI class with the current URI, stripping the query string - */ -$uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); -$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); -$currentUri->setQuery(''); - -/** - * Load the credential for the different services - */ -require_once __DIR__ . '/init.php'; diff --git a/vendor/lusitanian/oauth/examples/box.php b/vendor/lusitanian/oauth/examples/box.php deleted file mode 100644 index f1b06443..00000000 --- a/vendor/lusitanian/oauth/examples/box.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Box service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @author Antoine Corcy <contact@sbin.dk> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Box; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['box']['key'], - $servicesCredentials['box']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Box service using the credentials, http client and storage mechanism for the token -/** @var $boxService Box */ -$boxService = $serviceFactory->createService('box', $credentials, $storage); - -if (!empty($_GET['code'])) { - // retrieve the CSRF state parameter - $state = isset($_GET['state']) ? $_GET['state'] : null; - - // This was a callback request from box, get the token - $token = $boxService->requestAccessToken($_GET['code'], $state); - - // Send a request with it - $result = json_decode($boxService->request('/users/me'), true); - - // Show some of the resultant data - echo 'Your Box name is ' . $result['name'] . ' and your email is ' . $result['login']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $boxService->getAuthorizationUri(); - // var_dump($url); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Box!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/buffer.php b/vendor/lusitanian/oauth/examples/buffer.php deleted file mode 100644 index c1b9ddde..00000000 --- a/vendor/lusitanian/oauth/examples/buffer.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Buffer service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Buffer; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['buffer']['key'], - $servicesCredentials['buffer']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the buffer service using the credentials, http client and storage mechanism for the token -/** @var $bufferService buffer */ -$bufferService = $serviceFactory->createService('buffer', $credentials, $storage); - -if (!empty($_GET['code'])) { - // This was a callback request from buffer, get the token - $bufferService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($bufferService->request('user.json'), true); - - // Show some of the resultant data - echo 'Your unique user id is: ' . $result['id'] . ' and your plan is ' . $result['plan']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $bufferService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with buffer!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/dailymotion.php b/vendor/lusitanian/oauth/examples/dailymotion.php deleted file mode 100644 index 53f0878a..00000000 --- a/vendor/lusitanian/oauth/examples/dailymotion.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Dailymotion service - * - * PHP version 5.4 - * - * @author Mouhamed SEYE <mouhamed@seye.pro> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Dailymotion; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['dailymotion']['key'], - $servicesCredentials['dailymotion']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Dailymotion service using the credentials, http client, storage mechanism for the token and email scope -/** @var $dailymotionService Dailymotion */ -$dailymotionService = $serviceFactory->createService('dailymotion', $credentials, $storage, array('email')); - -if (!empty($_GET['code'])) { - // This was a callback request from Dailymotion, get the token - $token = $dailymotionService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($dailymotionService->request('/me?fields=email,id'), true); - - // Show some of the resultant data - echo 'Your unique Dailymotion user id is: ' . $result['id'] . ' and your email is ' . $result['email']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $dailymotionService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Dailymotion!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/dropbox.php b/vendor/lusitanian/oauth/examples/dropbox.php deleted file mode 100644 index 0d60551c..00000000 --- a/vendor/lusitanian/oauth/examples/dropbox.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Dropbox service - * - * PHP version 5.4 - * - * @author Flávio Heleno <flaviohbatista@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Dropbox; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['dropbox']['key'], - $servicesCredentials['dropbox']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Dropbox service using the credentials, http client and storage mechanism for the token -/** @var $dropboxService Dropbox */ -$dropboxService = $serviceFactory->createService('dropbox', $credentials, $storage, array()); - -if (!empty($_GET['code'])) { - // This was a callback request from Dropbox, get the token - $token = $dropboxService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($dropboxService->request('/account/info'), true); - - // Show some of the resultant data - echo 'Your unique Dropbox user id is: ' . $result['uid'] . ' and your name is ' . $result['display_name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $dropboxService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Dropbox!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/etsy.php b/vendor/lusitanian/oauth/examples/etsy.php deleted file mode 100644 index 0c0b79b7..00000000 --- a/vendor/lusitanian/oauth/examples/etsy.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Etsy service - * - * PHP version 5.4 - * - * @author Iñaki Abete <inakiabt+github@gmail.com> - * @copyright Copyright (c) 2013 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\Etsy; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['etsy']['key'], - $servicesCredentials['etsy']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Etsy service using the credentials, http client and storage mechanism for the token -/** @var $etsyService Etsy */ -$etsyService = $serviceFactory->createService('Etsy', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('Etsy'); - - // This was a callback request from Etsy, get the token - $etsyService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($etsyService->request('/private/users/__SELF__')); - - echo 'result: <pre>' . print_r($result, true) . '</pre>'; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $response = $etsyService->requestRequestToken(); - $extra = $response->getExtraParams(); - $url = $extra['login_url']; - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Etsy!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/facebook.php b/vendor/lusitanian/oauth/examples/facebook.php deleted file mode 100644 index b6426721..00000000 --- a/vendor/lusitanian/oauth/examples/facebook.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Facebook service - * - * PHP version 5.4 - * - * @author Benjamin Bender <bb@codepoet.de> - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Facebook; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['facebook']['key'], - $servicesCredentials['facebook']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Facebook service using the credentials, http client and storage mechanism for the token -/** @var $facebookService Facebook */ -$facebookService = $serviceFactory->createService('facebook', $credentials, $storage, array()); - -if (!empty($_GET['code'])) { - // This was a callback request from facebook, get the token - $token = $facebookService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($facebookService->request('/me'), true); - - // Show some of the resultant data - echo 'Your unique facebook user id is: ' . $result['id'] . ' and your name is ' . $result['name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $facebookService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Facebook!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/fitbit.php b/vendor/lusitanian/oauth/examples/fitbit.php deleted file mode 100644 index 35b3d09f..00000000 --- a/vendor/lusitanian/oauth/examples/fitbit.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the FitBit service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\FitBit; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['fitbit']['key'], - $servicesCredentials['fitbit']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the FitBit service using the credentials, http client and storage mechanism for the token -/** @var $fitbitService FitBit */ -$fitbitService = $serviceFactory->createService('FitBit', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('FitBit'); - - // This was a callback request from fitbit, get the token - $fitbitService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($fitbitService->request('user/-/profile.json')); - - echo 'result: <pre>' . print_r($result, true) . '</pre>'; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // extra request needed for oauth1 to request a request token :-) - $token = $fitbitService->requestRequestToken(); - - $url = $fitbitService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with FitBit!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/flickr.php b/vendor/lusitanian/oauth/examples/flickr.php deleted file mode 100644 index f7a80f67..00000000 --- a/vendor/lusitanian/oauth/examples/flickr.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Flickr service - * - * @author Christian Mayer <thefox21at@gmail.com> - * @copyright Copyright (c) 2013 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\Flickr; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; -use OAuth\Common\Http\Client\CurlClient; - -/** - * Bootstrap the example - */ -require_once __DIR__.'/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['flickr']['key'], - $servicesCredentials['flickr']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Flickr service using the credentials, http client and storage mechanism for the token -$flickrService = $serviceFactory->createService('Flickr', $credentials, $storage); - -$step = isset($_GET['step']) ? (int)$_GET['step'] : null; - -$oauth_token = isset($_GET['oauth_token']) ? $_GET['oauth_token'] : null; -$oauth_verifier = isset($_GET['oauth_verifier']) ? $_GET['oauth_verifier'] : null; - -if($oauth_token && $oauth_verifier){ - $step = 2; -} - -switch($step){ - default: - print "<a href='".$currentUri->getRelativeUri().'?step=1'."'>Login with Flickr!</a>"; - break; - - case 1: - - if($token = $flickrService->requestRequestToken()){ - $oauth_token = $token->getAccessToken(); - $secret = $token->getAccessTokenSecret(); - - if($oauth_token && $secret){ - $url = $flickrService->getAuthorizationUri(array('oauth_token' => $oauth_token, 'perms' => 'write')); - header('Location: '.$url); - } - } - - break; - - case 2: - $token = $storage->retrieveAccessToken('Flickr'); - $secret = $token->getAccessTokenSecret(); - - if($token = $flickrService->requestAccessToken($oauth_token, $oauth_verifier, $secret)){ - $oauth_token = $token->getAccessToken(); - $secret = $token->getAccessTokenSecret(); - - $storage->storeAccessToken('Flickr', $token); - - header('Location: '.$currentUri->getAbsoluteUri().'?step=3'); - } - break; - - case 3: - $xml = simplexml_load_string($flickrService->request('flickr.test.login')); - print "status: ".(string)$xml->attributes()->stat."\n"; - break; -} diff --git a/vendor/lusitanian/oauth/examples/foursquare.php b/vendor/lusitanian/oauth/examples/foursquare.php deleted file mode 100644 index f7920724..00000000 --- a/vendor/lusitanian/oauth/examples/foursquare.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Foursquare service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Foursquare; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['foursquare']['key'], - $servicesCredentials['foursquare']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Foursquare service using the credentials, http client and storage mechanism for the token -/** @var $foursquareService Foursquare */ -$foursquareService = $serviceFactory->createService('foursquare', $credentials, $storage); - -if (!empty($_GET['code'])) { - // This was a callback request from foursquare, get the token - $foursquareService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($foursquareService->request('users/self'), true); - - // Show some of the resultant data - echo 'Your unique foursquare user id is: ' . $result['response']['user']['id'] . ' and your name is ' . $result['response']['user']['firstName'] . $result['response']['user']['lastName']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $foursquareService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Foursquare!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/github.php b/vendor/lusitanian/oauth/examples/github.php deleted file mode 100644 index 23e971f8..00000000 --- a/vendor/lusitanian/oauth/examples/github.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Github service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\GitHub; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['github']['key'], - $servicesCredentials['github']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the GitHub service using the credentials, http client and storage mechanism for the token -/** @var $gitHub GitHub */ -$gitHub = $serviceFactory->createService('GitHub', $credentials, $storage, array('user')); - -if (!empty($_GET['code'])) { - // This was a callback request from github, get the token - $gitHub->requestAccessToken($_GET['code']); - - $result = json_decode($gitHub->request('user/emails'), true); - - echo 'The first email on your github account is ' . $result[0]; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $gitHub->getAuthorizationUri(); - header('Location: ' . $url); - -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Github!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/google.php b/vendor/lusitanian/oauth/examples/google.php deleted file mode 100644 index f05a03e0..00000000 --- a/vendor/lusitanian/oauth/examples/google.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Google service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Google; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['google']['key'], - $servicesCredentials['google']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Google service using the credentials, http client and storage mechanism for the token -/** @var $googleService Google */ -$googleService = $serviceFactory->createService('google', $credentials, $storage, array('userinfo_email', 'userinfo_profile')); - -if (!empty($_GET['code'])) { - // This was a callback request from google, get the token - $googleService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true); - - // Show some of the resultant data - echo 'Your unique google user id is: ' . $result['id'] . ' and your name is ' . $result['name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $googleService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Google!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/harvest.php b/vendor/lusitanian/oauth/examples/harvest.php deleted file mode 100644 index 1d11584a..00000000 --- a/vendor/lusitanian/oauth/examples/harvest.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the harvest service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\Common\Consumer\Credentials; -use OAuth\Common\Storage\Session; -use OAuth\Common\Token\Exception\ExpiredTokenException; -use OAuth\OAuth2\Service\Harvest; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -$serviceName = 'Harvest'; -$scopes = array(); - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['harvest']['key'], - $servicesCredentials['harvest']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Harvest service using the credentials, http client and storage mechanism for the token -/** @var $harves Harves */ -$harvest = $serviceFactory->createService($serviceName, $credentials, $storage, $scopes); - -if (!empty($_GET['clearToken'])) { - // Clear the current AccessToken and go back to the Beginning. - $storage->clearToken($serviceName); - header('Location: ' . $currentUri->getAbsoluteUri()); - -} elseif ($storage->hasAccessToken($serviceName)) { - // fetch the accessToken for the service - $accessToken = $storage->retrieveAccessToken($serviceName); - - // is the accessToken expired? then let's refesh it! - if ($accessToken->isExpired() === TRUE) { - $harvest->refreshAccessToken($accessToken); - } - - // use the service with the valid access token to fetch my email - $result = json_decode($harvest->request('account/who_am_i'), true); - echo 'The email on your harvest account is ' . $result['user']['email']; - - $url = $currentUri->getRelativeUri() . '?clearToken=1'; - echo " <a href='$url'>Click here to clear the current access token</a>"; - -} elseif (!empty($_GET['code'])) { - // This was a callback request from harvest, get the token - $harvest->requestAccessToken($_GET['code']); - header('Location: ' . $currentUri->getAbsoluteUri()); - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // Redirect to the Authorization uri - $url = $harvest->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Harvest!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/init.example.php b/vendor/lusitanian/oauth/examples/init.example.php deleted file mode 100644 index fb6aee40..00000000 --- a/vendor/lusitanian/oauth/examples/init.example.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php - -/** - * This file sets up the information needed to test the examples in different environments. - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -/** - * @var array A list of all the credentials to be used by the different services in the examples - */ -$servicesCredentials = array( - 'amazon' => array( - 'key' => '', - 'secret' => '', - ), - 'bitbucket' => array( - 'key' => '', - 'secret' => '', - ), - 'bitly' => array( - 'key' => '', - 'secret' => '', - ), - 'box' => array( - 'key' => '', - 'secret' => '', - ), - 'buffer' => array( - 'key' => '', - 'secret' => '', - ), - 'dailymotion' => array( - 'key' => '', - 'secret' => '', - ), - 'dropbox' => array( - 'key' => '', - 'secret' => '', - ), - 'etsy' => array( - 'key' => '', - 'secret' => '', - ), - 'facebook' => array( - 'key' => '', - 'secret' => '', - ), - 'fitbit' => array( - 'key' => '', - 'secret' => '', - ), - 'flickr' => array( - 'key' => '', - 'secret' => '', - ), - 'foursquare' => array( - 'key' => '', - 'secret' => '', - ), - 'github' => array( - 'key' => '', - 'secret' => '', - ), - 'google' => array( - 'key' => '', - 'secret' => '', - ), - 'instagram' => array( - 'key' => '', - 'secret' => '', - ), - 'linkedin' => array( - 'key' => '', - 'secret' => '', - ), - 'mailchimp' => array( - 'key' => '', - 'secret' => '', - ), - 'microsoft' => array( - 'key' => '', - 'secret' => '', - ), - 'paypal' => array( - 'key' => '', - 'secret' => '', - ), - 'pocket' => array( - 'key' => '', - ), - 'reddit' => array( - 'key' => '', - 'secret' => '', - ), - 'runkeeper' => array( - 'key' => '', - 'secret' => '', - ), - 'scoopit' => array( - 'key' => '', - 'secret' => '' - ), - 'soundcloud' => array( - 'key' => '', - 'secret' => '', - ), - 'tumblr' => array( - 'key' => '', - 'secret' => '', - ), - 'twitter' => array( - 'key' => '', - 'secret' => '', - ), - 'ustream' => array( - 'key' => '', - 'secret' => '', - ), - 'yahoo' => array( - 'key' => '', - 'secret' => '' - ), - 'yammer' => array( - 'key' => '', - 'secret' => '' - ), -); - -/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */ -$serviceFactory = new \OAuth\ServiceFactory(); diff --git a/vendor/lusitanian/oauth/examples/instagram.php b/vendor/lusitanian/oauth/examples/instagram.php deleted file mode 100644 index 2e44094c..00000000 --- a/vendor/lusitanian/oauth/examples/instagram.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Instagram service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @author Hannes Van De Vreken <vandevreken.hannes@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Instagram; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['instagram']['key'], - $servicesCredentials['instagram']['secret'], - $currentUri->getAbsoluteUri() -); - -$scopes = array('basic', 'comments', 'relationships', 'likes'); - -// Instantiate the Instagram service using the credentials, http client and storage mechanism for the token -/** @var $instagramService Instagram */ -$instagramService = $serviceFactory->createService('instagram', $credentials, $storage, $scopes); - -if (!empty($_GET['code'])) { - // This was a callback request from Instagram, get the token - $instagramService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($instagramService->request('users/self'), true); - - // Show some of the resultant data - echo 'Your unique instagram user id is: ' . $result['data']['id'] . ' and your name is ' . $result['data']['full_name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $instagramService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Instagram!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/linkedin.php b/vendor/lusitanian/oauth/examples/linkedin.php deleted file mode 100644 index db14ab25..00000000 --- a/vendor/lusitanian/oauth/examples/linkedin.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Linkedin service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @author Antoine Corcy <contact@sbin.dk> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Linkedin; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['linkedin']['key'], - $servicesCredentials['linkedin']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Linkedin service using the credentials, http client and storage mechanism for the token -/** @var $linkedinService Linkedin */ -$linkedinService = $serviceFactory->createService('linkedin', $credentials, $storage, array('r_basicprofile')); - -if (!empty($_GET['code'])) { - // retrieve the CSRF state parameter - $state = isset($_GET['state']) ? $_GET['state'] : null; - - // This was a callback request from linkedin, get the token - $token = $linkedinService->requestAccessToken($_GET['code'], $state); - - // Send a request with it. Please note that XML is the default format. - $result = json_decode($linkedinService->request('/people/~?format=json'), true); - - // Show some of the resultant data - echo 'Your linkedin first name is ' . $result['firstName'] . ' and your last name is ' . $result['lastName']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $linkedinService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Linkedin!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/mailchimp.php b/vendor/lusitanian/oauth/examples/mailchimp.php deleted file mode 100644 index dd7e12bd..00000000 --- a/vendor/lusitanian/oauth/examples/mailchimp.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Mailchimp service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Hannes Van De Vreken <vandevreken.hannes@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Mailchimp; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -$_SERVER['SERVER_PORT'] = 80; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['mailchimp']['key'], - $servicesCredentials['mailchimp']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Mailchimp service using the credentials, http client and storage mechanism for the token -/** @var $mailchimpService Mailchimp */ -$mailchimpService = $serviceFactory->createService('mailchimp', $credentials, $storage, array()); - -if (!empty($_GET['code'])) { - // This was a callback request from mailchimp, get the token - $token = $mailchimpService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = $mailchimpService->request('/users/profile.json'); - - header('Content-Type: application/json'); - echo $result; exit; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $mailchimpService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Mailchimp!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/microsoft.php b/vendor/lusitanian/oauth/examples/microsoft.php deleted file mode 100644 index 1edb13f1..00000000 --- a/vendor/lusitanian/oauth/examples/microsoft.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Microsoft service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Microsoft; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['microsoft']['key'], - $servicesCredentials['microsoft']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Microsoft service using the credentials, http client and storage mechanism for the token -/** @var $microsoft Microsoft */ -$microsoft = $serviceFactory->createService('microsoft', $credentials, $storage, array('basic')); - -if (!empty($_GET['code'])) { - // This was a callback request from Microsoft, get the token - $token = $microsoft->requestAccessToken($_GET['code']); - - var_dump($token); - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $microsoft->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Microsoft!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/paypal.php b/vendor/lusitanian/oauth/examples/paypal.php deleted file mode 100644 index 207357f2..00000000 --- a/vendor/lusitanian/oauth/examples/paypal.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the PayPal service - * - * PHP version 5.4 - * - * @author Flávio Heleno <flaviohbatista@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Paypal; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['paypal']['key'], - $servicesCredentials['paypal']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the PayPal service using the credentials, http client, storage mechanism for the token and profile/openid scopes -/** @var $paypalService PayPal */ -$paypalService = $serviceFactory->createService('paypal', $credentials, $storage, array('profile', 'openid')); - -if (!empty($_GET['code'])) { - // This was a callback request from PayPal, get the token - $token = $paypalService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($paypalService->request('/identity/openidconnect/userinfo/?schema=openid'), true); - - // Show some of the resultant data - echo 'Your unique PayPal user id is: ' . $result['user_id'] . ' and your name is ' . $result['name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $paypalService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with PayPal!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/pocket.php b/vendor/lusitanian/oauth/examples/pocket.php deleted file mode 100644 index b96d2ace..00000000 --- a/vendor/lusitanian/oauth/examples/pocket.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Pocket service. - * - * @author Christian Mayer <thefox21at@gmail.com> - * @copyright Copyright (c) 2014 Christian Mayer <thefox21at@gmail.com> - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Pocket; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; -use OAuth\Common\Http\Client\CurlClient; - -/** - * Bootstrap the example - */ -require_once __DIR__.'/bootstrap.php'; - -$step = isset($_GET['step']) ? (int)$_GET['step'] : null; -$code = isset($_GET['code']) ? $_GET['code'] : null; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['pocket']['key'], - null, // Pocket API doesn't have a secret key. :S - $currentUri->getAbsoluteUri().($code ? '?step=3&code='.$code : '') -); - -// Instantiate the Pocket service using the credentials, http client and storage mechanism for the token -$pocketService = $serviceFactory->createService('Pocket', $credentials, $storage); - -switch($step){ - default: - print '<a href="'.$currentUri->getRelativeUri().'?step=1">Login with Pocket</a>'; - - break; - - case 1: - $code = $pocketService->requestRequestToken(); - header('Location: '.$currentUri->getRelativeUri().'?step=2&code='.$code); - - break; - - case 2: - $url = $pocketService->getAuthorizationUri(array('request_token' => $code)); - header('Location: '.$url); - - break; - - case 3: - $token = $pocketService->requestAccessToken($code); - $accessToken = $token->getAccessToken(); - $extraParams = $token->getExtraParams(); - - print 'User: '.$extraParams['username'].'<br />'; - print 'Access Token: '.$accessToken; - break; -} diff --git a/vendor/lusitanian/oauth/examples/reddit.php b/vendor/lusitanian/oauth/examples/reddit.php deleted file mode 100644 index 7363d840..00000000 --- a/vendor/lusitanian/oauth/examples/reddit.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Reddit service - * - * PHP version 5.4 - * - * @author Connor Hindley <conn.hindley@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Reddit; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['reddit']['key'], - $servicesCredentials['reddit']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Reddit service using the credentials, http client and storage mechanism for the token -/** @var $reddit Reddit */ -$reddit = $serviceFactory->createService('Reddit', $credentials, $storage, array('identity')); - -if (!empty($_GET['code'])) { - // retrieve the CSRF state parameter - $state = isset($_GET['state']) ? $_GET['state'] : null; - - // This was a callback request from reddit, get the token - $reddit->requestAccessToken($_GET['code'], $state); - - $result = json_decode($reddit->request('api/v1/me.json'), true); - - echo 'Your unique reddit user id is: ' . $result['id'] . ' and your username is ' . $result['name']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $reddit->getAuthorizationUri(); - header('Location: ' . $url); - -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Reddit!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/runkeeper.php b/vendor/lusitanian/oauth/examples/runkeeper.php deleted file mode 100644 index 61a203f9..00000000 --- a/vendor/lusitanian/oauth/examples/runkeeper.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token from the RunKeeper service - * - * PHP version 5.4 - * - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\RunKeeper; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['runkeeper']['key'], - $servicesCredentials['runkeeper']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Runkeeper service using the credentials, http client and storage mechanism for the token -/** @var $runkeeperService RunKeeper */ -$runkeeperService = $serviceFactory->createService('RunKeeper', $credentials, $storage, array()); - -if (!empty($_GET['code'])) { - // This was a callback request from RunKeeper, get the token - $token = $runkeeperService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($runkeeperService->request('/user'), true); - - // Show some of the resultant data - echo 'Your unique RunKeeper user id is: ' . $result['userID']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $runkeeperService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with RunKeeper!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/scoopit.php b/vendor/lusitanian/oauth/examples/scoopit.php deleted file mode 100644 index cc1c103b..00000000 --- a/vendor/lusitanian/oauth/examples/scoopit.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -/** - * Example of making API calls for the ScoopIt service - * - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2013 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\ScoopIt; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__.'/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['scoopit']['key'], - $servicesCredentials['scoopit']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the ScoopIt service using the credentials, http client and storage mechanism for the token -$scoopItService = $serviceFactory->createService('ScoopIt', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('ScoopIt'); - - // This was a callback request from ScoopIt, get the token - $scoopItService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($scoopItService->request('profile')); - - echo 'result: <pre>' . print_r($result, true) . '</pre>'; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // extra request needed for oauth1 to request a request token :-) - $token = $scoopItService->requestRequestToken(); - - $url = $scoopItService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with ScoopIt!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/soundcloud.php b/vendor/lusitanian/oauth/examples/soundcloud.php deleted file mode 100644 index 2629490b..00000000 --- a/vendor/lusitanian/oauth/examples/soundcloud.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the SoundCloud service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\SoundCloud; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['soundcloud']['key'], - $servicesCredentials['soundcloud']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the SoundCloud service using the credentials, http client and storage mechanism for the token -/** @var $soundcloudService SoundCloud */ -$soundcloudService = $serviceFactory->createService('soundCloud', $credentials, $storage); - -if (!empty($_GET['code'])) { - // This was a callback request from SoundCloud, get the token - $soundcloudService->requestAccessToken($_GET['code']); - - // Send a request with it - $result = json_decode($soundcloudService->request('me.json'), true); - - // Show some of the resultant data - echo 'Your unique user id is: ' . $result['id'] . ' and your name is ' . $result['username']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $soundcloudService->getAuthorizationUri(); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with SoundCloud!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/tumblr.php b/vendor/lusitanian/oauth/examples/tumblr.php deleted file mode 100644 index bde0521b..00000000 --- a/vendor/lusitanian/oauth/examples/tumblr.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Tumblr service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\Tumblr; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// We need to use a persistent storage to save the token, because oauth1 requires the token secret received before' -// the redirect (request token request) in the access token request. -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['tumblr']['key'], - $servicesCredentials['tumblr']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the tumblr service using the credentials, http client and storage mechanism for the token -/** @var $tumblrService Tumblr */ -$tumblrService = $serviceFactory->createService('tumblr', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('Tumblr'); - - // This was a callback request from tumblr, get the token - $tumblrService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($tumblrService->request('user/info')); - - echo 'result: <pre>' . print_r($result, true) . '</pre>'; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // extra request needed for oauth1 to request a request token :-) - $token = $tumblrService->requestRequestToken(); - - $url = $tumblrService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Tumblr!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/twitter.php b/vendor/lusitanian/oauth/examples/twitter.php deleted file mode 100644 index 6b14a222..00000000 --- a/vendor/lusitanian/oauth/examples/twitter.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Twitter service - * - * PHP version 5.4 - * - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\Twitter; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// We need to use a persistent storage to save the token, because oauth1 requires the token secret received before' -// the redirect (request token request) in the access token request. -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['twitter']['key'], - $servicesCredentials['twitter']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the twitter service using the credentials, http client and storage mechanism for the token -/** @var $twitterService Twitter */ -$twitterService = $serviceFactory->createService('twitter', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('Twitter'); - - // This was a callback request from twitter, get the token - $twitterService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($twitterService->request('account/verify_credentials.json')); - - echo 'result: <pre>' . print_r($result, true) . '</pre>'; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // extra request needed for oauth1 to request a request token :-) - $token = $twitterService->requestRequestToken(); - - $url = $twitterService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Twitter!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/ustream.php b/vendor/lusitanian/oauth/examples/ustream.php deleted file mode 100644 index e3ca0bb4..00000000 --- a/vendor/lusitanian/oauth/examples/ustream.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -/** - * Example of retrieving an authentication token of the Ustream service - * - * PHP version 5.4 - * - * @author Attila Gonda <pcdevil7@gmail.com> - * @copyright Copyright (c) 2014 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth2\Service\Ustream; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__ . '/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['ustream']['key'], - $servicesCredentials['ustream']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Ustream service using the credentials, http client and storage mechanism for the token -/** @var $ustream Ustream */ -$ustream = $serviceFactory->createService('Ustream', $credentials, $storage, array('identity')); - -if (!empty($_GET['code'])) { - // retrieve the CSRF state parameter - $state = isset($_GET['state']) ? $_GET['state'] : null; - - // This was a callback request from Ustream, get the token - $ustream->requestAccessToken($_GET['code'], $state); - - $result = json_decode($ustream->request('users/self.json'), true); - - echo 'Your unique Ustream user id is: ' . $result['id'] . ' and your username is ' . $result['username']; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - $url = $ustream->getAuthorizationUri(); - header('Location: ' . $url); - -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Ustream!</a>"; -} diff --git a/vendor/lusitanian/oauth/examples/yahoo.php b/vendor/lusitanian/oauth/examples/yahoo.php deleted file mode 100644 index 549332e9..00000000 --- a/vendor/lusitanian/oauth/examples/yahoo.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -/** - * Example of making API calls for the Yahoo service - * - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2014 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -use OAuth\OAuth1\Service\Yahoo; -use OAuth\Common\Storage\Session; -use OAuth\Common\Consumer\Credentials; - -/** - * Bootstrap the example - */ -require_once __DIR__.'/bootstrap.php'; - -// Session storage -$storage = new Session(); - -// Setup the credentials for the requests -$credentials = new Credentials( - $servicesCredentials['yahoo']['key'], - $servicesCredentials['yahoo']['secret'], - $currentUri->getAbsoluteUri() -); - -// Instantiate the Yahoo service using the credentials, http client and storage mechanism for the token -$yahooService = $serviceFactory->createService('Yahoo', $credentials, $storage); - -if (!empty($_GET['oauth_token'])) { - $token = $storage->retrieveAccessToken('Yahoo'); - - // This was a callback request from Yahoo, get the token - $yahooService->requestAccessToken( - $_GET['oauth_token'], - $_GET['oauth_verifier'], - $token->getRequestTokenSecret() - ); - - // Send a request now that we have access token - $result = json_decode($yahooService->request('profile')); - - echo 'result: <pre>' . print_r($result, true) . '</pre>'; - -} elseif (!empty($_GET['go']) && $_GET['go'] === 'go') { - // extra request needed for oauth1 to request a request token :-) - $token = $yahooService->requestRequestToken(); - - $url = $yahooService->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); - header('Location: ' . $url); -} else { - $url = $currentUri->getRelativeUri() . '?go=go'; - echo "<a href='$url'>Login with Yahoo!</a>"; -} diff --git a/vendor/lusitanian/oauth/phpunit.xml.dist b/vendor/lusitanian/oauth/phpunit.xml.dist deleted file mode 100644 index ee281953..00000000 --- a/vendor/lusitanian/oauth/phpunit.xml.dist +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<phpunit backupGlobals="true" - backupStaticAttributes="false" - bootstrap="tests/bootstrap.php" - colors="false" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - forceCoversAnnotation="false" - mapTestClassNameToCoveredClassName="false" - processIsolation="false" - stopOnError="false" - stopOnFailure="false" - stopOnIncomplete="false" - stopOnSkipped="false" - testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader" - strict="false" - verbose="false"> - <testsuites> - <testsuite name="Unit"> - <directory>tests/Unit</directory> - </testsuite> - </testsuites> - <filter> - <whitelist> - <directory suffix=".php">src/</directory> - <exclude> - <file>src/OAuth/bootstrap.php</file> - <file>src/OAuth/Common/Exception/Exception.php</file> - <file>src/OAuth/Common/Http/Exception/TokenResponseException.php</file> - <file>src/OAuth/Common/Storage/Exception/StorageException.php</file> - <file>src/OAuth/Common/Storage/Exception/TokenNotFoundException.php</file> - <file>src/OAuth/Common/Token/Exception/ExpiredTokenException.php</file> - <file>src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php</file> - <file>src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php</file> - <file>src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php</file> - <file>src/OAuth/OAuth2/Token/StdOAuth2Token.php</file> - </exclude> - </whitelist> - </filter> - <php> - <env name="redis_host" value="127.0.0.1"/> - <env name="redis_port" value="6379"/> - </php> -</phpunit> diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php b/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php deleted file mode 100644 index 9fe7951c..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -namespace OAuth\Common; - -/** - * PSR-0 Autoloader - * - * @author ieter Hordijk <info@pieterhordijk.com> - */ -class AutoLoader -{ - /** - * @var string The namespace prefix for this instance. - */ - protected $namespace = ''; - - /** - * @var string The filesystem prefix to use for this instance - */ - protected $path = ''; - - /** - * Build the instance of the autoloader - * - * @param string $namespace The prefixed namespace this instance will load - * @param string $path The filesystem path to the root of the namespace - */ - public function __construct($namespace, $path) - { - $this->namespace = ltrim($namespace, '\\'); - $this->path = rtrim($path, '/\\') . DIRECTORY_SEPARATOR; - } - - /** - * Try to load a class - * - * @param string $class The class name to load - * - * @return boolean If the loading was successful - */ - public function load($class) - { - $class = ltrim($class, '\\'); - - if (strpos($class, $this->namespace) === 0) { - $nsparts = explode('\\', $class); - $class = array_pop($nsparts); - $nsparts[] = ''; - $path = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts); - $path .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; - - if (file_exists($path)) { - require $path; - - return true; - } - } - - return false; - } - - /** - * Register the autoloader to PHP - * - * @return boolean The status of the registration - */ - public function register() - { - return spl_autoload_register(array($this, 'load')); - } - - /** - * Unregister the autoloader to PHP - * - * @return boolean The status of the unregistration - */ - public function unregister() - { - return spl_autoload_unregister(array($this, 'load')); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php b/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php deleted file mode 100644 index 8e98e9fa..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -namespace OAuth\Common\Consumer; - -/** - * Value object for the credentials of an OAuth service. - */ -class Credentials implements CredentialsInterface -{ - /** - * @var string - */ - protected $consumerId; - - /** - * @var string - */ - protected $consumerSecret; - - /** - * @var string - */ - protected $callbackUrl; - - /** - * @param string $consumerId - * @param string $consumerSecret - * @param string $callbackUrl - */ - public function __construct($consumerId, $consumerSecret, $callbackUrl) - { - $this->consumerId = $consumerId; - $this->consumerSecret = $consumerSecret; - $this->callbackUrl = $callbackUrl; - } - - /** - * @return string - */ - public function getCallbackUrl() - { - return $this->callbackUrl; - } - - /** - * @return string - */ - public function getConsumerId() - { - return $this->consumerId; - } - - /** - * @return string - */ - public function getConsumerSecret() - { - return $this->consumerSecret; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php deleted file mode 100644 index a33e54e9..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -namespace OAuth\Common\Consumer; - -/** - * Credentials Interface, credentials should implement this. - */ -interface CredentialsInterface -{ - /** - * @return string - */ - public function getCallbackUrl(); - - /** - * @return string - */ - public function getConsumerId(); - - /** - * @return string - */ - public function getConsumerSecret(); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Exception/Exception.php b/vendor/lusitanian/oauth/src/OAuth/Common/Exception/Exception.php deleted file mode 100644 index 2e399217..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Exception/Exception.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace OAuth\Common\Exception; - -/** - * Generic library-level exception. - */ -class Exception extends \Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/AbstractClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/AbstractClient.php deleted file mode 100644 index 94000b18..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/AbstractClient.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Client; - -/** - * Abstract HTTP client - */ -abstract class AbstractClient implements ClientInterface -{ - /** - * @var string The user agent string passed to services - */ - protected $userAgent; - - /** - * @var int The maximum number of redirects - */ - protected $maxRedirects = 5; - - /** - * @var int The maximum timeout - */ - protected $timeout = 15; - - /** - * Creates instance - * - * @param string $userAgent The UA string the client will use - */ - public function __construct($userAgent = 'PHPoAuthLib') - { - $this->userAgent = $userAgent; - } - - /** - * @param int $redirects Maximum redirects for client - * - * @return ClientInterface - */ - public function setMaxRedirects($redirects) - { - $this->maxRedirects = $redirects; - - return $this; - } - - /** - * @param int $timeout Request timeout time for client in seconds - * - * @return ClientInterface - */ - public function setTimeout($timeout) - { - $this->timeout = $timeout; - - return $this; - } - - /** - * @param array $headers - */ - public function normalizeHeaders(&$headers) - { - // Normalize headers - array_walk( - $headers, - function (&$val, &$key) { - $key = ucfirst(strtolower($key)); - $val = ucfirst(strtolower($key)) . ': ' . $val; - } - ); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php deleted file mode 100644 index f9c20226..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Client; - -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Http\Exception\TokenResponseException; - -/** - * Any HTTP clients to be used with the library should implement this interface. - */ -interface ClientInterface -{ - /** - * Any implementing HTTP providers should send a request to the provided endpoint with the parameters. - * They should return, in string form, the response body and throw an exception on error. - * - * @param UriInterface $endpoint - * @param mixed $requestBody - * @param array $extraHeaders - * @param string $method - * - * @return string - * - * @throws TokenResponseException - */ - public function retrieveResponse( - UriInterface $endpoint, - $requestBody, - array $extraHeaders = array(), - $method = 'POST' - ); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/CurlClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/CurlClient.php deleted file mode 100644 index eae1be3e..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/CurlClient.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Client; - -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Client implementation for cURL - */ -class CurlClient extends AbstractClient -{ - /** - * If true, explicitly sets cURL to use SSL version 3. Use this if cURL - * compiles with GnuTLS SSL. - * - * @var bool - */ - private $forceSSL3 = false; - - /** - * Additional parameters (as `key => value` pairs) to be passed to `curl_setopt` - * - * @var array - */ - private $parameters = array(); - - /** - * Additional `curl_setopt` parameters - * - * @param array $parameters - */ - public function setCurlParameters(array $parameters) - { - $this->parameters = $parameters; - } - - /** - * @param bool $force - * - * @return CurlClient - */ - public function setForceSSL3($force) - { - $this->forceSSL3 = $force; - - return $this; - } - - /** - * Any implementing HTTP providers should send a request to the provided endpoint with the parameters. - * They should return, in string form, the response body and throw an exception on error. - * - * @param UriInterface $endpoint - * @param mixed $requestBody - * @param array $extraHeaders - * @param string $method - * - * @return string - * - * @throws TokenResponseException - * @throws \InvalidArgumentException - */ - public function retrieveResponse( - UriInterface $endpoint, - $requestBody, - array $extraHeaders = array(), - $method = 'POST' - ) { - // Normalize method name - $method = strtoupper($method); - - $this->normalizeHeaders($extraHeaders); - - if ($method === 'GET' && !empty($requestBody)) { - throw new \InvalidArgumentException('No body expected for "GET" request.'); - } - - if (!isset($extraHeaders['Content-Type']) && $method === 'POST' && is_array($requestBody)) { - $extraHeaders['Content-Type'] = 'Content-Type: application/x-www-form-urlencoded'; - } - - $extraHeaders['Host'] = 'Host: '.$endpoint->getHost(); - $extraHeaders['Connection'] = 'Connection: close'; - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $endpoint->getAbsoluteUri()); - - if ($method === 'POST' || $method === 'PUT') { - if ($requestBody && is_array($requestBody)) { - $requestBody = http_build_query($requestBody, '', '&'); - } - - if ($method === 'PUT') { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); - } else { - curl_setopt($ch, CURLOPT_POST, true); - } - - curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); - } else { - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); - } - - if ($this->maxRedirects > 0) { - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_MAXREDIRS, $this->maxRedirects); - } - - curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, false); - curl_setopt($ch, CURLOPT_HTTPHEADER, $extraHeaders); - curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); - - foreach ($this->parameters as $key => $value) { - curl_setopt($ch, $key, $value); - } - - if ($this->forceSSL3) { - curl_setopt($ch, CURLOPT_SSLVERSION, 3); - } - - $response = curl_exec($ch); - $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - if (false === $response) { - $errNo = curl_errno($ch); - $errStr = curl_error($ch); - curl_close($ch); - if (empty($errStr)) { - throw new TokenResponseException('Failed to request resource.', $responseCode); - } - throw new TokenResponseException('cURL Error # '.$errNo.': '.$errStr, $responseCode); - } - - curl_close($ch); - - return $response; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php deleted file mode 100644 index 7f3c5249..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Client; - -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Client implementation for streams/file_get_contents - */ -class StreamClient extends AbstractClient -{ - /** - * Any implementing HTTP providers should send a request to the provided endpoint with the parameters. - * They should return, in string form, the response body and throw an exception on error. - * - * @param UriInterface $endpoint - * @param mixed $requestBody - * @param array $extraHeaders - * @param string $method - * - * @return string - * - * @throws TokenResponseException - * @throws \InvalidArgumentException - */ - public function retrieveResponse( - UriInterface $endpoint, - $requestBody, - array $extraHeaders = array(), - $method = 'POST' - ) { - // Normalize method name - $method = strtoupper($method); - - $this->normalizeHeaders($extraHeaders); - - if ($method === 'GET' && !empty($requestBody)) { - throw new \InvalidArgumentException('No body expected for "GET" request.'); - } - - if (!isset($extraHeaders['Content-Type']) && $method === 'POST' && is_array($requestBody)) { - $extraHeaders['Content-Type'] = 'Content-Type: application/x-www-form-urlencoded'; - } - - $host = 'Host: '.$endpoint->getHost(); - // Append port to Host if it has been specified - if ($endpoint->hasExplicitPortSpecified()) { - $host .= ':'.$endpoint->getPort(); - } - - $extraHeaders['Host'] = $host; - $extraHeaders['Connection'] = 'Connection: close'; - - if (is_array($requestBody)) { - $requestBody = http_build_query($requestBody, '', '&'); - } - $extraHeaders['Content-length'] = 'Content-length: '.strlen($requestBody); - - $context = $this->generateStreamContext($requestBody, $extraHeaders, $method); - - $level = error_reporting(0); - $response = file_get_contents($endpoint->getAbsoluteUri(), false, $context); - error_reporting($level); - if (false === $response) { - $lastError = error_get_last(); - if (is_null($lastError)) { - throw new TokenResponseException('Failed to request resource.'); - } - throw new TokenResponseException($lastError['message']); - } - - return $response; - } - - private function generateStreamContext($body, $headers, $method) - { - return stream_context_create( - array( - 'http' => array( - 'method' => $method, - 'header' => implode("\r\n", array_values($headers)), - 'content' => $body, - 'protocol_version' => '1.1', - 'user_agent' => $this->userAgent, - 'max_redirects' => $this->maxRedirects, - 'timeout' => $this->timeout - ), - ) - ); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php deleted file mode 100644 index c519a223..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception relating to token response from service. - */ -class TokenResponseException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/Uri.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/Uri.php deleted file mode 100644 index c5114937..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/Uri.php +++ /dev/null @@ -1,408 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Uri; - -use InvalidArgumentException; - -/** - * Standards-compliant URI class. - */ -class Uri implements UriInterface -{ - /** - * @var string - */ - private $scheme = 'http'; - - /** - * @var string - */ - private $userInfo = ''; - - /** - * @var string - */ - private $rawUserInfo = ''; - - /** - * @var string - */ - private $host; - - /** - * @var int - */ - private $port = 80; - - /** - * @var string - */ - private $path = '/'; - - /** - * @var string - */ - private $query = ''; - - /** - * @var string - */ - private $fragment = ''; - - /** - * @var bool - */ - private $explicitPortSpecified = false; - - /** - * @var bool - */ - private $explicitTrailingHostSlash = false; - - /** - * @param string $uri - */ - public function __construct($uri = null) - { - if (null !== $uri) { - $this->parseUri($uri); - } - } - - /** - * @param string $uri - * - * @throws \InvalidArgumentException - */ - protected function parseUri($uri) - { - if (false === ($uriParts = parse_url($uri))) { - // congratulations if you've managed to get parse_url to fail, - // it seems to always return some semblance of a parsed url no matter what - throw new InvalidArgumentException("Invalid URI: $uri"); - } - - if (!isset($uriParts['scheme'])) { - throw new InvalidArgumentException('Invalid URI: http|https scheme required'); - } - - $this->scheme = $uriParts['scheme']; - $this->host = $uriParts['host']; - - if (isset($uriParts['port'])) { - $this->port = $uriParts['port']; - $this->explicitPortSpecified = true; - } else { - $this->port = strcmp('https', $uriParts['scheme']) ? 80 : 443; - $this->explicitPortSpecified = false; - } - - if (isset($uriParts['path'])) { - $this->path = $uriParts['path']; - if ('/' === $uriParts['path']) { - $this->explicitTrailingHostSlash = true; - } - } else { - $this->path = '/'; - } - - $this->query = isset($uriParts['query']) ? $uriParts['query'] : ''; - $this->fragment = isset($uriParts['fragment']) ? $uriParts['fragment'] : ''; - - $userInfo = ''; - if (!empty($uriParts['user'])) { - $userInfo .= $uriParts['user']; - } - if ($userInfo && !empty($uriParts['pass'])) { - $userInfo .= ':' . $uriParts['pass']; - } - - $this->setUserInfo($userInfo); - } - - /** - * @param string $rawUserInfo - * - * @return string - */ - protected function protectUserInfo($rawUserInfo) - { - $colonPos = strpos($rawUserInfo, ':'); - - // rfc3986-3.2.1 | http://tools.ietf.org/html/rfc3986#section-3.2 - // "Applications should not render as clear text any data - // after the first colon (":") character found within a userinfo - // subcomponent unless the data after the colon is the empty string - // (indicating no password)" - if ($colonPos !== false && strlen($rawUserInfo)-1 > $colonPos) { - return substr($rawUserInfo, 0, $colonPos) . ':********'; - } else { - return $rawUserInfo; - } - } - - /** - * @return string - */ - public function getScheme() - { - return $this->scheme; - } - - /** - * @return string - */ - public function getUserInfo() - { - return $this->userInfo; - } - - /** - * @return string - */ - public function getRawUserInfo() - { - return $this->rawUserInfo; - } - - /** - * @return string - */ - public function getHost() - { - return $this->host; - } - - /** - * @return int - */ - public function getPort() - { - return $this->port; - } - - /** - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * @return string - */ - public function getQuery() - { - return $this->query; - } - - /** - * @return string - */ - public function getFragment() - { - return $this->fragment; - } - - /** - * Uses protected user info by default as per rfc3986-3.2.1 - * Uri::getRawAuthority() is available if plain-text password information is desirable. - * - * @return string - */ - public function getAuthority() - { - $authority = $this->userInfo ? $this->userInfo.'@' : ''; - $authority .= $this->host; - - if ($this->explicitPortSpecified) { - $authority .= ":{$this->port}"; - } - - return $authority; - } - - /** - * @return string - */ - public function getRawAuthority() - { - $authority = $this->rawUserInfo ? $this->rawUserInfo.'@' : ''; - $authority .= $this->host; - - if ($this->explicitPortSpecified) { - $authority .= ":{$this->port}"; - } - - return $authority; - } - - /** - * @return string - */ - public function getAbsoluteUri() - { - $uri = $this->scheme . '://' . $this->getRawAuthority(); - - if ('/' === $this->path) { - $uri .= $this->explicitTrailingHostSlash ? '/' : ''; - } else { - $uri .= $this->path; - } - - if (!empty($this->query)) { - $uri .= "?{$this->query}"; - } - - if (!empty($this->fragment)) { - $uri .= "#{$this->fragment}"; - } - - return $uri; - } - - /** - * @return string - */ - public function getRelativeUri() - { - $uri = ''; - - if ('/' === $this->path) { - $uri .= $this->explicitTrailingHostSlash ? '/' : ''; - } else { - $uri .= $this->path; - } - - return $uri; - } - - /** - * Uses protected user info by default as per rfc3986-3.2.1 - * Uri::getAbsoluteUri() is available if plain-text password information is desirable. - * - * @return string - */ - public function __toString() - { - $uri = $this->scheme . '://' . $this->getAuthority(); - - if ('/' === $this->path) { - $uri .= $this->explicitTrailingHostSlash ? '/' : ''; - } else { - $uri .= $this->path; - } - - if (!empty($this->query)) { - $uri .= "?{$this->query}"; - } - - if (!empty($this->fragment)) { - $uri .= "#{$this->fragment}"; - } - - return $uri; - } - - /** - * @param $path - */ - public function setPath($path) - { - if (empty($path)) { - $this->path = '/'; - $this->explicitTrailingHostSlash = false; - } else { - $this->path = $path; - if ('/' === $this->path) { - $this->explicitTrailingHostSlash = true; - } - } - } - - /** - * @param string $query - */ - public function setQuery($query) - { - $this->query = $query; - } - - /** - * @param string $var - * @param string $val - */ - public function addToQuery($var, $val) - { - if (strlen($this->query) > 0) { - $this->query .= '&'; - } - $this->query .= http_build_query(array($var => $val), '', '&'); - } - - /** - * @param string $fragment - */ - public function setFragment($fragment) - { - $this->fragment = $fragment; - } - - /** - * @param string $scheme - */ - public function setScheme($scheme) - { - $this->scheme = $scheme; - } - - - /** - * @param string $userInfo - */ - public function setUserInfo($userInfo) - { - $this->userInfo = $userInfo ? $this->protectUserInfo($userInfo) : ''; - $this->rawUserInfo = $userInfo; - } - - - /** - * @param int $port - */ - public function setPort($port) - { - $this->port = intval($port); - - if (('https' === $this->scheme && $this->port === 443) || ('http' === $this->scheme && $this->port === 80)) { - $this->explicitPortSpecified = false; - } else { - $this->explicitPortSpecified = true; - } - } - - /** - * @param string $host - */ - public function setHost($host) - { - $this->host = $host; - } - - /** - * @return bool - */ - public function hasExplicitTrailingHostSlash() - { - return $this->explicitTrailingHostSlash; - } - - /** - * @return bool - */ - public function hasExplicitPortSpecified() - { - return $this->explicitPortSpecified; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php deleted file mode 100644 index 127aa203..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php +++ /dev/null @@ -1,168 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Uri; - -use RuntimeException; - -/** - * Factory class for uniform resource indicators - */ -class UriFactory implements UriFactoryInterface -{ - /** - * Factory method to build a URI from a super-global $_SERVER array. - * - * @param array $_server - * - * @return UriInterface - */ - public function createFromSuperGlobalArray(array $_server) - { - if ($uri = $this->attemptProxyStyleParse($_server)) { - return $uri; - } - - $scheme = $this->detectScheme($_server); - $host = $this->detectHost($_server); - $port = $this->detectPort($_server); - $path = $this->detectPath($_server); - $query = $this->detectQuery($_server); - - return $this->createFromParts($scheme, '', $host, $port, $path, $query); - } - - /** - * @param string $absoluteUri - * - * @return UriInterface - */ - public function createFromAbsolute($absoluteUri) - { - return new Uri($absoluteUri); - } - - /** - * Factory method to build a URI from parts - * - * @param string $scheme - * @param string $userInfo - * @param string $host - * @param string $port - * @param string $path - * @param string $query - * @param string $fragment - * - * @return UriInterface - */ - public function createFromParts($scheme, $userInfo, $host, $port, $path = '', $query = '', $fragment = '') - { - $uri = new Uri(); - $uri->setScheme($scheme); - $uri->setUserInfo($userInfo); - $uri->setHost($host); - $uri->setPort($port); - $uri->setPath($path); - $uri->setQuery($query); - $uri->setFragment($fragment); - - return $uri; - } - - /** - * @param array $_server - * - * @return UriInterface|null - */ - private function attemptProxyStyleParse($_server) - { - // If the raw HTTP request message arrives with a proxy-style absolute URI in the - // initial request line, the absolute URI is stored in $_SERVER['REQUEST_URI'] and - // we only need to parse that. - if (isset($_server['REQUEST_URI']) && parse_url($_server['REQUEST_URI'], PHP_URL_SCHEME)) { - return new Uri($_server['REQUEST_URI']); - } - - return null; - } - - /** - * @param array $_server - * - * @return string - * - * @throws RuntimeException - */ - private function detectPath($_server) - { - if (isset($_server['REQUEST_URI'])) { - $uri = $_server['REQUEST_URI']; - } elseif (isset($_server['REDIRECT_URL'])) { - $uri = $_server['REDIRECT_URL']; - } else { - throw new RuntimeException('Could not detect URI path from superglobal'); - } - - $queryStr = strpos($uri, '?'); - if ($queryStr !== false) { - $uri = substr($uri, 0, $queryStr); - } - - return $uri; - } - - /** - * @param array $_server - * - * @return string - */ - private function detectHost(array $_server) - { - $host = isset($_server['HTTP_HOST']) ? $_server['HTTP_HOST'] : ''; - - if (strstr($host, ':')) { - $host = parse_url($host, PHP_URL_HOST); - } - - return $host; - } - - /** - * @param array $_server - * - * @return string - */ - private function detectPort(array $_server) - { - return isset($_server['SERVER_PORT']) ? $_server['SERVER_PORT'] : 80; - } - - /** - * @param array $_server - * - * @return string - */ - private function detectQuery(array $_server) - { - return isset($_server['QUERY_STRING']) ? $_server['QUERY_STRING'] : ''; - } - - /** - * Determine URI scheme component from superglobal array - * - * When using ISAPI with IIS, the value will be "off" if the request was - * not made through the HTTPS protocol. As a result, we filter the - * value to a bool. - * - * @param array $_server A super-global $_SERVER array - * - * @return string Returns http or https depending on the URI scheme - */ - private function detectScheme(array $_server) - { - if (isset($_server['HTTPS']) && filter_var($_server['HTTPS'], FILTER_VALIDATE_BOOLEAN)) { - return 'https'; - } else { - return 'http'; - } - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php deleted file mode 100644 index 2b157d84..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Uri; - -/** - * Factory interface for uniform resource indicators - */ -interface UriFactoryInterface -{ - /** - * Factory method to build a URI from a super-global $_SERVER array. - * - * @param array $_server - * - * @return UriInterface - */ - public function createFromSuperGlobalArray(array $_server); - - /** - * Creates a URI from an absolute URI - * - * @param string $absoluteUri - * - * @return UriInterface - */ - public function createFromAbsolute($absoluteUri); - - /** - * Factory method to build a URI from parts - * - * @param string $scheme - * @param string $userInfo - * @param string $host - * @param string $port - * @param string $path - * @param string $query - * @param string $fragment - * - * @return UriInterface - */ - public function createFromParts($scheme, $userInfo, $host, $port, $path = '', $query = '', $fragment = ''); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriInterface.php deleted file mode 100644 index 008d4647..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriInterface.php +++ /dev/null @@ -1,133 +0,0 @@ -<?php - -namespace OAuth\Common\Http\Uri; - -interface UriInterface -{ - /** - * @return string - */ - public function getScheme(); - - /** - * @param string $scheme - */ - public function setScheme($scheme); - - /** - * @return string - */ - public function getHost(); - - /** - * @param string $host - */ - public function setHost($host); - - /** - * @return int - */ - public function getPort(); - - /** - * @param int $port - */ - public function setPort($port); - - /** - * @return string - */ - public function getPath(); - - /** - * @param string $path - */ - public function setPath($path); - - /** - * @return string - */ - public function getQuery(); - - /** - * @param string $query - */ - public function setQuery($query); - - /** - * Adds a param to the query string. - * - * @param string $var - * @param string $val - */ - public function addToQuery($var, $val); - - /** - * @return string - */ - public function getFragment(); - - /** - * Should return URI user info, masking protected user info data according to rfc3986-3.2.1 - * - * @return string - */ - public function getUserInfo(); - - /** - * @param string $userInfo - */ - public function setUserInfo($userInfo); - - /** - * Should return the URI Authority, masking protected user info data according to rfc3986-3.2.1 - * - * @return string - */ - public function getAuthority(); - - /** - * Should return the URI string, masking protected user info data according to rfc3986-3.2.1 - * - * @return string the URI string with user protected info masked - */ - public function __toString(); - - /** - * Should return the URI Authority without masking protected user info data - * - * @return string - */ - public function getRawAuthority(); - - /** - * Should return the URI user info without masking protected user info data - * - * @return string - */ - public function getRawUserInfo(); - - /** - * Build the full URI based on all the properties - * - * @return string The full URI without masking user info - */ - public function getAbsoluteUri(); - - /** - * Build the relative URI based on all the properties - * - * @return string The relative URI - */ - public function getRelativeUri(); - - /** - * @return bool - */ - public function hasExplicitTrailingHostSlash(); - - /** - * @return bool - */ - public function hasExplicitPortSpecified(); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/Common/Service/AbstractService.php deleted file mode 100644 index 0bf572b4..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Service/AbstractService.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -namespace OAuth\Common\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Exception\Exception; -use OAuth\Common\Storage\TokenStorageInterface; - -/** - * Abstract OAuth service, version-agnostic - */ -abstract class AbstractService implements ServiceInterface -{ - /** @var Credentials */ - protected $credentials; - - /** @var ClientInterface */ - protected $httpClient; - - /** @var TokenStorageInterface */ - protected $storage; - - /** - * @param CredentialsInterface $credentials - * @param ClientInterface $httpClient - * @param TokenStorageInterface $storage - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage - ) { - $this->credentials = $credentials; - $this->httpClient = $httpClient; - $this->storage = $storage; - } - - /** - * @param UriInterface|string $path - * @param UriInterface $baseApiUri - * - * @return UriInterface - * - * @throws Exception - */ - protected function determineRequestUriFromPath($path, UriInterface $baseApiUri = null) - { - if ($path instanceof UriInterface) { - $uri = $path; - } elseif (stripos($path, 'http://') === 0 || stripos($path, 'https://') === 0) { - $uri = new Uri($path); - } else { - if (null === $baseApiUri) { - throw new Exception( - 'An absolute URI must be passed to ServiceInterface::request as no baseApiUri is set.' - ); - } - - $uri = clone $baseApiUri; - if (false !== strpos($path, '?')) { - $parts = explode('?', $path, 2); - $path = $parts[0]; - $query = $parts[1]; - $uri->setQuery($query); - } - - if ($path[0] === '/') { - $path = substr($path, 1); - } - - $uri->setPath($uri->getPath() . $path); - } - - return $uri; - } - - /** - * Accessor to the storage adapter to be able to retrieve tokens - * - * @return TokenStorageInterface - */ - public function getStorage() - { - return $this->storage; - } - - /** - * @return string - */ - public function service() - { - // get class name without backslashes - $classname = get_class($this); - - return preg_replace('/^.*\\\\/', '', $classname); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php deleted file mode 100644 index 5856a039..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php - -namespace OAuth\Common\Service; - -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Defines methods common among all OAuth services. - */ -interface ServiceInterface -{ - /** - * Sends an authenticated API request to the path provided. - * If the path provided is not an absolute URI, the base API Uri (service-specific) will be used. - * - * @param string|UriInterface $path - * @param string $method HTTP method - * @param array $body Request body if applicable (an associative array will - * automatically be converted into a urlencoded body) - * @param array $extraHeaders Extra headers if applicable. These will override service-specific - * any defaults. - * - * @return string - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()); - - /** - * Returns the url to redirect to for authorization purposes. - * - * @param array $additionalParameters - * - * @return UriInterface - */ - public function getAuthorizationUri(array $additionalParameters = array()); - - /** - * Returns the authorization API endpoint. - * - * @return UriInterface - */ - public function getAuthorizationEndpoint(); - - /** - * Returns the access token API endpoint. - * - * @return UriInterface - */ - public function getAccessTokenEndpoint(); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php deleted file mode 100644 index b3daeabb..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace OAuth\Common\Storage\Exception; - -/** - * Exception thrown when a state is not found in storage. - */ -class AuthorizationStateNotFoundException extends StorageException -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/StorageException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/StorageException.php deleted file mode 100644 index 4378ee8f..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/StorageException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace OAuth\Common\Storage\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Generic storage exception. - */ -class StorageException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php deleted file mode 100644 index 06222508..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace OAuth\Common\Storage\Exception; - -/** - * Exception thrown when a token is not found in storage. - */ -class TokenNotFoundException extends StorageException -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Memory.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Memory.php deleted file mode 100644 index d42c2251..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Memory.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php - -namespace OAuth\Common\Storage; - -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; -use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException; - -/* - * Stores a token in-memory only (destroyed at end of script execution). - */ -class Memory implements TokenStorageInterface -{ - /** - * @var object|TokenInterface - */ - protected $tokens; - - /** - * @var array - */ - protected $states; - - public function __construct() - { - $this->tokens = array(); - $this->states = array(); - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if ($this->hasAccessToken($service)) { - return $this->tokens[$service]; - } - - throw new TokenNotFoundException('Token not stored'); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - $this->tokens[$service] = $token; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - return isset($this->tokens[$service]) && $this->tokens[$service] instanceof TokenInterface; - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - if (array_key_exists($service, $this->tokens)) { - unset($this->tokens[$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - $this->tokens = array(); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if ($this->hasAuthorizationState($service)) { - return $this->states[$service]; - } - - throw new AuthorizationStateNotFoundException('State not stored'); - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - $this->states[$service] = $state; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - return isset($this->states[$service]) && null !== $this->states[$service]; - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - if (array_key_exists($service, $this->states)) { - unset($this->states[$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - $this->states = array(); - - // allow chaining - return $this; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php deleted file mode 100644 index 77318bd6..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php - -namespace OAuth\Common\Storage; - -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; -use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException; -use Predis\Client as Predis; - -/* - * Stores a token in a Redis server. Requires the Predis library available at https://github.com/nrk/predis - */ -class Redis implements TokenStorageInterface -{ - /** - * @var string - */ - protected $key; - - protected $stateKey; - - /** - * @var object|\Redis - */ - protected $redis; - - /** - * @var object|TokenInterface - */ - protected $cachedTokens; - - /** - * @var object - */ - protected $cachedStates; - - /** - * @param Predis $redis An instantiated and connected redis client - * @param string $key The key to store the token under in redis - * @param string $stateKey The key to store the state under in redis. - */ - public function __construct(Predis $redis, $key, $stateKey) - { - $this->redis = $redis; - $this->key = $key; - $this->stateKey = $stateKey; - $this->cachedTokens = array(); - $this->cachedStates = array(); - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if (!$this->hasAccessToken($service)) { - throw new TokenNotFoundException('Token not found in redis'); - } - - if (isset($this->cachedTokens[$service])) { - return $this->cachedTokens[$service]; - } - - $val = $this->redis->hget($this->key, $service); - - return $this->cachedTokens[$service] = unserialize($val); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - // (over)write the token - $this->redis->hset($this->key, $service, serialize($token)); - $this->cachedTokens[$service] = $token; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - if (isset($this->cachedTokens[$service]) - && $this->cachedTokens[$service] instanceof TokenInterface - ) { - return true; - } - - return $this->redis->hexists($this->key, $service); - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - $this->redis->hdel($this->key, $service); - unset($this->cachedTokens[$service]); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - // memory - $this->cachedTokens = array(); - - // redis - $keys = $this->redis->hkeys($this->key); - $me = $this; // 5.3 compat - - // pipeline for performance - $this->redis->pipeline( - function ($pipe) use ($keys, $me) { - foreach ($keys as $k) { - $pipe->hdel($me->getKey(), $k); - } - } - ); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if (!$this->hasAuthorizationState($service)) { - throw new AuthorizationStateNotFoundException('State not found in redis'); - } - - if (isset($this->cachedStates[$service])) { - return $this->cachedStates[$service]; - } - - $val = $this->redis->hget($this->stateKey, $service); - - return $this->cachedStates[$service] = unserialize($val); - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - // (over)write the token - $this->redis->hset($this->stateKey, $service, $state); - $this->cachedStates[$service] = $state; - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - if (isset($this->cachedStates[$service]) - && null !== $this->cachedStates[$service] - ) { - return true; - } - - return $this->redis->hexists($this->stateKey, $service); - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - $this->redis->hdel($this->stateKey, $service); - unset($this->cachedStates[$service]); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - // memory - $this->cachedStates = array(); - - // redis - $keys = $this->redis->hkeys($this->stateKey); - $me = $this; // 5.3 compat - - // pipeline for performance - $this->redis->pipeline( - function ($pipe) use ($keys, $me) { - foreach ($keys as $k) { - $pipe->hdel($me->getKey(), $k); - } - } - ); - - // allow chaining - return $this; - } - - /** - * @return Predis $redis - */ - public function getRedis() - { - return $this->redis; - } - - /** - * @return string $key - */ - public function getKey() - { - return $this->key; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php deleted file mode 100644 index e908a67e..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php +++ /dev/null @@ -1,188 +0,0 @@ -<?php - -namespace OAuth\Common\Storage; - -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; -use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException; - -/** - * Stores a token in a PHP session. - */ -class Session implements TokenStorageInterface -{ - /** - * @var bool - */ - protected $startSession; - - /** - * @var string - */ - protected $sessionVariableName; - - /** - * @var string - */ - protected $stateVariableName; - - /** - * @param bool $startSession Whether or not to start the session upon construction. - * @param string $sessionVariableName the variable name to use within the _SESSION superglobal - * @param string $stateVariableName - */ - public function __construct( - $startSession = true, - $sessionVariableName = 'lusitanian_oauth_token', - $stateVariableName = 'lusitanian_oauth_state' - ) { - if ($startSession && !isset($_SESSION)) { - session_start(); - } - - $this->startSession = $startSession; - $this->sessionVariableName = $sessionVariableName; - $this->stateVariableName = $stateVariableName; - if (!isset($_SESSION[$sessionVariableName])) { - $_SESSION[$sessionVariableName] = array(); - } - if (!isset($_SESSION[$stateVariableName])) { - $_SESSION[$stateVariableName] = array(); - } - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if ($this->hasAccessToken($service)) { - return unserialize($_SESSION[$this->sessionVariableName][$service]); - } - - throw new TokenNotFoundException('Token not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - $serializedToken = serialize($token); - - if (isset($_SESSION[$this->sessionVariableName]) - && is_array($_SESSION[$this->sessionVariableName]) - ) { - $_SESSION[$this->sessionVariableName][$service] = $serializedToken; - } else { - $_SESSION[$this->sessionVariableName] = array( - $service => $serializedToken, - ); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - return isset($_SESSION[$this->sessionVariableName], $_SESSION[$this->sessionVariableName][$service]); - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - if (array_key_exists($service, $_SESSION[$this->sessionVariableName])) { - unset($_SESSION[$this->sessionVariableName][$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - unset($_SESSION[$this->sessionVariableName]); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - if (isset($_SESSION[$this->stateVariableName]) - && is_array($_SESSION[$this->stateVariableName]) - ) { - $_SESSION[$this->stateVariableName][$service] = $state; - } else { - $_SESSION[$this->stateVariableName] = array( - $service => $state, - ); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - return isset($_SESSION[$this->stateVariableName], $_SESSION[$this->stateVariableName][$service]); - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if ($this->hasAuthorizationState($service)) { - return $_SESSION[$this->stateVariableName][$service]; - } - - throw new AuthorizationStateNotFoundException('State not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - if (array_key_exists($service, $_SESSION[$this->stateVariableName])) { - unset($_SESSION[$this->stateVariableName][$service]); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - unset($_SESSION[$this->stateVariableName]); - - // allow chaining - return $this; - } - - public function __destruct() - { - if ($this->startSession) { - session_write_close(); - } - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php deleted file mode 100644 index 6c5fbf60..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php +++ /dev/null @@ -1,200 +0,0 @@ -<?php - -namespace OAuth\Common\Storage; - -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; -use OAuth\Common\Storage\Exception\AuthorizationStateNotFoundException; -use Symfony\Component\HttpFoundation\Session\SessionInterface; - -class SymfonySession implements TokenStorageInterface -{ - private $session; - private $sessionVariableName; - private $stateVariableName; - - /** - * @param SessionInterface $session - * @param bool $startSession - * @param string $sessionVariableName - * @param string $stateVariableName - */ - public function __construct( - SessionInterface $session, - $startSession = true, - $sessionVariableName = 'lusitanian_oauth_token', - $stateVariableName = 'lusitanian_oauth_state' - ) { - $this->session = $session; - $this->sessionVariableName = $sessionVariableName; - $this->stateVariableName = $stateVariableName; - } - - /** - * {@inheritDoc} - */ - public function retrieveAccessToken($service) - { - if ($this->hasAccessToken($service)) { - // get from session - $tokens = $this->session->get($this->sessionVariableName); - - // one item - return $tokens[$service]; - } - - throw new TokenNotFoundException('Token not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function storeAccessToken($service, TokenInterface $token) - { - // get previously saved tokens - $tokens = $this->session->get($this->sessionVariableName); - - if (!is_array($tokens)) { - $tokens = array(); - } - - $tokens[$service] = $token; - - // save - $this->session->set($this->sessionVariableName, $tokens); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAccessToken($service) - { - // get from session - $tokens = $this->session->get($this->sessionVariableName); - - return is_array($tokens) - && isset($tokens[$service]) - && $tokens[$service] instanceof TokenInterface; - } - - /** - * {@inheritDoc} - */ - public function clearToken($service) - { - // get previously saved tokens - $tokens = $this->session->get($this->sessionVariableName); - - if (is_array($tokens) && array_key_exists($service, $tokens)) { - unset($tokens[$service]); - - // Replace the stored tokens array - $this->session->set($this->sessionVariableName, $tokens); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllTokens() - { - $this->session->remove($this->sessionVariableName); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function retrieveAuthorizationState($service) - { - if ($this->hasAuthorizationState($service)) { - // get from session - $states = $this->session->get($this->stateVariableName); - - // one item - return $states[$service]; - } - - throw new AuthorizationStateNotFoundException('State not found in session, are you sure you stored it?'); - } - - /** - * {@inheritDoc} - */ - public function storeAuthorizationState($service, $state) - { - // get previously saved tokens - $states = $this->session->get($this->stateVariableName); - - if (!is_array($states)) { - $states = array(); - } - - $states[$service] = $state; - - // save - $this->session->set($this->stateVariableName, $states); - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function hasAuthorizationState($service) - { - // get from session - $states = $this->session->get($this->stateVariableName); - - return is_array($states) - && isset($states[$service]) - && null !== $states[$service]; - } - - /** - * {@inheritDoc} - */ - public function clearAuthorizationState($service) - { - // get previously saved tokens - $states = $this->session->get($this->stateVariableName); - - if (is_array($states) && array_key_exists($service, $states)) { - unset($states[$service]); - - // Replace the stored tokens array - $this->session->set($this->stateVariableName, $states); - } - - // allow chaining - return $this; - } - - /** - * {@inheritDoc} - */ - public function clearAllAuthorizationStates() - { - $this->session->remove($this->stateVariableName); - - // allow chaining - return $this; - } - - /** - * @return Session - */ - public function getSession() - { - return $this->session; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php deleted file mode 100644 index 46552cee..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php - -namespace OAuth\Common\Storage; - -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Storage\Exception\TokenNotFoundException; - -/** - * All token storage providers must implement this interface. - */ -interface TokenStorageInterface -{ - /** - * @param string $service - * - * @return TokenInterface - * - * @throws TokenNotFoundException - */ - public function retrieveAccessToken($service); - - /** - * @param string $service - * @param TokenInterface $token - * - * @return TokenStorageInterface - */ - public function storeAccessToken($service, TokenInterface $token); - - /** - * @param string $service - * - * @return bool - */ - public function hasAccessToken($service); - - /** - * Delete the users token. Aka, log out. - * - * @param string $service - * - * @return TokenStorageInterface - */ - public function clearToken($service); - - /** - * Delete *ALL* user tokens. Use with care. Most of the time you will likely - * want to use clearToken() instead. - * - * @return TokenStorageInterface - */ - public function clearAllTokens(); - - /** - * Store the authorization state related to a given service - * - * @param string $service - * @param string $state - * - * @return TokenStorageInterface - */ - public function storeAuthorizationState($service, $state); - - /** - * Check if an authorization state for a given service exists - * - * @param string $service - * - * @return bool - */ - public function hasAuthorizationState($service); - - /** - * Retrieve the authorization state for a given service - * - * @param string $service - * - * @return string - */ - public function retrieveAuthorizationState($service); - - /** - * Clear the authorization state of a given service - * - * @param string $service - * - * @return TokenStorageInterface - */ - public function clearAuthorizationState($service); - - /** - * Delete *ALL* user authorization states. Use with care. Most of the time you will likely - * want to use clearAuthorization() instead. - * - * @return TokenStorageInterface - */ - public function clearAllAuthorizationStates(); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Token/AbstractToken.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/AbstractToken.php deleted file mode 100644 index 7a362473..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Token/AbstractToken.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -namespace OAuth\Common\Token; - -/** - * Base token implementation for any OAuth version. - */ -abstract class AbstractToken implements TokenInterface -{ - /** - * @var string - */ - protected $accessToken; - - /** - * @var string - */ - protected $refreshToken; - - /** - * @var int - */ - protected $endOfLife; - - /** - * @var array - */ - protected $extraParams = array(); - - /** - * @param string $accessToken - * @param string $refreshToken - * @param int $lifetime - * @param array $extraParams - */ - public function __construct($accessToken = null, $refreshToken = null, $lifetime = null, $extraParams = array()) - { - $this->accessToken = $accessToken; - $this->refreshToken = $refreshToken; - $this->setLifetime($lifetime); - $this->extraParams = $extraParams; - } - - /** - * @return string - */ - public function getAccessToken() - { - return $this->accessToken; - } - - /** - * @return string - */ - public function getRefreshToken() - { - return $this->refreshToken; - } - - /** - * @return int - */ - public function getEndOfLife() - { - return $this->endOfLife; - } - - /** - * @param array $extraParams - */ - public function setExtraParams(array $extraParams) - { - $this->extraParams = $extraParams; - } - - /** - * @return array - */ - public function getExtraParams() - { - return $this->extraParams; - } - - /** - * @param string $accessToken - */ - public function setAccessToken($accessToken) - { - $this->accessToken = $accessToken; - } - - /** - * @param int $endOfLife - */ - public function setEndOfLife($endOfLife) - { - $this->endOfLife = $endOfLife; - } - - /** - * @param int $lifetime - */ - public function setLifetime($lifetime) - { - if (0 === $lifetime || static::EOL_NEVER_EXPIRES === $lifetime) { - $this->endOfLife = static::EOL_NEVER_EXPIRES; - } elseif (null !== $lifetime) { - $this->endOfLife = intval($lifetime) + time(); - } else { - $this->endOfLife = static::EOL_UNKNOWN; - } - } - - /** - * @param string $refreshToken - */ - public function setRefreshToken($refreshToken) - { - $this->refreshToken = $refreshToken; - } - - public function isExpired() - { - return ($this->getEndOfLife() !== TokenInterface::EOL_NEVER_EXPIRES - && $this->getEndOfLife() !== TokenInterface::EOL_UNKNOWN - && time() > $this->getEndOfLife()); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php deleted file mode 100644 index 26ad6cc5..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace OAuth\Common\Token\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception thrown when an expired token is attempted to be used. - */ -class ExpiredTokenException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/Common/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/TokenInterface.php deleted file mode 100644 index 84a41092..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/Common/Token/TokenInterface.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -namespace OAuth\Common\Token; - -/** - * Base token interface for any OAuth version. - */ -interface TokenInterface -{ - /** - * Denotes an unknown end of life time. - */ - const EOL_UNKNOWN = -9001; - - /** - * Denotes a token which never expires, should only happen in OAuth1. - */ - const EOL_NEVER_EXPIRES = -9002; - - /** - * @return string - */ - public function getAccessToken(); - - /** - * @return int - */ - public function getEndOfLife(); - - /** - * @return array - */ - public function getExtraParams(); - - /** - * @param string $accessToken - */ - public function setAccessToken($accessToken); - - /** - * @param int $endOfLife - */ - public function setEndOfLife($endOfLife); - - /** - * @param int $lifetime - */ - public function setLifetime($lifetime); - - /** - * @param array $extraParams - */ - public function setExtraParams(array $extraParams); - - /** - * @return string - */ - public function getRefreshToken(); - - /** - * @param string $refreshToken - */ - public function setRefreshToken($refreshToken); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php deleted file mode 100644 index 43c9c9f6..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php +++ /dev/null @@ -1,305 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\TokenInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Service\AbstractService as BaseAbstractService; - -abstract class AbstractService extends BaseAbstractService implements ServiceInterface -{ - /** @const OAUTH_VERSION */ - const OAUTH_VERSION = 1; - - /** @var SignatureInterface */ - protected $signature; - - /** @var UriInterface|null */ - protected $baseApiUri; - - /** - * {@inheritDoc} - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage); - - $this->signature = $signature; - $this->baseApiUri = $baseApiUri; - - $this->signature->setHashingAlgorithm($this->getSignatureMethod()); - } - - /** - * {@inheritDoc} - */ - public function requestRequestToken() - { - $authorizationHeader = array('Authorization' => $this->buildAuthorizationHeaderForTokenRequest()); - $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders()); - - $responseBody = $this->httpClient->retrieveResponse($this->getRequestTokenEndpoint(), array(), $headers); - - $token = $this->parseRequestTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($additionalParameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritDoc} - */ - public function requestAccessToken($token, $verifier, $tokenSecret = null) - { - if (is_null($tokenSecret)) { - $storedRequestToken = $this->storage->retrieveAccessToken($this->service()); - $tokenSecret = $storedRequestToken->getRequestTokenSecret(); - } - $this->signature->setTokenSecret($tokenSecret); - - $bodyParams = array( - 'oauth_verifier' => $verifier, - ); - - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest( - 'POST', - $this->getAccessTokenEndpoint(), - $this->storage->retrieveAccessToken($this->service()), - $bodyParams - ) - ); - - $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders()); - - $responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * Sends an authenticated API request to the path provided. - * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. - * - * @param string|UriInterface $path - * @param string $method HTTP method - * @param array $body Request body if applicable (key/value pairs) - * @param array $extraHeaders Extra headers if applicable. - * These will override service-specific any defaults. - * - * @return string - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri); - - /** @var $token StdOAuth1Token */ - $token = $this->storage->retrieveAccessToken($this->service()); - $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body) - ); - $headers = array_merge($authorizationHeader, $extraHeaders); - - return $this->httpClient->retrieveResponse($uri, $body, $headers, $method); - } - - /** - * Return any additional headers always needed for this service implementation's OAuth calls. - * - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array(); - } - - /** - * Return any additional headers always needed for this service implementation's API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array(); - } - - /** - * Builds the authorization header for getting an access or request token. - * - * @param array $extraParameters - * - * @return string - */ - protected function buildAuthorizationHeaderForTokenRequest(array $extraParameters = array()) - { - $parameters = $this->getBasicAuthorizationHeaderInfo(); - $parameters = array_merge($parameters, $extraParameters); - $parameters['oauth_signature'] = $this->signature->getSignature( - $this->getRequestTokenEndpoint(), - $parameters, - 'POST' - ); - - $authorizationHeader = 'OAuth '; - $delimiter = ''; - foreach ($parameters as $key => $value) { - $authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"'; - - $delimiter = ', '; - } - - return $authorizationHeader; - } - - /** - * Builds the authorization header for an authenticated API request - * - * @param string $method - * @param UriInterface $uri The uri the request is headed - * @param TokenInterface $token - * @param array $bodyParams Request body if applicable (key/value pairs) - * - * @return string - */ - protected function buildAuthorizationHeaderForAPIRequest( - $method, - UriInterface $uri, - TokenInterface $token, - $bodyParams = null - ) { - $this->signature->setTokenSecret($token->getAccessTokenSecret()); - $parameters = $this->getBasicAuthorizationHeaderInfo(); - if (isset($parameters['oauth_callback'])) { - unset($parameters['oauth_callback']); - } - - $parameters = array_merge($parameters, array('oauth_token' => $token->getAccessToken())); - $parameters = (is_array($bodyParams)) ? array_merge($parameters, $bodyParams) : $parameters; - $parameters['oauth_signature'] = $this->signature->getSignature($uri, $parameters, $method); - - $authorizationHeader = 'OAuth '; - $delimiter = ''; - - foreach ($parameters as $key => $value) { - $authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"'; - $delimiter = ', '; - } - - return $authorizationHeader; - } - - /** - * Builds the authorization header array. - * - * @return array - */ - protected function getBasicAuthorizationHeaderInfo() - { - $dateTime = new \DateTime(); - $headerParameters = array( - 'oauth_callback' => $this->credentials->getCallbackUrl(), - 'oauth_consumer_key' => $this->credentials->getConsumerId(), - 'oauth_nonce' => $this->generateNonce(), - 'oauth_signature_method' => $this->getSignatureMethod(), - 'oauth_timestamp' => $dateTime->format('U'), - 'oauth_version' => $this->getVersion(), - ); - - return $headerParameters; - } - - /** - * Pseudo random string generator used to build a unique string to sign each request - * - * @param int $length - * - * @return string - */ - protected function generateNonce($length = 32) - { - $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; - - $nonce = ''; - $maxRand = strlen($characters)-1; - for ($i = 0; $i < $length; $i++) { - $nonce.= $characters[rand(0, $maxRand)]; - } - - return $nonce; - } - - /** - * @return string - */ - protected function getSignatureMethod() - { - return 'HMAC-SHA1'; - } - - /** - * This returns the version used in the authorization header of the requests - * - * @return string - */ - protected function getVersion() - { - return '1.0'; - } - - /** - * Parses the request token response and returns a TokenInterface. - * This is only needed to verify the `oauth_callback_confirmed` parameter. The actual - * parsing logic is contained in the access token parser. - * - * @abstract - * - * @param string $responseBody - * - * @return TokenInterface - * - * @throws TokenResponseException - */ - abstract protected function parseRequestTokenResponse($responseBody); - - /** - * Parses the access token response and returns a TokenInterface. - * - * @abstract - * - * @param string $responseBody - * - * @return TokenInterface - * - * @throws TokenResponseException - */ - abstract protected function parseAccessTokenResponse($responseBody); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php deleted file mode 100644 index f6d8edfe..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class BitBucket extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://bitbucket.org/api/1.0/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://bitbucket.org/!api/1.0/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://bitbucket.org/!api/1.0/oauth/authenticate'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://bitbucket.org/!api/1.0/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php deleted file mode 100644 index 30dc331c..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class Etsy extends AbstractService -{ - - protected $scopes = array(); - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://openapi.etsy.com/v2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - $uri = new Uri($this->baseApiUri . 'oauth/request_token'); - $scopes = $this->getScopes(); - - if (count($scopes)) { - $uri->setQuery('scope=' . implode('%20', $scopes)); - } - - return $uri; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri($this->baseApiUri); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri($this->baseApiUri . 'oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } - - /** - * Set the scopes for permissions - * @see https://www.etsy.com/developers/documentation/getting_started/oauth#section_permission_scopes - * @param array $scopes - * - * @return $this - */ - public function setScopes(array $scopes) - { - if (!is_array($scopes)) { - $scopes = array(); - } - - $this->scopes = $scopes; - return $this; - } - - /** - * Return the defined scopes - * @return array - */ - public function getScopes() - { - return $this->scopes; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php deleted file mode 100644 index 78032d75..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class FitBit extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.fitbit.com/1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.fitbit.com/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.fitbit.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.fitbit.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php deleted file mode 100644 index f06d282a..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class Flickr extends AbstractService -{ - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - if ($baseApiUri === null) { - $this->baseApiUri = new Uri('https://api.flickr.com/services/rest/'); - } - } - - public function getRequestTokenEndpoint() - { - return new Uri('https://www.flickr.com/services/oauth/request_token'); - } - - public function getAuthorizationEndpoint() - { - return new Uri('https://www.flickr.com/services/oauth/authorize'); - } - - public function getAccessTokenEndpoint() - { - return new Uri('https://www.flickr.com/services/oauth/access_token'); - } - - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - return $this->parseAccessTokenResponse($responseBody); - } - - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - if ($data === null || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } - - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath('/', $this->baseApiUri); - $uri->addToQuery('method', $path); - - $token = $this->storage->retrieveAccessToken($this->service()); - $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); - $authorizationHeader = array( - 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body) - ); - $headers = array_merge($authorizationHeader, $extraHeaders); - - return $this->httpClient->retrieveResponse($uri, $body, $headers, $method); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php deleted file mode 100644 index 28bd250b..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class ScoopIt extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://www.scoop.it/api/1/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://www.scoop.it/oauth/request'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.scoop.it/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.scoop.it/oauth/access'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php deleted file mode 100644 index 3f91fbf2..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Service\ServiceInterface as BaseServiceInterface; -use OAuth\OAuth1\Signature\SignatureInterface; - -/** - * Defines the common methods across OAuth 1 services. - */ -interface ServiceInterface extends BaseServiceInterface -{ - /** - * Retrieves and stores/returns the OAuth1 request token obtained from the service. - * - * @return TokenInterface $token - * - * @throws TokenResponseException - */ - public function requestRequestToken(); - - /** - * Retrieves and stores/returns the OAuth1 access token after a successful authorization. - * - * @param string $token The request token from the callback. - * @param string $verifier - * @param string $tokenSecret - * - * @return TokenInterface $token - * - * @throws TokenResponseException - */ - public function requestAccessToken($token, $verifier, $tokenSecret); - - /** - * @return UriInterface - */ - public function getRequestTokenEndpoint(); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php deleted file mode 100644 index 3f5d38a8..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class Tumblr extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.tumblr.com/v2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://www.tumblr.com/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.tumblr.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.tumblr.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php deleted file mode 100644 index f46c34e4..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php +++ /dev/null @@ -1,121 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Exception\Exception; - -class Twitter extends AbstractService -{ - const ENDPOINT_AUTHENTICATE = "https://api.twitter.com/oauth/authenticate"; - const ENDPOINT_AUTHORIZE = "https://api.twitter.com/oauth/authorize"; - - protected $authorizationEndpoint = self::ENDPOINT_AUTHENTICATE; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.twitter.com/1.1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.twitter.com/oauth/request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - if ($this->authorizationEndpoint != self::ENDPOINT_AUTHENTICATE - && $this->authorizationEndpoint != self::ENDPOINT_AUTHORIZE) { - $this->authorizationEndpoint = self::ENDPOINT_AUTHENTICATE; - } - return new Uri($this->authorizationEndpoint); - } - - /** - * @param string $authorizationEndpoint - * - * @throws Exception - */ - public function setAuthorizationEndpoint($endpoint) - { - if ($endpoint != self::ENDPOINT_AUTHENTICATE && $endpoint != self::ENDPOINT_AUTHORIZE) { - throw new Exception( - sprintf("'%s' is not a correct Twitter authorization endpoint.", $endpoint) - ); - } - $this->authorizationEndpoint = $endpoint; - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.twitter.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php deleted file mode 100644 index 03e3357f..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class Xing extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.xing.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.xing.com/v1/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.xing.com/v1/access_token'); - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.xing.com/v1/request_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php deleted file mode 100644 index cff291d4..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Service; - -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\OAuth1\Token\StdOAuth1Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class Yahoo extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://social.yahooapis.com/v1/'); - } - } - - /** - * {@inheritDoc} - */ - public function getRequestTokenEndpoint() - { - return new Uri('https://api.login.yahoo.com/oauth/v2/get_request_token'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.login.yahoo.com/oauth/v2/request_auth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.login.yahoo.com/oauth/v2/get_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth1Token(); - - $token->setRequestToken($data['oauth_token']); - $token->setRequestTokenSecret($data['oauth_token_secret']); - $token->setAccessToken($data['oauth_token']); - $token->setAccessTokenSecret($data['oauth_token_secret']); - - $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); - unset($data['oauth_token'], $data['oauth_token_secret']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php deleted file mode 100644 index 44c36ce7..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Signature\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Thrown when an unsupported hash mechanism is requested in signature class. - */ -class UnsupportedHashAlgorithmException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php deleted file mode 100644 index 2e13eb37..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Signature; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\OAuth1\Signature\Exception\UnsupportedHashAlgorithmException; - -class Signature implements SignatureInterface -{ - /** - * @var Credentials - */ - protected $credentials; - - /** - * @var string - */ - protected $algorithm; - - /** - * @var string - */ - protected $tokenSecret = null; - - /** - * @param CredentialsInterface $credentials - */ - public function __construct(CredentialsInterface $credentials) - { - $this->credentials = $credentials; - } - - /** - * @param string $algorithm - */ - public function setHashingAlgorithm($algorithm) - { - $this->algorithm = $algorithm; - } - - /** - * @param string $token - */ - public function setTokenSecret($token) - { - $this->tokenSecret = $token; - } - - /** - * @param UriInterface $uri - * @param array $params - * @param string $method - * - * @return string - */ - public function getSignature(UriInterface $uri, array $params, $method = 'POST') - { - parse_str($uri->getQuery(), $queryStringData); - - foreach (array_merge($queryStringData, $params) as $key => $value) { - $signatureData[rawurlencode($key)] = rawurlencode($value); - } - - ksort($signatureData); - - // determine base uri - $baseUri = $uri->getScheme() . '://' . $uri->getRawAuthority(); - - if ('/' === $uri->getPath()) { - $baseUri .= $uri->hasExplicitTrailingHostSlash() ? '/' : ''; - } else { - $baseUri .= $uri->getPath(); - } - - $baseString = strtoupper($method) . '&'; - $baseString .= rawurlencode($baseUri) . '&'; - $baseString .= rawurlencode($this->buildSignatureDataString($signatureData)); - - return base64_encode($this->hash($baseString)); - } - - /** - * @param array $signatureData - * - * @return string - */ - protected function buildSignatureDataString(array $signatureData) - { - $signatureString = ''; - $delimiter = ''; - foreach ($signatureData as $key => $value) { - $signatureString .= $delimiter . $key . '=' . $value; - - $delimiter = '&'; - } - - return $signatureString; - } - - /** - * @return string - */ - protected function getSigningKey() - { - $signingKey = rawurlencode($this->credentials->getConsumerSecret()) . '&'; - if ($this->tokenSecret !== null) { - $signingKey .= rawurlencode($this->tokenSecret); - } - - return $signingKey; - } - - /** - * @param string $data - * - * @return string - * - * @throws UnsupportedHashAlgorithmException - */ - protected function hash($data) - { - switch (strtoupper($this->algorithm)) { - case 'HMAC-SHA1': - return hash_hmac('sha1', $data, $this->getSigningKey(), true); - default: - throw new UnsupportedHashAlgorithmException( - 'Unsupported hashing algorithm (' . $this->algorithm . ') used.' - ); - } - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php deleted file mode 100644 index da50ddb6..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Signature; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; - -interface SignatureInterface -{ - /** - * @param string $algorithm - */ - public function setHashingAlgorithm($algorithm); - - /** - * @param string $token - */ - public function setTokenSecret($token); - - /** - * @param UriInterface $uri - * @param array $params - * @param string $method - * - * @return string - */ - public function getSignature(UriInterface $uri, array $params, $method = 'POST'); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php deleted file mode 100644 index a12a7971..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Token; - -use OAuth\Common\Token\AbstractToken; - -/** - * Standard OAuth1 token implementation. - * Implements OAuth\OAuth1\Token\TokenInterface in case of any OAuth1 specific features. - */ -class StdOAuth1Token extends AbstractToken implements TokenInterface -{ - /** - * @var string - */ - protected $requestToken; - - /** - * @var string - */ - protected $requestTokenSecret; - - /** - * @var string - */ - protected $accessTokenSecret; - - /** - * @param string $requestToken - */ - public function setRequestToken($requestToken) - { - $this->requestToken = $requestToken; - } - - /** - * @return string - */ - public function getRequestToken() - { - return $this->requestToken; - } - - /** - * @param string $requestTokenSecret - */ - public function setRequestTokenSecret($requestTokenSecret) - { - $this->requestTokenSecret = $requestTokenSecret; - } - - /** - * @return string - */ - public function getRequestTokenSecret() - { - return $this->requestTokenSecret; - } - - /** - * @param string $accessTokenSecret - */ - public function setAccessTokenSecret($accessTokenSecret) - { - $this->accessTokenSecret = $accessTokenSecret; - } - - /** - * @return string - */ - public function getAccessTokenSecret() - { - return $this->accessTokenSecret; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php deleted file mode 100644 index 0bc3f739..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace OAuth\OAuth1\Token; - -use OAuth\Common\Token\TokenInterface as BaseTokenInterface; - -/** - * OAuth1 specific token interface - */ -interface TokenInterface extends BaseTokenInterface -{ - /** - * @return string - */ - public function getAccessTokenSecret(); - - /** - * @param string $accessTokenSecret - */ - public function setAccessTokenSecret($accessTokenSecret); - - /** - * @return string - */ - public function getRequestTokenSecret(); - - /** - * @param string $requestTokenSecret - */ - public function setRequestTokenSecret($requestTokenSecret); - - /** - * @return string - */ - public function getRequestToken(); - - /** - * @param string $requestToken - */ - public function setRequestToken($requestToken); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php deleted file mode 100644 index 57dc76f2..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php +++ /dev/null @@ -1,333 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Exception\Exception; -use OAuth\Common\Service\AbstractService as BaseAbstractService; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\OAuth2\Service\Exception\InvalidAuthorizationStateException; -use OAuth\OAuth2\Service\Exception\InvalidScopeException; -use OAuth\OAuth2\Service\Exception\MissingRefreshTokenException; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Token\Exception\ExpiredTokenException; - -abstract class AbstractService extends BaseAbstractService implements ServiceInterface -{ - /** @const OAUTH_VERSION */ - const OAUTH_VERSION = 2; - - /** @var array */ - protected $scopes; - - /** @var UriInterface|null */ - protected $baseApiUri; - - /** @var bool */ - protected $stateParameterInAuthUrl; - - /** - * @param CredentialsInterface $credentials - * @param ClientInterface $httpClient - * @param TokenStorageInterface $storage - * @param array $scopes - * @param UriInterface|null $baseApiUri - * @param bool $stateParameterInAutUrl - * - * @throws InvalidScopeException - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null, - $stateParameterInAutUrl = false - ) { - parent::__construct($credentials, $httpClient, $storage); - $this->stateParameterInAuthUrl = $stateParameterInAutUrl; - - foreach ($scopes as $scope) { - if (!$this->isValidScope($scope)) { - throw new InvalidScopeException('Scope ' . $scope . ' is not valid for service ' . get_class($this)); - } - } - - $this->scopes = $scopes; - - $this->baseApiUri = $baseApiUri; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - if ($this->needsStateParameterInAuthUrl()) { - if (!isset($parameters['state'])) { - $parameters['state'] = $this->generateAuthorizationState(); - } - $this->storeAuthorizationState($parameters['state']); - } - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function requestAccessToken($code, $state = null) - { - if (null !== $state) { - $this->validateAuthorizationState($state); - } - - $bodyParams = array( - 'code' => $code, - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'grant_type' => 'authorization_code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * Sends an authenticated API request to the path provided. - * If the path provided is not an absolute URI, the base API Uri (must be passed into constructor) will be used. - * - * @param string|UriInterface $path - * @param string $method HTTP method - * @param array $body Request body if applicable. - * @param array $extraHeaders Extra headers if applicable. These will override service-specific - * any defaults. - * - * @return string - * - * @throws ExpiredTokenException - * @throws Exception - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri); - $token = $this->storage->retrieveAccessToken($this->service()); - - if ($token->getEndOfLife() !== TokenInterface::EOL_NEVER_EXPIRES - && $token->getEndOfLife() !== TokenInterface::EOL_UNKNOWN - && time() > $token->getEndOfLife() - ) { - throw new ExpiredTokenException( - sprintf( - 'Token expired on %s at %s', - date('m/d/Y', $token->getEndOfLife()), - date('h:i:s A', $token->getEndOfLife()) - ) - ); - } - - // add the token where it may be needed - if (static::AUTHORIZATION_METHOD_HEADER_OAUTH === $this->getAuthorizationMethod()) { - $extraHeaders = array_merge(array('Authorization' => 'OAuth ' . $token->getAccessToken()), $extraHeaders); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING === $this->getAuthorizationMethod()) { - $uri->addToQuery('access_token', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V2 === $this->getAuthorizationMethod()) { - $uri->addToQuery('oauth2_access_token', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_QUERY_STRING_V3 === $this->getAuthorizationMethod()) { - $uri->addToQuery('apikey', $token->getAccessToken()); - } elseif (static::AUTHORIZATION_METHOD_HEADER_BEARER === $this->getAuthorizationMethod()) { - $extraHeaders = array_merge(array('Authorization' => 'Bearer ' . $token->getAccessToken()), $extraHeaders); - } - - $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); - - return $this->httpClient->retrieveResponse($uri, $body, $extraHeaders, $method); - } - - /** - * Accessor to the storage adapter to be able to retrieve tokens - * - * @return TokenStorageInterface - */ - public function getStorage() - { - return $this->storage; - } - - /** - * Refreshes an OAuth2 access token. - * - * @param TokenInterface $token - * - * @return TokenInterface $token - * - * @throws MissingRefreshTokenException - */ - public function refreshAccessToken(TokenInterface $token) - { - $refreshToken = $token->getRefreshToken(); - - if (empty($refreshToken)) { - throw new MissingRefreshTokenException(); - } - - $parameters = array( - 'grant_type' => 'refresh_token', - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'refresh_token' => $refreshToken, - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $parameters, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * Return whether or not the passed scope value is valid. - * - * @param string $scope - * - * @return bool - */ - public function isValidScope($scope) - { - $reflectionClass = new \ReflectionClass(get_class($this)); - - return in_array($scope, $reflectionClass->getConstants(), true); - } - - /** - * Check if the given service need to generate a unique state token to build the authorization url - * - * @return bool - */ - public function needsStateParameterInAuthUrl() - { - return $this->stateParameterInAuthUrl; - } - - /** - * Validates the authorization state against a given one - * - * @param string $state - * @throws InvalidAuthorizationStateException - */ - protected function validateAuthorizationState($state) - { - if ($this->retrieveAuthorizationState() !== $state) { - throw new InvalidAuthorizationStateException(); - } - } - - /** - * Generates a random string to be used as state - * - * @return string - */ - protected function generateAuthorizationState() - { - return md5(rand()); - } - - /** - * Retrieves the authorization state for the current service - * - * @return string - */ - protected function retrieveAuthorizationState() - { - return $this->storage->retrieveAuthorizationState($this->service()); - } - - /** - * Stores a given authorization state into the storage - * - * @param string $state - */ - protected function storeAuthorizationState($state) - { - $this->storage->storeAuthorizationState($this->service(), $state); - } - - /** - * Return any additional headers always needed for this service implementation's OAuth calls. - * - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array(); - } - - /** - * Return any additional headers always needed for this service implementation's API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array(); - } - - /** - * Parses the access token response and returns a TokenInterface. - * - * @abstract - * - * @param string $responseBody - * - * @return TokenInterface - * - * @throws TokenResponseException - */ - abstract protected function parseAccessTokenResponse($responseBody); - - /** - * Returns a class constant from ServiceInterface defining the authorization method used for the API - * Header is the sane default. - * - * @return int - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_OAUTH; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php deleted file mode 100644 index 035d1a55..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Amazon service. - * - * @author Flávio Heleno <flaviohbatista@gmail.com> - * @link https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-developer-guide._TTH_.pdf - */ -class Amazon extends AbstractService -{ - /** - * Defined scopes - * @link https://images-na.ssl-images-amazon.com/images/G/01/lwa/dev/docs/website-developer-guide._TTH_.pdf - */ - const SCOPE_PROFILE = 'profile'; - const SCOPE_POSTAL_CODE = 'postal_code'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.amazon.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.amazon.com/ap/oa'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.amazon.com/ap/oatoken'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error_description'] . '"'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php deleted file mode 100644 index e01cbc42..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Bitly extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api-ssl.bitly.com/v3/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://bitly.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api-ssl.bitly.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // I'm invincible!!! - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function requestAccessToken($code, $state = null) - { - if (null !== $state) { - $this->validateAuthorizationState($state); - } - - $bodyParams = array( - 'code' => $code, - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'grant_type' => 'authorization_code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - - // we can scream what we want that we want bitly to return a json encoded string (format=json), but the - // WOAH WATCH YOUR LANGUAGE ;) service doesn't seem to like screaming, hence we need to manually - // parse the result - $parsedResult = array(); - parse_str($responseBody, $parsedResult); - - $token = $this->parseAccessTokenResponse(json_encode($parsedResult)); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php deleted file mode 100644 index 14696c59..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Box service. - * - * @author Antoine Corcy <contact@sbin.dk> - * @link https://developers.box.com/oauth/ - */ -class Box extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.box.com/2.0/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.box.com/api/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.box.com/api/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php deleted file mode 100644 index 5905678e..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -/** - * Buffer API. - * @author Sumukh Sridhara <@sumukhsridhara> - * @link https://bufferapp.com/developers/api - */ -class Buffer extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - if ($baseApiUri === null) { - $this->baseApiUri = new Uri('https://api.bufferapp.com/1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://bufferapp.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.bufferapp.com/1/oauth2/token.json'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function requestRequestToken() - { - $responseBody = $this->httpClient->retrieveResponse( - $this->getRequestTokenEndpoint(), - array( - 'client_key' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $code = $this->parseRequestTokenResponse($responseBody); - - return $code; - } - - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['code'])) { - throw new TokenResponseException('Error in retrieving code.'); - } - return $data['code']; - } - - public function requestAccessToken($code) - { - $bodyParams = array( - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'code' => $code, - 'grant_type' => 'authorization_code', - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if ($data === null || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php deleted file mode 100644 index 095a467f..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php +++ /dev/null @@ -1,129 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Dailymotion service. - * - * @author Mouhamed SEYE <mouhamed@seye.pro> - * @link http://www.dailymotion.com/doc/api/authentication.html - */ -class Dailymotion extends AbstractService -{ - /** - * Scopes - * - * @var string - */ - const SCOPE_EMAIL = 'email', - SCOPE_PROFILE = 'userinfo', - SCOPE_VIDEOS = 'manage_videos', - SCOPE_COMMENTS = 'manage_comments', - SCOPE_PLAYLIST = 'manage_playlists', - SCOPE_TILES = 'manage_tiles', - SCOPE_SUBSCRIPTIONS = 'manage_subscriptions', - SCOPE_FRIENDS = 'manage_friends', - SCOPE_FAVORITES = 'manage_favorites', - SCOPE_GROUPS = 'manage_groups'; - - /** - * Dialog form factors - * - * @var string - */ - const DISPLAY_PAGE = 'page', - DISPLAY_POPUP = 'popup', - DISPLAY_MOBILE = 'mobile'; - - /** - * {@inheritdoc} - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.dailymotion.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.dailymotion.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.dailymotion.com/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_OAUTH; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description']) || isset($data['error'])) { - throw new TokenResponseException( - sprintf( - 'Error in retrieving token: "%s"', - isset($data['error_description']) ? $data['error_description'] : $data['error'] - ) - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php deleted file mode 100644 index 43ec6c7f..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Dropbox service. - * - * @author Flávio Heleno <flaviohbatista@gmail.com> - * @link https://www.dropbox.com/developers/core/docs - */ -class Dropbox extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.dropbox.com/1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.dropbox.com/1/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.dropbox.com/1/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php deleted file mode 100644 index 398df2fd..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception thrown when an invalid accessType for the Google Service is specified - */ -class InvalidAccessTypeException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php deleted file mode 100644 index fe9d550a..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service\Exception; - -/** - * Exception thrown when the state parameter received during the authorization process is invalid. - */ -class InvalidAuthorizationStateException extends \Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php deleted file mode 100644 index c6a51c88..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/** - * @author David Desberg <david@daviddesberg.com> - * Released under the MIT license. - */ - -namespace OAuth\OAuth2\Service\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception thrown when a scope provided to a service is invalid. - */ -class InvalidScopeException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php deleted file mode 100644 index 21eece6a..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/** - * @author David Desberg <david@daviddesberg.com> - * Released under the MIT license. - */ - -namespace OAuth\OAuth2\Service\Exception; - -use OAuth\Common\Exception\Exception; - -/** - * Exception thrown when service is requested to refresh the access token but no refresh token can be found. - */ -class MissingRefreshTokenException extends Exception -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php deleted file mode 100644 index 80b25c05..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\Common\Exception\Exception; -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Facebook extends AbstractService -{ - /** - * Facebook www url - used to build dialog urls - */ - const WWW_URL = 'https://www.facebook.com/'; - - /** - * Defined scopes - * - * If you don't think this is scary you should not be allowed on the web at all - * - * @link https://developers.facebook.com/docs/reference/login/ - * @link https://developers.facebook.com/tools/explorer For a list of permissions use 'Get Access Token' - */ - // email scopes - const SCOPE_EMAIL = 'email'; - // extended permissions - const SCOPE_READ_FRIENDLIST = 'read_friendlists'; - const SCOPE_READ_INSIGHTS = 'read_insights'; - const SCOPE_READ_MAILBOX = 'read_mailbox'; - const SCOPE_READ_PAGE_MAILBOXES = 'read_page_mailboxes'; - const SCOPE_READ_REQUESTS = 'read_requests'; - const SCOPE_READ_STREAM = 'read_stream'; - const SCOPE_VIDEO_UPLOAD = 'video_upload'; - const SCOPE_XMPP_LOGIN = 'xmpp_login'; - const SCOPE_USER_ONLINE_PRESENCE = 'user_online_presence'; - const SCOPE_FRIENDS_ONLINE_PRESENCE = 'friends_online_presence'; - const SCOPE_ADS_MANAGEMENT = 'ads_management'; - const SCOPE_ADS_READ = 'ads_read'; - const SCOPE_CREATE_EVENT = 'create_event'; - const SCOPE_CREATE_NOTE = 'create_note'; - const SCOPE_EXPORT_STREAM = 'export_stream'; - const SCOPE_MANAGE_FRIENDLIST = 'manage_friendlists'; - const SCOPE_MANAGE_NOTIFICATIONS = 'manage_notifications'; - const SCOPE_PHOTO_UPLOAD = 'photo_upload'; - const SCOPE_PUBLISH_ACTIONS = 'publish_actions'; - const SCOPE_PUBLISH_CHECKINS = 'publish_checkins'; - const SCOPE_PUBLISH_STREAM = 'publish_stream'; - const SCOPE_RSVP_EVENT = 'rsvp_event'; - const SCOPE_SHARE_ITEM = 'share_item'; - const SCOPE_SMS = 'sms'; - const SCOPE_STATUS_UPDATE = 'status_update'; - // Extended Profile Properties - const SCOPE_USER_FRIENDS = 'user_friends'; - const SCOPE_USER_ABOUT = 'user_about_me'; - const SCOPE_FRIENDS_ABOUT = 'friends_about_me'; - const SCOPE_USER_ACTIVITIES = 'user_activities'; - const SCOPE_FRIENDS_ACTIVITIES = 'friends_activities'; - const SCOPE_USER_BIRTHDAY = 'user_birthday'; - const SCOPE_FRIENDS_BIRTHDAY = 'friends_birthday'; - const SCOPE_USER_CHECKINS = 'user_checkins'; - const SCOPE_FRIENDS_CHECKINS = 'friends_checkins'; - const SCOPE_USER_EDUCATION = 'user_education_history'; - const SCOPE_FRIENDS_EDUCATION = 'friends_education_history'; - const SCOPE_USER_EVENTS = 'user_events'; - const SCOPE_FRIENDS_EVENTS = 'friends_events'; - const SCOPE_USER_GROUPS = 'user_groups'; - const SCOPE_FRIENDS_GROUPS = 'friends_groups'; - const SCOPE_USER_HOMETOWN = 'user_hometown'; - const SCOPE_FRIENDS_HOMETOWN = 'friends_hometown'; - const SCOPE_USER_INTERESTS = 'user_interests'; - const SCOPE_FRIEND_INTERESTS = 'friends_interests'; - const SCOPE_USER_LIKES = 'user_likes'; - const SCOPE_FRIENDS_LIKES = 'friends_likes'; - const SCOPE_USER_LOCATION = 'user_location'; - const SCOPE_FRIENDS_LOCATION = 'friends_location'; - const SCOPE_USER_NOTES = 'user_notes'; - const SCOPE_FRIENDS_NOTES = 'friends_notes'; - const SCOPE_USER_PHOTOS = 'user_photos'; - const SCOPE_USER_PHOTO_VIDEO_TAGS = 'user_photo_video_tags'; - const SCOPE_FRIENDS_PHOTOS = 'friends_photos'; - const SCOPE_FRIENDS_PHOTO_VIDEO_TAGS = 'friends_photo_video_tags'; - const SCOPE_USER_QUESTIONS = 'user_questions'; - const SCOPE_FRIENDS_QUESTIONS = 'friends_questions'; - const SCOPE_USER_RELATIONSHIPS = 'user_relationships'; - const SCOPE_FRIENDS_RELATIONSHIPS = 'friends_relationships'; - const SCOPE_USER_RELATIONSHIPS_DETAILS = 'user_relationship_details'; - const SCOPE_FRIENDS_RELATIONSHIPS_DETAILS = 'friends_relationship_details'; - const SCOPE_USER_RELIGION = 'user_religion_politics'; - const SCOPE_FRIENDS_RELIGION = 'friends_religion_politics'; - const SCOPE_USER_STATUS = 'user_status'; - const SCOPE_FRIENDS_STATUS = 'friends_status'; - const SCOPE_USER_SUBSCRIPTIONS = 'user_subscriptions'; - const SCOPE_FRIENDS_SUBSCRIPTIONS = 'friends_subscriptions'; - const SCOPE_USER_VIDEOS = 'user_videos'; - const SCOPE_FRIENDS_VIDEOS = 'friends_videos'; - const SCOPE_USER_WEBSITE = 'user_website'; - const SCOPE_FRIENDS_WEBSITE = 'friends_website'; - const SCOPE_USER_WORK = 'user_work_history'; - const SCOPE_FRIENDS_WORK = 'friends_work_history'; - // Open Graph Permissions - const SCOPE_USER_MUSIC = 'user_actions.music'; - const SCOPE_FRIENDS_MUSIC = 'friends_actions.music'; - const SCOPE_USER_NEWS = 'user_actions.news'; - const SCOPE_FRIENDS_NEWS = 'friends_actions.news'; - const SCOPE_USER_VIDEO = 'user_actions.video'; - const SCOPE_FRIENDS_VIDEO = 'friends_actions.video'; - const SCOPE_USER_APP = 'user_actions:APP_NAMESPACE'; - const SCOPE_FRIENDS_APP = 'friends_actions:APP_NAMESPACE'; - const SCOPE_USER_GAMES = 'user_games_activity'; - const SCOPE_FRIENDS_GAMES = 'friends_games_activity'; - //Page Permissions - const SCOPE_PAGES = 'manage_pages'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://graph.facebook.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.facebook.com/dialog/oauth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://graph.facebook.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ? - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires'])) { - $token->setLifeTime($data['expires']); - } - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires']); - - $token->setExtraParams($data); - - return $token; - } - - public function getDialogUri($dialogPath, array $parameters) - { - if (!isset($parameters['redirect_uri'])) { - throw new Exception("Redirect uri is mandatory for this request"); - } - $parameters['app_id'] = $this->credentials->getConsumerId(); - $baseUrl = self::WWW_URL . 'dialog/' . $dialogPath; - $query = http_build_query($parameters); - return new Uri($baseUrl . '?' . $query); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php deleted file mode 100644 index fdbabf98..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Foursquare extends AbstractService -{ - private $apiVersionDate = '20130829'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.foursquare.com/v2/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://foursquare.com/oauth2/authenticate'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://foursquare.com/oauth2/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Foursquare tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - $uri = new Uri($this->baseApiUri . $path); - $uri->addToQuery('v', $this->apiVersionDate); - - return parent::request($uri, $method, $body, $extraHeaders); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php deleted file mode 100644 index 9fee2ba0..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php +++ /dev/null @@ -1,208 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class GitHub extends AbstractService -{ - /** - * Defined scopes, see http://developer.github.com/v3/oauth/ for definitions. - */ - - /** - * Public read-only access (includes public user profile info, public repo info, and gists) - */ - const SCOPE_READONLY = ''; - - /** - * Read/write access to profile info only. - * - * Includes SCOPE_USER_EMAIL and SCOPE_USER_FOLLOW. - */ - const SCOPE_USER = 'user'; - - /** - * Read access to a user’s email addresses. - */ - const SCOPE_USER_EMAIL = 'user:email'; - - /** - * Access to follow or unfollow other users. - */ - const SCOPE_USER_FOLLOW = 'user:follow'; - - /** - * Read/write access to public repos and organizations. - */ - const SCOPE_PUBLIC_REPO = 'public_repo'; - - /** - * Read/write access to public and private repos and organizations. - * - * Includes SCOPE_REPO_STATUS. - */ - const SCOPE_REPO = 'repo'; - - /** - * Grants access to deployment statuses for public and private repositories. - * This scope is only necessary to grant other users or services access to deployment statuses, - * without granting access to the code. - */ - const SCOPE_REPO_DEPLOYMENT = 'repo_deployment'; - - /** - * Read/write access to public and private repository commit statuses. This scope is only necessary to grant other - * users or services access to private repository commit statuses without granting access to the code. The repo and - * public_repo scopes already include access to commit status for private and public repositories, respectively. - */ - const SCOPE_REPO_STATUS = 'repo:status'; - - /** - * Delete access to adminable repositories. - */ - const SCOPE_DELETE_REPO = 'delete_repo'; - - /** - * Read access to a user’s notifications. repo is accepted too. - */ - const SCOPE_NOTIFICATIONS = 'notifications'; - - /** - * Write access to gists. - */ - const SCOPE_GIST = 'gist'; - - /** - * Grants read and ping access to hooks in public or private repositories. - */ - const SCOPE_HOOKS_READ = 'read:repo_hook'; - - /** - * Grants read, write, and ping access to hooks in public or private repositories. - */ - const SCOPE_HOOKS_WRITE = 'write:repo_hook'; - - /** - * Grants read, write, ping, and delete access to hooks in public or private repositories. - */ - const SCOPE_HOOKS_ADMIN = 'admin:repo_hook'; - - /** - * Read-only access to organization, teams, and membership. - */ - const SCOPE_ORG_READ = 'read:org'; - - /** - * Publicize and unpublicize organization membership. - */ - const SCOPE_ORG_WRITE = 'write:org'; - - /** - * Fully manage organization, teams, and memberships. - */ - const SCOPE_ORG_ADMIN = 'admin:org'; - - /** - * List and view details for public keys. - */ - const SCOPE_PUBLIC_KEY_READ = 'read:public_key'; - - /** - * Create, list, and view details for public keys. - */ - const SCOPE_PUBLIC_KEY_WRITE = 'write:public_key'; - - /** - * Fully manage public keys. - */ - const SCOPE_PUBLIC_KEY_ADMIN = 'admin:public_key'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.github.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://github.com/login/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://github.com/login/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Github tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * Used to configure response type -- we want JSON from github, default is query string format - * - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } - - /** - * Required for GitHub API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array('Accept' => 'application/vnd.github.beta+json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php deleted file mode 100644 index 096876b6..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException; -use OAuth\Common\Http\Uri\Uri; - -class Google extends AbstractService -{ - /** - * Defined scopes - More scopes are listed here: - * https://developers.google.com/oauthplayground/ - * - * Make a pull request if you need more scopes. - */ - - // Basic - const SCOPE_EMAIL = 'email'; - const SCOPE_PROFILE = 'profile'; - - const SCOPE_USERINFO_EMAIL = 'https://www.googleapis.com/auth/userinfo.email'; - const SCOPE_USERINFO_PROFILE = 'https://www.googleapis.com/auth/userinfo.profile'; - - // Google+ - const SCOPE_GPLUS_ME = 'https://www.googleapis.com/auth/plus.me'; - const SCOPE_GPLUS_LOGIN = 'https://www.googleapis.com/auth/plus.login'; - const SCOPE_GPLUS_CIRCLES_READ = 'https://www.googleapis.com/auth/plus.circles.read'; - const SCOPE_GPLUS_CIRCLES_WRITE = 'https://www.googleapis.com/auth/plus.circles.write'; - const SCOPE_GPLUS_STREAM_READ = 'https://www.googleapis.com/auth/plus.stream.read'; - const SCOPE_GPLUS_STREAM_WRITE = 'https://www.googleapis.com/auth/plus.stream.write'; - const SCOPE_GPLUS_MEDIA = 'https://www.googleapis.com/auth/plus.media.upload'; - - // Google Drive - const SCOPE_DOCUMENTSLIST = 'https://docs.google.com/feeds/'; - const SCOPE_SPREADSHEETS = 'https://spreadsheets.google.com/feeds/'; - const SCOPE_GOOGLEDRIVE = 'https://www.googleapis.com/auth/drive'; - const SCOPE_DRIVE_APPS = 'https://www.googleapis.com/auth/drive.appdata'; - const SCOPE_DRIVE_APPS_READ_ONLY = 'https://www.googleapis.com/auth/drive.apps.readonly'; - const SCOPE_GOOGLEDRIVE_FILES = 'https://www.googleapis.com/auth/drive.file'; - const SCOPE_DRIVE_METADATA_READ_ONLY = 'https://www.googleapis.com/auth/drive.metadata.readonly'; - const SCOPE_DRIVE_READ_ONLY = 'https://www.googleapis.com/auth/drive.readonly'; - const SCOPE_DRIVE_SCRIPTS = 'https://www.googleapis.com/auth/drive.scripts'; - - // Adwords - const SCOPE_ADSENSE = 'https://www.googleapis.com/auth/adsense'; - const SCOPE_ADWORDS = 'https://adwords.google.com/api/adwords/'; - const SCOPE_GAN = 'https://www.googleapis.com/auth/gan'; // google affiliate network...? - - // Google Analytics - const SCOPE_ANALYTICS = 'https://www.googleapis.com/auth/analytics'; - const SCOPE_ANALYTICS_EDIT = 'https://www.googleapis.com/auth/analytics.edit'; - const SCOPE_ANALYTICS_MANAGE_USERS = 'https://www.googleapis.com/auth/analytics.manage.users'; - const SCOPE_ANALYTICS_READ_ONLY = 'https://www.googleapis.com/auth/analytics.readonly'; - - // Other services - const SCOPE_BOOKS = 'https://www.googleapis.com/auth/books'; - const SCOPE_BLOGGER = 'https://www.googleapis.com/auth/blogger'; - const SCOPE_CALENDAR = 'https://www.googleapis.com/auth/calendar'; - const SCOPE_CALENDAR_READ_ONLY = 'https://www.googleapis.com/auth/calendar.readonly'; - const SCOPE_CONTACT = 'https://www.google.com/m8/feeds/'; - const SCOPE_CHROMEWEBSTORE = 'https://www.googleapis.com/auth/chromewebstore.readonly'; - const SCOPE_GMAIL = 'https://mail.google.com/mail/feed/atom'; - const SCOPE_GMAIL_IMAP_SMTP = 'https://mail.google.com'; - const SCOPE_PICASAWEB = 'https://picasaweb.google.com/data/'; - const SCOPE_SITES = 'https://sites.google.com/feeds/'; - const SCOPE_URLSHORTENER = 'https://www.googleapis.com/auth/urlshortener'; - const SCOPE_WEBMASTERTOOLS = 'https://www.google.com/webmasters/tools/feeds/'; - const SCOPE_TASKS = 'https://www.googleapis.com/auth/tasks'; - - // Cloud services - const SCOPE_CLOUDSTORAGE = 'https://www.googleapis.com/auth/devstorage.read_write'; - const SCOPE_CONTENTFORSHOPPING = 'https://www.googleapis.com/auth/structuredcontent'; // what even is this - const SCOPE_USER_PROVISIONING = 'https://apps-apis.google.com/a/feeds/user/'; - const SCOPE_GROUPS_PROVISIONING = 'https://apps-apis.google.com/a/feeds/groups/'; - const SCOPE_NICKNAME_PROVISIONING = 'https://apps-apis.google.com/a/feeds/alias/'; - - // Old - const SCOPE_ORKUT = 'https://www.googleapis.com/auth/orkut'; - const SCOPE_GOOGLELATITUDE = - 'https://www.googleapis.com/auth/latitude.all.best https://www.googleapis.com/auth/latitude.all.city'; - const SCOPE_OPENID = 'openid'; - - // YouTube - const SCOPE_YOUTUBE_GDATA = 'https://gdata.youtube.com'; - const SCOPE_YOUTUBE_ANALYTICS_MONETARY = 'https://www.googleapis.com/auth/yt-analytics-monetary.readonly'; - const SCOPE_YOUTUBE_ANALYTICS = 'https://www.googleapis.com/auth/yt-analytics.readonly'; - const SCOPE_YOUTUBE = 'https://www.googleapis.com/auth/youtube'; - const SCOPE_YOUTUBE_READ_ONLY = 'https://www.googleapis.com/auth/youtube.readonly'; - const SCOPE_YOUTUBE_UPLOAD = 'https://www.googleapis.com/auth/youtube.upload'; - const SCOPE_YOUTUBE_PARTNER = 'https://www.googleapis.com/auth/youtubepartner'; - const SCOPE_YOUTUBE_PARTNER_AUDIT = 'https://www.googleapis.com/auth/youtubepartner-channel-audit'; - - // Google Glass - const SCOPE_GLASS_TIMELINE = 'https://www.googleapis.com/auth/glass.timeline'; - const SCOPE_GLASS_LOCATION = 'https://www.googleapis.com/auth/glass.location'; - - // Android Publisher - const SCOPE_ANDROID_PUBLISHER = 'https://www.googleapis.com/auth/androidpublisher'; - - protected $accessType = 'online'; - - - public function setAccessType($accessType) - { - if (!in_array($accessType, array('online', 'offline'), true)) { - throw new InvalidAccessTypeException('Invalid accessType, expected either online or offline'); - } - $this->accessType = $accessType; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://accounts.google.com/o/oauth2/auth?access_type=' . $this->accessType); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://accounts.google.com/o/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php deleted file mode 100644 index 96fb0f2d..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Token\TokenInterface; -use OAuth\OAuth2\Token\StdOAuth2Token; - -class Harvest extends AbstractService -{ - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.harvestapp.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'state' => 'optional-csrf-token', - 'response_type' => 'code', - ) - ); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.harvestapp.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.harvestapp.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || ! is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - $token->setRefreshToken($data['refresh_token']); - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * Refreshes an OAuth2 access token. - * - * @param TokenInterface $token - * - * @return TokenInterface $token - * - * @throws MissingRefreshTokenException - */ - public function refreshAccessToken(TokenInterface $token) - { - $refreshToken = $token->getRefreshToken(); - - if (empty($refreshToken)) { - throw new MissingRefreshTokenException(); - } - - $parameters = array( - 'grant_type' => 'refresh_token', - 'type' => 'web_server', - 'client_id' => $this->credentials->getConsumerId(), - 'client_secret' => $this->credentials->getConsumerSecret(), - 'refresh_token' => $refreshToken, - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $parameters, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - /** - * @return array - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } - - /** - * Return any additional headers always needed for this service implementation's API calls. - * - * @return array - */ - protected function getExtraApiHeaders() - { - return array('Accept' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php deleted file mode 100644 index 470cedc3..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Heroku service. - * - * @author Thomas Welton <thomaswelton@me.com> - * @link https://devcenter.heroku.com/articles/oauth - */ -class Heroku extends AbstractService -{ - /** - * Defined scopes - * @link https://devcenter.heroku.com/articles/oauth#scopes - */ - const SCOPE_GLOBAL = 'global'; - const SCOPE_IDENTITY = 'identity'; - const SCOPE_READ = 'read'; - const SCOPE_WRITE = 'write'; - const SCOPE_READ_PROTECTED = 'read-protected'; - const SCOPE_WRITE_PROTECTED = 'write-protected'; - - /** - * {@inheritdoc} - */ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.heroku.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://id.heroku.com/oauth/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://id.heroku.com/oauth/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error_description']) || isset($data['error'])) { - throw new TokenResponseException( - sprintf( - 'Error in retrieving token: "%s"', - isset($data['error_description']) ? $data['error_description'] : $data['error'] - ) - ); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/vnd.heroku+json; version=3'); - } - - /** - * {@inheritdoc} - */ - protected function getExtraApiHeaders() - { - return array('Accept' => 'application/vnd.heroku+json; version=3', 'Content-Type' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php deleted file mode 100644 index 49e9c8c9..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Instagram extends AbstractService -{ - /** - * Defined scopes - * @link http://instagram.com/developer/authentication/#scope - */ - const SCOPE_BASIC = 'basic'; - const SCOPE_COMMENTS = 'comments'; - const SCOPE_RELATIONSHIPS = 'relationships'; - const SCOPE_LIKES = 'likes'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.instagram.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://api.instagram.com/oauth/authorize/'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.instagram.com/oauth/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Instagram tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php deleted file mode 100644 index bb801e6a..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Linkedin service. - * - * @author Antoine Corcy <contact@sbin.dk> - * @link http://developer.linkedin.com/documents/authentication - */ -class Linkedin extends AbstractService -{ - /** - * Defined scopes - * @link http://developer.linkedin.com/documents/authentication#granting - */ - const SCOPE_R_BASICPROFILE = 'r_basicprofile'; - const SCOPE_R_FULLPROFILE = 'r_fullprofile'; - const SCOPE_R_EMAILADDRESS = 'r_emailaddress'; - const SCOPE_R_NETWORK = 'r_network'; - const SCOPE_R_CONTACTINFO = 'r_contactinfo'; - const SCOPE_RW_NUS = 'rw_nus'; - const SCOPE_RW_COMPANY_ADMIN = 'rw_company_admin'; - const SCOPE_RW_GROUPS = 'rw_groups'; - const SCOPE_W_MESSAGES = 'w_messages'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.linkedin.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.linkedin.com/uas/oauth2/authorization'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.linkedin.com/uas/oauth2/accessToken'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING_V2; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php deleted file mode 100644 index 42abd3c1..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Mailchimp extends AbstractService -{ - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (is_null($this->baseApiUri) && $storage->hasAccessToken($this->service())) { - $this->setBaseApiUri($storage->retrieveAccessToken($this->service())); - } - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING_V3; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://login.mailchimp.com/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://login.mailchimp.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - // Parse JSON - $data = json_decode($responseBody, true); - - // Do validation. - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - // Create token object. - $token = new StdOAuth2Token($data['access_token']); - - // Set the right API endpoint. - $this->setBaseApiUri($token); - - // Mailchimp tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - - return $token; - } - - /** - * {@inheritdoc} - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - if (is_null($this->baseApiUri)) { - $this->setBaseApiUri($this->storage->retrieveAccessToken($this->service())); - } - - return parent::request($path, $method, $body, $extraHeaders); - } - - /** - * Set the right base endpoint. - * - * @param StdOAuth2Token $token - */ - protected function setBaseApiUri(StdOAuth2Token $token) - { - // Make request uri. - $endpoint = 'https://login.mailchimp.com/oauth2/metadata?oauth_token='. $token->getAccessToken(); - - // Grab meta data about the token. - $response = $this->httpClient->retrieveResponse(new Uri($endpoint), array(), array(), 'GET'); - - // Parse JSON. - $meta = json_decode($response, true); - - // Set base api uri. - $this->baseApiUri = new Uri('https://'. $meta['dc'] .'.api.mailchimp.com/2.0/'); - - // Allow chaining. - return $this; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php deleted file mode 100644 index 183ef452..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Microsoft extends AbstractService -{ - const SCOPE_BASIC = 'wl.basic'; - const SCOPE_OFFLINE = 'wl.offline_access'; - const SCOPE_SIGNIN = 'wl.signin'; - const SCOPE_BIRTHDAY = 'wl.birthday'; - const SCOPE_CALENDARS = 'wl.calendars'; - const SCOPE_CALENDARS_UPDATE = 'wl.calendars_update'; - const SCOPE_CONTACTS_BIRTHDAY = 'wl.contacts_birthday'; - const SCOPE_CONTACTS_CREATE = 'wl.contacts_create'; - const SCOPE_CONTACTS_CALENDARS = 'wl.contacts_calendars'; - const SCOPE_CONTACTS_PHOTOS = 'wl.contacts_photos'; - const SCOPE_CONTACTS_SKYDRIVE = 'wl.contacts_skydrive'; - const SCOPE_EMAILS = 'wl.emails'; - const SCOPE_EVENTS_CREATE = 'wl.events_create'; - const SCOPE_MESSENGER = 'wl.messenger'; - const SCOPE_PHONE_NUMBERS = 'wl.phone_numbers'; - const SCOPE_PHOTOS = 'wl.photos'; - const SCOPE_POSTAL_ADDRESSES = 'wl.postal_addresses'; - const SCOPE_SHARE = 'wl.share'; - const SCOPE_SKYDRIVE = 'wl.skydrive'; - const SCOPE_SKYDRIVE_UPDATE = 'wl.skydrive_update'; - const SCOPE_WORK_PROFILE = 'wl.work_profile'; - const SCOPE_APPLICATIONS = 'wl.applications'; - const SCOPE_APPLICATIONS_CREATE = 'wl.applications_create'; - - /** - * MS uses some magical not officialy supported scope to get even moar info like full emailaddresses. - * They agree that giving 3rd party apps access to 3rd party emailaddresses is a pretty lame thing to do so in all - * their wisdom they added this scope because fuck you that's why. - * - * https://github.com/Lusitanian/PHPoAuthLib/issues/214 - * http://social.msdn.microsoft.com/Forums/live/en-US/c6dcb9ab-aed4-400a-99fb-5650c393a95d/how-retrieve-users- - * contacts-email-address?forum=messengerconnect - * - * Considering this scope is not officially supported: use with care - */ - const SCOPE_CONTACTS_EMAILS = 'wl.contacts_emails'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://apis.live.net/v5.0/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://login.live.com/oauth20_authorize.srf'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://login.live.com/oauth20_token.srf'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifetime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php deleted file mode 100644 index 761c09d6..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * PayPal service. - * - * @author Flávio Heleno <flaviohbatista@gmail.com> - * @link https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/ - */ -class Paypal extends AbstractService -{ - /** - * Defined scopes - * @link https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/ - * @see #attributes - */ - const SCOPE_OPENID = 'openid'; - const SCOPE_PROFILE = 'profile'; - const SCOPE_PAYPALATTRIBUTES = 'https://uri.paypal.com/services/paypalattributes'; - const SCOPE_EMAIL = 'email'; - const SCOPE_ADDRESS = 'address'; - const SCOPE_PHONE = 'phone'; - const SCOPE_EXPRESSCHECKOUT = 'https://uri.paypal.com/services/expresscheckout'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.paypal.com/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.paypal.com/v1/identity/openidconnect/tokenservice'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['message'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['message'] . '"'); - } elseif (isset($data['name'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['name'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php deleted file mode 100644 index 8c955440..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; - -class Pocket extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - if ($baseApiUri === null) { - $this->baseApiUri = new Uri('https://getpocket.com/v3/'); - } - } - - public function getRequestTokenEndpoint() - { - return new Uri('https://getpocket.com/v3/oauth/request'); - } - - public function getAuthorizationEndpoint() - { - return new Uri('https://getpocket.com/auth/authorize'); - } - - public function getAccessTokenEndpoint() - { - return new Uri('https://getpocket.com/v3/oauth/authorize'); - } - - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'redirect_uri' => $this->credentials->getCallbackUrl(), - ) - ); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - public function requestRequestToken() - { - $responseBody = $this->httpClient->retrieveResponse( - $this->getRequestTokenEndpoint(), - array( - 'consumer_key' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - ) - ); - - $code = $this->parseRequestTokenResponse($responseBody); - - return $code; - } - - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['code'])) { - throw new TokenResponseException('Error in retrieving code.'); - } - return $data['code']; - } - - public function requestAccessToken($code) - { - $bodyParams = array( - 'consumer_key' => $this->credentials->getConsumerId(), - 'code' => $code, - ); - - $responseBody = $this->httpClient->retrieveResponse( - $this->getAccessTokenEndpoint(), - $bodyParams, - $this->getExtraOAuthHeaders() - ); - $token = $this->parseAccessTokenResponse($responseBody); - $this->storage->storeAccessToken($this->service(), $token); - - return $token; - } - - protected function parseAccessTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if ($data === null || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - #$token->setRequestToken($data['access_token']); - $token->setAccessToken($data['access_token']); - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php deleted file mode 100644 index 9e524d12..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Reddit extends AbstractService -{ - /** - * Defined scopes - * - * @link http://www.reddit.com/dev/api/oauth - */ - // User scopes - const SCOPE_EDIT = 'edit'; - const SCOPE_HISTORY = 'history'; - const SCOPE_IDENTITY = 'identity'; - const SCOPE_MYSUBREDDITS = 'mysubreddits'; - const SCOPE_PRIVATEMESSAGES = 'privatemessages'; - const SCOPE_READ = 'read'; - const SCOPE_SAVE = 'save'; - const SCOPE_SUBMIT = 'submit'; - const SCOPE_SUBSCRIBE = 'subscribe'; - const SCOPE_VOTE = 'vote'; - // Mod Scopes - const SCOPE_MODCONFIG = 'modconfig'; - const SCOPE_MODFLAIR = 'modflair'; - const SCOPE_MODLOG = 'modlog'; - const SCOPE_MODPOST = 'modpost'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://oauth.reddit.com'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://ssl.reddit.com/api/v1/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://ssl.reddit.com/api/v1/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - // Reddit uses a Basic OAuth header - return array('Authorization' => 'Basic ' . - base64_encode($this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret())); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php deleted file mode 100644 index 71584076..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * RunKeeper service. - * - * @link http://runkeeper.com/developer/healthgraph/registration-authorization - */ -class RunKeeper extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.runkeeper.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - $parameters = array_merge( - $additionalParameters, - array( - 'client_id' => $this->credentials->getConsumerId(), - 'redirect_uri' => $this->credentials->getCallbackUrl(), - 'response_type' => 'code', - ) - ); - - $parameters['scope'] = implode(' ', $this->scopes); - - // Build the url - $url = clone $this->getAuthorizationEndpoint(); - foreach ($parameters as $key => $val) { - $url->addToQuery($key, $val); - } - - return $url; - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://runkeeper.com/apps/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://runkeeper.com/apps/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php deleted file mode 100644 index 583e4347..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Service\AbstractService; -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class SalesforceService extends AbstractService -{ - /** - * Scopes - * - * @var string - */ - const SCOPE_API = 'api', - SCOPE_REFRESH_TOKEN = 'refresh_token'; - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://login.salesforce.com/services/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://na1.salesforce.com/services/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - parse_str($responseBody, $data); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') { - throw new TokenResponseException('Error in retrieving token.'); - } - - return $this->parseAccessTokenResponse($responseBody); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - // Salesforce tokens evidently never expire... - $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); - unset($data['access_token']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Accept' => 'application/json'); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php deleted file mode 100644 index f3d1bdad..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Service\ServiceInterface as BaseServiceInterface; -use OAuth\Common\Http\Uri\UriInterface; - -/** - * Defines the common methods across OAuth 2 services. - */ -interface ServiceInterface extends BaseServiceInterface -{ - /** - * Authorization methods for various services - */ - const AUTHORIZATION_METHOD_HEADER_OAUTH = 0; - const AUTHORIZATION_METHOD_HEADER_BEARER = 1; - const AUTHORIZATION_METHOD_QUERY_STRING = 2; - const AUTHORIZATION_METHOD_QUERY_STRING_V2 = 3; - const AUTHORIZATION_METHOD_QUERY_STRING_V3 = 4; - - /** - * Retrieves and stores/returns the OAuth2 access token after a successful authorization. - * - * @param string $code The access code from the callback. - * - * @return TokenInterface $token - * - * @throws TokenResponseException - */ - public function requestAccessToken($code); -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/SoundCloud.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/SoundCloud.php deleted file mode 100644 index 32a3b46c..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/SoundCloud.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class SoundCloud extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.soundcloud.com/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://soundcloud.com/connect'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://api.soundcloud.com/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - - if (isset($data['expires_in'])) { - $token->setLifetime($data['expires_in']); - unset($data['expires_in']); - } - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php deleted file mode 100644 index 7e558153..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php +++ /dev/null @@ -1,98 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Ustream extends AbstractService -{ - /** - * Scopes - * - * @var string - */ - const SCOPE_OFFLINE = 'offline'; - const SCOPE_BROADCASTER = 'broadcaster'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.ustream.tv/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.ustream.tv/oauth2/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.ustream.tv/oauth2/token'); - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getExtraOAuthHeaders() - { - return array('Authorization' => 'Basic ' . $this->credentials->getConsumerSecret()); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php deleted file mode 100644 index 4a7744ec..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Vkontakte extends AbstractService -{ - /** - * Defined scopes - * - * @link http://vk.com/dev/permissions - */ - const SCOPE_EMAIL = 'email'; - const SCOPE_NOTIFY = 'notify'; - const SCOPE_FRIENDS = 'friends'; - const SCOPE_PHOTOS = 'photos'; - const SCOPE_AUDIO = 'audio'; - const SCOPE_VIDEO = 'video'; - const SCOPE_DOCS = 'docs'; - const SCOPE_NOTES = 'notes'; - const SCOPE_PAGES = 'pages'; - const SCOPE_APP_LINK = ''; - const SCOPE_STATUS = 'status'; - const SCOPE_OFFERS = 'offers'; - const SCOPE_QUESTIONS = 'questions'; - const SCOPE_WALL = 'wall'; - const SCOPE_GROUPS = 'groups'; - const SCOPE_MESSAGES = 'messages'; - const SCOPE_NOTIFICATIONS = 'notifications'; - const SCOPE_STATS = 'stats'; - const SCOPE_ADS = 'ads'; - const SCOPE_OFFLINE = 'offline'; - const SCOPE_NOHTTPS = 'nohttps'; - - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://api.vk.com/method/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://oauth.vk.com/authorize'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://oauth.vk.com/access_token'); - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']); - $token->setLifeTime($data['expires_in']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } - - /** - * {@inheritdoc} - */ - protected function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_QUERY_STRING; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php deleted file mode 100644 index 994a2935..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php +++ /dev/null @@ -1,82 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Service; - -use OAuth\OAuth2\Token\StdOAuth2Token; -use OAuth\Common\Http\Exception\TokenResponseException; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Yammer extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); - - if (null === $baseApiUri) { - $this->baseApiUri = new Uri('https://www.yammer.com/api/v1/'); - } - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - return new Uri('https://www.yammer.com/dialog/oauth'); - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - return new Uri('https://www.yammer.com/oauth2/access_token.json'); - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationMethod() - { - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - $data = json_decode($responseBody, true); - - if (null === $data || !is_array($data)) { - throw new TokenResponseException('Unable to parse response.'); - } elseif (isset($data['error'])) { - throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); - } - - $token = new StdOAuth2Token(); - $token->setAccessToken($data['access_token']['token']); - $token->setLifetime($data['access_token']['expires_at']); - - if (isset($data['refresh_token'])) { - $token->setRefreshToken($data['refresh_token']); - unset($data['refresh_token']); - } - - unset($data['access_token']); - unset($data['expires_in']); - - $token->setExtraParams($data); - - return $token; - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php deleted file mode 100644 index eaaacac7..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Token; - -use OAuth\Common\Token\AbstractToken; - -/** - * Standard OAuth2 token implementation. - * Implements OAuth\OAuth2\Token\TokenInterface for any functionality that might not be provided by AbstractToken. - */ -class StdOAuth2Token extends AbstractToken implements TokenInterface -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/TokenInterface.php deleted file mode 100644 index aa592aa1..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/TokenInterface.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -namespace OAuth\OAuth2\Token; - -use OAuth\Common\Token\TokenInterface as BaseTokenInterface; - -interface TokenInterface extends BaseTokenInterface -{ -} diff --git a/vendor/lusitanian/oauth/src/OAuth/ServiceFactory.php b/vendor/lusitanian/oauth/src/OAuth/ServiceFactory.php deleted file mode 100644 index 2be9c463..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/ServiceFactory.php +++ /dev/null @@ -1,229 +0,0 @@ -<?php - -/** - * OAuth service factory. - * - * PHP version 5.4 - * - * @category OAuth - * @author David Desberg <david@daviddesberg.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2013 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth; - -use OAuth\Common\Service\ServiceInterface; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Http\Client\StreamClient; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Exception\Exception; -use OAuth\OAuth1\Signature\Signature; - -class ServiceFactory -{ - /** - *@var ClientInterface - */ - protected $httpClient; - - /** - * @var array - */ - protected $serviceClassMap = array( - 'OAuth1' => array(), - 'OAuth2' => array() - ); - - /** - * @var array - */ - protected $serviceBuilders = array( - 'OAuth2' => 'buildV2Service', - 'OAuth1' => 'buildV1Service', - ); - - /** - * @param ClientInterface $httpClient - * - * @return ServiceFactory - */ - public function setHttpClient(ClientInterface $httpClient) - { - $this->httpClient = $httpClient; - - return $this; - } - - /** - * Register a custom service to classname mapping. - * - * @param string $serviceName Name of the service - * @param string $className Class to instantiate - * - * @return ServiceFactory - * - * @throws Exception If the class is nonexistent or does not implement a valid ServiceInterface - */ - public function registerService($serviceName, $className) - { - if (!class_exists($className)) { - throw new Exception(sprintf('Service class %s does not exist.', $className)); - } - - $reflClass = new \ReflectionClass($className); - - foreach (array('OAuth2', 'OAuth1') as $version) { - if ($reflClass->implementsInterface('OAuth\\' . $version . '\\Service\\ServiceInterface')) { - $this->serviceClassMap[$version][ucfirst($serviceName)] = $className; - - return $this; - } - } - - throw new Exception(sprintf('Service class %s must implement ServiceInterface.', $className)); - } - - /** - * Builds and returns oauth services - * - * It will first try to build an OAuth2 service and if none found it will try to build an OAuth1 service - * - * @param string $serviceName Name of service to create - * @param CredentialsInterface $credentials - * @param TokenStorageInterface $storage - * @param array|null $scopes If creating an oauth2 service, array of scopes - * @param UriInterface|null $baseApiUri - * - * @return ServiceInterface - */ - public function createService( - $serviceName, - CredentialsInterface $credentials, - TokenStorageInterface $storage, - $scopes = array(), - UriInterface $baseApiUri = null - ) { - if (!$this->httpClient) { - // for backwards compatibility. - $this->httpClient = new StreamClient(); - } - - foreach ($this->serviceBuilders as $version => $buildMethod) { - $fullyQualifiedServiceName = $this->getFullyQualifiedServiceName($serviceName, $version); - - if (class_exists($fullyQualifiedServiceName)) { - return $this->$buildMethod($fullyQualifiedServiceName, $credentials, $storage, $scopes, $baseApiUri); - } - } - - return null; - } - - /** - * Gets the fully qualified name of the service - * - * @param string $serviceName The name of the service of which to get the fully qualified name - * @param string $type The type of the service to get (either OAuth1 or OAuth2) - * - * @return string The fully qualified name of the service - */ - private function getFullyQualifiedServiceName($serviceName, $type) - { - $serviceName = ucfirst($serviceName); - - if (isset($this->serviceClassMap[$type][$serviceName])) { - return $this->serviceClassMap[$type][$serviceName]; - } - - return '\\OAuth\\' . $type . '\\Service\\' . $serviceName; - } - - /** - * Builds v2 services - * - * @param string $serviceName The fully qualified service name - * @param CredentialsInterface $credentials - * @param TokenStorageInterface $storage - * @param array|null $scopes Array of scopes for the service - * @param UriInterface|null $baseApiUri - * - * @return ServiceInterface - * - * @throws Exception - */ - private function buildV2Service( - $serviceName, - CredentialsInterface $credentials, - TokenStorageInterface $storage, - array $scopes, - UriInterface $baseApiUri = null - ) { - return new $serviceName( - $credentials, - $this->httpClient, - $storage, - $this->resolveScopes($serviceName, $scopes), - $baseApiUri - ); - } - - /** - * Resolves scopes for v2 services - * - * @param string $serviceName The fully qualified service name - * @param array $scopes List of scopes for the service - * - * @return array List of resolved scopes - */ - private function resolveScopes($serviceName, array $scopes) - { - $reflClass = new \ReflectionClass($serviceName); - $constants = $reflClass->getConstants(); - - $resolvedScopes = array(); - foreach ($scopes as $scope) { - $key = strtoupper('SCOPE_' . $scope); - - if (array_key_exists($key, $constants)) { - $resolvedScopes[] = $constants[$key]; - } else { - $resolvedScopes[] = $scope; - } - } - - return $resolvedScopes; - } - - /** - * Builds v1 services - * - * @param string $serviceName The fully qualified service name - * @param CredentialsInterface $credentials - * @param TokenStorageInterface $storage - * @param array $scopes - * @param UriInterface $baseApiUri - * - * @return ServiceInterface - * - * @throws Exception - */ - private function buildV1Service( - $serviceName, - CredentialsInterface $credentials, - TokenStorageInterface $storage, - $scopes, - UriInterface $baseApiUri = null - ) { - if (!empty($scopes)) { - throw new Exception( - 'Scopes passed to ServiceFactory::createService but an OAuth1 service was requested.' - ); - } - - return new $serviceName($credentials, $this->httpClient, $storage, new Signature($credentials), $baseApiUri); - } -} diff --git a/vendor/lusitanian/oauth/src/OAuth/bootstrap.php b/vendor/lusitanian/oauth/src/OAuth/bootstrap.php deleted file mode 100644 index 548678aa..00000000 --- a/vendor/lusitanian/oauth/src/OAuth/bootstrap.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -/* - * Bootstrap the library. - */ - -namespace OAuth; - -require_once __DIR__ . '/Common/AutoLoader.php'; - -$autoloader = new Common\AutoLoader(__NAMESPACE__, dirname(__DIR__)); - -$autoloader->register(); diff --git a/vendor/lusitanian/oauth/tests/Mocks/Common/FakeProject/NS/SomeClass.php b/vendor/lusitanian/oauth/tests/Mocks/Common/FakeProject/NS/SomeClass.php deleted file mode 100644 index c033c4e2..00000000 --- a/vendor/lusitanian/oauth/tests/Mocks/Common/FakeProject/NS/SomeClass.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace FakeProject\NS; - -class SomeClass -{ - public function isLoaded() - { - return true; - } -} diff --git a/vendor/lusitanian/oauth/tests/Mocks/Common/Service/Mock.php b/vendor/lusitanian/oauth/tests/Mocks/Common/Service/Mock.php deleted file mode 100644 index a812c7d1..00000000 --- a/vendor/lusitanian/oauth/tests/Mocks/Common/Service/Mock.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -namespace OAuthTest\Mocks\Common\Service; - -use OAuth\Common\Service\AbstractService; -use OAuth\Common\Http\Uri\UriInterface; - -class Mock extends AbstractService -{ - /** - * Sends an authenticated API request to the path provided. - * If the path provided is not an absolute URI, the base API Uri (service-specific) will be used. - * - * @param string|UriInterface $path - * @param string $method HTTP method - * @param array $body Request body if applicable (an associative array will - * automatically be converted into a urlencoded body) - * @param array $extraHeaders Extra headers if applicable. These will override service-specific - * any defaults. - * - * @return string - */ - public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) - { - } - - /** - * Returns the url to redirect to for authorization purposes. - * - * @param array $additionalParameters - * - * @return UriInterface - */ - public function getAuthorizationUri(array $additionalParameters = array()) - { - } - - /** - * Returns the authorization API endpoint. - * - * @return UriInterface - */ - public function getAuthorizationEndpoint() - { - } - - /** - * Returns the access token API endpoint. - * - * @return UriInterface - */ - public function getAccessTokenEndpoint() - { - } - - public function testDetermineRequestUriFromPath($path, UriInterface $baseApiUri = null) - { - return $this->determineRequestUriFromPath($path, $baseApiUri); - } -} diff --git a/vendor/lusitanian/oauth/tests/Mocks/OAuth1/Service/Fake.php b/vendor/lusitanian/oauth/tests/Mocks/OAuth1/Service/Fake.php deleted file mode 100644 index 5dac52e7..00000000 --- a/vendor/lusitanian/oauth/tests/Mocks/OAuth1/Service/Fake.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -namespace OAuthTest\Mocks\OAuth1\Service; - -use OAuth\OAuth1\Service\AbstractService; -use OAuth\Common\Consumer\CredentialsInterface; -use OAuth\Common\Http\Client\ClientInterface; -use OAuth\Common\Storage\TokenStorageInterface; -use OAuth\OAuth1\Signature\SignatureInterface; -use OAuth\Common\Http\Uri\UriInterface; - -class Fake extends AbstractService -{ - public function __construct( - CredentialsInterface $credentials, - ClientInterface $httpClient, - TokenStorageInterface $storage, - SignatureInterface $signature, - UriInterface $baseApiUri = null - ) { - } - - /** - * {@inheritdoc} - */ - public function getRequestTokenEndpoint() - { - } - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - } - - /** - * {@inheritdoc} - */ - protected function parseRequestTokenResponse($responseBody) - { - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - } -} diff --git a/vendor/lusitanian/oauth/tests/Mocks/OAuth1/Service/Mock.php b/vendor/lusitanian/oauth/tests/Mocks/OAuth1/Service/Mock.php deleted file mode 100644 index 9f0bf27f..00000000 --- a/vendor/lusitanian/oauth/tests/Mocks/OAuth1/Service/Mock.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace OAuthTest\Mocks\OAuth1\Service; - -use OAuth\OAuth1\Service\AbstractService; -use OAuth\Common\Http\Uri\Uri; -use OAuth\OAuth1\Token\StdOAuth1Token; - -class Mock extends AbstractService -{ - public function getRequestTokenEndpoint() - { - return new Uri('http://pieterhordijk.com/token'); - } - - public function getAuthorizationEndpoint() - { - return new Uri('http://pieterhordijk.com/auth'); - } - - public function getAccessTokenEndpoint() - { - return new Uri('http://pieterhordijk.com/access'); - } - - protected function parseRequestTokenResponse($responseBody) - { - return new StdOAuth1Token(); - } - - protected function parseAccessTokenResponse($responseBody) - { - return new StdOAuth1Token(); - } -} diff --git a/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Fake.php b/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Fake.php deleted file mode 100644 index d8de2b00..00000000 --- a/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Fake.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -namespace OAuthTest\Mocks\OAuth2\Service; - -use OAuth\OAuth2\Service\AbstractService; - -class Fake extends AbstractService -{ - const SCOPE_FOO = 'https://www.pieterhordijk.com/auth'; - const SCOPE_CUSTOM = 'custom'; - - /** - * {@inheritdoc} - */ - public function getAuthorizationEndpoint() - { - } - - /** - * {@inheritdoc} - */ - public function getAccessTokenEndpoint() - { - } - - /** - * {@inheritdoc} - */ - protected function parseAccessTokenResponse($responseBody) - { - } -} diff --git a/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php b/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php deleted file mode 100644 index 508aea00..00000000 --- a/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -namespace OAuthTest\Mocks\OAuth2\Service; - -use OAuth\OAuth2\Service\AbstractService; -use OAuth\Common\Http\Uri\Uri; -use OAuth\OAuth2\Token\StdOAuth2Token; - -class Mock extends AbstractService -{ - const SCOPE_MOCK = 'mock'; - const SCOPE_MOCK_2 = 'mock2'; - - private $authorizationMethod = null; - - public function getAuthorizationEndpoint() - { - return new Uri('http://pieterhordijk.com/auth'); - } - - public function getAccessTokenEndpoint() - { - return new Uri('http://pieterhordijk.com/access'); - } - - protected function parseAccessTokenResponse($responseBody) - { - return new StdOAuth2Token(); - } - - // this allows us to set different auth methods for tests - public function setAuthorizationMethod($method) - { - $this->authorizationMethod = $method; - } - - /** - * Returns a class constant from ServiceInterface defining the authorization method used for the API - * Header is the sane default. - * - * @return int - */ - protected function getAuthorizationMethod() - { - switch($this->authorizationMethod) { - case 'querystring': - return static::AUTHORIZATION_METHOD_QUERY_STRING; - - case 'querystring2': - return static::AUTHORIZATION_METHOD_QUERY_STRING_V2; - - case 'bearer': - return static::AUTHORIZATION_METHOD_HEADER_BEARER; - } - - return parent::getAuthorizationMethod(); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/AutoloaderTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/AutoloaderTest.php deleted file mode 100644 index eebc3408..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/AutoloaderTest.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Commen\Core; - -use OAuth\Common\AutoLoader; - -class AutoLoaderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - */ - public function testRegister() - { - $autoloader = new AutoLoader('Test', '/'); - - $this->assertTrue($autoloader->register()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::unregister - */ - public function testUnregister() - { - $autoloader = new AutoLoader('Test', '/'); - - $this->assertTrue($autoloader->register()); - $this->assertTrue($autoloader->unregister()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccess() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraSlashedNamespace() - { - $autoloader = new AutoLoader('\\\\FakeProject', dirname(__DIR__) . '/../Mocks/Common'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraForwardSlashedPath() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common//'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraBackwardSlashedPath() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common\\'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraMixedSlashedPath() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common\\\\/\\//'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadUnknownClass() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common\\\\/\\//'); - - $this->assertTrue($autoloader->register()); - - $this->assertFalse($autoloader->load('IDontExistClass')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Consumer/CredentialsTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Consumer/CredentialsTest.php deleted file mode 100644 index 1a895fbc..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Consumer/CredentialsTest.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace OAuth\Unit\Common\Consumer; - -use OAuth\Common\Consumer\Credentials; - -class CredentialsTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - */ - public function testConstructCorrectInterface() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertInstanceOf('\\OAuth\\Common\\Consumer\\CredentialsInterface', $credentials); - } - - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - * @covers OAuth\Common\Consumer\Credentials::getConsumerId - */ - public function testGetConsumerId() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertSame('foo', $credentials->getConsumerId()); - } - - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - * @covers OAuth\Common\Consumer\Credentials::getConsumerSecret - */ - public function testGetConsumerSecret() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertSame('bar', $credentials->getConsumerSecret()); - } - - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - * @covers OAuth\Common\Consumer\Credentials::getCallbackUrl - */ - public function testGetCallbackUrl() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertSame('baz', $credentials->getCallbackUrl()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/AbstractClientTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/AbstractClientTest.php deleted file mode 100644 index b3531527..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/AbstractClientTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http; - -class AbstractClientTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - */ - public function testConstructCorrectInterface() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client); - } - - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - * @covers OAuth\Common\Http\Client\AbstractClient::setMaxRedirects - */ - public function testSetMaxRedirects() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client->setMaxRedirects(10)); - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client->setMaxRedirects(10)); - } - - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - * @covers OAuth\Common\Http\Client\AbstractClient::setTimeout - */ - public function testSetTimeout() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client->setTimeout(25)); - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client->setTimeout(25)); - } - - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - * @covers OAuth\Common\Http\Client\AbstractClient::normalizeHeaders - */ - public function testNormalizeHeaders() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $original = array( - 'lowercasekey' => 'lowercasevalue', - 'UPPERCASEKEY' => 'UPPERCASEVALUE', - 'mIxEdCaSeKey' => 'MiXeDcAsEvAlUe', - '31i71casekey' => '31i71casevalue', - ); - - $goal = array( - 'lowercasekey' => 'Lowercasekey: lowercasevalue', - 'UPPERCASEKEY' => 'Uppercasekey: UPPERCASEVALUE', - 'mIxEdCaSeKey' => 'Mixedcasekey: MiXeDcAsEvAlUe', - '31i71casekey' => '31i71casekey: 31i71casevalue', - ); - - $client->normalizeHeaders($original); - - $this->assertSame($goal, $original); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/CurlClientTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/CurlClientTest.php deleted file mode 100644 index f635ce89..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/CurlClientTest.php +++ /dev/null @@ -1,378 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Client; - -use OAuth\Common\Http\Client\CurlClient; - -class CurlClientTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInstance() - { - $client = new CurlClient(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::setForceSSL3 - */ - public function testSetForceSSL3() - { - $client = new CurlClient(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\CurlClient', $client->setForceSSL3(true)); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBody() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new CurlClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'GET' - ); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBodyMethodConvertedToUpper() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new CurlClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'get' - ); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseDefaultUserAgent() - { - $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/get')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('PHPoAuthLib', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseCustomUserAgent() - { - $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/get')); - - $client = new CurlClient('My Super Awesome Http Client'); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('My Super Awesome Http Client', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseWithCustomContentType() - { - $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/get')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseWithFormUrlEncodedContentType() - { - $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/post')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('application/x-www-form-urlencoded', $response['headers']['Content-Type']); - $this->assertEquals(array('foo' => 'bar', 'baz' => 'fab'), $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseHost() - { - $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/post')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('httpbin.org', $response['headers']['Host']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponsePostRequestWithRequestBodyAsString() - { - $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/post')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponsePutRequestWithRequestBodyAsString() - { - $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/put')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'PUT' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponsePutRequestWithRequestBodyAsStringNoRedirects() - { - $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/put')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new CurlClient(); - - $client->setMaxRedirects(0); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'PUT' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseWithForcedSsl3() - { - $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('https://httpbin.org/get')); - - $client = new CurlClient(); - - $client->setForceSSL3(true); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnInvalidUrl() - { - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('jkehfkefcmekjhcnkerjh')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('jkehfkefcmekjhcnkerjh')); - - $client = new CurlClient(); - - $client->setForceSSL3(true); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - 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']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/StreamClientTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/StreamClientTest.php deleted file mode 100644 index f634f406..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/StreamClientTest.php +++ /dev/null @@ -1,283 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Client; - -use OAuth\Common\Http\Client\StreamClient; - -class StreamClientTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInstance() - { - $client = new StreamClient(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBody() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new StreamClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'GET' - ); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBodyMethodConvertedToUpper() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new StreamClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'get' - ); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseDefaultUserAgent() - { - $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/get')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('PHPoAuthLib', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseCustomUserAgent() - { - $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/get')); - - $client = new StreamClient('My Super Awesome Http Client'); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('My Super Awesome Http Client', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseWithCustomContentType() - { - $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/get')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseWithFormUrlEncodedContentType() - { - $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/post')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('application/x-www-form-urlencoded', $response['headers']['Content-Type']); - $this->assertEquals(array('foo' => 'bar', 'baz' => 'fab'), $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseHost() - { - $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/post')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('httpbin.org', $response['headers']['Host']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponsePostRequestWithRequestBodyAsString() - { - $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/post')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponsePutRequestWithRequestBodyAsString() - { - $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/put')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'PUT' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseThrowsExceptionOnInvalidRequest() - { - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('dskjhfckjhekrsfhkehfkreljfrekljfkre')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('dskjhfckjhekrsfhkehfkreljfrekljfkre')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/HttpClientsTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/HttpClientsTest.php deleted file mode 100644 index 6fa9eace..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/HttpClientsTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Http; - -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Http\Client; - -class HttpClientsTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var object|\OAuth\Common\Http\Client\ClientInterface[] - */ - protected $clients; - - public function setUp() - { - $streamClient = new Client\StreamClient(); - $streamClient->setTimeout(3); - - $curlClient = new Client\CurlClient(); - $curlClient->setTimeout(3); - - $this->clients[] = $streamClient; - $this->clients[] = $curlClient; - } - - public function tearDown() - { - foreach ($this->clients as $client) { - unset($client); - } - } - - /** - * Test that extra headers are passed properly - */ - public function testHeaders() - { - $testUri = new Uri('http://httpbin.org/get'); - - $me = $this; - $headerCb = function ($response) use ($me) { - $data = json_decode($response, true); - $me->assertEquals('extraheadertest', $data['headers']['Testingheader']); - }; - - $this->__doTestRetrieveResponse($testUri, array(), array('Testingheader' => 'extraheadertest'), 'GET', $headerCb); - } - - /** - * Tests that we get an exception for a >= 400 status code - */ - public function testException() - { - // sending a post here should get us a 405 which should trigger an exception - $testUri = new Uri('http://httpbin.org/delete'); - foreach ($this->clients as $client) { - $this->setExpectedException('OAuth\Common\Http\Exception\TokenResponseException'); - $client->retrieveResponse($testUri, array('blah' => 'blih')); - } - } - - /** - * Tests the DELETE method - */ - public function testDelete() - { - $testUri = new Uri('http://httpbin.org/delete'); - - $me = $this; - $deleteTestCb = function ($response) use ($me) { - $data = json_decode($response, true); - $me->assertEquals('', $data['data']); - }; - - $this->__doTestRetrieveResponse($testUri, array(), array(), 'DELETE', $deleteTestCb); - } - - /** - * Tests the PUT method - */ - public function testPut() - { - $testUri = new Uri('http://httpbin.org/put'); - - $me = $this; - $putTestCb = function ($response) use ($me) { - // verify the put response - $data = json_decode($response, true); - $me->assertEquals(json_encode(array('testKey' => 'testValue')), $data['data']); - }; - - $this->__doTestRetrieveResponse($testUri, json_encode(array('testKey' => 'testValue')), array('Content-Type' => 'application/json'), 'PUT', $putTestCb); - } - - /** - * Tests the POST method - */ - public function testPost() - { - // http test server - $testUri = new Uri('http://httpbin.org/post'); - - $me = $this; - $postTestCb = function ($response) use ($me) { - // verify the post response - $data = json_decode($response, true); - // note that we check this because the retrieveResponse wrapper function automatically adds a content-type - // if there isn't one and it - $me->assertEquals('testValue', $data['form']['testKey']); - }; - - $this->__doTestRetrieveResponse($testUri, array('testKey' => 'testValue'), array(), 'POST', $postTestCb); - } - - /** - * Expect exception when we try to send a GET request with a body - */ - public function testInvalidGet() - { - $testUri = new Uri('http://site.net'); - - foreach ($this->clients as $client) { - $this->setExpectedException('InvalidArgumentException'); - $client->retrieveResponse($testUri, array('blah' => 'blih'), array(), 'GET'); - } - } - - /** - * Tests the GET method - */ - public function testGet() - { - // test uri - $testUri = new Uri('http://httpbin.org/get?testKey=testValue'); - - $me = $this; - $getTestCb = function ($response) use ($me) { - $data = json_decode($response, true); - $me->assertEquals('testValue', $data['args']['testKey']); - }; - - $this->__doTestRetrieveResponse($testUri, array(), array(), 'GET', $getTestCb); - } - - /** - * Test on all HTTP clients. - * - * @param UriInterface $uri - * @param array $param - * @param array $header - * @param string $method - * @param \Closure $responseCallback - */ - protected function __doTestRetrieveResponse(UriInterface $uri, $param, array $header, $method, $responseCallback) - { - foreach ($this->clients as $client) { - $response = $client->retrieveResponse($uri, $param, $header, $method); - $responseCallback($response, $client); - } - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriFactoryTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriFactoryTest.php deleted file mode 100644 index ea743509..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriFactoryTest.php +++ /dev/null @@ -1,331 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Uri; - -use OAuth\Common\Http\Uri\UriFactory; -use OAuth\Common\Http\Uri\Uri; - -class UriFactoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInterface() - { - $factory = new UriFactory(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriFactoryInterface', $factory); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - */ - public function testCreateFromSuperGlobalArrayUsingProxyStyle() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array('REQUEST_URI' => 'http://example.com')); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayHttp() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTPS' => 'off', - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * This looks wonky David. Should the port really fallback to 80 even when supplying https as scheme? - * - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayHttps() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTPS' => 'on', - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('https://example.com:80/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayPortSupplied() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'SERVER_PORT' => 21, - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com:21/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayPortNotSet() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayRequestUriSet() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayRedirectUrlSet() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REDIRECT_URL' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayThrowsExceptionOnDetectingPathMissingIndices() - { - $factory = new UriFactory(); - - $this->setExpectedException('\\RuntimeException'); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'QUERY_STRING' => 'param1=value1', - )); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayWithQueryString() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo?param1=value1', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayWithoutQueryString() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayHostWithColon() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com:80', - 'REQUEST_URI' => '/foo', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromAbsolute - */ - public function testCreateFromAbsolute() - { - $factory = new UriFactory(); - - $uri = $factory->createFromAbsolute('http://example.com'); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriTest.php deleted file mode 100644 index bc158ffa..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriTest.php +++ /dev/null @@ -1,898 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Uri; - -use OAuth\Common\Http\Uri\Uri; - -class UriTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - */ - public function testConstructCorrectInterfaceWithoutUri() - { - $uri = new Uri(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - */ - public function testConstructThrowsExceptionOnInvalidUri() - { - $this->setExpectedException('\\InvalidArgumentException'); - - // http://lxr.php.net/xref/PHP_5_4/ext/standard/tests/url/urls.inc#92 - $uri = new Uri('http://@:/'); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - */ - public function testConstructThrowsExceptionOnUriWithoutScheme() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $uri = new Uri('www.pieterhordijk.com'); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getScheme - */ - public function testGetScheme() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http', $uri->getScheme()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getUserInfo - */ - public function testGetUserInfo() - { - $uri = new Uri('http://peehaa@example.com'); - - $this->assertSame('peehaa', $uri->getUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getUserInfo - */ - public function testGetUserInfoWithPass() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:********', $uri->getUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawUserInfo - */ - public function testGetRawUserInfo() - { - $uri = new Uri('http://peehaa@example.com'); - - $this->assertSame('peehaa', $uri->getRawUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawUserInfo - */ - public function testGetRawUserInfoWithPass() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:pass', $uri->getRawUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getHost - */ - public function testGetHost() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('example.com', $uri->getHost()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPort - */ - public function testGetPortImplicitHttp() - { - $uri = new Uri('http://example.com'); - - $this->assertSame(80, $uri->getPort()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPort - */ - public function testGetPortImplicitHttps() - { - $uri = new Uri('https://example.com'); - - $this->assertSame(443, $uri->getPort()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPort - */ - public function testGetPortExplicit() - { - $uri = new Uri('http://example.com:21'); - - $this->assertSame(21, $uri->getPort()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPath - */ - public function testGetPathNotSupplied() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('/', $uri->getPath()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPath - */ - public function testGetPathSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('/', $uri->getPath()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPath - */ - public function testGetPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('/foo', $uri->getPath()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getQuery - */ - public function testGetQueryWithParams() - { - $uri = new Uri('http://example.com?param1=first¶m2=second'); - - $this->assertSame('param1=first¶m2=second', $uri->getQuery()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getQuery - */ - public function testGetQueryWithoutParams() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('', $uri->getQuery()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getFragment - */ - public function testGetFragmentExists() - { - $uri = new Uri('http://example.com#foo'); - - $this->assertSame('foo', $uri->getFragment()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getFragment - */ - public function testGetFragmentNotExists() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('', $uri->getFragment()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithoutUserInfo() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('example.com', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithoutUserInfoWithExplicitPort() - { - $uri = new Uri('http://example.com:21'); - - $this->assertSame('example.com:21', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithUsernameWithExplicitPort() - { - $uri = new Uri('http://peehaa@example.com:21'); - - $this->assertSame('peehaa@example.com:21', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithUsernameAndPassWithExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com:21'); - - $this->assertSame('peehaa:********@example.com:21', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithUsernameAndPassWithoutExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:********@example.com', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithoutUserInfo() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('example.com', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithoutUserInfoWithExplicitPort() - { - $uri = new Uri('http://example.com:21'); - - $this->assertSame('example.com:21', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithUsernameWithExplicitPort() - { - $uri = new Uri('http://peehaa@example.com:21'); - - $this->assertSame('peehaa@example.com:21', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithUsernameAndPassWithExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com:21'); - - $this->assertSame('peehaa:pass@example.com:21', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithUsernameAndPassWithoutExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:pass@example.com', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriBare() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithAuthority() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('http://peehaa:pass@example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithoutPath() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithoutPathExplicitTrailingSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('http://example.com/', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithQuery() - { - $uri = new Uri('http://example.com?param1=value1'); - - $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithFragment() - { - $uri = new Uri('http://example.com#foo'); - - $this->assertSame('http://example.com#foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri - */ - public function testGetRelativeUriWithoutPath() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('', $uri->getRelativeUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri - */ - public function testGetRelativeUriWithPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('/foo', $uri->getRelativeUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri - */ - public function testGetRelativeUriWithExplicitTrailingSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('/', $uri->getRelativeUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringBare() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithAuthority() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('http://peehaa:********@example.com', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('http://example.com/foo', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithoutPath() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithoutPathExplicitTrailingSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('http://example.com/', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithQuery() - { - $uri = new Uri('http://example.com?param1=value1'); - - $this->assertSame('http://example.com?param1=value1', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithFragment() - { - $uri = new Uri('http://example.com#foo'); - - $this->assertSame('http://example.com#foo', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPath - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPathEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setPath(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPath - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPathWithPath() - { - $uri = new Uri('http://example.com'); - $uri->setPath('/foo'); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPath - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPathWithOnlySlash() - { - $uri = new Uri('http://example.com'); - $uri->setPath('/'); - - $this->assertSame('http://example.com/', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetQueryEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setQuery(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetQueryFilled() - { - $uri = new Uri('http://example.com'); - $uri->setQuery('param1=value1¶m2=value2'); - - $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::addToQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testAddToQueryAppend() - { - $uri = new Uri('http://example.com?param1=value1'); - $uri->addToQuery('param2', 'value2'); - - $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::addToQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testAddToQueryCreate() - { - $uri = new Uri('http://example.com'); - $uri->addToQuery('param1', 'value1'); - - $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setFragment - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetFragmentEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setFragment(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setFragment - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetFragmentWithData() - { - $uri = new Uri('http://example.com'); - $uri->setFragment('foo'); - - $this->assertSame('http://example.com#foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setScheme - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetSchemeWithEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setScheme(''); - - $this->assertSame('://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setScheme - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetSchemeWithData() - { - $uri = new Uri('http://example.com'); - $uri->setScheme('foo'); - - $this->assertSame('foo://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetUserInfoEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setUserInfo(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetUserInfoWithData() - { - $uri = new Uri('http://example.com'); - $uri->setUserInfo('foo:bar'); - - $this->assertSame('http://foo:bar@example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortCustom() - { - $uri = new Uri('http://example.com'); - $uri->setPort('21'); - - $this->assertSame('http://example.com:21', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpImplicit() - { - $uri = new Uri('http://example.com'); - $uri->setPort(80); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpsImplicit() - { - $uri = new Uri('https://example.com'); - $uri->setPort(443); - - $this->assertSame('https://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpExplicit() - { - $uri = new Uri('http://example.com'); - $uri->setPort(443); - - $this->assertSame('http://example.com:443', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpsExplicit() - { - $uri = new Uri('https://example.com'); - $uri->setPort(80); - - $this->assertSame('https://example.com:80', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setHost - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetHost() - { - $uri = new Uri('http://example.com'); - $uri->setHost('pieterhordijk.com'); - - $this->assertSame('http://pieterhordijk.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitTrailingHostSlash - */ - public function testHasExplicitTrailingHostSlashTrue() - { - $uri = new Uri('http://example.com/'); - - $this->assertTrue($uri->hasExplicitTrailingHostSlash()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitTrailingHostSlash - */ - public function testHasExplicitTrailingHostSlashFalse() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertFalse($uri->hasExplicitTrailingHostSlash()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified - */ - public function testHasExplicitPortSpecifiedTrue() - { - $uri = new Uri('http://example.com:8080'); - - $this->assertTrue($uri->hasExplicitPortSpecified()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified - */ - public function testHasExplicitPortSpecifiedFalse() - { - $uri = new Uri('http://example.com'); - - $this->assertFalse($uri->hasExplicitPortSpecified()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php deleted file mode 100644 index 2d8bff46..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Service; - -use OAuthTest\Mocks\Common\Service\Mock; - -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Service\AbstractService::__construct - */ - public function testConstructCorrectInterface() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\Common\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::getStorage - */ - public function testGetStorage() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\Common\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $service->getStorage()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::service - */ - public function testService() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('Mock', $service->service()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathUsingUriObject() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $service->testDetermineRequestUriFromPath($this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')) - ); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathUsingHttpPath() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath('http://example.com'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathUsingHttpsPath() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath('https://example.com'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('https://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathThrowsExceptionOnInvalidUri() - { - $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath('example.com'); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathWithQueryString() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath( - 'path?param1=value1', - new \OAuth\Common\Http\Uri\Uri('https://example.com') - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('https://example.com/path?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathWithLeadingSlashInPath() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath( - '/path', - new \OAuth\Common\Http\Uri\Uri('https://example.com') - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('https://example.com/path', $uri->getAbsoluteUri()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/MemoryTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/MemoryTest.php deleted file mode 100644 index 93a01a79..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/MemoryTest.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Storage; - -use OAuth\Common\Storage\Memory; - -class MemoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Storage\Memory::__construct - */ - public function testConstructCorrectInterface() - { - $storage = new Memory(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - */ - public function testStoreAccessToken() - { - $storage = new Memory(); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Storage\\Memory', - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) - ); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::retrieveAccessToken - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testRetrieveAccessTokenValid() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $storage->retrieveAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::retrieveAccessToken - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testRetrieveAccessTokenThrowsExceptionWhenTokenIsNotFound() - { - $this->setExpectedException('\\OAuth\\Common\\Storage\\Exception\\TokenNotFoundException'); - - $storage = new Memory(); - - $storage->retrieveAccessToken('foo'); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testHasAccessTokenTrue() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testHasAccessTokenFalse() - { - $storage = new Memory(); - - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::clearToken - */ - public function testClearTokenIsNotSet() - { - $storage = new Memory(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::clearToken - */ - public function testClearTokenSet() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearToken('foo')); - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::clearAllTokens - */ - public function testClearAllTokens() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - $storage->storeAccessToken('bar', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertTrue($storage->hasAccessToken('bar')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearAllTokens()); - $this->assertFalse($storage->hasAccessToken('foo')); - $this->assertFalse($storage->hasAccessToken('bar')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/RedisTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/RedisTest.php deleted file mode 100644 index 83e7a284..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/RedisTest.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Storage; - -use OAuth\Common\Storage\Redis; -use Predis\Client as Predis; -use OAuth\OAuth2\Token\StdOAuth2Token; - -class RedisTest extends \PHPUnit_Framework_TestCase -{ - protected $storage; - - public function setUp() - { - // connect to a redis daemon - $predis = new Predis(array( - 'host' => $_ENV['redis_host'], - 'port' => $_ENV['redis_port'], - )); - - // set it - $this->storage = new Redis($predis, 'test_user_token', 'test_user_state'); - - try { - $predis->connect(); - } catch (\Predis\Connection\ConnectionException $e) { - $this->markTestSkipped('No redis instance available: ' . $e->getMessage()); - } - } - - public function tearDown() - { - // delete - $this->storage->clearAllTokens(); - - // close connection - $this->storage->getRedis()->quit(); - } - - /** - * Check that the token gets properly stored. - */ - public function testStorage() - { - // arrange - $service_1 = 'Facebook'; - $service_2 = 'Foursquare'; - - $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service_1, $token_1); - $this->storage->storeAccessToken($service_2, $token_2); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); - $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); - } - - /** - * Test hasAccessToken. - */ - public function testHasAccessToken() - { - // arrange - $service = 'Facebook'; - $this->storage->clearToken($service); - - // act - // assert - $this->assertFalse($this->storage->hasAccessToken($service)); - } - - /** - * Check that the token gets properly deleted. - */ - public function testStorageClears() - { - // arrange - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage->clearToken($service); - - // assert - $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); - $this->storage->retrieveAccessToken($service); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SessionTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SessionTest.php deleted file mode 100644 index 72f38b1a..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SessionTest.php +++ /dev/null @@ -1,245 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Storage; - -use OAuth\Common\Storage\Session; - -class SessionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructCorrectInterface() - { - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructWithoutStartingSession() - { - session_start(); - - $storage = new Session(false); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructTryingToStartWhileSessionAlreadyExists() - { - session_start(); - - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructWithExistingSessionKey() - { - session_start(); - - $_SESSION['lusitanian_oauth_token'] = array(); - - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * - * @runInSeparateProcess - */ - public function testStoreAccessTokenIsAlreadyArray() - { - $storage = new Session(); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Storage\\Session', - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) - ); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * - * @runInSeparateProcess - */ - public function testStoreAccessTokenIsNotArray() - { - $storage = new Session(); - - $_SESSION['lusitanian_oauth_token'] = 'foo'; - - $this->assertInstanceOf( - '\\OAuth\\Common\\Storage\\Session', - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) - ); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::retrieveAccessToken - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testRetrieveAccessTokenValid() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $storage->retrieveAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::retrieveAccessToken - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testRetrieveAccessTokenThrowsExceptionWhenTokenIsNotFound() - { - $this->setExpectedException('\\OAuth\\Common\\Storage\\Exception\\TokenNotFoundException'); - - $storage = new Session(); - - $storage->retrieveAccessToken('foo'); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testHasAccessTokenTrue() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testHasAccessTokenFalse() - { - $storage = new Session(); - - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::clearToken - * - * @runInSeparateProcess - */ - public function testClearTokenIsNotSet() - { - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Session', $storage->clearToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::clearToken - * - * @runInSeparateProcess - */ - public function testClearTokenSet() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Session', $storage->clearToken('foo')); - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::clearAllTokens - * - * @runInSeparateProcess - */ - public function testClearAllTokens() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - $storage->storeAccessToken('bar', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertTrue($storage->hasAccessToken('bar')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Session', $storage->clearAllTokens()); - $this->assertFalse($storage->hasAccessToken('foo')); - $this->assertFalse($storage->hasAccessToken('bar')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::__destruct - * - * @runInSeparateProcess - */ - public function testDestruct() - { - $storage = new Session(); - - unset($storage); - } - - /** - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::retrieveAccessToken - * - * @runInSeparateProcess - */ - public function testSerializeUnserialize() - { - $mock = $this->getMock('\\OAuth\\Common\\Token\\AbstractToken', array('__sleep')); - $mock->expects($this->once()) - ->method('__sleep') - ->will($this->returnValue(array('accessToken'))); - - $storage = new Session(); - $storage->storeAccessToken('foo', $mock); - $retrievedToken = $storage->retrieveAccessToken('foo'); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\AbstractToken', $retrievedToken); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/StorageTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/StorageTest.php deleted file mode 100644 index 3fe19906..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/StorageTest.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @author Hannes Van De Vreken <vandevreken.hannes@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Storage; - -use \OAuth\OAuth2\Token\StdOAuth2Token; - -abstract class StorageTest extends \PHPUnit_Framework_TestCase -{ - protected $storage; - - /** - * Check that the token gets properly stored. - */ - public function testStorage() - { - // arrange - $service_1 = 'Facebook'; - $service_2 = 'Foursquare'; - - $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service_1, $token_1); - $this->storage->storeAccessToken($service_2, $token_2); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); - $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); - } - - /** - * Test hasAccessToken. - */ - public function testHasAccessToken() - { - // arrange - $service = 'Facebook'; - $this->storage->clearToken($service); - - // act - // assert - $this->assertFalse($this->storage->hasAccessToken($service)); - } - - /** - * Check that the token gets properly deleted. - */ - public function testStorageClears() - { - // arrange - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage->clearToken($service); - - // assert - $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); - $this->storage->retrieveAccessToken($service); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SymfonySessionTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SymfonySessionTest.php deleted file mode 100644 index c6434612..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SymfonySessionTest.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Storage; - -use OAuth\Common\Storage\SymfonySession; -use OAuth\OAuth2\Token\StdOAuth2Token; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; - -class SymfonySessionTest extends \PHPUnit_Framework_TestCase -{ - protected $session; - - protected $storage; - - public function setUp() - { - // set it - $this->session = new Session(new MockArraySessionStorage()); - $this->storage = new SymfonySession($this->session); - } - - public function tearDown() - { - // delete - $this->storage->getSession()->clear(); - unset($this->storage); - } - - /** - * Check that the token survives the constructor - */ - public function testStorageSurvivesConstructor() - { - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage = null; - $this->storage = new SymfonySession($this->session); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token, $this->storage->retrieveAccessToken($service)); - } - - /** - * Check that the token gets properly stored. - */ - public function testStorage() - { - // arrange - $service_1 = 'Facebook'; - $service_2 = 'Foursquare'; - - $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service_1, $token_1); - $this->storage->storeAccessToken($service_2, $token_2); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); - $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); - } - - /** - * Test hasAccessToken. - */ - public function testHasAccessToken() - { - // arrange - $service = 'Facebook'; - $this->storage->clearToken($service); - - // act - // assert - $this->assertFalse($this->storage->hasAccessToken($service)); - } - - /** - * Check that the token gets properly deleted. - */ - public function testStorageClears() - { - // arrange - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage->clearToken($service); - - // assert - $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); - $this->storage->retrieveAccessToken($service); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Token/AbstractTokenTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Token/AbstractTokenTest.php deleted file mode 100644 index 54b3bb63..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Token/AbstractTokenTest.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Token; - -use \OAuth\Common\Token\AbstractToken; - -class AbstractTokenTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - */ - public function testConstructCorrectInterface() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $token); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getAccessToken - */ - public function testGetAccessTokenNotSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertNull($token->getAccessToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getAccessToken - */ - public function testGetAccessTokenSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo')); - - $this->assertSame('foo', $token->getAccessToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getAccessToken - * @covers OAuth\Common\Token\AbstractToken::setAccessToken - */ - public function testSetAccessToken() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setAccessToken('foo'); - - $this->assertSame('foo', $token->getAccessToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getRefreshToken - */ - public function testGetRefreshToken() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertNull($token->getRefreshToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getRefreshToken - */ - public function testGetRefreshTokenSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar')); - - $this->assertSame('bar', $token->getRefreshToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getRefreshToken - * @covers OAuth\Common\Token\AbstractToken::setRefreshToken - */ - public function testSetRefreshToken() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setRefreshToken('foo'); - - $this->assertSame('foo', $token->getRefreshToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getExtraParams - */ - public function testGetExtraParamsNotSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertSame(array(), $token->getExtraParams()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getExtraParams - */ - public function testGetExtraParamsSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', null, array('foo', 'bar'))); - - $this->assertEquals(array('foo', 'bar'), $token->getExtraParams()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setExtraParams - * @covers OAuth\Common\Token\AbstractToken::getExtraParams - */ - public function testSetExtraParams() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setExtraParams(array('foo', 'bar')); - - $this->assertSame(array('foo', 'bar'), $token->getExtraParams()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeNotSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertSame(AbstractToken::EOL_UNKNOWN, $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeZero() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', 0)); - - $this->assertSame(AbstractToken::EOL_NEVER_EXPIRES, $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeNeverExpires() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', AbstractToken::EOL_NEVER_EXPIRES)); - - $this->assertSame(AbstractToken::EOL_NEVER_EXPIRES, $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeNeverExpiresFiveMinutes() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', 5 * 60)); - - $this->assertSame(time() + (5*60), $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - * @covers OAuth\Common\Token\AbstractToken::setEndOfLife - */ - public function testSetEndOfLife() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setEndOfLife(10); - - $this->assertSame(10, $token->getEndOfLife()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php deleted file mode 100644 index ab5417b2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuthTest\Mocks\OAuth1\Service\Mock; - -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\AbstractService::__construct - */ - public function testConstructCorrectInterface() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth1\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - ) - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::__construct - */ - public function testConstructCorrectParent() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth1\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::requestRequestToken - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForTokenRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth1\Service\AbstractService::parseRequestTokenResponse - */ - public function testRequestRequestTokenBuildAuthHeaderTokenRequestWithoutParams() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($endpoint, $array, $headers) { - \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/token', $endpoint->getAbsoluteUri()); - })); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithoutParameters() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('http://pieterhordijk.com/auth', $service->getAuthorizationUri()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithParameters() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('http://pieterhordijk.com/auth?foo=bar&baz=beer', $service->getAuthorizationUri(array( - 'foo' => 'bar', - 'baz' => 'beer', - ))->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::requestAccessToken - * @covers OAuth\OAuth1\Service\AbstractService::service - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - * @covers OAuth\OAuth1\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth1\Service\AbstractService::parseAccessTokenResponse - */ - public function testRequestAccessTokenWithoutSecret() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($endpoint, $array, $headers) { - \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri()); - })); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - $token->expects($this->once())->method('getRequestTokenSecret')->will($this->returnValue('baz')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar')); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::requestAccessToken - * @covers OAuth\OAuth1\Service\AbstractService::service - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - * @covers OAuth\OAuth1\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth1\Service\AbstractService::parseAccessTokenResponse - */ - public function testRequestAccessTokenWithSecret() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($endpoint, $array, $headers) { - \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri()); - })); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::request - * @covers OAuth\OAuth1\Service\AbstractService::determineRequestUriFromPath - * @covers OAuth\OAuth1\Service\AbstractService::service - * @covers OAuth\OAuth1\Service\AbstractService::getExtraApiHeaders - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - //$token->expects($this->once())->method('getRequestTokenSecret')->will($this->returnValue('baz')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php deleted file mode 100644 index 87be98b1..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\BitBucket; - -class BitBucketTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://bitbucket.org/!api/1.0/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://bitbucket.org/!api/1.0/oauth/authenticate', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://bitbucket.org/!api/1.0/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\BitBucket::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php deleted file mode 100644 index 97ad3cdd..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Etsy; - -class EtsyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://openapi.etsy.com/v2/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - - $service->setScopes(array('email_r', 'cart_rw')); - - $this->assertSame( - 'https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20cart_rw', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://openapi.etsy.com/v2/', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://openapi.etsy.com/v2/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Etsy::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php deleted file mode 100644 index a8b7ae2d..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\FitBit; - -class FitBitTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.fitbit.com/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.fitbit.com/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.fitbit.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\FitBit::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php deleted file mode 100644 index ee88f714..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php +++ /dev/null @@ -1,302 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Flickr; - -class FlickrTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.flickr.com/services/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.flickr.com/services/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.flickr.com/services/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Flickr::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php deleted file mode 100644 index 4ba83fa6..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php +++ /dev/null @@ -1,302 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\ScoopIt; - -class ScoopItTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.scoop.it/oauth/request', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.scoop.it/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.scoop.it/oauth/access', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\ScoopIt::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php deleted file mode 100644 index f1467ad6..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Tumblr; - -class TumblrTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.tumblr.com/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.tumblr.com/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.tumblr.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Tumblr::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php deleted file mode 100644 index bb31fa29..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php +++ /dev/null @@ -1,307 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Twitter; - -class TwitterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.twitter.com/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertTrue( - in_array( - strtolower($service->getAuthorizationEndpoint()->getAbsoluteUri()), - array(\OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHENTICATE, \OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHORIZE) - ) - ); - - $service->setAuthorizationEndpoint( \OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHORIZE ); - - $this->assertTrue( - in_array( - strtolower($service->getAuthorizationEndpoint()->getAbsoluteUri()), - array(\OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHENTICATE, \OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHORIZE) - ) - ); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::setAuthorizationEndpoint - */ - public function testSetAuthorizationEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); - - $service->setAuthorizationEndpoint('foo'); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.twitter.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Twitter::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php deleted file mode 100644 index d3a5f4ae..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php +++ /dev/null @@ -1,239 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Xing; - -class XingTest extends \PHPUnit_Framework_TestCase -{ - private $client; - private $storage; - private $xing; - - - protected function setUp() - { - parent::setUp(); - - $this->client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $this->storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - - $this->xing = new Xing( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->client, - $this->storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Service\\ServiceInterface', $this->xing - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Service\\AbstractService', $this->xing - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Xing( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->client, - $this->storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $this->assertSame( - 'https://api.xing.com/v1/request_token', - $this->xing->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $this->assertSame( - 'https://api.xing.com/v1/authorize', - $this->xing->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $this->assertSame( - 'https://api.xing.com/v1/access_token', - $this->xing->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue(null)); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('notanarray')); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('foo=bar')); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('oauth_callback_confirmed=false')); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Xing::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Token\\StdOAuth1Token', - $this->xing->requestRequestToken() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $this->storage - ->expects($this->any()) - ->method('retrieveAccessToken') - ->will($this->returnValue($token)); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('oauth_token=foo&oauth_token_secret=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $this->storage - ->expects($this->any()) - ->method('retrieveAccessToken') - ->will($this->returnValue($token)); - - - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Token\\StdOAuth1Token', - $this->xing->requestAccessToken('foo', 'bar', $token) - ); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php deleted file mode 100644 index e8feb5dc..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php +++ /dev/null @@ -1,302 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Yahoo; - -class YahooTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.login.yahoo.com/oauth/v2/get_request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.login.yahoo.com/oauth/v2/request_auth', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.login.yahoo.com/oauth/v2/get_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Yahoo::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Signature/SignatureTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Signature/SignatureTest.php deleted file mode 100644 index 44c731f5..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Signature/SignatureTest.php +++ /dev/null @@ -1,325 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Signature; - -use OAuth\OAuth1\Signature\Signature; - -class SignatureTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - */ - public function testConstructCorrectInterface() - { - $signature = new Signature($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface')); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Signature\\SignatureInterface', $signature); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - */ - public function testSetHashingAlgorithm() - { - $signature = new Signature($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface')); - - $this->assertNull($signature->setHashingAlgorithm('foo')); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - */ - public function testSetTokenSecret() - { - $signature = new Signature($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface')); - - $this->assertNull($signature->setTokenSecret('foo')); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureBareUri() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/foo')); - - $this->assertSame('uoCpiII/Lg/cPiF0XrU2pj4eGFQ=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithQueryString() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/foo')); - - $this->assertSame('LxtD+WjJBRppIUvEI79iQ7I0hSo=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithAuthority() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/foo')); - - $this->assertSame('MHvkRndIntLrxiPkjkiCNsMEqv4=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithBarePathNonExplicitTrailingHostSlash() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(false)); - - $this->assertSame('iFELDoiI5Oj9ixB3kHzoPvBpq0w=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithBarePathWithExplicitTrailingHostSlash() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(true)); - - $this->assertSame('IEhUsArSTLvbQ3QYr0zzn+Rxpjg=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureNoTokenSecretSet() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(true)); - - $this->assertSame('YMHF7FYmLq7wzGnnHWYtd1VoBBE=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureThrowsExceptionOnUnsupportedAlgo() - { - $this->setExpectedException('\\OAuth\\OAuth1\\Signature\\Exception\\UnsupportedHashAlgorithmException'); - - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('UnsupportedAlgo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(true)); - - $signature->getSignature($uri, array('pee' => 'haa')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php deleted file mode 100644 index 9b065b1e..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Token; - -use OAuth\OAuth1\Token\StdOAuth1Token; - -class StdOAuth1TokenTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInterfaces() - { - $token = new StdOAuth1Token(); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\TokenInterface', $token); - $this->assertInstanceOf('\\OAuth\\Common\\Token\\AbstractToken', $token); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestToken - */ - public function testSetRequestToken() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestToken('foo')); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestToken - * @covers OAuth\OAuth1\Token\StdOAuth1Token::getRequestToken - */ - public function testGetRequestToken() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestToken('foo')); - $this->assertSame('foo', $token->getRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestTokenSecret - */ - public function testSetRequestTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestTokenSecret('foo')); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestTokenSecret - * @covers OAuth\OAuth1\Token\StdOAuth1Token::getRequestTokenSecret - */ - public function testGetRequestTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestTokenSecret('foo')); - $this->assertSame('foo', $token->getRequestTokenSecret()); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setAccessTokenSecret - */ - public function testSetAccessTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setAccessTokenSecret('foo')); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setAccessTokenSecret - * @covers OAuth\OAuth1\Token\StdOAuth1Token::getAccessTokenSecret - */ - public function testGetAccessTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setAccessTokenSecret('foo')); - $this->assertSame('foo', $token->getAccessTokenSecret()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AbstractServiceTest.php deleted file mode 100644 index 595db2a3..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AbstractServiceTest.php +++ /dev/null @@ -1,401 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuthTest\Mocks\OAuth2\Service\Mock; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Token\TokenInterface; - -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - */ - public function testConstructCorrectInterface() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth2\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - ) - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - */ - public function testConstructCorrectParent() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth2\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - */ - public function testConstructCorrectParentCustomUri() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth2\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - */ - public function testConstructThrowsExceptionOnInvalidScope() - { - $this->setExpectedException('\\OAuth\\OAuth2\\Service\\Exception\\InvalidScopeException'); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array('invalidscope') - ); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithoutParametersOrScopes() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); - $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); - - $service = new Mock( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'http://pieterhordijk.com/auth?type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithParametersWithoutScopes() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); - $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); - - $service = new Mock( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'http://pieterhordijk.com/auth?foo=bar&baz=beer&type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri(array('foo' => 'bar', 'baz' => 'beer'))->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithParametersAndScopes() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); - $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); - - $service = new Mock( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array('mock', 'mock2') - ); - - $this->assertSame( - 'http://pieterhordijk.com/auth?foo=bar&baz=beer&type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=mock+mock2', - $service->getAuthorizationUri(array('foo' => 'bar', 'baz' => 'beer'))->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::requestAccessToken - * @covers OAuth\OAuth2\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth2\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\AbstractService::service - */ - public function testRequestAccessToken() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceof('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('code')); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::request - * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath - */ - public function testRequestThrowsExceptionWhenTokenIsExpired() - { - $tokenExpiration = new \DateTime('26-03-1984 00:00:00'); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->any())->method('getEndOfLife')->will($this->returnValue($tokenExpiration->format('U'))); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $storage - ); - - $this->setExpectedException('\\OAuth\\Common\\Token\\Exception\\ExpiredTokenException', 'Token expired on 03/26/1984 at 12:00:00 AM'); - - $service->request('https://pieterhordijk.com/my/awesome/path'); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::request - * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\AbstractService::service - * @covers OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders - */ - public function testRequestOauthAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::request - * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\AbstractService::service - * @covers OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders - */ - public function testRequestQueryStringMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $service->setAuthorizationMethod('querystring'); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::request - * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\AbstractService::service - * @covers OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders - */ - public function testRequestQueryStringTwoMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $service->setAuthorizationMethod('querystring2'); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('oauth2_access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::request - * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\AbstractService::service - * @covers OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders - */ - public function testRequestBearerMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $service->setAuthorizationMethod('bearer'); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::getStorage - */ - public function testGetStorage() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $service->getStorage()); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::refreshAccessToken - * @covers OAuth\OAuth2\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth2\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - */ - public function testRefreshAccessTokenSuccess() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\StdOAuth2Token'); - $token->expects($this->once())->method('getRefreshToken')->will($this->returnValue('foo')); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->refreshAccessToken($token)); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - */ - public function testIsValidScopeTrue() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertTrue($service->isValidScope('mock')); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - */ - public function testIsValidScopeFalse() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertFalse($service->isValidScope('invalid')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AmazonTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AmazonTest.php deleted file mode 100644 index f70fe401..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AmazonTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Amazon; -use OAuth\Common\Token\TokenInterface; - -class AmazonTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.amazon.com/ap/oa', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.amazon.com/ap/oatoken', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BitlyTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BitlyTest.php deleted file mode 100644 index 9944b260..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BitlyTest.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Bitly; -use OAuth\Common\Token\TokenInterface; - -class BitlyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://bitly.com/oauth/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api-ssl.bitly.com/oauth/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\Bitly::requestAccessToken - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('access_token=foo')); - - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BoxTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BoxTest.php deleted file mode 100644 index b5b2a789..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BoxTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Box; -use OAuth\Common\Token\TokenInterface; - -class BoxTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Box::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.box.com/api/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.box.com/api/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BufferTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BufferTest.php deleted file mode 100644 index 29726d0a..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BufferTest.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Buffer; -use OAuth\Common\Token\TokenInterface; - -class BufferTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://bufferapp.com/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.bufferapp.com/1/oauth2/token.json', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\Buffer::requestAccessToken - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo"}')); - - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -}
\ No newline at end of file diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DailymotionTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DailymotionTest.php deleted file mode 100644 index f3fbaa8e..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DailymotionTest.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Dailymotion; -use OAuth\Common\Token\TokenInterface; - -class DailymotionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.dailymotion.com/oauth/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.dailymotion.com/oauth/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::getExtraOAuthHeaders - */ - public function testGetExtraOAuthHeaders() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($uri, $params, $extraHeaders) { - \PHPUnit_Framework_Assert::assertTrue(array_key_exists('Accept', $extraHeaders)); - \PHPUnit_Framework_Assert::assertTrue(in_array('application/json', $extraHeaders, true)); - - return '{"access_token":"foo","expires_in":"bar"}'; - })); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DropboxTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DropboxTest.php deleted file mode 100644 index 8f052c6b..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DropboxTest.php +++ /dev/null @@ -1,231 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Dropbox; -use OAuth\Common\Token\TokenInterface; - -class DropboxTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationUri - */ - public function testGetAuthorizationUriWithoutAdditionalParams() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); - $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); - - $service = new Dropbox( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.dropbox.com/1/oauth2/authorize?client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationUri - */ - public function testGetAuthorizationUriWithAdditionalParams() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); - $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); - - $service = new Dropbox( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.dropbox.com/1/oauth2/authorize?client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.dropbox.com/1/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.dropbox.com/1/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FacebookTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FacebookTest.php deleted file mode 100644 index f2fed463..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FacebookTest.php +++ /dev/null @@ -1,242 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Facebook; -use OAuth\Common\Token\TokenInterface; - -class FacebookTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.facebook.com/dialog/oauth', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://graph.facebook.com/oauth/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('access_token=foo&expires=bar')); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('access_token=foo&expires=bar&refresh_token=baz')); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getDialogUri - */ - public function testGetDialogUriRedirectUriMissing() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); - - $service->getDialogUri('feed', array()); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getDialogUri - */ - public function testGetDialogUriInstanceofUri() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $dialogUri = $service->getDialogUri( - 'feed', - array( - 'redirect_uri' => 'http://www.facebook.com', - 'state' => 'Random state' - ) - ); - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\Uri',$dialogUri); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getDialogUri - */ - public function testGetDialogUriContainsAppIdAndOtherParameters() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any())->method('getConsumerId')->will($this->returnValue('application_id')); - - - $service = new Facebook( - $credentials, - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $dialogUri = $service->getDialogUri( - 'feed', - array( - 'redirect_uri' => 'http://www.facebook.com', - 'state' => 'Random state' - ) - ); - - $queryString = $dialogUri->getQuery(); - parse_str($queryString, $queryArray); - - $this->assertArrayHasKey('app_id', $queryArray); - $this->assertArrayHasKey('redirect_uri', $queryArray); - $this->assertArrayHasKey('state', $queryArray); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FoursquareTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FoursquareTest.php deleted file mode 100644 index 96356ec5..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FoursquareTest.php +++ /dev/null @@ -1,197 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Foursquare; -use OAuth\Common\Token\TokenInterface; - -class FoursquareTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://foursquare.com/oauth2/authenticate', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://foursquare.com/oauth2/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"error":"some_error"}')); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $this->assertSame( - 'https://api.foursquare.com/v2/https://pieterhordijk.com/my/awesome/path?v=20130829', - $service->request('https://pieterhordijk.com/my/awesome/path')->getAbsoluteUri() - ); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GitHubTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GitHubTest.php deleted file mode 100644 index edb0fee3..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GitHubTest.php +++ /dev/null @@ -1,220 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\GitHub; -use OAuth\Common\Token\TokenInterface; - -class GitHubTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://github.com/login/oauth/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://github.com/login/oauth/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"error":"some_error"}')); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getExtraOAuthHeaders - */ - public function testGetExtraOAuthHeaders() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($uri, $params, $extraHeaders) { - \PHPUnit_Framework_Assert::assertTrue(array_key_exists('Accept', $extraHeaders)); - \PHPUnit_Framework_Assert::assertTrue(in_array('application/json', $extraHeaders, true)); - - return '{"access_token":"foo","expires_in":"bar"}'; - })); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getExtraApiHeaders - */ - public function testGetExtraApiHeaders() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Accept', $headers)); - $this->assertSame('application/vnd.github.beta+json', $headers['Accept']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GoogleTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GoogleTest.php deleted file mode 100644 index b55808d2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GoogleTest.php +++ /dev/null @@ -1,195 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Google; -use OAuth\Common\Token\TokenInterface; - -class GoogleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Google::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://accounts.google.com/o/oauth2/auth?access_type=online', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - - // Verify that 'offine' works - $service->setAccessType('offline'); - $this->assertSame( - 'https://accounts.google.com/o/oauth2/auth?access_type=offline', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpointException() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('OAuth\OAuth2\Service\Exception\InvalidAccessTypeException'); - - try { - $service->setAccessType('invalid'); - } catch (InvalidAccessTypeException $e) { - return; - } - $this->fail('Expected InvalidAccessTypeException not thrown'); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://accounts.google.com/o/oauth2/token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/HerokuTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/HerokuTest.php deleted file mode 100644 index cc2c0f69..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/HerokuTest.php +++ /dev/null @@ -1,261 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Heroku; -use OAuth\Common\Token\TokenInterface; - -class HerokuTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://id.heroku.com/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://id.heroku.com/oauth/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getExtraOAuthHeaders - */ - public function testGetExtraOAuthHeaders() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($uri, $params, $extraHeaders) { - \PHPUnit_Framework_Assert::assertTrue(array_key_exists('Accept', $extraHeaders)); - \PHPUnit_Framework_Assert::assertTrue(in_array('application/vnd.heroku+json; version=3', $extraHeaders, true)); - - return '{"access_token":"foo","expires_in":"bar"}'; - })); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getExtraApiHeaders - */ - public function testGetExtraApiHeaders() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Accept', $headers)); - $this->assertSame('application/vnd.heroku+json; version=3', $headers['Accept']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/InstagramTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/InstagramTest.php deleted file mode 100644 index bf9d764c..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/InstagramTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Instagram; -use OAuth\Common\Token\TokenInterface; - -class InstagramTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://api.instagram.com/oauth/authorize/', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://api.instagram.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/LinkedinTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/LinkedinTest.php deleted file mode 100644 index c7f5c76e..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/LinkedinTest.php +++ /dev/null @@ -1,213 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Linkedin; -use OAuth\Common\Token\TokenInterface; - -class LinkedinTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.linkedin.com/uas/oauth2/authorization', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.linkedin.com/uas/oauth2/accessToken', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('oauth2_access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MailchimpTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MailchimpTest.php deleted file mode 100644 index e7f955e1..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MailchimpTest.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Mailchimp; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Http\Uri\Uri; - -class MailchimpTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.mailchimp.com/oauth2/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.mailchimp.com/oauth2/token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\StdOAuth2Token'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - array(), - new Uri('https://us1.api.mailchimp.com/2.0/') - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('apikey=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->at(0))->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - $client->expects($this->at(1))->method('retrieveResponse')->will($this->returnValue('{"dc": "us7"}')); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MicrosoftTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MicrosoftTest.php deleted file mode 100644 index 4001e1e4..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MicrosoftTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Microsoft; -use OAuth\Common\Token\TokenInterface; - -class MicrosoftTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.live.com/oauth20_authorize.srf', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.live.com/oauth20_token.srf', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/PaypalTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/PaypalTest.php deleted file mode 100644 index 5396326f..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/PaypalTest.php +++ /dev/null @@ -1,213 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Paypal; -use OAuth\Common\Token\TokenInterface; - -class PaypalTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://api.paypal.com/v1/identity/openidconnect/tokenservice', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnMessage() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('message=some_error')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnName() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('name=some_error')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RedditTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RedditTest.php deleted file mode 100644 index e8741e6f..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RedditTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Reddit; -use OAuth\Common\Token\TokenInterface; - -class RedditTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://ssl.reddit.com/api/v1/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://ssl.reddit.com/api/v1/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RunKeeperTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RunKeeperTest.php deleted file mode 100644 index 671bd0cf..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RunKeeperTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\RunKeeper; -use OAuth\Common\Token\TokenInterface; - -class RunKeeperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://runkeeper.com/apps/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://runkeeper.com/apps/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('/user'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/SoundCloudTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/SoundCloudTest.php deleted file mode 100644 index ac988ba2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/SoundCloudTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\SoundCloud; -use OAuth\Common\Token\TokenInterface; - -class SoundCloudTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://soundcloud.com/connect', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.soundcloud.com/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/UstreamTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/UstreamTest.php deleted file mode 100644 index 48965ae0..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/UstreamTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Ustream; -use OAuth\Common\Token\TokenInterface; - -class UstreamTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.ustream.tv/oauth2/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.ustream.tv/oauth2/token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/VkontakteTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/VkontakteTest.php deleted file mode 100644 index 7a8279b2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/VkontakteTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Vkontakte; -use OAuth\Common\Token\TokenInterface; - -class VkontakteTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://oauth.vk.com/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://oauth.vk.com/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/YammerTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/YammerTest.php deleted file mode 100644 index 86440395..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/YammerTest.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Yammer; -use OAuth\Common\Token\TokenInterface; - -class YammerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.yammer.com/dialog/oauth', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.yammer.com/oauth2/access_token.json', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2)); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES)); - $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":{"token":"foo", "expires_at":null}}')); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":{"token":"foo", "expires_at":null},"refresh_token":"baz"}')); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/ServiceFactoryTest.php b/vendor/lusitanian/oauth/tests/Unit/ServiceFactoryTest.php deleted file mode 100644 index 26588dc0..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/ServiceFactoryTest.php +++ /dev/null @@ -1,311 +0,0 @@ -<?php -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @author Chris Heng <bigblah@gmail.com> - * @author Pieter Hordijk <info@pieterhordijk.com> - * @copyright Copyright (c) 2013 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ -namespace OAuth\Unit; - -use OAuth\ServiceFactory; - -class ServiceFactoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\ServiceFactory::setHttpClient - */ - public function testSetHttpClient() - { - $factory = new ServiceFactory(); - - $this->assertInstanceOf( - '\\OAuth\\ServiceFactory', - $factory->setHttpClient($this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface')) - ); - } - - /** - * @covers OAuth\ServiceFactory::registerService - */ - public function testRegisterServiceThrowsExceptionNonExistentClass() - { - $this->setExpectedException('\\OAuth\Common\Exception\Exception'); - - $factory = new ServiceFactory(); - $factory->registerService('foo', 'bar'); - } - - /** - * @covers OAuth\ServiceFactory::registerService - */ - public function testRegisterServiceThrowsExceptionWithClassIncorrectImplementation() - { - $this->setExpectedException('\\OAuth\Common\Exception\Exception'); - - $factory = new ServiceFactory(); - $factory->registerService('foo', 'OAuth\\ServiceFactory'); - } - - /** - * @covers OAuth\ServiceFactory::registerService - */ - public function testRegisterServiceSuccessOAuth1() - { - $factory = new ServiceFactory(); - - $this->assertInstanceOf( - '\\OAuth\\ServiceFactory', - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake') - ); - } - - /** - * @covers OAuth\ServiceFactory::registerService - */ - public function testRegisterServiceSuccessOAuth2() - { - $factory = new ServiceFactory(); - - $this->assertInstanceOf( - '\\OAuth\\ServiceFactory', - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake') - ); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV1Service - */ - public function testCreateServiceOAuth1NonRegistered() - { - $factory = new ServiceFactory(); - - $service = $factory->createService( - 'twitter', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\Twitter', $service); - } - - /** - * @covers OAuth\ServiceFactory::registerService - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV1Service - */ - public function testCreateServiceOAuth1Registered() - { - $factory = new ServiceFactory(); - - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake'); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\OAuth1\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake', $service); - } - - /** - * @covers OAuth\ServiceFactory::registerService - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV1Service - */ - public function testCreateServiceOAuth1RegisteredAndNonRegisteredSameName() - { - $factory = new ServiceFactory(); - - $factory->registerService('twitter', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake'); - - $service = $factory->createService( - 'twitter', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\OAuth1\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake', $service); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV2Service - * @covers OAuth\ServiceFactory::resolveScopes - */ - public function testCreateServiceOAuth2NonRegistered() - { - $factory = new ServiceFactory(); - - $service = $factory->createService( - 'facebook', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\Facebook', $service); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV2Service - * @covers OAuth\ServiceFactory::resolveScopes - */ - public function testCreateServiceOAuth2Registered() - { - $factory = new ServiceFactory(); - - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake'); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV2Service - * @covers OAuth\ServiceFactory::resolveScopes - */ - public function testCreateServiceOAuth2RegisteredAndNonRegisteredSameName() - { - $factory = new ServiceFactory(); - - $factory->registerService('facebook', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake'); - - $service = $factory->createService( - 'facebook', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service); - } - - /** - * @covers OAuth\ServiceFactory::registerService - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV1Service - */ - public function testCreateServiceThrowsExceptionOnPassingScopesToV1Service() - { - $this->setExpectedException('\\OAuth\Common\Exception\Exception'); - - $factory = new ServiceFactory(); - - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake'); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array('bar') - ); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - */ - public function testCreateServiceNonExistentService() - { - $factory = new ServiceFactory(); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertNull($service); - } - - /** - * @covers OAuth\ServiceFactory::registerService - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV2Service - * @covers OAuth\ServiceFactory::resolveScopes - */ - public function testCreateServicePrefersOauth2() - { - $factory = new ServiceFactory(); - - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake'); - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake'); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV2Service - * @covers OAuth\ServiceFactory::resolveScopes - */ - public function testCreateServiceOAuth2RegisteredWithClassConstantsAsScope() - { - $factory = new ServiceFactory(); - - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake'); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array('FOO') - ); - - $this->assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service); - } - - /** - * @covers OAuth\ServiceFactory::createService - * @covers OAuth\ServiceFactory::getFullyQualifiedServiceName - * @covers OAuth\ServiceFactory::buildV2Service - * @covers OAuth\ServiceFactory::resolveScopes - */ - public function testCreateServiceOAuth2RegisteredWithCustomScope() - { - $factory = new ServiceFactory(); - - $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake'); - - $service = $factory->createService( - 'foo', - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array('custom') - ); - - $this->assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service); - $this->assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service); - } -} diff --git a/vendor/lusitanian/oauth/tests/bootstrap.php b/vendor/lusitanian/oauth/tests/bootstrap.php deleted file mode 100644 index 193b857a..00000000 --- a/vendor/lusitanian/oauth/tests/bootstrap.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Bootstrap the tests - * - * PHP version 5.3 - * - * @category OAuthTest - * @author Pieter Hordijk <info@pieterhordijk.com> - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 Pieter Hordijk - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ -namespace OAuthTest; - -/** - * Setting up the default timezone. because well... PHP sucks - */ -date_default_timezone_set('Europe/Amsterdam'); - -/** - * Simple SPL autoloader for the OAuthTest mocks - * - * @param string $class The class name to load - * - * @return void - */ -spl_autoload_register(function ($class) { - $nslen = strlen(__NAMESPACE__); - if (substr($class, 0, $nslen) !== __NAMESPACE__) { - return; - } - $path = substr(str_replace('\\', '/', $class), $nslen); - $path = __DIR__ . $path . '.php'; - if (file_exists($path)) { - require $path; - } -}); - -/** - * Fire up the autoloader - */ -require_once __DIR__ . '/../vendor/autoload.php'; |