diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..050b5e0
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+/.* export-ignore
+/_test export-ignore
diff --git a/.github/workflows/dokuwiki.yml b/.github/workflows/dokuwiki.yml
new file mode 100644
index 0000000..bb23bc1
--- /dev/null
+++ b/.github/workflows/dokuwiki.yml
@@ -0,0 +1,11 @@
+name: DokuWiki Default Tasks
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '14 0 5 * *'
+
+
+jobs:
+ all:
+ uses: dokuwiki/github-action/.github/workflows/all.yml@main
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 70e0935..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-# Config file for travis-ci.org
-
-language: php
-php:
- - "7.3"
- - "7.2"
- - "7.1"
- - "7.0"
- - "5.6"
-env:
- - DOKUWIKI=master
- - DOKUWIKI=stable
-before_install: wget https://raw.github.com/splitbrain/dokuwiki-travis/master/travis.sh
-install: sh travis.sh
-script: cd _test && ./phpunit.phar --stderr --group plugin_oauth
diff --git a/Adapter.php b/Adapter.php
new file mode 100644
index 0000000..de3969c
--- /dev/null
+++ b/Adapter.php
@@ -0,0 +1,395 @@
+register_hook('PLUGIN_OAUTH_BACKEND_REGISTER', 'AFTER', $this, 'handleRegister');
+ }
+
+ /**
+ * Auto register this plugin with the oAuth authentication plugin
+ */
+ public function handleRegister(Event $event, $param)
+ {
+ $event->data[$this->getServiceID()] = $this;
+ }
+
+ /**
+ * Initialize the oAuth service
+ *
+ * @param string $storageId user based storage key (if available, yet)
+ * @throws \OAuth\Common\Exception\Exception
+ */
+ public function initOAuthService($storageId = '')
+ {
+ /** @var \helper_plugin_oauth $hlp */
+ $hlp = plugin_load('helper', 'oauth');
+
+ $credentials = new Credentials(
+ $this->getKey(),
+ $this->getSecret(),
+ $hlp->redirectURI()
+ );
+
+ $serviceFactory = new ServiceFactory();
+ $serviceFactory->setHttpClient(new HTTPClient());
+
+ $servicename = $this->getServiceID();
+ $serviceclass = $this->registerServiceClass();
+ if ($serviceclass) {
+ $serviceFactory->registerService($servicename, $serviceclass);
+ }
+
+ if ($storageId) {
+ $storage = new Storage($storageId);
+ } else {
+ $storage = new SessionStorage();
+ }
+
+ $this->oAuth = $serviceFactory->createService(
+ $servicename,
+ $credentials,
+ $storage,
+ $this->getScopes()
+ );
+
+ if ($this->oAuth === null) {
+ throw new Exception('Failed to initialize Service ' . $this->getLabel());
+ }
+ }
+
+ /**
+ * @return Abstract2Service|Abstract1Service
+ * @throws Exception
+ */
+ public function getOAuthService()
+ {
+ if ($this->oAuth === null) throw new Exception('OAuth Service not properly initialized');
+ return $this->oAuth;
+ }
+
+ /**
+ * Once a user has been authenticated, the current token storage needs to be made permanent
+ *
+ * @param string $storageId
+ * @throws Exception
+ * @throws TokenNotFoundException
+ */
+ public function upgradeStorage($storageId)
+ {
+ $oauth = $this->getOAuthService();
+ $service = $oauth->service();
+
+ $oldStorage = $oauth->getStorage();
+ $newStorage = new Storage($storageId);
+ if ($oldStorage->hasAccessToken($service)) {
+ $newStorage->storeAccessToken($service, $oldStorage->retrieveAccessToken($service));
+ }
+ if ($oldStorage->hasAuthorizationState($service)) {
+ $newStorage->storeAuthorizationState($service, $oldStorage->retrieveAuthorizationState($service));
+ }
+
+ // fixme invalidate current oauth object? reinitialize it?
+ }
+
+ /**
+ * Refresh a possibly outdated access token
+ *
+ * Does nothing when the current token is still good to use
+ *
+ * @return void
+ * @throws MissingRefreshTokenException
+ * @throws TokenNotFoundException
+ * @throws TokenResponseException
+ * @throws Exception
+ */
+ public function refreshOutdatedToken()
+ {
+ $oauth = $this->getOAuthService();
+
+ if (!$oauth->getStorage()->hasAccessToken($oauth->service())) {
+ // no token to refresh
+ return;
+ }
+
+ $token = $oauth->getStorage()->retrieveAccessToken($oauth->service());
+ if (
+ $token->getEndOfLife() < 0 ||
+ $token->getEndOfLife() - time() > 3600
+ ) {
+ // token is still good
+ return;
+ }
+
+ $refreshToken = $token->getRefreshToken();
+ $token = $oauth->refreshAccessToken($token);
+
+ // If the IDP did not provide a new refresh token, store the old one
+ if (!$token->getRefreshToken()) {
+ $token->setRefreshToken($refreshToken);
+ $oauth->getStorage()->storeAccessToken($oauth->service(), $token);
+ }
+ }
+
+ /**
+ * Redirects to the service for requesting access
+ *
+ * This is the first step of oAuth authentication
+ *
+ * This implementation tries to abstract away differences between oAuth1 and oAuth2,
+ * but might need to be overwritten for specific services
+ *
+ * @throws TokenResponseException
+ * @throws \Exception
+ */
+ public function login()
+ {
+ $oauth = $this->getOAuthService();
+
+ // store Farmer animal in oAuth state parameter
+ /** @var \helper_plugin_farmer $farmer */
+ $farmer = plugin_load('helper', 'farmer');
+ $parameters = [];
+ if ($farmer && $animal = $farmer->getAnimal()) {
+ $parameters['state'] = urlencode(base64_encode(json_encode(
+ [
+ 'animal' => $animal,
+ 'state' => md5(random_int(0, mt_getrandmax())),
+ ]
+ )));
+ $oauth->getStorage()->storeAuthorizationState($oauth->service(), $parameters['state']);
+ }
+
+ if (is_a($oauth, Abstract1Service::class)) { /* oAuth1 handling */
+ // extra request needed for oauth1 to request a request token
+ $token = $oauth->requestRequestToken();
+ $parameters['oauth_token'] = $token->getRequestToken();
+ }
+ $url = $oauth->getAuthorizationUri($parameters);
+
+ send_redirect($url);
+ }
+
+ /**
+ * Request access token
+ *
+ * This is the second step of oAuth authentication
+ *
+ * This implementation tries to abstract away differences between oAuth1 and oAuth2,
+ * but might need to be overwritten for specific services
+ *
+ * Thrown exceptions indicate a non-successful login because of some error, appropriate messages
+ * should be shown to the user. A return of false with no exceptions indicates that there was no
+ * oauth data at all. This can probably be silently ignored.
+ *
+ * @return bool true if authentication was successful
+ * @throws \OAuth\Common\Exception\Exception
+ * @throws InvalidAuthorizationStateException
+ */
+ public function checkToken()
+ {
+ global $INPUT;
+
+ $oauth = $this->getOAuthService();
+
+ if (is_a($oauth, Abstract2Service::class)) {
+ if (!$INPUT->get->has('code')) return false;
+ $state = $INPUT->get->str('state', null);
+ $accessToken = $oauth->requestAccessToken($INPUT->get->str('code'), $state);
+ } else {
+ if (!$INPUT->get->has('oauth_token')) return false;
+ /** @var TokenInterface $token */
+ $token = $oauth->getStorage()->retrieveAccessToken($this->getServiceID());
+ $accessToken = $oauth->requestAccessToken(
+ $INPUT->get->str('oauth_token'),
+ $INPUT->get->str('oauth_verifier'),
+ $token->getRequestTokenSecret()
+ );
+ }
+
+ if (
+ $accessToken->getEndOfLife() !== $accessToken::EOL_NEVER_EXPIRES &&
+ !$accessToken->getRefreshToken()
+ ) {
+ msg('Service did not provide a Refresh Token. You will be logged out when the session expires.');
+ }
+
+ return true;
+ }
+
+ /**
+ * Return the Service Login Button
+ *
+ * @return string
+ */
+ public function loginButton()
+ {
+ global $ID;
+
+ $attr = buildAttributes([
+ 'href' => wl($ID, ['oauthlogin' => $this->getServiceID()], false, '&'),
+ 'class' => 'plugin_oauth_' . $this->getServiceID(),
+ 'style' => 'background-color: ' . $this->getColor(),
+ ]);
+
+ return '' . $this->getSvgLogo() . '' . $this->getLabel() . ' ';
+ }
+ // endregion
+
+ // region overridable methods
+
+ /**
+ * Called on logout
+ *
+ * If there are required procedures for the service, you can implement them by overriding this.
+ *
+ * @return void
+ */
+ public function logout()
+ {
+ }
+
+ /**
+ * Retrieve the user's data via API
+ *
+ * The returned array needs to contain at least 'email', 'name', 'user' and optionally 'grps'
+ *
+ * Use the request() method of the oauth object to talk to the API
+ *
+ * @return array
+ * @throws Exception
+ * @see getOAuthService()
+ */
+ abstract public function getUser();
+
+ /**
+ * Return the scopes to request
+ *
+ * This should return the minimal scopes needed for accessing the user's data
+ *
+ * @return string[]
+ */
+ public function getScopes()
+ {
+ return [];
+ }
+
+ /**
+ * Return the user friendly name of the service
+ *
+ * Defaults to ServiceID. You may want to override this.
+ *
+ * @return string
+ */
+ public function getLabel()
+ {
+ return ucfirst($this->getServiceID());
+ }
+
+ /**
+ * Return the internal name of the Service
+ *
+ * Defaults to the plugin name (without oauth prefix). This has to match the Service class name in
+ * the appropriate lusitantian oauth Service namespace
+ *
+ * @return string
+ */
+ public function getServiceID()
+ {
+ $name = $this->getPluginName();
+ if (substr($name, 0, 5) === 'oauth') {
+ $name = substr($name, 5);
+ }
+
+ return $name;
+ }
+
+ /**
+ * Register a new Service
+ *
+ * @return string A fully qualified class name to register as new Service for your ServiceID
+ */
+ public function registerServiceClass()
+ {
+ return null;
+ }
+
+ /**
+ * Return the button color to use
+ *
+ * @return string
+ */
+ public function getColor()
+ {
+ return '#999';
+ }
+
+ /**
+ * Return the SVG of the logo for this service
+ *
+ * Defaults to a logo.svg in the plugin directory
+ *
+ * @return string
+ */
+ public function getSvgLogo()
+ {
+ $logo = DOKU_PLUGIN . $this->getPluginName() . '/logo.svg';
+ if (file_exists($logo)) return inlineSVG($logo);
+ return '';
+ }
+
+ /**
+ * The oauth key
+ *
+ * @return string
+ */
+ public function getKey()
+ {
+ return $this->getConf('key');
+ }
+
+ /**
+ * The oauth secret
+ *
+ * @return string
+ */
+ public function getSecret()
+ {
+ return $this->getConf('secret');
+ }
+
+ // endregion
+}
diff --git a/Exception.php b/Exception.php
new file mode 100644
index 0000000..efdba5b
--- /dev/null
+++ b/Exception.php
@@ -0,0 +1,46 @@
+context = $context;
+ }
+
+ /**
+ * Get the translation context
+ *
+ * @return array
+ */
+ public function getContext()
+ {
+ return $this->context;
+ }
+
+ /**
+ * Set the translation context
+ *
+ * @param array $context
+ */
+ public function setContext(array $context)
+ {
+ $this->context = $context;
+ }
+}
diff --git a/HTTPClient.php b/HTTPClient.php
new file mode 100644
index 0000000..7f54e6a
--- /dev/null
+++ b/HTTPClient.php
@@ -0,0 +1,38 @@
+keep_alive = false;
+ $http->headers = array_merge($http->headers, $extraHeaders);
+
+ $ok = $http->sendRequest($endpoint->getAbsoluteUri(), $requestBody, $method);
+ if (!$ok || $http->status < 200 || $http->status > 299) {
+ $msg = "An error occured during the request to the oauth provider:\n";
+ throw new HttpTokenResponseException(
+ $msg . $http->error . ' [HTTP ' . $http->status . ']',
+ $http->status,
+ $http->error,
+ $http->resp_body
+ );
+ }
+
+ return $http->resp_body;
+ }
+}
diff --git a/HttpTokenResponseException.php b/HttpTokenResponseException.php
new file mode 100644
index 0000000..be493c7
--- /dev/null
+++ b/HttpTokenResponseException.php
@@ -0,0 +1,67 @@
+httpStatusCode = $httpStatusCode;
+ $this->httpErrorMessage = $httpErrorMessage;
+ $this->httpRespBody = $httpRespBody;
+ }
+
+ /**
+ * Get the HTTP status code
+ *
+ * @return int
+ */
+ public function getHttpStatusCode()
+ {
+ return $this->httpStatusCode;
+ }
+
+ /**
+ * Get the HTTP error message
+ *
+ * @return string
+ */
+ public function getHttpErrorMessage()
+ {
+ return $this->httpErrorMessage;
+ }
+
+ /**
+ * Get the HTTP response body
+ *
+ * @return mixed
+ */
+ public function getHttpRespBody()
+ {
+ return $this->httpRespBody;
+ }
+}
diff --git a/OAuthManager.php b/OAuthManager.php
new file mode 100644
index 0000000..b7f0f94
--- /dev/null
+++ b/OAuthManager.php
@@ -0,0 +1,315 @@
+setLoginData($servicename, $ID);
+
+ $service = $this->loadService($servicename);
+ $service->initOAuthService();
+ $service->login(); // redirects
+ }
+
+ /**
+ * Continues the flow from various states
+ *
+ * @return bool true if the login has been handled
+ * @throws Exception
+ * @throws \OAuth\Common\Exception\Exception
+ */
+ public function continueFlow()
+ {
+ return $this->loginByService() || $this->loginBySession() || $this->loginByCookie();
+ }
+
+ /**
+ * Second step in a explicit login, validates the oauth code
+ *
+ * @return bool true if successful, false if not applies
+ * @throws \OAuth\Common\Exception\Exception
+ */
+ protected function loginByService()
+ {
+ global $INPUT;
+
+ if (!$INPUT->get->has('code') && !$INPUT->get->has('oauth_token')) {
+ return false;
+ }
+
+ $session = Session::getInstance();
+
+ // init service from session
+ $logindata = $session->getLoginData();
+ if (!$logindata) return false;
+ $service = $this->loadService($logindata['servicename']);
+ $service->initOAuthService();
+
+ $session->clearLoginData();
+
+ // oAuth login
+ if (!$service->checkToken()) throw new \OAuth\Common\Exception\Exception("Invalid Token - Login failed");
+ $userdata = $service->getUser();
+
+ // processing
+ $userdata = $this->validateUserData($userdata, $logindata['servicename']);
+ $userdata = $this->processUserData($userdata, $logindata['servicename']);
+
+ // store data
+ $storageId = $this->getStorageId($userdata['mail']);
+ $service->upgradeStorage($storageId);
+
+ // login
+ $session->setUser($userdata); // log in
+ $session->setCookie($logindata['servicename'], $storageId); // set cookie
+
+ // redirect to the appropriate ID
+ if (!empty($logindata['id'])) {
+ send_redirect(wl($logindata['id'], [], true, '&'));
+ }
+ return true;
+ }
+
+ /**
+ * Login based on user's current session data
+ *
+ * This will also log in plainauth users
+ *
+ * @return bool true if successful, false if not applies
+ * @throws Exception
+ */
+ protected function loginBySession()
+ {
+ $session = Session::getInstance();
+ if (!$session->isValid()) {
+ $session->clear();
+ return false;
+ }
+
+ $userdata = $session->getUser();
+ if (!$userdata) return false;
+ if (!isset($userdata['user'])) return false; // default dokuwiki does not put username here, let DW handle it
+ $session->setUser($userdata, false); // does a login without resetting the time
+ return true;
+ }
+
+ /**
+ * Login based on user cookie and a previously saved access token
+ *
+ * @return bool true if successful, false if not applies
+ * @throws \OAuth\Common\Exception\Exception
+ */
+ protected function loginByCookie()
+ {
+ $session = Session::getInstance();
+ $cookie = $session->getCookie();
+ if (!$cookie) return false;
+
+ $service = $this->loadService($cookie['servicename']);
+ $service->initOAuthService($cookie['storageId']);
+
+ // ensure that we have a current access token
+ $service->refreshOutdatedToken();
+
+ // this should use a previously saved token
+ $userdata = $service->getUser();
+
+ // processing
+ $userdata = $this->validateUserData($userdata, $cookie['servicename']);
+ $userdata = $this->processUserData($userdata, $cookie['servicename']);
+
+ $session->setUser($userdata); // log in
+ return true;
+ }
+
+ /**
+ * Callback service's logout
+ *
+ * @return void
+ */
+ public function logout()
+ {
+ $session = Session::getInstance();
+ $cookie = $session->getCookie();
+ if (!$cookie) return;
+ try {
+ $service = $this->loadService($cookie['servicename']);
+ $service->initOAuthService($cookie['storageId']);
+ $service->logout();
+ } catch (\OAuth\Common\Exception\Exception $e) {
+ return;
+ }
+ }
+
+ // endregion
+
+ /**
+ * The ID we store authentication data as
+ *
+ * @param string $mail
+ * @return string
+ */
+ protected function getStorageId($mail)
+ {
+ return md5($mail);
+ }
+
+ /**
+ * Clean and validate the user data provided from the service
+ *
+ * @param array $userdata
+ * @param string $servicename
+ * @return array
+ * @throws Exception
+ */
+ protected function validateUserData($userdata, $servicename)
+ {
+ /** @var \auth_plugin_oauth */
+ global $auth;
+
+ // mail is required
+ if (empty($userdata['mail'])) {
+ throw new Exception('noEmail', [$servicename]);
+ }
+
+ $userdata['mail'] = strtolower($userdata['mail']);
+
+ // mail needs to be allowed
+ /** @var \helper_plugin_oauth $hlp */
+ $hlp = plugin_load('helper', 'oauth');
+
+ if (!$hlp->checkMail($userdata['mail'])) {
+ throw new Exception('rejectedEMail', [implode(', ', $hlp->getValidDomains())]);
+ }
+
+ // make username from mail if empty
+ if (!isset($userdata['user'])) $userdata['user'] = '';
+ $userdata['user'] = $auth->cleanUser((string)$userdata['user']);
+ if ($userdata['user'] === '') {
+ [$userdata['user']] = explode('@', $userdata['mail']);
+ }
+
+ // make full name from username if empty
+ if (empty($userdata['name'])) {
+ $userdata['name'] = $userdata['user'];
+ }
+
+ // make sure groups are array and valid
+ if (!isset($userdata['grps'])) $userdata['grps'] = [];
+ $userdata['grps'] = array_map([$auth, 'cleanGroup'], (array)$userdata['grps']);
+
+ return $userdata;
+ }
+
+ /**
+ * Process the userdata, update the user info array and create the user if necessary
+ *
+ * Uses the global $auth object for user management
+ *
+ * @param array $userdata User info received from authentication
+ * @param string $servicename Auth service
+ * @return array the modified user info
+ * @throws Exception
+ */
+ protected function processUserData($userdata, $servicename)
+ {
+ /** @var \auth_plugin_oauth $auth */
+ global $auth;
+
+ // see if the user is known already
+ $localUser = $auth->getUserByEmail($userdata['mail']);
+ if ($localUser) {
+ $localUserInfo = $auth->getUserData($localUser);
+ $localUserInfo['user'] = $localUser;
+ if (isset($localUserInfo['pass'])) unset($localUserInfo['pass']);
+
+ // check if the user allowed access via this service
+ if (!in_array($auth->cleanGroup($servicename), $localUserInfo['grps'])) {
+ throw new Exception('authnotenabled', [$servicename]);
+ }
+
+ $helper = plugin_load('helper', 'oauth');
+
+ $userdata['user'] = $localUser;
+ $userdata['name'] = $localUserInfo['name'];
+ $userdata['grps'] = $this->mergeGroups(
+ $localUserInfo['grps'],
+ $userdata['grps'] ?? [],
+ array_keys($helper->listServices(false)),
+ $auth->getConf('overwrite-groups')
+ );
+
+ // update user if changed
+ sort($localUserInfo['grps']);
+ sort($userdata['grps']);
+ if ($localUserInfo != $userdata && !isset($localUserInfo['protected'])) {
+ $auth->modifyUser($localUser, $userdata);
+ }
+ } elseif (actionOK('register') || $auth->getConf('register-on-auth')) {
+ if (!$auth->registerOAuthUser($userdata, $servicename)) {
+ throw new Exception('generic create error');
+ }
+ } else {
+ throw new Exception('addUser not possible');
+ }
+
+ return $userdata;
+ }
+
+ /**
+ * Merges local and provider user groups. Keeps internal
+ * Dokuwiki groups unless configured to overwrite all ('overwrite-groups' setting)
+ *
+ * @param string[] $localGroups Local user groups
+ * @param string[] $providerGroups Groups fetched from the provider
+ * @param string[] $servicenames Service names that should be kept if set
+ * @param bool $overwrite Config setting to overwrite local DokuWiki groups
+ *
+ * @return array
+ */
+ protected function mergeGroups($localGroups, $providerGroups, $servicenames, $overwrite)
+ {
+ global $conf;
+
+ // overwrite-groups set in config - remove all local groups except services and default
+ if ($overwrite) {
+ $localGroups = array_intersect($localGroups, array_merge($servicenames, [$conf['defaultgroup']]));
+ }
+
+ return array_unique(array_merge($localGroups, $providerGroups));
+ }
+
+ /**
+ * Instantiates a Service by name
+ *
+ * @param string $servicename
+ * @return Adapter
+ * @throws Exception
+ */
+ protected function loadService($servicename)
+ {
+ /** @var \helper_plugin_oauth $hlp */
+ $hlp = plugin_load('helper', 'oauth');
+ $srv = $hlp->loadService($servicename);
+
+ if ($srv === null) throw new Exception("No such service $servicename");
+ return $srv;
+ }
+}
diff --git a/RedirectSetting.php b/RedirectSetting.php
new file mode 100644
index 0000000..545d3f4
--- /dev/null
+++ b/RedirectSetting.php
@@ -0,0 +1,32 @@
+key);
+ $value = '' . $hlp->redirectURI() . '
';
+
+ $label = '' . $this->prompt($plugin) . ' ';
+ $input = '
' . $value . '
';
+ return [$label, $input];
+ }
+}
diff --git a/Service/AbstractOAuth2Base.php b/Service/AbstractOAuth2Base.php
new file mode 100644
index 0000000..5927984
--- /dev/null
+++ b/Service/AbstractOAuth2Base.php
@@ -0,0 +1,57 @@
+setAccessToken($data['access_token']);
+ unset($data['access_token']);
+
+ if (isset($data['expires_in'])) {
+ $token->setLifeTime($data['expires_in']);
+ unset($data['expires_in']);
+ } else {
+ $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
+ }
+
+ if (isset($data['refresh_token'])) {
+ $token->setRefreshToken($data['refresh_token']);
+ unset($data['refresh_token']);
+ }
+
+ $token->setExtraParams($data);
+
+ return $token;
+ }
+
+ /**
+ * We accept arbitrary scopes
+ *
+ * @param string $scope
+ * @return bool
+ */
+ public function isValidScope($scope)
+ {
+ return true;
+ }
+}
diff --git a/Session.php b/Session.php
new file mode 100644
index 0000000..3b63438
--- /dev/null
+++ b/Session.php
@@ -0,0 +1,181 @@
+ $servicename,
+ 'id' => $id,
+ ];
+ }
+
+ /**
+ * Get the current login environment
+ *
+ * @return false|array Either [servicename=>*, id=>*] or false
+ */
+ public function getLoginData()
+ {
+ return $_SESSION[DOKU_COOKIE]['auth']['oauth'] ?? false;
+ }
+
+ /**
+ * Clear login environment after login
+ *
+ * @return void
+ */
+ public function clearLoginData()
+ {
+ if (isset($_SESSION[DOKU_COOKIE]['auth']['oauth'])) {
+ unset($_SESSION[DOKU_COOKIE]['auth']['oauth']);
+ }
+ }
+
+ /**
+ * This basically duplicates what DokuWiki does when a user is logged in
+ *
+ * @param array $userdata
+ * @param bool $resettime Set a new session time? False only when restoring from session
+ * @return void
+ * @throws Exception
+ */
+ public function setUser($userdata, $resettime = true)
+ {
+ global $USERINFO;
+
+ if (
+ !isset($userdata['user']) ||
+ !isset($userdata['name']) ||
+ !isset($userdata['mail']) ||
+ !isset($userdata['grps']) ||
+ !is_array($userdata['grps'])
+ ) {
+ throw new Exception('Missing user data, cannot save to session');
+ }
+
+ $USERINFO = $userdata;
+ $_SERVER['REMOTE_USER'] = $userdata['user'];
+
+ $_SESSION[DOKU_COOKIE]['auth']['user'] = $userdata['user'];
+ $_SESSION[DOKU_COOKIE]['auth']['pass'] = 'not-set'; // pass is neither needed nor wanted
+ $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
+ $_SESSION[DOKU_COOKIE]['auth']['buid'] = auth_browseruid();
+ if ($resettime) {
+ $_SESSION[DOKU_COOKIE]['auth']['time'] = time();
+ }
+ }
+
+ /**
+ * The user data currently saved in the session if any
+ *
+ * @return false|array
+ */
+ public function getUser()
+ {
+ return $_SESSION[DOKU_COOKIE]['auth']['info'] ?? false;
+ }
+
+ /**
+ * Set oAuth info to cookie
+ *
+ * We use the same cookie as standard DokuWiki, but write different info.
+ *
+ * @param string $servicename
+ * @param string $storageId
+ * @return void
+ */
+ public function setCookie($servicename, $storageId)
+ {
+ global $conf;
+ $validityPeriodInSeconds = 60 * 60 * 24 * 365;
+ $cookie = "$servicename|oauth|$storageId";
+ $cookieDir = empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'];
+ $time = time() + $validityPeriodInSeconds;
+ setcookie(
+ DOKU_COOKIE,
+ $cookie,
+ [
+ 'expires' => $time,
+ 'path' => $cookieDir,
+ 'domain' => '',
+ 'secure' => $conf['securecookie'] && is_ssl(),
+ 'httponly' => true
+ ]
+ );
+ }
+
+ /**
+ * Get oAuth info from cookie
+ *
+ * @return array|false Either [servicename=>?, storageID=>?] or false if no oauth data in cookie
+ */
+ public function getCookie()
+ {
+ if (!isset($_COOKIE[DOKU_COOKIE])) return false;
+ [$servicename, $oauth, $storageId] = explode('|', $_COOKIE[DOKU_COOKIE]);
+ if ($oauth !== 'oauth') return false;
+ return ['servicename' => $servicename, 'storageId' => $storageId];
+ }
+
+ /**
+ * Is any auth data in the session currently trustworthy?
+ * @return bool
+ */
+ public function isValid()
+ {
+ global $conf;
+
+ if (!isset($_SESSION[DOKU_COOKIE]['auth']['buid'])) return false;
+ if (!isset($_SESSION[DOKU_COOKIE]['auth']['time'])) return false;
+ if ($_SESSION[DOKU_COOKIE]['auth']['buid'] != auth_browseruid()) return false;
+ if ($_SESSION[DOKU_COOKIE]['auth']['time'] < time() - $conf['auth_security_timeout']) return false;
+
+ return true;
+ }
+
+ /**
+ * Clear the session from auth related data
+ * @return void
+ */
+ public function clear()
+ {
+ //FIXME clear cookie?
+ $this->clearLoginData();
+ }
+}
diff --git a/Storage.php b/Storage.php
new file mode 100644
index 0000000..f2bf76b
--- /dev/null
+++ b/Storage.php
@@ -0,0 +1,152 @@
+storageId = $storageId;
+ }
+
+ /**
+ * The path to the file where tokens for this service and user are stored
+ *
+ * @param string $service
+ * @return string
+ */
+ protected function getServiceFile($service)
+ {
+ return getCacheName($this->storageId . $service, '.oauth');
+ }
+
+ /**
+ * Load the data from disk
+ *
+ * @param string $service
+ * @return array
+ */
+ protected function loadServiceFile($service)
+ {
+ $file = $this->getServiceFile($service);
+ if (file_exists($file)) {
+ return unserialize(io_readFile($file, false));
+ } else {
+ return [];
+ }
+ }
+
+ /**
+ * Store the data to disk
+ *
+ * @param string $service
+ * @param array $data
+ */
+ protected function saveServiceFile($service, $data)
+ {
+ $file = $this->getServiceFile($service);
+ io_saveFile($file, serialize($data));
+ }
+
+ /** @inheritDoc */
+ public function retrieveAccessToken($service)
+ {
+ $data = $this->loadServiceFile($service);
+ if (!isset($data['token'])) {
+ throw new TokenNotFoundException('No token found in storage');
+ }
+ return $data['token'];
+ }
+
+ /** @inheritDoc */
+ public function storeAccessToken($service, TokenInterface $token)
+ {
+ $data = $this->loadServiceFile($service);
+ $data['token'] = $token;
+ $this->saveServiceFile($service, $data);
+ }
+
+ /** @inheritDoc */
+ public function hasAccessToken($service)
+ {
+ $data = $this->loadServiceFile($service);
+ return isset($data['token']);
+ }
+
+ /** @inheritDoc */
+ public function clearToken($service)
+ {
+ $data = $this->loadServiceFile($service);
+ if (isset($data['token'])) unset($data['token']);
+ $this->saveServiceFile($service, $data);
+
+ return $this;
+ }
+
+ /** @inheritDoc */
+ public function clearAllTokens()
+ {
+ // TODO: Implement clearAllTokens() method.
+ return $this;
+ }
+
+ /** @inheritDoc */
+ public function storeAuthorizationState($service, $state)
+ {
+ $data = $this->loadServiceFile($service);
+ $data['state'] = $state;
+ $this->saveServiceFile($service, $data);
+ return $this;
+ }
+
+ /** @inheritDoc */
+ public function hasAuthorizationState($service)
+ {
+ $data = $this->loadServiceFile($service);
+ return isset($data['state']);
+ }
+
+ /**
+ * @inheritDoc
+ * @throws TokenNotFoundException
+ */
+ public function retrieveAuthorizationState($service)
+ {
+ $data = $this->loadServiceFile($service);
+ if (!isset($data['state'])) {
+ throw new TokenNotFoundException('No state found in storage');
+ }
+ return $data['state'];
+ }
+
+ /** @inheritDoc */
+ public function clearAuthorizationState($service)
+ {
+ $data = $this->loadServiceFile($service);
+ if (isset($data['state'])) unset($data['state']);
+ $this->saveServiceFile($service, $data);
+
+ return $this;
+ }
+
+ /** @inheritDoc */
+ public function clearAllAuthorizationStates()
+ {
+ // TODO: Implement clearAllAuthorizationStates() method.
+
+ return $this;
+ }
+}
diff --git a/_test/CheckMailTest.php b/_test/CheckMailTest.php
new file mode 100644
index 0000000..9ee283e
--- /dev/null
+++ b/_test/CheckMailTest.php
@@ -0,0 +1,51 @@
+assertSame($expected, $hlp->checkMail($input));
+ }
+}
diff --git a/_test/GeneralTest.php b/_test/GeneralTest.php
new file mode 100644
index 0000000..335650d
--- /dev/null
+++ b/_test/GeneralTest.php
@@ -0,0 +1,86 @@
+assertFileExists($file);
+
+ $info = confToHash($file);
+
+ $this->assertArrayHasKey('base', $info);
+ $this->assertArrayHasKey('author', $info);
+ $this->assertArrayHasKey('email', $info);
+ $this->assertArrayHasKey('date', $info);
+ $this->assertArrayHasKey('name', $info);
+ $this->assertArrayHasKey('desc', $info);
+ $this->assertArrayHasKey('url', $info);
+
+ $this->assertEquals('oauth', $info['base']);
+ $this->assertRegExp('/^https?:\/\//', $info['url']);
+ $this->assertTrue(mail_isvalid($info['email']));
+ $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
+ $this->assertTrue(false !== strtotime($info['date']));
+ }
+
+ /**
+ * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in
+ * conf/metadata.php.
+ */
+ public function testPluginConf(): void
+ {
+ $conf_file = __DIR__ . '/../conf/default.php';
+ $meta_file = __DIR__ . '/../conf/metadata.php';
+
+ if (!file_exists($conf_file) && !file_exists($meta_file)) {
+ self::markTestSkipped('No config files exist -> skipping test');
+ }
+
+ if (file_exists($conf_file)) {
+ include($conf_file);
+ }
+ if (file_exists($meta_file)) {
+ include($meta_file);
+ }
+
+ $this->assertEquals(
+ gettype($conf),
+ gettype($meta),
+ 'Both ' . DOKU_PLUGIN . 'oauth/conf/default.php and ' . DOKU_PLUGIN . 'oauth/conf/metadata.php have to exist and contain the same keys.'
+ );
+
+ if ($conf !== null && $meta !== null) {
+ foreach ($conf as $key => $value) {
+ $this->assertArrayHasKey(
+ $key,
+ $meta,
+ 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'oauth/conf/metadata.php'
+ );
+ }
+
+ foreach ($meta as $key => $value) {
+ $this->assertArrayHasKey(
+ $key,
+ $conf,
+ 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'oauth/conf/default.php'
+ );
+ }
+ }
+
+ }
+}
diff --git a/_test/MergeGroupsTest.php b/_test/MergeGroupsTest.php
new file mode 100644
index 0000000..79ab0a6
--- /dev/null
+++ b/_test/MergeGroupsTest.php
@@ -0,0 +1,73 @@
+callInaccessibleMethod(
+ $oauthMgr, 'mergeGroups',
+ [$localGroups, $providerGroups, $services, $overwrite]
+ );
+ sort($expect);
+ sort($result);
+
+ $this->assertEquals($expect, $result);
+ }
+
+}
diff --git a/_test/ValidateUserDataTest.php b/_test/ValidateUserDataTest.php
new file mode 100644
index 0000000..c399511
--- /dev/null
+++ b/_test/ValidateUserDataTest.php
@@ -0,0 +1,62 @@
+ 'test@ExamPLe.com'],
+ ['user' => 'test', 'name' => 'test', 'mail' => 'test@example.com', 'grps' => []],
+ ],
+ [
+ ['user' => 'tuser', 'mail' => 'test@example.com', 'grps' => ['one grp', 'Two']],
+ ['user' => 'tuser', 'name' => 'tuser', 'mail' => 'test@example.com', 'grps' => ['one_grp', 'two']],
+ ],
+ [
+ ['user' => 'TEST', 'name' => 'Test User', 'mail' => 'test@example.com', 'grps' => ['one', 'two']],
+ ['user' => 'test', 'name' => 'Test User', 'mail' => 'test@example.com', 'grps' => ['one', 'two']],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideUserData
+ */
+ public function testValidateUserData($input, $expect)
+ {
+ $oauthMgr = new OAuthManager();
+ $result = $this->callInaccessibleMethod($oauthMgr, 'validateUserData', [$input, 'service']);
+ $this->assertEquals($expect, $result);
+ }
+
+ public function testMissingMail()
+ {
+ $this->expectException(Exception::class);
+
+ $input = [
+ 'user' => 'test',
+ 'name' => 'Test USer',
+ ];
+ $oauthMgr = new OAuthManager();
+ $this->callInaccessibleMethod($oauthMgr, 'validateUserData', [$input, 'service']);
+ }
+}
diff --git a/_test/checkMail.test.php b/_test/checkMail.test.php
deleted file mode 100644
index 5175e51..0000000
--- a/_test/checkMail.test.php
+++ /dev/null
@@ -1,44 +0,0 @@
-assertTrue($hlp->checkMail($testmail),$testmail);
- $testmail = "bar@example.com";
- $this->assertTrue($hlp->checkMail($testmail), $testmail);
- $testmail = "bar@bar.org";
- $this->assertFalse($hlp->checkMail($testmail), $testmail);
- }
-
- public function test_checkMail_oneDomains() {
-
- global $conf;
- $conf['plugin']['oauth']['mailRestriction'] = '@foo.org';
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
-
- $testmail = "bar@foo.org";
- $this->assertTrue($hlp->checkMail($testmail),$testmail);
- $testmail = "bar@example.com";
- $this->assertFalse($hlp->checkMail($testmail), $testmail);
- $testmail = "bar@bar.org";
- $this->assertFalse($hlp->checkMail($testmail), $testmail);
- }
-
-}
diff --git a/_test/general.test.php b/_test/general.test.php
deleted file mode 100644
index 7182af5..0000000
--- a/_test/general.test.php
+++ /dev/null
@@ -1,33 +0,0 @@
-assertFileExists($file);
-
- $info = confToHash($file);
-
- $this->assertArrayHasKey('base', $info);
- $this->assertArrayHasKey('author', $info);
- $this->assertArrayHasKey('email', $info);
- $this->assertArrayHasKey('date', $info);
- $this->assertArrayHasKey('name', $info);
- $this->assertArrayHasKey('desc', $info);
- $this->assertArrayHasKey('url', $info);
-
- $this->assertEquals('oauth', $info['base']);
- $this->assertRegExp('/^https?:\/\//', $info['url']);
- $this->assertTrue(mail_isvalid($info['email']));
- $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
- $this->assertTrue(false !== strtotime($info['date']));
- }
-}
diff --git a/action.php b/action.php
deleted file mode 100644
index 2e6bce2..0000000
--- a/action.php
+++ /dev/null
@@ -1,259 +0,0 @@
-
- */
-
-// must be run within Dokuwiki
-if(!defined('DOKU_INC')) die();
-
-class action_plugin_oauth extends DokuWiki_Action_Plugin {
-
- /**
- * Registers a callback function for a given event
- *
- * @param Doku_Event_Handler $controller DokuWiki's event controller object
- * @return void
- */
- public function register(Doku_Event_Handler $controller) {
- global $conf;
- if($conf['authtype'] != 'oauth') return;
-
- $conf['profileconfirm'] = false; // password confirmation doesn't work with oauth only users
-
- $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_start');
- $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_loginform');
- $controller->register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'BEFORE', $this, 'handle_profileform');
- $controller->register_hook('AUTH_USER_CHANGE', 'BEFORE', $this, 'handle_usermod');
- $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_dologin');
- }
-
- /**
- * Start an oAuth login or restore environment after successful login
- *
- * @param Doku_Event $event event object by reference
- * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
- * handler was registered]
- * @return void
- */
- public function handle_start(Doku_Event &$event, $param) {
-
- if (isset($_SESSION[DOKU_COOKIE]['oauth-done']['do']) || !empty($_SESSION[DOKU_COOKIE]['oauth-done']['rev'])){
- $this->restoreSessionEnvironment();
- return;
- }
-
- $this->startOAuthLogin();
- }
-
- private function startOAuthLogin() {
- global $INPUT, $ID;
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
- $servicename = $INPUT->str('oauthlogin');
- $service = $hlp->loadService($servicename);
- if(is_null($service)) return;
-
- // remember service in session
- session_start();
- $_SESSION[DOKU_COOKIE]['oauth-inprogress']['service'] = $servicename;
- $_SESSION[DOKU_COOKIE]['oauth-inprogress']['id'] = $ID;
- session_write_close();
-
- $service->login();
- }
-
- private function restoreSessionEnvironment() {
- global $INPUT, $ACT, $TEXT, $PRE, $SUF, $SUM, $RANGE, $DATE_AT, $REV;
- $ACT = $_SESSION[DOKU_COOKIE]['oauth-done']['do'];
- $_REQUEST = $_SESSION[DOKU_COOKIE]['oauth-done']['$_REQUEST'];
-
- $REV = $INPUT->int('rev');
- $DATE_AT = $INPUT->str('at');
- $RANGE = $INPUT->str('range');
- if($INPUT->post->has('wikitext')) {
- $TEXT = cleanText($INPUT->post->str('wikitext'));
- }
- $PRE = cleanText(substr($INPUT->post->str('prefix'), 0, -1));
- $SUF = cleanText($INPUT->post->str('suffix'));
- $SUM = $INPUT->post->str('summary');
-
- unset($_SESSION[DOKU_COOKIE]['oauth-done']);
- }
-
- /**
- * Save groups for all the services a user has enabled
- *
- * @param Doku_Event $event event object by reference
- * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
- * handler was registered]
- * @return void
- */
- public function handle_usermod(Doku_Event &$event, $param) {
- global $ACT;
- global $USERINFO;
- global $auth;
- global $INPUT;
-
- if($event->data['type'] != 'modify') return;
- if($ACT != 'profile') return;
-
- // we want to modify the user's groups
- $groups = $USERINFO['grps']; //current groups
- if(isset($event->data['params'][1]['grps'])) {
- // something already defined new groups
- $groups = $event->data['params'][1]['grps'];
- }
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
-
- // get enabled and configured services
- $enabled = $INPUT->arr('oauth_group');
- $services = $hlp->listServices();
- $services = array_map(array($auth, 'cleanGroup'), $services);
-
- // add all enabled services as group, remove all disabled services
- foreach($services as $service) {
- if(isset($enabled[$service])) {
- $groups[] = $service;
- } else {
- $idx = array_search($service, $groups);
- if($idx !== false) unset($groups[$idx]);
- }
- }
- $groups = array_unique($groups);
-
- // add new group array to event data
- $event->data['params'][1]['grps'] = $groups;
-
- }
-
- /**
- * Add service selection to user profile
- *
- * @param Doku_Event $event event object by reference
- * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
- * handler was registered]
- * @return void
- */
- public function handle_profileform(Doku_Event &$event, $param) {
- global $USERINFO;
- /** @var auth_plugin_authplain $auth */
- global $auth;
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
-
- /** @var Doku_Form $form */
- $form =& $event->data;
- $pos = $form->findElementByAttribute('type', 'submit');
-
- $services = $hlp->listServices();
- if(!$services) return;
-
- $form->insertElement($pos, form_closefieldset());
- $form->insertElement(++$pos, form_openfieldset(array('_legend' => $this->getLang('loginwith'), 'class' => 'plugin_oauth')));
- foreach($services as $service) {
- $group = $auth->cleanGroup($service);
- $elem = form_makeCheckboxField(
- 'oauth_group['.$group.']',
- 1, $service, '', 'simple',
- array(
- 'checked' => (in_array($group, $USERINFO['grps'])) ? 'checked' : ''
- )
- );
-
- $form->insertElement(++$pos, $elem);
- }
- $form->insertElement(++$pos, form_closefieldset());
- $form->insertElement(++$pos, form_openfieldset(array()));
- }
-
- /**
- * Add the oAuth login links
- *
- * @param Doku_Event $event event object by reference
- * @param mixed $param [the parameters passed as fifth argument to register_hook() when this
- * handler was registered]
- * @return void
- */
- public function handle_loginform(Doku_Event &$event, $param) {
- global $conf;
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
- $singleService = $this->getConf('singleService');
- $enabledServices = $hlp->listServices();
-
- /** @var Doku_Form $form */
- $form =& $event->data;
- $html = '';
-
- $validDomains = $hlp->getValidDomains();
-
- if (count($validDomains) > 0) {
- $html .= sprintf($this->getLang('eMailRestricted'), join(', ', $validDomains));
- }
-
- if ($singleService == '') {
-
- foreach($hlp->listServices() as $service) {
- $html .= $this->service_html($service);
- }
- if(!$html) return;
-
- }else{
- if (in_array($singleService, $enabledServices, true) === false) {
- msg($this->getLang('wrongConfig'),-1);
- return;
- }
- $form->_content = array();
- $html = $this->service_html($singleService);
-
- }
- $form->_content[] = form_openfieldset(array('_legend' => $this->getLang('loginwith'), 'class' => 'plugin_oauth'));
- $form->_content[] = $html;
- $form->_content[] = form_closefieldset();
- }
-
- function service_html ($service){
- global $ID;
- $html = '';
- $html .= '';
- $html .= $service;
- $html .= ' ';
- return $html;
-
- }
-
- public function handle_dologin(Doku_Event &$event, $param) {
- global $lang;
- global $ID;
-
- $singleService = $this->getConf('singleService');
- if ($singleService == '') return true;
-
- $lang['btn_login'] = $this->getLang('loginButton') . $singleService;
-
- if($event->data != 'login') return true;
-
-
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
- $enabledServices = $hlp->listServices();
- if (in_array($singleService, $enabledServices, true) === false) {
- msg($this->getLang('wrongConfig'),-1);
- return false;
- }
-
- $url = wl($ID, array('oauthlogin' => $singleService), true, '&');
- send_redirect($url);
- }
-
-}
-// vim:ts=4:sw=4:et:
diff --git a/action/login.php b/action/login.php
new file mode 100644
index 0000000..8bb16f8
--- /dev/null
+++ b/action/login.php
@@ -0,0 +1,209 @@
+
+ */
+class action_plugin_oauth_login extends ActionPlugin
+{
+ /** @var helper_plugin_oauth */
+ protected $hlp;
+
+ /**
+ * Constructor
+ *
+ * Initializes the helper
+ */
+ public function __construct()
+ {
+ $this->hlp = plugin_load('helper', 'oauth');
+ }
+
+ /**
+ * Registers a callback function for a given event
+ *
+ * @param EventHandler $controller DokuWiki's event controller object
+ * @return void
+ */
+ public function register(EventHandler $controller)
+ {
+ global $conf;
+ if ($conf['authtype'] != 'oauth') return;
+
+ $conf['profileconfirm'] = false; // password confirmation doesn't work with oauth only users
+
+ $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handleStart');
+ $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handleOldLoginForm'); // @deprecated
+ $controller->register_hook('FORM_LOGIN_OUTPUT', 'BEFORE', $this, 'handleLoginForm');
+ $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handleDoLogin');
+ $controller->register_hook('ACTION_DENIED_TPLCONTENT', 'BEFORE', $this, 'handleDeniedForm');
+ }
+
+ /**
+ * Start an oAuth login or restore environment after successful login
+ *
+ * @param Event $event
+ * @return void
+ */
+ public function handleStart(Event $event)
+ {
+ global $INPUT;
+
+ // see if a login needs to be started
+ $servicename = $INPUT->str('oauthlogin');
+ if (!$servicename) return;
+
+ try {
+ $om = new OAuthManager();
+ $om->startFlow($servicename);
+ } catch (TokenResponseException | Exception $e) {
+ $this->hlp->showException($e, 'login failed');
+ }
+ }
+
+ /**
+ * Add the oAuth login links to login form
+ *
+ * @param Event $event event object by reference
+ * @return void
+ * @deprecated can be removed in the future
+ */
+ public function handleOldLoginForm(Event $event)
+ {
+ /** @var Doku_Form $form */
+ $form = $event->data;
+ $html = $this->prepareLoginButtons();
+ if (!$html) return;
+
+ // remove login form if single service is set
+ $singleService = $this->getConf('singleService');
+ if ($singleService) {
+ $form->_content = [];
+ }
+
+ $form->_content[] = form_openfieldset(
+ [
+ '_legend' => $this->getLang('loginwith'),
+ 'class' => 'plugin_oauth',
+ ]
+ );
+ $form->_content[] = $html;
+ $form->_content[] = form_closefieldset();
+ }
+
+ /**
+ * Add the oAuth login links to login form
+ *
+ * @param Event $event event object by reference
+ * @return void
+ * @deprecated can be removed in the future
+ */
+ public function handleLoginForm(Event $event)
+ {
+ /** @var Form $form */
+ $form = $event->data;
+ $html = $this->prepareLoginButtons();
+ if (!$html) return;
+
+ // remove login form if single service is set
+ $singleService = $this->getConf('singleService');
+ if ($singleService) {
+ do {
+ $form->removeElement(0);
+ } while ($form->elementCount() > 0);
+ }
+
+ $form->addFieldsetOpen($this->getLang('loginwith'))->addClass('plugin_oauth');
+ $form->addHTML($html);
+ $form->addFieldsetClose();
+ }
+
+ /**
+ * Create HTML for the various login buttons
+ *
+ * @return string the HTML
+ */
+ protected function prepareLoginButtons()
+ {
+ $html = '';
+
+ $validDomains = $this->hlp->getValidDomains();
+
+ if (count($validDomains) > 0) {
+ $html .= '' . sprintf(
+ $this->getLang('eMailRestricted'),
+ '' . implode(', ', $validDomains) . ' '
+ ) . '
';
+ }
+
+ $html .= '';
+ foreach ($this->hlp->listServices() as $service) {
+ $html .= $service->loginButton();
+ }
+ $html .= '
';
+
+ return $html;
+ }
+
+ /**
+ * When singleservice is wanted, do not show login, but execute login right away
+ *
+ * @param Event $event
+ * @return bool
+ */
+ public function handleDoLogin(Event $event)
+ {
+ global $ID;
+ global $INPUT;
+
+ if ($event->data != 'login' && $event->data != 'denied') return true;
+
+ $singleService = $this->getConf('singleService');
+ if (!$singleService) return true;
+
+ if ($INPUT->server->str('REMOTE_USER') !== '') {
+ // already logged in
+ return true;
+ }
+
+ $enabledServices = $this->hlp->listServices();
+ if (count($enabledServices) !== 1) {
+ msg($this->getLang('wrongConfig'), -1);
+ return false;
+ }
+
+ $service = array_shift($enabledServices);
+
+ $url = wl($ID, ['oauthlogin' => $service->getServiceID()], true, '&');
+ send_redirect($url);
+ return true; // never reached
+ }
+
+ /**
+ * Do not show a login form on restricted pages when SingleService is enabled
+ *
+ * This can happen when the user is already logged in, but still doesn't have enough permissions
+ *
+ * @param Event $event
+ * @return void
+ */
+ public function handleDeniedForm(Event $event)
+ {
+ if ($this->getConf('singleService')) {
+ $event->preventDefault();
+ $event->stopPropagation();
+ }
+ }
+}
diff --git a/action/user.php b/action/user.php
new file mode 100644
index 0000000..639abfe
--- /dev/null
+++ b/action/user.php
@@ -0,0 +1,176 @@
+
+ */
+class action_plugin_oauth_user extends ActionPlugin
+{
+ /** @var helper_plugin_oauth */
+ protected $hlp;
+
+ /**
+ * Constructor
+ *
+ * Initializes the helper
+ */
+ public function __construct()
+ {
+ $this->hlp = plugin_load('helper', 'oauth');
+ }
+
+ /**
+ * Registers a callback function for a given event
+ *
+ * @param EventHandler $controller DokuWiki's event controller object
+ * @return void
+ */
+ public function register(EventHandler $controller)
+ {
+ global $conf;
+ if ($conf['authtype'] != 'oauth') return;
+
+ $conf['profileconfirm'] = false; // password confirmation doesn't work with oauth only users
+
+ $controller->register_hook(
+ 'HTML_UPDATEPROFILEFORM_OUTPUT',
+ 'BEFORE',
+ $this,
+ 'handleOldProfileform'
+ ); // deprecated
+ $controller->register_hook('FORM_UPDATEPROFILE_OUTPUT', 'BEFORE', $this, 'handleProfileform');
+ $controller->register_hook('AUTH_USER_CHANGE', 'BEFORE', $this, 'handleUsermod');
+ }
+
+ /**
+ * Save groups for all the services a user has enabled
+ *
+ * @param Event $event event object by reference
+ * @return void
+ */
+ public function handleUsermod(Event $event)
+ {
+ global $ACT;
+ global $USERINFO;
+ global $auth;
+ global $INPUT;
+
+ if ($event->data['type'] != 'modify') return;
+ if ($ACT != 'profile') return;
+
+ // we want to modify the user's groups
+ $groups = $USERINFO['grps']; //current groups
+ if (isset($event->data['params'][1]['grps'])) {
+ // something already defined new groups
+ $groups = $event->data['params'][1]['grps'];
+ }
+
+ // get enabled and configured services
+ $enabled = $INPUT->arr('oauth_group');
+ $services = array_keys($this->hlp->listServices());
+ $services = array_map([$auth, 'cleanGroup'], $services);
+
+ // add all enabled services as group, remove all disabled services
+ foreach ($services as $service) {
+ if (isset($enabled[$service])) {
+ $groups[] = $service;
+ } else {
+ $idx = array_search($service, $groups);
+ if ($idx !== false) unset($groups[$idx]);
+ }
+ }
+ $groups = array_unique($groups);
+
+ // add new group array to event data
+ $event->data['params'][1]['grps'] = $groups;
+ }
+
+ /**
+ * Add service selection to user profile
+ *
+ * @param Event $event event object by reference
+ * @return void
+ * @deprecated
+ */
+ public function handleOldProfileform(Event $event)
+ {
+ global $USERINFO;
+ /** @var auth_plugin_authplain $auth */
+ global $auth;
+
+ /** @var Doku_Form $form */
+ $form = $event->data;
+ $pos = $form->findElementByAttribute('type', 'submit');
+
+ $services = $this->hlp->listServices();
+ if (!$services) return;
+
+ $form->insertElement($pos, form_closefieldset());
+ $form->insertElement(
+ ++$pos,
+ form_openfieldset(['_legend' => $this->getLang('loginwith'), 'class' => 'plugin_oauth'])
+ );
+ foreach ($services as $service) {
+ $group = $auth->cleanGroup($service->getServiceID());
+ $elem = form_makeCheckboxField(
+ 'oauth_group[' . $group . ']',
+ 1,
+ $service->getLabel(),
+ '',
+ 'simple',
+ [
+ 'checked' => (in_array($group, $USERINFO['grps'])) ? 'checked' : '',
+ ]
+ );
+
+ $form->insertElement(++$pos, $elem);
+ }
+ $form->insertElement(++$pos, form_closefieldset());
+ $form->insertElement(++$pos, form_openfieldset([]));
+ }
+
+ /**
+ * Add service selection to user profile
+ *
+ * @param Event $event event object by reference
+ * @return void
+ */
+ public function handleProfileform(Event $event)
+ {
+ global $USERINFO;
+ /** @var auth_plugin_authplain $auth */
+ global $auth;
+
+ /** @var Form $form */
+ $form = $event->data;
+ $pos = $form->findPositionByAttribute('type', 'submit');
+
+ $services = $this->hlp->listServices();
+ if (!$services) return;
+
+ $form->addFieldsetOpen($this->getLang('loginwith'), $pos)->addClass('plugin_oauth');
+
+ foreach ($services as $service) {
+ $group = $auth->cleanGroup($service->getServiceID());
+ $cb = $form->addCheckbox(
+ 'oauth_group[' . $group . ']',
+ $service->getLabel(),
+ ++$pos
+ );
+ if (in_array($group, $USERINFO['grps'])) {
+ $cb->attr('checked', 'checked');
+ }
+ }
+ $form->addFieldsetClose(++$pos);
+ }
+}
diff --git a/auth.php b/auth.php
index 0f37a11..96a4d85 100644
--- a/auth.php
+++ b/auth.php
@@ -1,420 +1,224 @@
*/
+class auth_plugin_oauth extends auth_plugin_authplain
+{
+ /** @var helper_plugin_oauth */
+ protected $hlp;
-// must be run within Dokuwiki
-if(!defined('DOKU_INC')) die();
+ /** @var OAuthManager */
+ protected $om;
-class auth_plugin_oauth extends auth_plugin_authplain {
+ // region standard auth methods
- /**
- * Constructor
- *
- * Sets capabilities.
- */
- public function __construct() {
+ /** @inheritDoc */
+ public function __construct()
+ {
parent::__construct();
-
$this->cando['external'] = true;
+ $this->hlp = $this->loadHelper('oauth');
}
- private function handleState($state) {
- /** @var \helper_plugin_farmer $farmer */
- $farmer = plugin_load('helper', 'farmer', false, true);
- $data = json_decode(base64_decode(urldecode($state)));
- if (empty($data->animal) || $farmer->getAnimal() == $data->animal) {
- return;
- }
- $animal = $data->animal;
- $allAnimals = $farmer->getAllAnimals();
- if (!in_array($animal, $allAnimals)) {
- msg('Animal ' . $animal . ' does not exist!');
- return;
- }
+ /** @inheritDoc */
+ public function trustExternal($user, $pass, $sticky = false)
+ {
global $INPUT;
- $url = $farmer->getAnimalURL($animal) . '/doku.php?' . $INPUT->server->str('QUERY_STRING');
- send_redirect($url);
- }
-
- /**
- * Handle the login
- *
- * This either trusts the session data (if any), processes the second oAuth step or simply
- * executes a normal plugin against local users.
- *
- * @param string $user
- * @param string $pass
- * @param bool $sticky
- * @return bool
- */
- function trustExternal($user, $pass, $sticky = false) {
- global $USERINFO, $INPUT;
-
- if ($INPUT->has('state') && plugin_load('helper', 'farmer', false, true)) {
- $this->handleState($INPUT->str('state'));
- }
-
- // check session for existing oAuth login data
- $session = $_SESSION[DOKU_COOKIE]['auth'];
- if(isset($session['oauth'])) {
- $servicename = $session['oauth'];
- // check if session data is still considered valid
- if ($this->isSessionValid($session)) {
- $_SERVER['REMOTE_USER'] = $session['user'];
- $USERINFO = $session['info'];
- return true;
- }
- }
-
- $existingLoginProcess = false;
- // are we in login progress?
- if(isset($_SESSION[DOKU_COOKIE]['oauth-inprogress'])) {
- $servicename = $_SESSION[DOKU_COOKIE]['oauth-inprogress']['service'];
- $page = $_SESSION[DOKU_COOKIE]['oauth-inprogress']['id'];
- $params = $_SESSION[DOKU_COOKIE]['oauth-inprogress']['params'];
- unset($_SESSION[DOKU_COOKIE]['oauth-inprogress']);
- $existingLoginProcess = true;
+ // handle redirects from farmer to animal wiki instances
+ if ($INPUT->has('state') && plugin_load('helper', 'farmer')) {
+ $this->handleFarmState($INPUT->str('state'));
}
- // either we're in oauth login or a previous log needs to be rechecked
- if(isset($servicename)) {
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
-
- /** @var OAuth\Plugin\AbstractAdapter $service */
- $service = $hlp->loadService($servicename);
- if(is_null($service)) {
- $this->cleanLogout();
- return false;
- }
-
- if($service->checkToken()) {
- $ok = $this->processLogin($sticky, $service, $servicename, $page, $params);
- if (!$ok) {
- $this->cleanLogout();
- return false;
- }
- return true;
- } else {
- if ($existingLoginProcess) {
- msg($this->getLang('oauth login failed'),0);
- $this->cleanLogout();
- return false;
- } else {
- // first time here
- $this->relogin($servicename);
- }
- }
-
- $this->cleanLogout();
- return false; // something went wrong during oAuth login
- } elseif (isset($_COOKIE[DOKU_COOKIE])) {
- global $INPUT;
- //try cookie
- list($cookieuser, $cookiesticky, $auth, $servicename) = explode('|', $_COOKIE[DOKU_COOKIE]);
- $cookieuser = base64_decode($cookieuser, true);
- $auth = base64_decode($auth, true);
- $servicename = base64_decode($servicename, true);
- if ($auth === 'oauth') {
- $this->relogin($servicename);
+ try {
+ // either oauth or "normal" plain auth login via form
+ $this->om = new OAuthManager();
+ if ($this->om->continueFlow()) return true;
+ if ($this->getConf('singleService')) {
+ return false; // no normal login in singleService mode
}
+ return null; // triggers the normal auth_login()
+ } catch (OAuthException $e) {
+ $this->hlp->showException($e);
+ auth_logoff(); // clears all session and cookie data
+ return false;
}
-
- // do the "normal" plain auth login via form
- return auth_login($user, $pass, $sticky);
}
/**
- * @param array $session cookie auth session
+ * Enhance function to check against duplicate emails
*
- * @return bool
+ * @inheritdoc
*/
- protected function isSessionValid ($session) {
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
- if ($hlp->validBrowserID($session)) {
- if (!$hlp->isSessionTimedOut($session)) {
- return true;
- } elseif (!($hlp->isGETRequest() && $hlp->isDokuPHP())) {
- // only force a recheck on a timed-out session during a GET request on the main script doku.php
- return true;
- }
- }
- return false;
- }
-
- protected function relogin($servicename) {
- global $INPUT;
-
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
- $service = $hlp->loadService($servicename);
- if(is_null($service)) return false;
-
- // remember service in session
- session_start();
- $_SESSION[DOKU_COOKIE]['oauth-inprogress']['service'] = $servicename;
- $_SESSION[DOKU_COOKIE]['oauth-inprogress']['id'] = $INPUT->str('id');
- $_SESSION[DOKU_COOKIE]['oauth-inprogress']['params'] = $_GET;
-
- $_SESSION[DOKU_COOKIE]['oauth-done']['$_REQUEST'] = $_REQUEST;
-
- if (is_array($INPUT->post->param('do'))) {
- $doPost = key($INPUT->post->arr('do'));
- } else {
- $doPost = $INPUT->post->str('do');
- }
- $doGet = $INPUT->get->str('do');
- if (!empty($doPost)) {
- $_SESSION[DOKU_COOKIE]['oauth-done']['do'] = $doPost;
- } elseif (!empty($doGet)) {
- $_SESSION[DOKU_COOKIE]['oauth-done']['do'] = $doGet;
+ public function createUser($user, $pwd, $name, $mail, $grps = null)
+ {
+ if ($this->getUserByEmail($mail)) {
+ msg($this->getLang('emailduplicate'), -1);
+ return false;
}
- session_write_close();
-
- $service->login();
+ return parent::createUser($user, $pwd, $name, $mail, $grps);
}
/**
- * @param $sticky
- * @param OAuth\Plugin\AbstractAdapter $service
- * @param string $servicename
- * @param string $page
- * @param array $params
+ * Enhance function to check against duplicate emails
*
- * @return bool
+ * @inheritdoc
*/
- protected function processLogin($sticky, $service, $servicename, $page, $params = array()) {
- $uinfo = $service->getUser();
- $ok = $this->processUser($uinfo, $servicename);
- if(!$ok) {
- return false;
- }
- $this->setUserSession($uinfo, $servicename);
- $this->setUserCookie($uinfo['user'], $sticky, $servicename);
- if(isset($page)) {
- if(!empty($params['id'])) unset($params['id']);
- send_redirect(wl($page, $params, false, '&'));
+ public function modifyUser($user, $changes)
+ {
+ global $conf;
+
+ if (isset($changes['mail'])) {
+ $found = $this->getUserByEmail($changes['mail']);
+ if ($found && $found != $user) {
+ msg($this->getLang('emailduplicate'), -1);
+ return false;
+ }
}
- return true;
+
+ $ok = parent::modifyUser($user, $changes);
+
+ // refresh session cache
+ touch($conf['cachedir'] . '/sessionpurge');
+ return $ok;
}
/**
- * process the user and update the $uinfo array
- *
- * @param $uinfo
- * @param $servicename
- *
- * @return bool
+ * Unset additional stuff in session on logout
*/
- protected function processUser(&$uinfo, $servicename) {
- $uinfo['user'] = $this->cleanUser((string) $uinfo['user']);
- if(!$uinfo['name']) $uinfo['name'] = $uinfo['user'];
-
- if(!$uinfo['user'] || !$uinfo['mail']) {
- msg("$servicename did not provide the needed user info. Can't log you in", -1);
- return false;
- }
-
- // see if the user is known already
- $user = $this->getUserByEmail($uinfo['mail']);
- if($user) {
- $sinfo = $this->getUserData($user);
- // check if the user allowed access via this service
- if(!in_array($this->cleanGroup($servicename), $sinfo['grps'])) {
- msg(sprintf($this->getLang('authnotenabled'), $servicename), -1);
- return false;
- }
- $uinfo['user'] = $user;
- $uinfo['name'] = $sinfo['name'];
- $uinfo['grps'] = array_merge((array) $uinfo['grps'], $sinfo['grps']);
- } elseif(actionOK('register') || $this->getConf('register-on-auth')) {
- $ok = $this->addUser($uinfo, $servicename);
- if(!$ok) {
- msg('something went wrong creating your user account. please try again later.', -1);
- return false;
- }
- } else {
- msg($this->getLang('addUser not possible'), -1);
- return false;
+ public function logOff()
+ {
+ parent::logOff();
+ if (isset($this->om)) {
+ $this->om->logout();
}
- return true;
+ (Session::getInstance())->clear();
}
+ // endregion
+
/**
- * new user, create him - making sure the login is unique by adding a number if needed
+ * Register a new user logged in by oauth
*
- * @param array $uinfo user info received from the oAuth service
+ * It ensures the username is unique, by adding a number if needed.
+ * Default and service name groups are set here.
+ * Registration notifications are triggered.
+ *
+ * @param array $userinfo This will be updated with the new username
* @param string $servicename
*
* @return bool
+ * @todo - should this be part of the OAuthManager class instead?
*/
- protected function addUser(&$uinfo, $servicename) {
+ public function registerOAuthUser(&$userinfo, $servicename)
+ {
global $conf;
- $user = $uinfo['user'];
+ $user = $userinfo['user'];
$count = '';
- while($this->getUserData($user . $count)) {
- if($count) {
+ while ($this->getUserData($user . $count)) {
+ if ($count) {
$count++;
} else {
$count = 1;
}
}
- $user = $user . $count;
- $uinfo['user'] = $user;
- $groups_on_creation = array();
+ $user .= $count;
+ $userinfo['user'] = $user;
+ $groups_on_creation = [];
$groups_on_creation[] = $conf['defaultgroup'];
$groups_on_creation[] = $this->cleanGroup($servicename); // add service as group
- $uinfo['grps'] = array_merge((array) $uinfo['grps'], $groups_on_creation);
+ $userinfo['grps'] = array_merge((array)$userinfo['grps'], $groups_on_creation);
+ // the password set here will remain unknown to the user
$ok = $this->triggerUserMod(
'create',
- array($user, auth_pwgen($user), $uinfo['name'], $uinfo['mail'], $groups_on_creation,)
+ [
+ $user,
+ auth_pwgen($user),
+ $userinfo['name'],
+ $userinfo['mail'],
+ $userinfo['grps'],
+ ]
);
- if(!$ok) {
+ if (!$ok) {
return false;
}
// send notification about the new user
- $subscription = new Subscription();
- $subscription->send_register($user, $uinfo['name'], $uinfo['mail']);
+ $subscriptionSender = new RegistrationSubscriptionSender();
+ $subscriptionSender->sendRegister($user, $userinfo['name'], $userinfo['mail']);
+
return true;
}
/**
- * Find a user by his email address
+ * Find a user by email address
*
* @param $mail
* @return bool|string
*/
- protected function getUserByEmail($mail) {
- if($this->users === null){
- if(is_callable([$this, '_loadUserData'])) {
- $this->_loadUserData();
- } else {
- $this->loadUserData();
- }
+ public function getUserByEmail($mail)
+ {
+ if ($this->users === null) {
+ $this->loadUserData();
}
$mail = strtolower($mail);
- foreach($this->users as $user => $uinfo) {
- if(strtolower($uinfo['mail']) == $mail) return $user;
+ foreach ($this->users as $user => $userinfo) {
+ if (strtolower($userinfo['mail']) === $mail) return $user;
}
return false;
}
/**
- * @param array $data
- * @param string $service
- */
- protected function setUserSession($data, $service) {
- global $USERINFO;
- global $conf;
-
- // set up groups
- if(!is_array($data['grps'])) {
- $data['grps'] = array();
- }
- $data['grps'][] = $this->cleanGroup($service);
- $data['grps'] = array_unique($data['grps']);
-
- $USERINFO = $data;
- $_SERVER['REMOTE_USER'] = $data['user'];
- $_SESSION[DOKU_COOKIE]['auth']['user'] = $data['user'];
- $_SESSION[DOKU_COOKIE]['auth']['pass'] = $data['pass'];
- $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO;
- $_SESSION[DOKU_COOKIE]['auth']['buid'] = auth_browseruid();
- $_SESSION[DOKU_COOKIE]['auth']['time'] = time();
- $_SESSION[DOKU_COOKIE]['auth']['oauth'] = $service;
- }
-
- /**
- * @param string $user
- * @param bool $sticky
- * @param string $servicename
- * @param int $validityPeriodInSeconds optional, per default 1 Year
- */
- private function setUserCookie($user, $sticky, $servicename, $validityPeriodInSeconds = 31536000) {
- $cookie = base64_encode($user).'|'.((int) $sticky).'|'.base64_encode('oauth').'|'.base64_encode($servicename);
- $cookieDir = empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'];
- $time = $sticky ? (time() + $validityPeriodInSeconds) : 0;
- setcookie(DOKU_COOKIE,$cookie, $time, $cookieDir, '',($conf['securecookie'] && is_ssl()), true);
- }
-
- /**
- * Unset additional stuff in session on logout
- */
- public function logOff() {
- parent::logOff();
-
- $this->cleanLogout();
- }
-
- /**
- * unset auth cookies and session information
- */
- private function cleanLogout() {
- if(isset($_SESSION[DOKU_COOKIE]['oauth-done'])) {
- unset($_SESSION[DOKU_COOKIE]['oauth-done']);
- }
- if(isset($_SESSION[DOKU_COOKIE]['auth'])) {
- unset($_SESSION[DOKU_COOKIE]['auth']);
- }
- $this->setUserCookie('',true,'',-60);
- }
-
- /**
- * Enhance function to check against duplicate emails
+ * Fall back to plain auth strings
*
- * @param string $user
- * @param string $pwd
- * @param string $name
- * @param string $mail
- * @param null $grps
- * @return bool|null|string
+ * @inheritdoc
*/
- public function createUser($user, $pwd, $name, $mail, $grps = null) {
- if($this->getUserByEmail($mail)) {
- msg($this->getLang('emailduplicate'), -1);
- return false;
- }
+ public function getLang($id)
+ {
+ $result = parent::getLang($id);
+ if ($result) return $result;
- return parent::createUser($user, $pwd, $name, $mail, $grps);
+ $parent = new auth_plugin_authplain();
+ return $parent->getLang($id);
}
/**
- * Enhance function to check aainst duplicate emails
+ * Farmer plugin support
*
- * @param string $user
- * @param array $changes
- * @return bool
+ * When coming back to farmer instance via OAUTH redirectURI, we need to redirect again
+ * to a proper animal instance detected from $state
+ *
+ * @param $state
*/
- public function modifyUser($user, $changes) {
- global $conf;
-
- if(isset($changes['mail'])) {
- $found = $this->getUserByEmail($changes['mail']);
- if($found != $user) {
- msg($this->getLang('emailduplicate'), -1);
- return false;
- }
+ protected function handleFarmState($state)
+ {
+ /** @var \helper_plugin_farmer $farmer */
+ $farmer = plugin_load('helper', 'farmer', false, true);
+ $data = json_decode(base64_decode(urldecode($state)));
+ if (empty($data->animal) || $farmer->getAnimal() == $data->animal) {
+ return;
}
-
- $ok = parent::modifyUser($user, $changes);
-
- // refresh session cache
- touch($conf['cachedir'] . '/sessionpurge');
-
- return $ok;
+ $animal = $data->animal;
+ $allAnimals = $farmer->getAllAnimals();
+ if (!in_array($animal, $allAnimals)) {
+ msg('Animal ' . $animal . ' does not exist!');
+ return;
+ }
+ global $INPUT;
+ $url = $farmer->getAnimalURL($animal) . '/doku.php?' . $INPUT->server->str('QUERY_STRING');
+ send_redirect($url);
}
-
}
-
-// vim:ts=4:sw=4:et:
diff --git a/classes/AbstractAdapter.php b/classes/AbstractAdapter.php
deleted file mode 100644
index 6c9da5e..0000000
--- a/classes/AbstractAdapter.php
+++ /dev/null
@@ -1,191 +0,0 @@
-hlp = plugin_load('helper', 'oauth');
-
- $credentials = new Credentials(
- $this->hlp->getKey($this->getAdapterName()),
- $this->hlp->getSecret($this->getAdapterName()),
- $url
- );
-
- $this->storage = new oAuthStorage();
-
- $serviceFactory = new ServiceFactory();
- $serviceFactory->setHttpClient(new oAuthHTTPClient());
- $this->oAuth = $serviceFactory->createService(
- $this->getServiceName(),
- $credentials,
- $this->storage,
- $this->getScope()
- );
- }
-
- /**
- * Check if the initialization worked
- *
- * @return bool
- */
- public function isInitialized() {
- if(is_null($this->oAuth)) return false;
- return true;
- }
-
- /**
- * Redirects to the service for requesting access
- *
- * This is the first step of oAuth authentication
- *
- * This implementation tries to abstract away differences between oAuth1 and oAuth2,
- * but might need to be overwritten for specific services
- */
- public function login() {
- if(is_a($this->oAuth, 'OAuth\OAuth2\Service\AbstractService')) { /* oAuth2 handling */
-
- $url = $this->oAuth->getAuthorizationUri();
- } else { /* oAuth1 handling */
-
- // extra request needed for oauth1 to request a request token :-)
- $token = $this->oAuth->requestRequestToken();
-
- $url = $this->oAuth->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
- }
-
- send_redirect($url);
- }
-
- /**
- * Request access token
- *
- * This is the second step of oAuth authentication
- *
- * This implementation tries to abstract away differences between oAuth1 and oAuth2,
- * but might need to be overwritten for specific services
- *
- * @return bool
- */
- public function checkToken() {
- global $INPUT, $conf;
-
- if(is_a($this->oAuth, 'OAuth\OAuth2\Service\AbstractService')) { /* oAuth2 handling */
-
- if(!$INPUT->get->has('code')) return false;
- $state = $INPUT->get->str('state', null);
-
- try {
- $this->oAuth->requestAccessToken($INPUT->get->str('code'), $state);
- } catch (TokenResponseException $e) {
- msg($e->getMessage(), -1);
- if($conf['allowdebug']) msg(''.hsc($e->getTraceAsString()).' ', -1);
- return false;
- }
- } else { /* oAuth1 handling */
-
- if(!$INPUT->get->has('oauth_token')) return false;
-
- $token = $this->storage->retrieveAccessToken($this->getServiceName());
-
- // This was a callback request from BitBucket, get the token
- try {
- $this->oAuth->requestAccessToken(
- $INPUT->get->str('oauth_token'),
- $INPUT->get->str('oauth_verifier'),
- $token->getRequestTokenSecret()
- );
- } catch (TokenResponseException $e) {
- msg($e->getMessage(), -1);
- return false;
- }
- }
-
- $validDomains = $this->hlp->getValidDomains();
- if (count($validDomains) > 0) {
- $userData = $this->getUser();
- if (!$this->hlp->checkMail($userData['mail'])) {
- msg(sprintf($this->hlp->getLang("rejectedEMail"),join(', ', $validDomains)),-1);
- send_redirect(wl('', array('do' => 'login',),false,'&'));
- }
- }
- return true;
- }
-
-
-
- /**
- * Return the name of the oAuth service class to use
- *
- * This should match with one of the files in
- * phpoauth/src/oAuth/oAuth[12]/Service/*
- *
- * By default extracts the name from the class name
- *
- * @return string
- */
- public function getServiceName() {
- return $this->getAdapterName();
- }
-
- /**
- * Retrun the name of this Adapter
- *
- * It specifies which configuration setting should be used
- *
- * @return string
- */
- public function getAdapterName() {
- $name = preg_replace('/Adapter$/', '', get_called_class());
- $name = str_replace('OAuth\\Plugin\\', '', $name);
- return $name;
- }
-
- /**
- * Return the scope to request
- *
- * This should return the minimal scope needed for accessing the user's data
- *
- * @return array
- */
- public function getScope() {
- return array();
- }
-
- /**
- * Retrieve the user's data
- *
- * The array needs to contain at least 'email', 'name', 'user', 'grps'
- *
- * @return array
- */
- abstract public function getUser();
-}
diff --git a/classes/Auth0Adapter.php b/classes/Auth0Adapter.php
deleted file mode 100644
index bdb0c9f..0000000
--- a/classes/Auth0Adapter.php
+++ /dev/null
@@ -1,46 +0,0 @@
-oAuth->request('/userinfo');
- $result = $JSON->decode($response);
-
- if( !empty($result['username']) )
- {
- $data['user'] = $result['username'];
- }
- else
- {
- $data['user'] = isset($result['name']) ? $result['name'] : $result['email'];
- }
- $data['name'] = isset($result['name']) ? $result['name'] : $result['email'];
- $data['mail'] = $result['email'];
-
- return $data;
- }
-
- /**
- * Access to user and his email addresses
- *
- * @return array
- */
- public function getScope() {
- return array(Auth0::SCOPE_OPENID);
- }
-
-}
diff --git a/classes/DataportenAdapter.php b/classes/DataportenAdapter.php
deleted file mode 100644
index 3cf5ccf..0000000
--- a/classes/DataportenAdapter.php
+++ /dev/null
@@ -1,30 +0,0 @@
-decode($this->oAuth->request('https://auth.dataporten.no/userinfo'));
- $result_grous = $JSON->decode($this->oAuth->request('https://groups-api.dataporten.no/groups/me/groups'));
-
- $data['user'] = $result['user']['userid'];
- $data['name'] = $result['user']['name'];
- $data['mail'] = $result['user']['email'];
-
- return $data;
- }
-
-}
diff --git a/classes/DoorkeeperAdapter.php b/classes/DoorkeeperAdapter.php
deleted file mode 100644
index 825848a..0000000
--- a/classes/DoorkeeperAdapter.php
+++ /dev/null
@@ -1,51 +0,0 @@
-oAuth */
- $result = $JSON->decode($this->oAuth->request('https://doorkeeper-provider.herokuapp.com/api/v1/me.json'));
-
- $data['user'] = 'doorkeeper-'.$result['id'];
- $data['name'] = 'doorkeeper-'.$result['id'];
- $data['mail'] = $result['email'];
-
- return $data;
- }
-
- /**
- * We make use of the "Generic" oAuth 2 Service as defined in
- * phpoauthlib/src/OAuth/OAuth2/Service/Generic.php
- *
- * @return string
- */
- public function getServiceName() {
- return 'Generic';
- }
-
-}
\ No newline at end of file
diff --git a/classes/FacebookAdapter.php b/classes/FacebookAdapter.php
deleted file mode 100644
index c9b8227..0000000
--- a/classes/FacebookAdapter.php
+++ /dev/null
@@ -1,47 +0,0 @@
-decode($this->oAuth->request('/me?fields=name,email'));
-
- if( !empty($result['username']) )
- {
- $data['user'] = $result['username'];
- }
- else
- {
- $data['user'] = $result['name'];
- }
- $data['name'] = $result['name'];
- $data['mail'] = $result['email'];
-
- return $data;
- }
-
- /**
- * Access to user and his email addresses
- *
- * @return array
- */
- public function getScope() {
- return array(Facebook::SCOPE_EMAIL);
- }
-
-}
diff --git a/classes/GithubAdapter.php b/classes/GithubAdapter.php
deleted file mode 100644
index 1aae9c4..0000000
--- a/classes/GithubAdapter.php
+++ /dev/null
@@ -1,44 +0,0 @@
-decode($this->oAuth->request('user'));
- $data['user'] = $result['login'];
- $data['name'] = $result['name'];
-
- $result = $JSON->decode($this->oAuth->request('user/emails'));
- foreach($result as $row) {
- if($row['primary']){
- $data['mail'] = $row['email'];
- break;
- }
- }
-
- return $data;
- }
-
- /**
- * Access to user and his email addresses
- *
- * @return array
- */
- public function getScope() {
- return array(GitHub::SCOPE_USER_EMAIL);
- }
-
-}
diff --git a/classes/GoogleAdapter.php b/classes/GoogleAdapter.php
deleted file mode 100644
index f17758a..0000000
--- a/classes/GoogleAdapter.php
+++ /dev/null
@@ -1,55 +0,0 @@
-decode($this->oAuth->request('https://www.googleapis.com/oauth2/v1/userinfo'));
-
- $data['user'] = $result['name'];
- $data['name'] = $result['name'];
- $data['mail'] = $result['email'];
-
- return $data;
- }
-
- /**
- * Access to user and his email addresses
- *
- * @return array
- */
- public function getScope() {
- return array(Google::SCOPE_USERINFO_EMAIL, Google::SCOPE_USERINFO_PROFILE);
- }
-
- public function login() {
- $parameters = array();
- if(!empty($_SESSION[DOKU_COOKIE]['auth']['info']['mail'])) {
- $usermail = $_SESSION[DOKU_COOKIE]['auth']['info']['mail'];
- $parameters['login_hint'] = $usermail;
- }
-
- /** @var \helper_plugin_farmer $farmer */
- $farmer = plugin_load('helper', 'farmer', false, true);
- if ($farmer && $animal = $farmer->getAnimal()) {
- $parameters['state'] = urlencode(base64_encode(json_encode(array('animal'=>$animal,'state'=> md5(rand())))));
- $this->storage->storeAuthorizationState('Google', $parameters['state']);
- }
- $url = $this->oAuth->getAuthorizationUri($parameters);
- send_redirect($url);
- }
-
-}
diff --git a/classes/KeycloakAdapter.php b/classes/KeycloakAdapter.php
deleted file mode 100644
index 2fd07ae..0000000
--- a/classes/KeycloakAdapter.php
+++ /dev/null
@@ -1,52 +0,0 @@
-oAuth */
- $result = $JSON->decode($this->oAuth->request($this->hlp->getUserInfoEndpoint('Keycloak')));
-
- $data['user'] = $result['preferred_username'];
- $data['name'] = $result['name'];
- $data['mail'] = $result['email'];
- if( !empty($result['groups']) )
- {
- $data['grps'] = $result['groups'];
- }
- $data['grps'] = $result['groups'];
-
- return $data;
- }
-
- /**
- * We make use of the Keycloak oauth2 service (slightly abstracted from "Generic") as defined in
- * phpoauthlib/src/OAuth/OAuth2/Service/Keycloak.php
- *
- * @return string
- */
- public function getServiceName() {
- return 'Keycloak';
- }
-
-}
\ No newline at end of file
diff --git a/classes/YahooAdapter.php b/classes/YahooAdapter.php
deleted file mode 100644
index e24444b..0000000
--- a/classes/YahooAdapter.php
+++ /dev/null
@@ -1,36 +0,0 @@
-decode($this->oAuth->request('me/guid'));
- $guid = $result['guid']['value'];
-
- $result = $JSON->decode($this->oAuth->request('users.guid('.$guid.')/profile'));
-
- foreach($result['profiles']['profile'][0]['emails'] as $email) {
- if(isset($email['primary'])) {
- $data['mail'] = $email['handle'];
- break;
- }
- }
- $data['name'] = trim($result['profiles']['profile'][0]['givenName'].' '.$result['profiles']['profile'][0]['familyName']);
- if(!$data['name']) $data['name'] = $result['profiles']['profile'][0]['nickname'];
- $data['user'] = $data['name'];
-
- return $data;
- }
-
-}
\ No newline at end of file
diff --git a/classes/oAuthHTTPClient.php b/classes/oAuthHTTPClient.php
deleted file mode 100644
index 42b6323..0000000
--- a/classes/oAuthHTTPClient.php
+++ /dev/null
@@ -1,46 +0,0 @@
-headers = array_merge($http->headers, $extraHeaders);
-
- $ok = $http->sendRequest($endpoint->getAbsoluteUri(), $requestBody, $method);
- if(!$ok){
- $msg = "An error occured during the request to the oauth provider:\n";
- throw new TokenResponseException($msg . $http->error);
- }
-
- return $http->resp_body;
- }
-}
diff --git a/classes/oAuthStorage.php b/classes/oAuthStorage.php
deleted file mode 100644
index 84df657..0000000
--- a/classes/oAuthStorage.php
+++ /dev/null
@@ -1,176 +0,0 @@
-getServiceFile($service);
- if(file_exists($file)) {
- return unserialize(io_readFile($file, false));
- } else {
- return array();
- }
- }
-
- /**
- * Store the data to disk
- *
- * @param string $service
- * @param array $data
- */
- protected function saveServiceFile($service, $data) {
- $file = $this->getServiceFile($service);
- io_saveFile($file, serialize($data));
- }
-
- /**
- * @param string $service
- *
- * @return TokenInterface
- *
- * @throws TokenNotFoundException
- */
- public function retrieveAccessToken($service) {
- $data = $this->loadServiceFile($service);
- if(!isset($data['token'])) {
- throw new TokenNotFoundException('No token found in storage');
- }
- return $data['token'];
- }
-
- /**
- * @param string $service
- * @param TokenInterface $token
- *
- * @return TokenStorageInterface
- */
- public function storeAccessToken($service, TokenInterface $token) {
- $data = $this->loadServiceFile($service);
- $data['token'] = $token;
- $this->saveServiceFile($service, $data);
- }
-
- /**
- * @param string $service
- *
- * @return bool
- */
- public function hasAccessToken($service) {
- $data = $this->loadServiceFile($service);
- return isset($data['token']);
- }
-
- /**
- * Delete the users token. Aka, log out.
- *
- * @param string $service
- *
- * @return TokenStorageInterface
- */
- public function clearToken($service) {
- $data = $this->loadServiceFile($service);
- if(isset($data['token'])) unset($data['token']);
- $this->saveServiceFile($service, $data);
- }
-
- /**
- * Delete *ALL* user tokens. Use with care. Most of the time you will likely
- * want to use clearToken() instead.
- *
- * @return TokenStorageInterface
- */
- public function clearAllTokens() {
- // TODO: Implement clearAllTokens() method.
- }
-
- /**
- * Store the authorization state related to a given service
- *
- * @param string $service
- * @param string $state
- *
- * @return TokenStorageInterface
- */
- public function storeAuthorizationState($service, $state) {
- $data = $this->loadServiceFile($service);
- $data['state'] = $state;
- $this->saveServiceFile($service, $data);
- }
-
- /**
- * Check if an authorization state for a given service exists
- *
- * @param string $service
- *
- * @return bool
- */
- public function hasAuthorizationState($service) {
- $data = $this->loadServiceFile($service);
- return isset($data['state']);
- }
-
- /**
- * Retrieve the authorization state for a given service
- *
- * @param string $service
- *
- * @throws \OAuth\Common\Storage\Exception\TokenNotFoundException
- * @return string
- */
- public function retrieveAuthorizationState($service) {
- $data = $this->loadServiceFile($service);
- if(!isset($data['state'])) {
- throw new TokenNotFoundException('No state found in storage');
- }
- return $data['state'];
- }
-
- /**
- * Clear the authorization state of a given service
- *
- * @param string $service
- *
- * @return TokenStorageInterface
- */
- public function clearAuthorizationState($service) {
- $data = $this->loadServiceFile($service);
- if(isset($data['state'])) unset($data['state']);
- $this->saveServiceFile($service, $data);
- }
-
- /**
- * 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() {
- // TODO: Implement clearAllAuthorizationStates() method.
- }
-}
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..968ffcf
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,9 @@
+{
+ "name": "cosmocode/dokuwiki-plugin-oauth",
+ "description": "OAuth Plugin for DokuWiki",
+ "type": "project",
+ "license": "GPL2",
+ "require": {
+ "lusitanian/oauth": "0.8.*"
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..c741d62
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,90 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "b8a6d75b139b4f8caffe4b3c81f7e77f",
+ "packages": [
+ {
+ "name": "lusitanian/oauth",
+ "version": "v0.8.11",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Lusitanian/PHPoAuthLib.git",
+ "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/fc11a53db4b66da555a6a11fce294f574a8374f9",
+ "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.7.*",
+ "predis/predis": "0.8.*@dev",
+ "squizlabs/php_codesniffer": "2.*",
+ "symfony/http-foundation": "~2.1"
+ },
+ "suggest": {
+ "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.",
+ "predis/predis": "Allows using the Redis storage backend.",
+ "symfony/http-foundation": "Allows using the Symfony Session storage backend."
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "OAuth": "src",
+ "OAuth\\Unit": "tests"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "David Desberg",
+ "email": "david@daviddesberg.com"
+ },
+ {
+ "name": "Elliot Chance",
+ "email": "elliotchance@gmail.com"
+ },
+ {
+ "name": "Pieter Hordijk",
+ "email": "info@pieterhordijk.com"
+ }
+ ],
+ "description": "PHP 5.3+ oAuth 1/2 Library",
+ "keywords": [
+ "Authentication",
+ "authorization",
+ "oauth",
+ "security"
+ ],
+ "support": {
+ "issues": "https://github.com/Lusitanian/PHPoAuthLib/issues",
+ "source": "https://github.com/Lusitanian/PHPoAuthLib/tree/master"
+ },
+ "time": "2018-02-14T22:37:14+00:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": [],
+ "plugin-api-version": "2.1.0"
+}
diff --git a/conf/default.php b/conf/default.php
index d8ccbcd..044c41f 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -1,33 +1,14 @@
*/
-$conf['auth0-key'] = '';
-$conf['auth0-secret'] = '';
-$conf['auth0-domain'] = '';
+$conf['info'] = '';
$conf['custom-redirectURI'] = '';
-$conf['facebook-key'] = '';
-$conf['facebook-secret'] = '';
-$conf['github-key'] = '';
-$conf['github-secret'] = '';
-$conf['google-key'] = '';
-$conf['google-secret'] = '';
-$conf['dataporten-key'] = '';
-$conf['dataporten-secret'] = '';
-$conf['keycloak-key'] = '';
-$conf['keycloak-secret'] = '';
-$conf['keycloak-authurl'] = 'https://keycloak.example.com/auth/realms/{realm}/protocol/openid-connect/auth';
-$conf['keycloak-tokenurl'] = 'https://keycloak.example.com/auth/realms/{realm}/protocol/openid-connect/token';
-$conf['keycloak-userinfourl'] = 'https://keycloak.example.com/auth/realms/{realm}/protocol/openid-connect/userinfo';
-$conf['yahoo-key'] = '';
-$conf['yahoo-secret'] = '';
-$conf['doorkeeper-key'] = '';
-$conf['doorkeeper-secret'] = '';
-$conf['doorkeeper-authurl'] = 'https://doorkeeper-provider.herokuapp.com/oauth/authorize';
-$conf['doorkeeper-tokenurl'] = 'https://doorkeeper-provider.herokuapp.com/oauth/token';
$conf['mailRestriction'] = '';
$conf['singleService'] = '';
$conf['register-on-auth'] = 0;
+$conf['overwrite-groups'] = 0;
diff --git a/conf/metadata.php b/conf/metadata.php
index 0868480..eb95d11 100644
--- a/conf/metadata.php
+++ b/conf/metadata.php
@@ -1,64 +1,15 @@
*/
-class setting_plugin_oauth extends setting {
-
- function update($input) {
- return true;
- }
-
- public function html(&$plugin, $echo = false) {
- /** @var helper_plugin_oauth $hlp */
- $hlp = plugin_load('helper', 'oauth');
-
- $key = htmlspecialchars($this->_key);
- $value = ''.$hlp->redirectURI().'
';
-
- $label = ''.$this->prompt($plugin).' ';
- $input = ''.$value.'
';
- return array($label, $input);
- }
-
-}
-
-$meta['info'] = array('plugin_oauth');
-$meta['auth0-key'] = array('string');
-$meta['auth0-secret'] = array('string');
-$meta['auth0-domain'] = array('string');
+$meta['info'] = array(\dokuwiki\plugin\oauth\RedirectSetting::class);
$meta['custom-redirectURI'] = array('string','_caution' => 'warning');
-$meta['facebook-key'] = array('string');
-$meta['facebook-secret'] = array('string');
-$meta['github-key'] = array('string');
-$meta['github-secret'] = array('string');
-$meta['google-key'] = array('string');
-$meta['google-secret'] = array('string');
-$meta['dataporten-key'] = array('string');
-$meta['dataporten-secret'] = array('string');
-$meta['keycloak-key'] = array('string');
-$meta['keycloak-secret'] = array('string');
-$meta['keycloak-authurl'] = array('string');
-$meta['keycloak-tokenurl'] = array('string');
-$meta['keycloak-userinfourl'] = array('string');
-$meta['yahoo-key'] = array('string');
-$meta['yahoo-secret'] = array('string');
-$meta['doorkeeper-key'] = array('string');
-$meta['doorkeeper-secret'] = array('string');
-$meta['doorkeeper-authurl'] = array('string');
-$meta['doorkeeper-tokenurl'] = array('string');
-$meta['mailRestriction'] = array('string','_pattern' => '!^(@[^,@]+(\.[^,@]+)+(,|$))*$!'); // https://regex101.com/r/mG4aL5/3
-$meta['singleService'] = array('multichoice',
- '_choices' => array(
- '',
- 'Auth0',
- 'Google',
- 'Dataporten',
- 'Facebook',
- 'Github',
- 'Yahoo',
- 'Doorkeeper',
- 'Keycloak'));
+// https://regex101.com/r/mG4aL5/3
+$meta['mailRestriction'] = array('string','_pattern' => '!^(@[^,@]+(\.[^,@]+)+(,|$))*$!');
+$meta['singleService'] = array('onoff');
$meta['register-on-auth'] = array('onoff','_caution' => 'security');
+$meta['overwrite-groups'] = array('onoff','_caution' => 'danger');
diff --git a/deleted.files b/deleted.files
new file mode 100644
index 0000000..2a8a44d
--- /dev/null
+++ b/deleted.files
@@ -0,0 +1,194 @@
+# This is a list of files that were present in previous releases
+# but were removed later. They should not exist in your installation.
+.travis.yml
+_test/checkMail.test.php
+_test/general.test.php
+action.php
+classes/AbstractAdapter.php
+classes/AbstractAuthService.php
+classes/Auth0Adapter.php
+classes/DataportenAdapter.php
+classes/DoorkeeperAdapter.php
+classes/FacebookAdapter.php
+classes/GithubAdapter.php
+classes/GithubAuthService.php
+classes/GoogleAdapter.php
+classes/KeycloakAdapter.php
+classes/YahooAdapter.php
+classes/oAuthHTTPClient.php
+classes/oAuthStorage.php
+images/facebook.png
+images/github.png
+images/google.png
+images/yahoo.png
+phpoauthlib/.gitignore
+phpoauthlib/.scrutinizer.yml
+phpoauthlib/.travis.yml
+phpoauthlib/LICENSE
+phpoauthlib/README.md
+phpoauthlib/composer.json
+phpoauthlib/examples/amazon.php
+phpoauthlib/examples/bitbucket.php
+phpoauthlib/examples/bitly.php
+phpoauthlib/examples/bootstrap.php
+phpoauthlib/examples/box.php
+phpoauthlib/examples/dailymotion.php
+phpoauthlib/examples/dropbox.php
+phpoauthlib/examples/etsy.php
+phpoauthlib/examples/facebook.php
+phpoauthlib/examples/fitbit.php
+phpoauthlib/examples/flickr.php
+phpoauthlib/examples/foursquare.php
+phpoauthlib/examples/github.php
+phpoauthlib/examples/google.php
+phpoauthlib/examples/init.example.php
+phpoauthlib/examples/instagram.php
+phpoauthlib/examples/linkedin.php
+phpoauthlib/examples/mailchimp.php
+phpoauthlib/examples/microsoft.php
+phpoauthlib/examples/paypal.php
+phpoauthlib/examples/pocket.php
+phpoauthlib/examples/reddit.php
+phpoauthlib/examples/runkeeper.php
+phpoauthlib/examples/scoopit.php
+phpoauthlib/examples/soundcloud.php
+phpoauthlib/examples/tumblr.php
+phpoauthlib/examples/twitter.php
+phpoauthlib/examples/yahoo.php
+phpoauthlib/phpunit.xml.dist
+phpoauthlib/src/OAuth/Common/AutoLoader.php
+phpoauthlib/src/OAuth/Common/Consumer/Credentials.php
+phpoauthlib/src/OAuth/Common/Consumer/CredentialsInterface.php
+phpoauthlib/src/OAuth/Common/Exception/Exception.php
+phpoauthlib/src/OAuth/Common/Http/Client/AbstractClient.php
+phpoauthlib/src/OAuth/Common/Http/Client/ClientInterface.php
+phpoauthlib/src/OAuth/Common/Http/Client/CurlClient.php
+phpoauthlib/src/OAuth/Common/Http/Client/StreamClient.php
+phpoauthlib/src/OAuth/Common/Http/Exception/TokenResponseException.php
+phpoauthlib/src/OAuth/Common/Http/Uri/Uri.php
+phpoauthlib/src/OAuth/Common/Http/Uri/UriFactory.php
+phpoauthlib/src/OAuth/Common/Http/Uri/UriFactoryInterface.php
+phpoauthlib/src/OAuth/Common/Http/Uri/UriInterface.php
+phpoauthlib/src/OAuth/Common/Service/AbstractService.php
+phpoauthlib/src/OAuth/Common/Service/ServiceInterface.php
+phpoauthlib/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php
+phpoauthlib/src/OAuth/Common/Storage/Exception/StorageException.php
+phpoauthlib/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php
+phpoauthlib/src/OAuth/Common/Storage/Memory.php
+phpoauthlib/src/OAuth/Common/Storage/Redis.php
+phpoauthlib/src/OAuth/Common/Storage/Session.php
+phpoauthlib/src/OAuth/Common/Storage/SymfonySession.php
+phpoauthlib/src/OAuth/Common/Storage/TokenStorageInterface.php
+phpoauthlib/src/OAuth/Common/Token/AbstractToken.php
+phpoauthlib/src/OAuth/Common/Token/Exception/ExpiredTokenException.php
+phpoauthlib/src/OAuth/Common/Token/TokenInterface.php
+phpoauthlib/src/OAuth/OAuth1/Service/AbstractService.php
+phpoauthlib/src/OAuth/OAuth1/Service/BitBucket.php
+phpoauthlib/src/OAuth/OAuth1/Service/Etsy.php
+phpoauthlib/src/OAuth/OAuth1/Service/FitBit.php
+phpoauthlib/src/OAuth/OAuth1/Service/Flickr.php
+phpoauthlib/src/OAuth/OAuth1/Service/ScoopIt.php
+phpoauthlib/src/OAuth/OAuth1/Service/ServiceInterface.php
+phpoauthlib/src/OAuth/OAuth1/Service/Tumblr.php
+phpoauthlib/src/OAuth/OAuth1/Service/Twitter.php
+phpoauthlib/src/OAuth/OAuth1/Service/Xing.php
+phpoauthlib/src/OAuth/OAuth1/Service/Yahoo.php
+phpoauthlib/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php
+phpoauthlib/src/OAuth/OAuth1/Signature/Signature.php
+phpoauthlib/src/OAuth/OAuth1/Signature/SignatureInterface.php
+phpoauthlib/src/OAuth/OAuth1/Token/StdOAuth1Token.php
+phpoauthlib/src/OAuth/OAuth1/Token/TokenInterface.php
+phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php
+phpoauthlib/src/OAuth/OAuth2/Service/Amazon.php
+phpoauthlib/src/OAuth/OAuth2/Service/Auth0.php
+phpoauthlib/src/OAuth/OAuth2/Service/Bitly.php
+phpoauthlib/src/OAuth/OAuth2/Service/Box.php
+phpoauthlib/src/OAuth/OAuth2/Service/Dailymotion.php
+phpoauthlib/src/OAuth/OAuth2/Service/Dataporten.php
+phpoauthlib/src/OAuth/OAuth2/Service/Dropbox.php
+phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php
+phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php
+phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php
+phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidServiceConfigurationException.php
+phpoauthlib/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php
+phpoauthlib/src/OAuth/OAuth2/Service/Facebook.php
+phpoauthlib/src/OAuth/OAuth2/Service/Foursquare.php
+phpoauthlib/src/OAuth/OAuth2/Service/Generic.php
+phpoauthlib/src/OAuth/OAuth2/Service/GitHub.php
+phpoauthlib/src/OAuth/OAuth2/Service/Google.php
+phpoauthlib/src/OAuth/OAuth2/Service/Harvest.php
+phpoauthlib/src/OAuth/OAuth2/Service/Heroku.php
+phpoauthlib/src/OAuth/OAuth2/Service/Instagram.php
+phpoauthlib/src/OAuth/OAuth2/Service/Keycloak.php
+phpoauthlib/src/OAuth/OAuth2/Service/Linkedin.php
+phpoauthlib/src/OAuth/OAuth2/Service/Mailchimp.php
+phpoauthlib/src/OAuth/OAuth2/Service/Microsoft.php
+phpoauthlib/src/OAuth/OAuth2/Service/Paypal.php
+phpoauthlib/src/OAuth/OAuth2/Service/Pocket.php
+phpoauthlib/src/OAuth/OAuth2/Service/Reddit.php
+phpoauthlib/src/OAuth/OAuth2/Service/RunKeeper.php
+phpoauthlib/src/OAuth/OAuth2/Service/Salesforce.php
+phpoauthlib/src/OAuth/OAuth2/Service/ServiceInterface.php
+phpoauthlib/src/OAuth/OAuth2/Service/SoundCloud.php
+phpoauthlib/src/OAuth/OAuth2/Service/Vkontakte.php
+phpoauthlib/src/OAuth/OAuth2/Service/Yammer.php
+phpoauthlib/src/OAuth/OAuth2/Token/StdOAuth2Token.php
+phpoauthlib/src/OAuth/OAuth2/Token/TokenInterface.php
+phpoauthlib/src/OAuth/ServiceFactory.php
+phpoauthlib/src/OAuth/bootstrap.php
+phpoauthlib/tests/Mocks/Common/FakeProject/NS/SomeClass.php
+phpoauthlib/tests/Mocks/Common/Service/Mock.php
+phpoauthlib/tests/Mocks/OAuth1/Service/Fake.php
+phpoauthlib/tests/Mocks/OAuth1/Service/Mock.php
+phpoauthlib/tests/Mocks/OAuth2/Service/Fake.php
+phpoauthlib/tests/Mocks/OAuth2/Service/Mock.php
+phpoauthlib/tests/Unit/Common/AutoloaderTest.php
+phpoauthlib/tests/Unit/Common/Consumer/CredentialsTest.php
+phpoauthlib/tests/Unit/Common/Http/Client/AbstractClientTest.php
+phpoauthlib/tests/Unit/Common/Http/Client/CurlClientTest.php
+phpoauthlib/tests/Unit/Common/Http/Client/StreamClientTest.php
+phpoauthlib/tests/Unit/Common/Http/HttpClientsTest.php
+phpoauthlib/tests/Unit/Common/Http/Uri/UriFactoryTest.php
+phpoauthlib/tests/Unit/Common/Http/Uri/UriTest.php
+phpoauthlib/tests/Unit/Common/Service/AbstractServiceTest.php
+phpoauthlib/tests/Unit/Common/Storage/MemoryTest.php
+phpoauthlib/tests/Unit/Common/Storage/RedisTest.php
+phpoauthlib/tests/Unit/Common/Storage/SessionTest.php
+phpoauthlib/tests/Unit/Common/Storage/StorageTest.php
+phpoauthlib/tests/Unit/Common/Storage/SymfonySessionTest.php
+phpoauthlib/tests/Unit/Common/Token/AbstractTokenTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/AbstractServiceTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/BitBucketTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/EtsyTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/FitBitTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/FlickrTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/ScoopItTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/TumblrTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/TwitterTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/XingTest.php
+phpoauthlib/tests/Unit/OAuth1/Service/YahooTest.php
+phpoauthlib/tests/Unit/OAuth1/Signature/SignatureTest.php
+phpoauthlib/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/AbstractServiceTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/AmazonTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/BitlyTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/BoxTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/DailymotionTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/DropboxTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/FacebookTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/FoursquareTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/GitHubTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/GoogleTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/HerokuTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/InstagramTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/LinkedinTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/MailchimpTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/MicrosoftTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/PaypalTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/RedditTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/RunKeeperTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/SoundCloudTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/VkontakteTest.php
+phpoauthlib/tests/Unit/OAuth2/Service/YammerTest.php
+phpoauthlib/tests/Unit/ServiceFactoryTest.php
+phpoauthlib/tests/bootstrap.php
diff --git a/helper.php b/helper.php
index 25eb088..8cbd185 100644
--- a/helper.php
+++ b/helper.php
@@ -1,4 +1,7 @@
*/
-// must be run within Dokuwiki
-if(!defined('DOKU_INC')) die();
+use dokuwiki\Extension\Plugin;
+use dokuwiki\Extension\Event;
+use dokuwiki\plugin\oauth\Adapter;
-class helper_plugin_oauth extends DokuWiki_Plugin {
+require_once(__DIR__ . '/vendor/autoload.php'); // @todo can be removed with next dw release
+/**
+ * Basic helper methods for the oauth flow
+ */
+class helper_plugin_oauth extends Plugin
+{
/**
* Load the needed libraries and initialize the named oAuth service
*
* @param string $servicename
- * @return null|\OAuth\Plugin\AbstractAdapter
+ * @return null|Adapter
*/
- public function loadService(&$servicename) {
- $id = getID(); // $ID isn't set in trustExternal, yet
-
- $servicename = preg_replace('/[^a-zA-Z0-9_]+/', '', $servicename);
- if(!$servicename) return null;
-
- require_once(__DIR__.'/phpoauthlib/src/OAuth/bootstrap.php');
- require_once(__DIR__.'/classes/AbstractAdapter.php');
- require_once(__DIR__.'/classes/oAuthHTTPClient.php');
- require_once(__DIR__.'/classes/oAuthStorage.php');
-
- $file = __DIR__.'/classes/'.$servicename.'Adapter.php';
- if(!file_exists($file)) return null;
- require_once($file);
- $class = '\\OAuth\\Plugin\\'.$servicename.'Adapter';
-
- /** @var \OAuth\Plugin\AbstractAdapter $service */
- $service = new $class($this->redirectURI());
- if(!$service->isInitialized()) {
- msg("Failed to initialize $service authentication service. Check credentials", -1);
- return null;
- }
-
- // The generic service can be externally configured
- if(is_a($service->oAuth, 'OAuth\\OAuth2\\Service\\Generic')) {
- $service->oAuth->setAuthorizationEndpoint($this->getAuthEndpoint($servicename));
- $service->oAuth->setAccessTokenEndpoint($this->getTokenEndpoint($servicename));
- }
-
- return $service;
+ public function loadService($servicename)
+ {
+ $services = $this->listServices(true);
+ if (!isset($services[$servicename])) return null;
+ return $services[$servicename];
}
/**
@@ -54,7 +38,8 @@ public function loadService(&$servicename) {
*
* @return string
*/
- public function redirectURI() {
+ public function redirectURI()
+ {
if ($this->getConf('custom-redirectURI') !== '') {
return $this->getConf('custom-redirectURI');
} else {
@@ -65,88 +50,39 @@ public function redirectURI() {
/**
* List available Services
*
- * @param bool $enabledonly list only enabled services
- * @return array
+ * Services returned here, do not have initialized oAuth providers yet!
+ *
+ * @param bool $enabledonly list only services that have been configured
+ * @triggers PLUGIN_OAUTH_BACKEND_REGISTER
+ * @return Adapter[] list of service objects
*/
- public function listServices($enabledonly = true) {
- $services = array();
- $files = glob(__DIR__.'/classes/*Adapter.php');
-
- foreach($files as $file) {
- $file = basename($file, 'Adapter.php');
- if($file == 'Abstract') continue;
- if($enabledonly && !$this->getKey($file)) continue;
- $services[] = $file;
+ public function listServices($enabledonly = true)
+ {
+ $services = [];
+ $event = new Event('PLUGIN_OAUTH_BACKEND_REGISTER', $services);
+ $event->advise_before(false);
+ $event->advise_after();
+
+ // filter out unconfigured services
+ if ($enabledonly) {
+ $services = array_filter($services, static fn($service) =>
+ /** @var Adapter $service */
+ (bool)$service->getKey());
}
return $services;
}
- /**
- * Return the configured key for the given service
- *
- * @param $service
- * @return string
- */
- public function getKey($service) {
- $service = strtolower($service);
- return $this->getConf($service.'-key');
- }
-
- /**
- * Return the configured secret for the given service
- *
- * @param $service
- * @return string
- */
- public function getSecret($service) {
- $service = strtolower($service);
- return $this->getConf($service.'-secret');
- }
-
- /**
- * Return the configured Authentication Endpoint URL for the given service
- *
- * @param $service
- * @return string
- */
- public function getAuthEndpoint($service) {
- $service = strtolower($service);
- return $this->getConf($service.'-authurl');
- }
-
- /**
- * Return the configured Access Token Endpoint URL for the given service
- *
- * @param $service
- * @return string
- */
- public function getTokenEndpoint($service) {
- $service = strtolower($service);
- return $this->getConf($service.'-tokenurl');
- }
-
- /**
- * Return the configured User Info Endpoint URL for the given service
- *
- * @param $service
- * @return string
- */
- public function getUserInfoEndpoint($service) {
- $service = strtolower($service);
- return $this->getConf($service.'-userinfourl');
- }
-
/**
* @return array
*/
- public function getValidDomains() {
+ public function getValidDomains()
+ {
if ($this->getConf('mailRestriction') === '') {
- return array();
+ return [];
}
$validDomains = explode(',', trim($this->getConf('mailRestriction'), ','));
- $validDomains = array_map('trim', $validDomains);
- return $validDomains;
+ return array_map('trim', $validDomains);
}
/**
@@ -154,11 +90,13 @@ public function getValidDomains() {
*
* @return bool
*/
- public function checkMail($mail) {
- $hostedDomains = $this->getValidDomains();
+ public function checkMail($mail)
+ {
+ $validDomains = $this->getValidDomains();
+ if (empty($validDomains)) return true;
- foreach ($hostedDomains as $validDomain) {
- if(substr($mail, -strlen($validDomain)) === $validDomain) {
+ foreach ($validDomains as $validDomain) {
+ if (str_ends_with($mail, $validDomain)) {
return true;
}
}
@@ -166,42 +104,32 @@ public function checkMail($mail) {
}
/**
- * @param array $session cookie auth session
- *
- * @return bool
- */
- public function validBrowserID ($session) {
- return $session['buid'] == auth_browseruid();
- }
-
- /**
- * @param array $session cookie auth session
+ * Display an exception to the user
*
- * @return bool
+ * @param Exception $e
+ * @param string $friendly - user friendly explanation if available
*/
- public function isSessionTimedOut ($session) {
+ public function showException(Exception $e, $friendly = '')
+ {
global $conf;
- return $session['time'] < time() - $conf['auth_security_timeout'];
- }
- /**
- * @return bool
- */
- public function isGETRequest () {
- global $INPUT;
- $result = $INPUT->server->str('REQUEST_METHOD') === 'GET';
- return $result;
- }
+ $msg = $e->getMessage();
- /**
- * check if we are handling a request to doku.php. Only doku.php defines $updateVersion
- *
- * @return bool
- */
- public function isDokuPHP() {
- global $updateVersion;
- return isset($updateVersion);
+ // translate the message if possible, using context if available
+ $trans = $this->getLang($msg);
+ if ($trans) {
+ if ($e instanceof \dokuwiki\plugin\oauth\Exception) {
+ $context = $e->getContext();
+ $trans = sprintf($trans, ...$context);
+ }
+ $msg = $trans;
+ }
+
+ msg('OAuth: ' . $friendly . ' ' . hsc($msg), -1);
+ if ($conf['allowdebug']) {
+ $msg = get_class($e) . ' at ' . $e->getFile() . ':' . $e->getLine() . ' ';
+ $msg .= hsc($e->getTraceAsString());
+ msg("$msg ", -1);
+ }
}
}
-
-// vim:ts=4:sw=4:et:
diff --git a/images/facebook.png b/images/facebook.png
deleted file mode 100644
index 9965265..0000000
Binary files a/images/facebook.png and /dev/null differ
diff --git a/images/github.png b/images/github.png
deleted file mode 100644
index fb252ea..0000000
Binary files a/images/github.png and /dev/null differ
diff --git a/images/google.png b/images/google.png
deleted file mode 100644
index fe0234e..0000000
Binary files a/images/google.png and /dev/null differ
diff --git a/images/yahoo.png b/images/yahoo.png
deleted file mode 100644
index 2d2f2cd..0000000
Binary files a/images/yahoo.png and /dev/null differ
diff --git a/lang/cs/lang.php b/lang/cs/lang.php
new file mode 100644
index 0000000..370409b
--- /dev/null
+++ b/lang/cs/lang.php
@@ -0,0 +1,18 @@
+
+ */
+
+$lang['emailduplicate'] = 'Tato emailová adresa je již spojená s jiným uživatelským účtem.';
+$lang['loginwith'] = 'Přihlásit se pomocí jiných služeb:';
+$lang['authnotenabled'] = 'Uživatelský účet spojený s vaší e-mailovou adresou nemá povolené přihlašování službou %s. Prosím přihlašte se jinou metodou a povolte přihlašování službou %s ve svém profilu.';
+$lang['wrongConfig'] = 'Plugin oAuth není správně nakonfigurovaný. Přihlášení je možné jen pomocí lokálního účtu. Prosím kontaktujte administrátora své wiki.';
+$lang['loginButton'] = 'Přihlášení službou ';//... i.e. Google (on SingleAuth)
+$lang['rejectedEMail'] = 'Byla použita nesprávná e-mailová adresa. V systému jsou povolené pouze emailové adresy následujících domén:: %s!';
+$lang['eMailRestricted'] = 'V systému jsou povolené pouze emailové adresy následujících domén: %s';
+$lang['noEmail'] = 'Služba %s neposkytla vaši e-mailovou adresu. Přihlášení není možné.';
+$lang['addUser not possible'] = 'Samoregistrace užívatele je momentálně zakázaná, nebo konfigurace v conf/users.auth.php není zapisovatelná. Prosím požádajte administrátora vaší wiki, aby vám vytvořil účet manuálně.';
+$lang['oauth login failed'] = 'Vaše (opakované) přihlášení selhalo.';
+$lang['generic create error'] = 'Při vytváření vašeh ouživatelského účtu nastala chyba. Zkuste to prosím znovu později.';
diff --git a/lang/cs/settings.php b/lang/cs/settings.php
new file mode 100644
index 0000000..2af68c4
--- /dev/null
+++ b/lang/cs/settings.php
@@ -0,0 +1,14 @@
+
+ */
+
+
+$lang['info'] = 'Redirect URI konfiguraci aplikací';
+$lang['custom-redirectURI'] = 'Použít vlastní redirect URI';
+$lang['mailRestriction'] = 'Omezit autentizaci na užívatele z této domény (volitelné, musí začínat @
)';
+$lang['singleService'] = 'Povolit přihlášení pouze se službou oAuth (zakáže přihlášení lokálními účty!)';
+$lang['singleService_o_'] = 'Povolit všechny služby';
+$lang['register-on-auth'] = 'Zaregistrovat autentizované uživatele i když je samo-registrace zakázaná v nastavení zabezpečení';
diff --git a/lang/de-informal/lang.php b/lang/de-informal/lang.php
index e1cdcba..212f85c 100644
--- a/lang/de-informal/lang.php
+++ b/lang/de-informal/lang.php
@@ -11,6 +11,6 @@
$lang['wrongConfig'] = 'Das oAuth Plugin ist fehlerhaft konfiguriert, es können derzeit nur lokale Anmeldedaten verwendet werden. Bitte wende dich an den Administrator dieses Wikis.';
$lang['loginButton'] = 'Anmelden mit';
$lang['rejectedEMail'] = 'Ungültige Emailadresse. Nur Adressen aus den folgenden Domänen sind erlaubt: %s!';
-$lang['eMailRestricted'] = 'Nur Adressen aus den folgenden Domänen sind erlaubt: %s!
';
+$lang['eMailRestricted'] = 'Nur Adressen aus den folgenden Domänen sind erlaubt: %s!';
$lang['addUser not possible'] = 'Die Registrierung ist nicht erlaubt oder conf/users.auth.php ist nicht schreibbar. Bitte wende dich an den Administrator dieses Wikis.';
$lang['oauth login failed'] = 'Anmeldung fehlgeschlagen.';
diff --git a/lang/de-informal/settings.php b/lang/de-informal/settings.php
index 8af4313..91e5558 100644
--- a/lang/de-informal/settings.php
+++ b/lang/de-informal/settings.php
@@ -7,19 +7,6 @@
*/
$lang['info'] = 'Weiterleitungs-URI für die Konfiguration der Applikationen';
$lang['custom-redirectURI'] = 'Folgende benutzerdefinierte Weiterleitungs-URI verwenden';
-$lang['auth0-key'] = 'Client ID deiner Auth0 Applikation ';
-$lang['auth0-secret'] = 'Client Geheimcode deiner Auth0 Applikation ';
-$lang['auth0-domain'] = 'Domäne deiner Auth0 Applikation ';
-$lang['facebook-key'] = 'App-ID deiner Facebook-App ';
-$lang['facebook-secret'] = 'App-Geheimcode deiner Facebook-App ';
-$lang['github-key'] = 'Client ID deiner Github Applikation ';
-$lang['github-secret'] = 'Client Secret deiner Github Applikation ';
-$lang['google-key'] = 'Client-ID deines Google Projects (siehe "APIs & Dienste / Zugangsdaten")';
-$lang['google-secret'] = 'Clientschlüssel deines Google Projects (siehe "APIs & Dienste / Zugangsdaten")';
-$lang['dataporten-key'] = 'Client ID deiner Dataporten Applikation ';
-$lang['dataporten-secret'] = 'Client Geheimhcode deiner Dataporten Applikation ';
-$lang['keycloak-key'] = 'Resource ID deiner Keycloak Applikation';
-$lang['keycloak-secret'] = 'Geheimcode deiner Keycloak Applikation';
$lang['mailRestriction'] = 'Beschränke Anmeldung auf Benutzerprofile dieser Domäne (optional, muss mit @
beginnen)';
$lang['singleService'] = 'Nur einen oAuth Service zulassen (lokale Anmeldung wird deaktiviert!)';
$lang['singleService_o_'] = 'Alle Services zulassen';
diff --git a/lang/de/lang.php b/lang/de/lang.php
index 5961962..1d9725c 100644
--- a/lang/de/lang.php
+++ b/lang/de/lang.php
@@ -11,6 +11,6 @@
$lang['wrongConfig'] = 'Das oAuth Plugin ist fehlerhaft konfiguriert, es können derzeit nur lokale Anmeldedaten verwendet werden. Bitte wenden Sie Sich an den Administrator dieses Wikis.';
$lang['loginButton'] = 'Anmelden mit';
$lang['rejectedEMail'] = 'Ungültige Emailadresse. Nur Adressen aus den folgenden Domänen sind erlaubt: %s!';
-$lang['eMailRestricted'] = 'Nur Adressen aus den folgenden Domänen sind erlaubt: %s!
';
+$lang['eMailRestricted'] = 'Nur Adressen aus den folgenden Domänen sind erlaubt: %s!';
$lang['addUser not possible'] = 'Die Registrierung ist nicht erlaubt oder conf/users.auth.php ist nicht schreibbar. Bitte wenden Sie Sich an den Administrator dieses Wikis.';
$lang['oauth login failed'] = 'Anmeldung fehlgeschlagen.';
diff --git a/lang/de/settings.php b/lang/de/settings.php
index b58ea3c..72d78fd 100644
--- a/lang/de/settings.php
+++ b/lang/de/settings.php
@@ -7,18 +7,8 @@
*/
$lang['info'] = 'Weiterleitungs-URI für die Konfiguration der Applikationen';
$lang['custom-redirectURI'] = 'Folgende benutzerdefinierte Weiterleitungs-URI verwenden';
-$lang['auth0-key'] = 'Client ID Ihrer Auth0 Applikation ';
-$lang['auth0-secret'] = 'Client Geheimcode Ihrer Auth0 Applikation ';
-$lang['auth0-domain'] = 'Domäne Ihrer Auth0 Applikation ';
-$lang['facebook-key'] = 'App-ID Ihrer Facebook-App ';
-$lang['facebook-secret'] = 'App-Geheimcode Ihrer Facebook-App ';
-$lang['github-key'] = 'Client ID Ihrer Github Applikation ';
-$lang['github-secret'] = 'Client Secret Ihrer Github Applikation ';
-$lang['google-key'] = 'Client-ID Ihres Google Projects (siehe "APIs & Dienste / Zugangsdaten")';
-$lang['google-secret'] = 'Clientschlüssel Ihres Google Projects (siehe "APIs & Dienste / Zugangsdaten")';
-$lang['dataporten-key'] = 'Client ID Ihrer Dataporten Applikation ';
-$lang['dataporten-secret'] = 'Client Geheimhcode Ihrer Dataporten Applikation ';
$lang['mailRestriction'] = 'Beschränke Anmeldung auf Benutzerprofile dieser Domäne (optional, muss mit @
beginnen)';
$lang['singleService'] = 'Nur einen oAuth Service zulassen (lokale Anmeldung wird deaktiviert!)';
$lang['singleService_o_'] = 'Alle Services zulassen';
$lang['register-on-auth'] = 'Authentifizierte Benutzer registrieren, auch wenn Selbstregistrierung in der Hauptkonfiguration nicht erlaubt ist.';
+$lang['overwrite-groups'] = 'Alle DokuWiki Nutzergruppen mit Service-Gruppen überschreiben';
diff --git a/lang/en/lang.php b/lang/en/lang.php
index d165531..837e9d4 100644
--- a/lang/en/lang.php
+++ b/lang/en/lang.php
@@ -6,11 +6,13 @@
*/
$lang['emailduplicate'] = 'This email is already associated with another user.';
-$lang['loginwith'] = 'Login with other Services:';
+$lang['loginwith'] = 'Log in with other Services:';
$lang['authnotenabled'] = 'The account associated with your email address has not enabled logging in with %s. Please login by other means and enable it in your profile.';
$lang['wrongConfig'] = 'The oAuth plugin has been malconfigured. Defaulting to local authentication only. Please contact your wiki administrator.';
-$lang['loginButton'] = 'Login with ';//... i.e. Google (on SingleAuth)
+$lang['loginButton'] = 'Log in with ';//... i.e. Google (on SingleAuth)
$lang['rejectedEMail'] = 'Invalid eMail-Account used. Only email accounts from the following domain(s) are allowed: %s!';
-$lang['eMailRestricted'] = 'Only email accounts from the following domain(s) are allowed: %s
';
+$lang['eMailRestricted'] = 'Only email accounts from the following domain(s) are allowed: %s';
+$lang['noEmail'] = '%s service did not provide the an email address. Can\'t log you in.';
$lang['addUser not possible'] = 'Self-Registration is currently disabled or conf/users.auth.php is not writable. Please ask your DokuWiki administrator to create your account manually.';
$lang['oauth login failed'] = 'Your (re)login has failed.';
+$lang['generic create error'] = 'Something went wrong creating your user account. Please try again later.';
diff --git a/lang/en/settings.php b/lang/en/settings.php
index 9539990..25136df 100644
--- a/lang/en/settings.php
+++ b/lang/en/settings.php
@@ -8,29 +8,8 @@
$lang['info'] = 'Redirect URI to use when configuring the applications';
$lang['custom-redirectURI'] = 'Use the following custom redirect URI';
-$lang['auth0-key'] = 'The Client ID of your registered Auth0 application ';
-$lang['auth0-secret'] = 'The Client Secret of your registered Auth0 application ';
-$lang['auth0-domain'] = 'The Domain of your registered Auth0 account ';
-$lang['facebook-key'] = 'The App ID of your registered Facebook application ';
-$lang['facebook-secret'] = 'The App Secret of your registered Facebook application ';
-$lang['github-key'] = 'The Client ID of your registered Github application ';
-$lang['github-secret'] = 'The Client Secret of your registered Github application ';
-$lang['google-key'] = 'The Client ID of your registered Google Project (see Credentials Screen)';
-$lang['google-secret'] = 'The Client Secret of your registered Google Project (see Credentials Screen)';
-$lang['dataporten-key'] = 'The Client ID of your registered Dataporten application ';
-$lang['dataporten-secret'] = 'The Client Secret of your registered Dataporten application ';
-$lang['keycloak-key'] = 'The resource id of your Keycloak application.';
-$lang['keycloak-secret'] = 'The Secret of your Keycloak Application.';
-$lang['keycloak-authurl'] = 'The authorization endpoint URL of your Keycloak setup.';
-$lang['keycloak-tokenurl'] = 'The access token endpoint URL of your Keycloak setup.';
-$lang['keycloak-userinfourl'] = 'The userinfo endpoint URL of your Keycloak setup.';
$lang['mailRestriction'] = "Limit authentification to users from this domain (optional, must start with an @
)";
-$lang['yahoo-key'] = 'The Consumer Key of your registered Yahoo Application ';
-$lang['yahoo-secret'] = 'The Consumer Secret of your registered Yahoo Application ';
-$lang['doorkeeper-key'] = '(Example) The Application ID of your registered Doorkeeper Application.';
-$lang['doorkeeper-secret'] = '(Example) The Secret of your registered Doorkeeper Application.';
-$lang['doorkeeper-authurl'] = '(Example) The authorization endpoint URL of your Doorkeeper setup.';
-$lang['doorkeeper-tokenurl'] = '(Example) The access token endpoint URL of your Doorkeeper setup.';
$lang['singleService'] = 'Login with single oAuth service only (disables local logins!)';
$lang['singleService_o_'] = 'Allow all services';
$lang['register-on-auth'] = 'Register authenticated users even if self-registration is disabled in main configuration';
+$lang['overwrite-groups'] = 'Overwrite all DokuWiki user groups by those supplied by provider';
diff --git a/lang/fr/lang.php b/lang/fr/lang.php
index cdd0bf2..8ed8462 100644
--- a/lang/fr/lang.php
+++ b/lang/fr/lang.php
@@ -9,12 +9,14 @@
* @author Andreas Gohr
* @author Cyrille Giquello
*/
-$lang['emailduplicate'] = 'Cette adresse de courriel est déjà associée à un utilisateur.';
-$lang['loginwith'] = 'Connectez vous avec d´autres services:';
+$lang['emailduplicate'] = 'Cette adresse de courriel est déjà associée à un autre utilisateur.';
+$lang['loginwith'] = 'Se connecter avec d´autres services:';
$lang['authnotenabled'] = 'Le compte associé à cette adresse de courriel n´a pas autorisé la connexion avec %s. Connectez-vous à ce compte par un autre moyen pour activer ce service.';
-$lang['wrongConfig'] = 'le greffon oAuth est mal configuré et n\'utilise donc que l\'authentification locale. Veuillez contacter l\'administrateur du wiki.';
+$lang['wrongConfig'] = 'le greffon oAuth est mal configuré. DokuWiki se rabat sur l\'authentification locale seule. Veuillez contacter l\'administrateur du wiki.';
$lang['loginButton'] = 'Se connecter avec';
-$lang['rejectedEMail'] = 'Compte de courriel invalide. Seuls les adresses du domaine %s sont autorisées.';
-$lang['eMailRestricted'] = 'Seuls les comptes de courriel de %s sont autorisés.
';
-$lang['addUser not possible'] = 'L\'enregistrement automatique est désactivé en ce moment, ou il est impossible de modifier conf/users.auth.php. Veuillez demander à l\'administrateur du wiki de créer un compte manuellement.';
+$lang['rejectedEMail'] = 'Compte de courriel invalide. Seules les adresses du domaine %s sont autorisées.';
+$lang['eMailRestricted'] = 'Seuls les comptes de courriel de %s sont autorisés.';
+$lang['noEmail'] = 'Le service %s n\'a pas fourni d\'adresse de courriel. Impossible de vous connecter.';
+$lang['addUser not possible'] = 'Soit l\'enregistrement automatique est désactivé en ce moment soit il est impossible de modifier conf/users.auth.php. Veuillez demander à l\'administrateur du wiki de créer un compte manuellement.';
$lang['oauth login failed'] = 'Votre (re)connexion a échoué.';
+$lang['generic create error'] = 'Quelque chose s\'est mal passé pendant la création de votre compte. Veuillez recommencer plus tard.';
diff --git a/lang/fr/settings.php b/lang/fr/settings.php
index 3c19a96..bcba307 100644
--- a/lang/fr/settings.php
+++ b/lang/fr/settings.php
@@ -6,33 +6,12 @@
* French language file for oauth plugin
*
* @author Schplurtz le Déboulonné
- * @author Andreas Gohr
* @author Cyrille Giquello
*/
$lang['info'] = 'URI de redirection à utiliser dans la configuration de l´application';
$lang['custom-redirectURI'] = 'Utiliser cet URI de redirection personnalisé';
-$lang['auth0-key'] = 'L\'ID client de votre application Auth0 enregistrée';
-$lang['auth0-secret'] = 'le secret client de votre application Auth0 enregistrée';
-$lang['auth0-domain'] = 'Le domaine de de votre compte Auth0 enregistrée';
-$lang['facebook-key'] = 'L´App ID de votre application Facebook enregistrée';
-$lang['facebook-secret'] = 'L´App Secret de votre application Facebook enregistrée';
-$lang['github-key'] = 'Le Client ID de votre application Github enregistrée';
-$lang['github-secret'] = 'Le Client Secret de votre application Github enregistrée';
-$lang['google-key'] = 'Le Client ID de votre projet Google enregistré (voir Credentials Screen)';
-$lang['google-secret'] = 'Le Client Secret de votre projet Google enregistré (voir Credentials Screen)';
-$lang['dataporten-key'] = 'L\'ID client de votre application Dataporten enregistrée';
-$lang['dataporten-secret'] = 'Le secret client de votre application Dataporten enregistrée';
-$lang['keycloak-key'] = 'L\'id de ressource de votre application Keycloak.';
-$lang['keycloak-secret'] = 'Le secret de votre application Keycloak.';
-$lang['keycloak-authurl'] = 'Le préfixe d\'URL de votre installation Keycloak.';
-$lang['keycloak-tokenurl'] = 'Le préfixe d\'URL du jeton d\'accès de votre installation Keycloak.';
-$lang['keycloak-userinfourl'] = 'Le préfixe d\'URL de votre installation Keycloak.';
$lang['mailRestriction'] = 'Limiter l\'authentification aux utilisateurs de ce domaine (optionnel, doit commencer par un @
).';
-$lang['yahoo-key'] = 'La Consumer Key de votre application Yahoo enregistrée';
-$lang['yahoo-secret'] = 'Le Consumer Secret de votre application Yahoo enregistrée';
-$lang['doorkeeper-key'] = '(Exemple) l´Application ID de votre application Doorkeeper.';
-$lang['doorkeeper-secret'] = '(Exemple) Le Secret de votre application Doorkeeper.';
-$lang['doorkeeper-authurl'] = '(Exemple) Le préfixe d\'URL d\'autorisation de votre installation Doorkeeper.';
-$lang['doorkeeper-tokenurl'] = '(Exemple) Le préfixe d\'URL du jeton d\'accès de votre installation Doorkeeper.';
$lang['singleService'] = 'Se connecter uniquement avec oAuth (désactive les logins locaux)';
$lang['singleService_o_'] = 'Autoriser tous les services';
+$lang['register-on-auth'] = 'Enregistrer les utilisateurs authentifiés même si l\'enregistrement automatique est désactivé dans la configuration principale';
+$lang['overwrite-groups'] = 'Écraser tous les groupes d\'utilisateurs DokuWiki par ceux livrés par le fournisseur.';
diff --git a/lang/ja/lang.php b/lang/ja/lang.php
index d710fdf..fa509ea 100644
--- a/lang/ja/lang.php
+++ b/lang/ja/lang.php
@@ -11,6 +11,6 @@
$lang['wrongConfig'] = 'oAuthプラグインが不正確に設定されました。デフォルトのローカル認証のみ使えます。このWikiの管理者にご連絡下さい。';
$lang['loginButton'] = 'ログイン方法';
$lang['rejectedEMail'] = '無効なメールアカウントが使われました。以下のドメインのメールアカウントのみ使えます:%s';
-$lang['eMailRestricted'] = '以下のドメインのメールアカウントのみ使えます:%s
';
+$lang['eMailRestricted'] = '以下のドメインのメールアカウントのみ使えます:%s';
$lang['addUser not possible'] = 'アカウントの自己登録が現在不可能となっているか、conf/users.auth.phpが書き込み不能となっています。アカウントを手動で作成するには、このWikiの管理者にご連絡下さい。';
$lang['oauth login failed'] = '(再)ログインに失敗しました。';
diff --git a/lang/ja/settings.php b/lang/ja/settings.php
index 145fef9..c5213ee 100644
--- a/lang/ja/settings.php
+++ b/lang/ja/settings.php
@@ -7,28 +7,6 @@
*/
$lang['info'] = 'アプリケーション設定の際に使うリダイレクトURI';
$lang['custom-redirectURI'] = '次のカスタム リダイレクトURIを使用する';
-$lang['auth0-key'] = 'お客様の登録したAuth0アプリケーション のクライアントID';
-$lang['auth0-secret'] = 'お客様の登録したAuth0アプリケーション のクライアントシークレット';
-$lang['auth0-domain'] = 'お客様の登録したAuth0アカウント のドメイン';
-$lang['facebook-key'] = 'お客様の登録したFacebookアプリケーション のApp ID';
-$lang['facebook-secret'] = 'お客様の登録したFacebookアプリケーション のAppシークレット';
-$lang['github-key'] = 'お客様の登録したGithubアプリケーション のクライアントID';
-$lang['github-secret'] = 'お客様の登録したGithubアプリケーション のクライアントシークレット';
-$lang['google-key'] = 'お客様の登録したGoogleプロジェクト のクライアントID(認証情報の画面をご覧下さい)';
-$lang['google-secret'] = 'お客様の登録したGoogleプロジェクト のクライアントシークレット(認証情報の画面をご覧下さい)';
-$lang['dataporten-key'] = 'お客様の登録したDataportenアプリケーション のクライアントID';
-$lang['dataporten-secret'] = 'お客様の登録したDataportenアプリケーション のクライアントシークレット';
-$lang['keycloak-key'] = 'お客様のKeycloakアプリケーションのリソースID';
-$lang['keycloak-secret'] = 'お客様のKeycloakアプリケーションのシークレット';
-$lang['keycloak-authurl'] = 'お客様のKeycloakセットアップの認証エンドポイントURL';
-$lang['keycloak-tokenurl'] = 'お客様のKeycloakセットアップのアクセストークン エンドポイントURL';
-$lang['keycloak-userinfourl'] = 'お客様のKeycloakセットアップのユーザー情報 エンドポイントURL';
$lang['mailRestriction'] = 'このドメインからのユーザーの確認を制限する(任意項目・必ず@
で始めて下さい)';
-$lang['yahoo-key'] = 'お客様の登録したYahooアプリケーション のコンシューマ キー';
-$lang['yahoo-secret'] = 'お客様の登録したYahooアプリケーション のコンシューマ シークレット';
-$lang['doorkeeper-key'] = '(例)お客様の登録したDoorkeeperアプリケーションのアプリケーションID';
-$lang['doorkeeper-secret'] = '(例)お客様の登録したDoorkeeperアプリケーションのシークレット';
-$lang['doorkeeper-authurl'] = '(例)お客様のDoorkeeperセットアップの認証エンドポイントURL';
-$lang['doorkeeper-tokenurl'] = '(例)お客様のDoorkeeperセットアップのアクセストークン エンドポイントURL';
$lang['singleService'] = '単一のoAuthサービスでのみログインする(ローカルログインを無効化します)';
$lang['singleService_o_'] = '全サービスを許可する';
diff --git a/lang/ko/settings.php b/lang/ko/settings.php
index dced8a7..fdd241b 100644
--- a/lang/ko/settings.php
+++ b/lang/ko/settings.php
@@ -7,15 +7,3 @@
$lang['info'] = '앱 설정시 입력할 이동주소(Redirect URI)';
-$lang['facebook-key'] = '등록한 페이스북 앱 의 App ID';
-$lang['facebook-secret'] = '등록한 페이스북 앱 의 App Secret ';
-$lang['github-key'] = '등록한 깃헙 앱 의 Client ID';
-$lang['github-secret'] = '등록한 깃헙 앱 의 Client Secret';
-$lang['google-key'] = '등록한 구글프로젝트 의 Client ID (Credentials Screen 참조)';
-$lang['google-secret'] = '등록한 구글프로젝트 의 Client Secret (Credentials Screen 참조)';
-$lang['yahoo-key'] = '등록한 야후 앱 의 Consumer Key';
-$lang['yahoo-secret'] = '등록한 야후 앱 의 Consumer Secret';
-$lang['doorkeeper-key'] = '(예제) 등록한 Doorkeeper 앱의 Application ID.';
-$lang['doorkeeper-secret'] = '(예제) 등록한 Doorkeeper 앱의 Secret ';
-$lang['doorkeeper-authurl'] = '(예제) 등록한 Doorkeeper 앱 설정의 authorization endpoint URL.';
-$lang['doorkeeper-tokenurl'] = '(예제) 등록한 Doorkeeper 앱 설정의 access token endpoint URL.';
diff --git a/lang/nl/lang.php b/lang/nl/lang.php
index 4d4ffee..36d8578 100644
--- a/lang/nl/lang.php
+++ b/lang/nl/lang.php
@@ -3,7 +3,7 @@
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
- * @author Gerrit Uitslag
+ * @author Gerrit
* @author Hans Drexler
*/
$lang['emailduplicate'] = 'Dit e-mail adres hoort bij een andere gebruiker.';
@@ -12,6 +12,8 @@
$lang['wrongConfig'] = 'De oAuth plugin is verkeerd geconfigureerd. Overgeschakeld naar enkel lokale authenticatie. Waarschuw a.u.b. uw wiki beheerder.';
$lang['loginButton'] = 'Login met';
$lang['rejectedEMail'] = 'Ongeschikt e-mail adres gebruikt. Enkel e-mail accounts van de volgende domeinen zijn toegestaan: %s';
-$lang['eMailRestricted'] = 'Enkel e-mail accounts van de volgende domeinen zijn toegestaan: %s
';
+$lang['eMailRestricted'] = 'Enkel e-mail accounts van de volgende domeinen zijn toegestaan: %s';
+$lang['noEmail'] = '%s service heeft geen e-mailadres verstrekt. Daardoor kun je niet inloggen.';
$lang['addUser not possible'] = 'Zelf-registratie is momenteel uitgeschakeld, of het bestand conf/users.auth.php is niet schrijfbaar. Vraag a.u.b. uw DokuWiki beheerder om uw account handmatig aan te maken.';
$lang['oauth login failed'] = 'Uw (her)login is mislukt.';
+$lang['generic create error'] = 'Iets ging verkeerd bij het aanmaken van uw gebruikersaccount. Probeer later alstublieft opnieuw.';
diff --git a/lang/nl/settings.php b/lang/nl/settings.php
index 8525ac0..8476f07 100644
--- a/lang/nl/settings.php
+++ b/lang/nl/settings.php
@@ -3,34 +3,13 @@
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
- * @author Gerrit Uitslag
+ * @author Gerrit
* @author Hans Drexler
*/
$lang['info'] = 'Redirect URI om te gebruiken voor applicatie configuratie';
$lang['custom-redirectURI'] = 'Gebruik de volgende custom redirect URI';
-$lang['auth0-key'] = 'Het Client ID van uw geregistreerde Auth0 applicatie ';
-$lang['auth0-secret'] = 'De geheime Client code van uw geregistreerde Auth0 applicatie ';
-$lang['auth0-domain'] = 'Het Domein van uw geregistreerde Auth0 account ';
-$lang['facebook-key'] = 'De App ID van uw geregistreerde Facebook applicatie ';
-$lang['facebook-secret'] = 'De geheime App code van uw geregistreerde Facebook applicatie ';
-$lang['github-key'] = 'Het Client ID van uw geregistreerde Github applicatie ';
-$lang['github-secret'] = 'De geheime Client code van uw geregistreerde Github applicatie ';
-$lang['google-key'] = 'Het Client ID van uw geregistreerde Google Project (zie Credentials Screen)';
-$lang['google-secret'] = 'De geheime Client code van uw geregistreerde Google Project (see Credentials Screen)';
-$lang['dataporten-key'] = 'Het Client ID van uw geregistreerde Dataporten applicatie ';
-$lang['dataporten-secret'] = 'De geheime Client code van uw geregistreerde Dataporten applicatie ';
-$lang['keycloak-key'] = 'Het bron id van uw Keycloak applicatie';
-$lang['keycloak-secret'] = 'De geheime code van uw Keycloak applicatie';
-$lang['keycloak-authurl'] = 'De URL van het autorisatie-eindpunt van uw Keycloak systeem.';
-$lang['keycloak-tokenurl'] = 'De toegangscode van het autorisatie-eindpunt van uw Keycloak systeem.';
-$lang['keycloak-userinfourl'] = 'De URL van de gebruikerinformatie van uw Keycloak systeem.';
$lang['mailRestriction'] = 'Limiteer authenticatie tot gebruikers van dit domein (optioneel, moet beginnen met @
)';
-$lang['yahoo-key'] = 'De Consumenten-sleutel van uw geregistreerde Yahoo Applicatie ';
-$lang['yahoo-secret'] = 'De geheime code van uw geregistreerde Yahoo Applicatie ';
-$lang['doorkeeper-key'] = '(Voorbeeld) De applicatie-ID van uw geregistreerde Doorkeeper-applicatie.';
-$lang['doorkeeper-secret'] = '(Voorbeeld) De geheime code van uw geregistreerde Doorkeeper-applicatie.';
-$lang['doorkeeper-authurl'] = '(Voorbeeld) De URL van het autorisatie-eindpunt van uw geregistreerde Doorkeeper-applicatie.';
-$lang['doorkeeper-tokenurl'] = '(Voorbeeld) De toegangcode eindpunt URL van uw geregistreerde Doorkeeper-applicatie.';
$lang['singleService'] = 'Login met maar één oAuth-service (schakelt lokale login-methodes uit)';
$lang['singleService_o_'] = 'Sta alle diensten toe';
$lang['register-on-auth'] = 'Geverifieerde gebruikers registreren, zelfs als zelfregistratie is uitgeschakeld in de hoofdconfiguratie';
+$lang['overwrite-groups'] = 'Overschrijf alle DokuWiki gebruikersgroepen met de groepen die geleverd worden door de provider.';
diff --git a/lang/pl/lang.php b/lang/pl/lang.php
new file mode 100644
index 0000000..903fcd7
--- /dev/null
+++ b/lang/pl/lang.php
@@ -0,0 +1,18 @@
+
+ */
+$lang['emailduplicate'] = 'Ten adres email jest już powiązany z innym użytkownikiem.';
+$lang['loginwith'] = 'Logowanie innymi serwisami:';
+$lang['authnotenabled'] = 'Konto powiązane z twoim adresem email nie ma włączonego logowania poprzez %s.
+Zaloguj się inną metodą i włącz tą metodę w swoim profilu.';
+$lang['wrongConfig'] = 'Plugin oAuth został źle skonfigurowany, możliwe jest tylko logowanie lokalnym kontem. Skontaktuj się z administratorem.';
+$lang['loginButton'] = 'Zaloguj się poprzez';
+$lang['rejectedEMail'] = 'Użyto niedozwolonego adresu email. Dozwolone są tylko adresy email z następujących domen: %s';
+$lang['eMailRestricted'] = 'Dozwolone są tylko adresy email z następujących domen: %s';
+$lang['noEmail'] = 'Serwis %s nie przekazał nam twojego adresu email. Logowanie nie powiodło się.';
+$lang['oauth login failed'] = 'Twoje (ponowne) logowanie nie powiodło się.';
+$lang['generic create error'] = 'Coś poszło nie tak podczas tworzenia twojego konta. Spróbuj ponownie później.';
diff --git a/lang/pt-br/lang.php b/lang/pt-br/lang.php
new file mode 100644
index 0000000..561c4b2
--- /dev/null
+++ b/lang/pt-br/lang.php
@@ -0,0 +1,18 @@
+
+ */
+$lang['emailduplicate'] = 'Este e-mail já está associado a outro usuário.';
+$lang['loginwith'] = 'Faça login com outros serviços:';
+$lang['authnotenabled'] = 'A conta associada ao seu endereço de e-mail não permitiu o login com %s. Faça o login por outros meios e habilite-o em seu perfil.';
+$lang['wrongConfig'] = 'O plug-in oAuth foi configurado incorretamente. Padronizando apenas para autenticação local. Entre em contato com o administrador do wiki.';
+$lang['loginButton'] = 'Entrar com';
+$lang['rejectedEMail'] = 'Conta de e-mail usada é inválida. Somente contas de e-mail do(s) seguinte(s) domínio(s) são permitidas: %s!';
+$lang['eMailRestricted'] = 'Somente contas de e-mail do(s) seguinte(s) domínio(s) são permitidas: %s';
+$lang['noEmail'] = 'O serviço %s não forneceu um endereço de e-mail. Não é possível fazer login.';
+$lang['addUser not possible'] = 'O auto-registro está atualmente desabilitado ou o arquivo conf/users.auth.php não é gravável. Por favor, peça ao administrador do DokuWiki para criar sua conta manualmente.';
+$lang['oauth login failed'] = 'O seu (re)login falhou.';
+$lang['generic create error'] = 'Algo deu errado ao criar sua conta de usuário. Por favor, tente novamente mais tarde.';
diff --git a/lang/pt-br/settings.php b/lang/pt-br/settings.php
new file mode 100644
index 0000000..bbf8424
--- /dev/null
+++ b/lang/pt-br/settings.php
@@ -0,0 +1,14 @@
+
+ */
+$lang['info'] = 'Redirecione o URI para usar ao configurar os aplicativos';
+$lang['custom-redirectURI'] = 'Use o URI de redirecionamento personalizado a seguir';
+$lang['mailRestriction'] = 'Limite a autenticação a usuários deste domínio (opcional, deve começar com um @
)';
+$lang['singleService'] = 'Faça login apenas com um único serviço oAuth (desativa os logins locais!)';
+$lang['singleService_o_'] = 'Permitir todos os serviços';
+$lang['register-on-auth'] = 'Registre usuários autenticados mesmo se o autorregistro estiver desabilitado na configuração principal';
+$lang['overwrite-groups'] = 'Substitua todos os grupos de usuários do DokuWiki por aqueles fornecidos pelo provedor';
diff --git a/lang/ru/lang.php b/lang/ru/lang.php
index 44a02f4..87c47cf 100644
--- a/lang/ru/lang.php
+++ b/lang/ru/lang.php
@@ -3,8 +3,17 @@
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
+ * @author mod
* @author NoName
*/
+$lang['emailduplicate'] = 'Этот адрес электронной почты уже связан с другим пользователем.';
$lang['loginwith'] = 'Войти через другие Сервисы';
+$lang['authnotenabled'] = 'Учетная запись, связанная с вашим адресом электронной почты, не позволяет войти в систему с помощью %s. Пожалуйста, войдите в систему другим способом и включите его в своем профиле.';
+$lang['wrongConfig'] = 'Плагин oAuth настроен неправильно. По умолчанию используется только локальная аутентификация. Пожалуйста, свяжитесь с администратором вашей вики.';
$lang['loginButton'] = 'Войти через';
-$lang['eMailRestricted'] = 'Разрешены аккаунты электронных почт только со следующих доменов: %s
';
+$lang['rejectedEMail'] = 'Использован неверный адрес электронной почты. Разрешены только учетные записи электронной почты из следующих доменов: %s!';
+$lang['eMailRestricted'] = 'Разрешены аккаунты электронных почт только со следующих доменов: %s';
+$lang['noEmail'] = 'Служба %s не предоставила адрес электронной почты. Не могу войти в систему.';
+$lang['addUser not possible'] = 'Самостоятельная регистрация в настоящее время отключена или файл conf/users.auth.php недоступен для записи. Попросите администратора «Вики» создать вашу учетную запись вручную.';
+$lang['oauth login failed'] = 'Ваш вход не удался.';
+$lang['generic create error'] = 'Что-то пошло не так при создании вашей учетной записи. Пожалуйста, повторите попытку позже.';
diff --git a/lang/ru/settings.php b/lang/ru/settings.php
index ee6397a..80f2925 100644
--- a/lang/ru/settings.php
+++ b/lang/ru/settings.php
@@ -3,16 +3,13 @@
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*
+ * @author mod
* @author NoName
*/
-$lang['auth0-key'] = 'Ваш Клиентский ID зарегестрирован как Auth0 application ';
-$lang['auth0-secret'] = 'Ваш Клиентский Секрет зарегестрирован как Auth0 application ';
-$lang['auth0-domain'] = 'Ваш домен зарегестрирован как Auth0 account ';
-$lang['github-key'] = 'Github application ';
-$lang['github-secret'] = 'Github application ';
-$lang['google-key'] = 'Google Project (see Credentials Screen)';
-$lang['google-secret'] = ' Google Project (see Credentials Screen)';
-$lang['dataporten-key'] = 'Ваш Клиентский ID зарегестрирован как Dataporten application ';
-$lang['dataporten-secret'] = 'Ваш Клиентский Секрет зарегестрирован как Dataporten application ';
+$lang['info'] = 'URI перенаправления для использования при настройке приложений';
+$lang['custom-redirectURI'] = 'Используйте следующий пользовательский URI перенаправления';
$lang['mailRestriction'] = 'Предел аутентификации пользователей этого домена (дополнителен, должен начинаться с @
)';
+$lang['singleService'] = 'Вход только с помощью одной службы oAuth (отключает локальный вход!)';
$lang['singleService_o_'] = 'Разрешить все сервисы';
+$lang['register-on-auth'] = 'Регистрируйте аутентифицированных пользователей, даже если самостоятельная регистрация отключена в основной конфигурации.';
+$lang['overwrite-groups'] = 'Перезаписать все группы пользователей «Вики» группами, предоставленными провайдером.';
diff --git a/lang/sk/lang.php b/lang/sk/lang.php
new file mode 100644
index 0000000..72d1dae
--- /dev/null
+++ b/lang/sk/lang.php
@@ -0,0 +1,18 @@
+
+ */
+
+$lang['emailduplicate'] = 'Táto e-mailová adresa je už asociovaná s iným používateľom.';
+$lang['loginwith'] = 'Prihlásiť sa pomocou iných služieb:';
+$lang['authnotenabled'] = 'Používateľský účet asociovaný s vašou e-mailovou adresou nemá povolené prihlasovanie sa pomocou %s. Prosím prihláste sa inou metódou, a vo svojom používateľskom profile povoľte prihlasovanie sa pomocou %s.';
+$lang['wrongConfig'] = 'oAuth plugin nie je správne nakonfigurovaný. Je možné prihlásiť sa len pomocou lokálneho účtu. Prosím kontaktujte administrátora stránky.';
+$lang['loginButton'] = 'Prihlásiť sa pomocou ';//... i.e. Google (on SingleAuth)
+$lang['rejectedEMail'] = 'Použitá nesprávna e-mailová adresa. Povolené sú len e-mailové adresy z nasledujúcich domén: %s!';
+$lang['eMailRestricted'] = 'Povolené sú len e-mailové adresy z nasledujcich domén: %s';
+$lang['noEmail'] = 'Služba %s nám neposkytla vašu e-mailovú adresu. Nevieme vás preto prihlásiť.';
+$lang['addUser not possible'] = 'Samoregistrácia užívateľa je momentálne zakázaná, alebo konfigurácia v conf/users.auth.php nie je zapisovateľná. Prosím požiadajte administrátora stránky, aby vám vytvoril váš účet manuálne.';
+$lang['oauth login failed'] = 'Vaše (opätovné) prihlásenie sa zlyhalo.';
+$lang['generic create error'] = 'Počas vytvárania vášho užívateľského účtu niekde nastala chyba. Prosím skúste to znova neskôr.';
diff --git a/lang/sk/settings.php b/lang/sk/settings.php
new file mode 100644
index 0000000..30af08d
--- /dev/null
+++ b/lang/sk/settings.php
@@ -0,0 +1,14 @@
+
+ */
+
+
+$lang['info'] = 'Redirect URI pre konfiguráciu aplikácií';
+$lang['custom-redirectURI'] = 'Použiť vlastné redirect URI';
+$lang['mailRestriction'] = "Obmedziť autentifikáciu na užívateľov z tejto domény (voliteľné, musí začínať s @
)";
+$lang['singleService'] = 'Povoliť prihlásenie s jedinou oAuth službou (zakáže prihlasovanie sa s lokálnymi účtami!)';
+$lang['singleService_o_'] = 'Povoliť všetky služby';
+$lang['register-on-auth'] = 'Zaregistrovať autentifikovaných používateľov aj napriek zakázanej samo-registrácii v nastaveniach zabezpečenia';
diff --git a/phpoauthlib/.gitignore b/phpoauthlib/.gitignore
deleted file mode 100644
index 186115c..0000000
--- a/phpoauthlib/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.idea
-vendor
-.DS_Store
-composer.lock
-examples/init.php
\ No newline at end of file
diff --git a/phpoauthlib/.scrutinizer.yml b/phpoauthlib/.scrutinizer.yml
deleted file mode 100644
index 5a274c9..0000000
--- a/phpoauthlib/.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/phpoauthlib/.travis.yml b/phpoauthlib/.travis.yml
deleted file mode 100644
index 2b10e57..0000000
--- a/phpoauthlib/.travis.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-language: php
-
-php:
- - 5.3
- - 5.4
- - 5.5
-
-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/phpoauthlib/examples/amazon.php b/phpoauthlib/examples/amazon.php
deleted file mode 100644
index 0798eaf..0000000
--- a/phpoauthlib/examples/amazon.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @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 "Login with Amazon! ";
-}
diff --git a/phpoauthlib/examples/bitbucket.php b/phpoauthlib/examples/bitbucket.php
deleted file mode 100644
index d933096..0000000
--- a/phpoauthlib/examples/bitbucket.php
+++ /dev/null
@@ -1,64 +0,0 @@
-
- *
- * Shamelessly cribbed from work by:
- * @author David Desberg
- * @author Pieter Hordijk
- * @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 "Login with BitBucket! ";
-}
diff --git a/phpoauthlib/examples/bitly.php b/phpoauthlib/examples/bitly.php
deleted file mode 100644
index 9cd27e3..0000000
--- a/phpoauthlib/examples/bitly.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @author Pieter Hordijk
- * @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 "Login with Bitly! ";
-}
diff --git a/phpoauthlib/examples/bootstrap.php b/phpoauthlib/examples/bootstrap.php
deleted file mode 100644
index f02da41..0000000
--- a/phpoauthlib/examples/bootstrap.php
+++ /dev/null
@@ -1,29 +0,0 @@
-createFromSuperGlobalArray($_SERVER);
-$currentUri->setQuery('');
-
-/**
- * Load the credential for the different services
- */
-require_once __DIR__ . '/init.php';
diff --git a/phpoauthlib/examples/box.php b/phpoauthlib/examples/box.php
deleted file mode 100644
index f1b0644..0000000
--- a/phpoauthlib/examples/box.php
+++ /dev/null
@@ -1,58 +0,0 @@
-
- * @author Pieter Hordijk
- * @author Antoine Corcy
- * @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 "Login with Box! ";
-}
diff --git a/phpoauthlib/examples/dailymotion.php b/phpoauthlib/examples/dailymotion.php
deleted file mode 100644
index 53f0878..0000000
--- a/phpoauthlib/examples/dailymotion.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @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 "Login with Dailymotion! ";
-}
diff --git a/phpoauthlib/examples/dropbox.php b/phpoauthlib/examples/dropbox.php
deleted file mode 100644
index 0d60551..0000000
--- a/phpoauthlib/examples/dropbox.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @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 "Login with Dropbox! ";
-}
diff --git a/phpoauthlib/examples/etsy.php b/phpoauthlib/examples/etsy.php
deleted file mode 100644
index 0c0b79b..0000000
--- a/phpoauthlib/examples/etsy.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
- * @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: ' . print_r($result, true) . ' ';
-
-} 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 "Login with Etsy! ";
-}
diff --git a/phpoauthlib/examples/facebook.php b/phpoauthlib/examples/facebook.php
deleted file mode 100644
index b642672..0000000
--- a/phpoauthlib/examples/facebook.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- * @author David Desberg
- * @author Pieter Hordijk
- * @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 "Login with Facebook! ";
-}
diff --git a/phpoauthlib/examples/fitbit.php b/phpoauthlib/examples/fitbit.php
deleted file mode 100644
index 35b3d09..0000000
--- a/phpoauthlib/examples/fitbit.php
+++ /dev/null
@@ -1,61 +0,0 @@
-
- * @author Pieter Hordijk
- * @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: ' . print_r($result, true) . ' ';
-
-} 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 "Login with FitBit! ";
-}
diff --git a/phpoauthlib/examples/flickr.php b/phpoauthlib/examples/flickr.php
deleted file mode 100644
index f7a80f6..0000000
--- a/phpoauthlib/examples/flickr.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
- * @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 "Login with Flickr! ";
- 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/phpoauthlib/examples/foursquare.php b/phpoauthlib/examples/foursquare.php
deleted file mode 100644
index f792072..0000000
--- a/phpoauthlib/examples/foursquare.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @author Pieter Hordijk
- * @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 "Login with Foursquare! ";
-}
diff --git a/phpoauthlib/examples/github.php b/phpoauthlib/examples/github.php
deleted file mode 100644
index 23e971f..0000000
--- a/phpoauthlib/examples/github.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @author Pieter Hordijk
- * @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 "Login with Github! ";
-}
diff --git a/phpoauthlib/examples/google.php b/phpoauthlib/examples/google.php
deleted file mode 100644
index f05a03e..0000000
--- a/phpoauthlib/examples/google.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @author Pieter Hordijk
- * @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 "Login with Google! ";
-}
diff --git a/phpoauthlib/examples/init.example.php b/phpoauthlib/examples/init.example.php
deleted file mode 100644
index c0653fc..0000000
--- a/phpoauthlib/examples/init.example.php
+++ /dev/null
@@ -1,128 +0,0 @@
-
- * @author Pieter Hordijk
- * @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' => '',
- ),
- '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' => '',
- ),
- 'yahoo' => array(
- 'key' => '',
- 'secret' => ''
- ),
- 'yammer' => array(
- 'key' => '',
- 'secret' => ''
- ),
-);
-
-/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
-$serviceFactory = new \OAuth\ServiceFactory();
diff --git a/phpoauthlib/examples/instagram.php b/phpoauthlib/examples/instagram.php
deleted file mode 100644
index 2e44094..0000000
--- a/phpoauthlib/examples/instagram.php
+++ /dev/null
@@ -1,56 +0,0 @@
-
- * @author Pieter Hordijk
- * @author Hannes Van De Vreken
- * @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 "Login with Instagram! ";
-}
diff --git a/phpoauthlib/examples/linkedin.php b/phpoauthlib/examples/linkedin.php
deleted file mode 100644
index db14ab2..0000000
--- a/phpoauthlib/examples/linkedin.php
+++ /dev/null
@@ -1,57 +0,0 @@
-
- * @author Pieter Hordijk
- * @author Antoine Corcy
- * @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 "Login with Linkedin! ";
-}
diff --git a/phpoauthlib/examples/mailchimp.php b/phpoauthlib/examples/mailchimp.php
deleted file mode 100644
index dd7e12b..0000000
--- a/phpoauthlib/examples/mailchimp.php
+++ /dev/null
@@ -1,55 +0,0 @@
-
- * @author Hannes Van De Vreken
- * @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 "Login with Mailchimp! ";
-}
diff --git a/phpoauthlib/examples/microsoft.php b/phpoauthlib/examples/microsoft.php
deleted file mode 100644
index 1edb13f..0000000
--- a/phpoauthlib/examples/microsoft.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
- * @author Pieter Hordijk
- * @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 "Login with Microsoft! ";
-}
diff --git a/phpoauthlib/examples/paypal.php b/phpoauthlib/examples/paypal.php
deleted file mode 100644
index 207357f..0000000
--- a/phpoauthlib/examples/paypal.php
+++ /dev/null
@@ -1,52 +0,0 @@
-
- * @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 "Login with PayPal! ";
-}
diff --git a/phpoauthlib/examples/pocket.php b/phpoauthlib/examples/pocket.php
deleted file mode 100644
index b96d2ac..0000000
--- a/phpoauthlib/examples/pocket.php
+++ /dev/null
@@ -1,63 +0,0 @@
-
- * @copyright Copyright (c) 2014 Christian Mayer
- * @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 'Login with Pocket ';
-
- 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'].' ';
- print 'Access Token: '.$accessToken;
- break;
-}
diff --git a/phpoauthlib/examples/reddit.php b/phpoauthlib/examples/reddit.php
deleted file mode 100644
index 7363d84..0000000
--- a/phpoauthlib/examples/reddit.php
+++ /dev/null
@@ -1,54 +0,0 @@
-
- * @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 "Login with Reddit! ";
-}
diff --git a/phpoauthlib/examples/runkeeper.php b/phpoauthlib/examples/runkeeper.php
deleted file mode 100644
index 61a203f..0000000
--- a/phpoauthlib/examples/runkeeper.php
+++ /dev/null
@@ -1,51 +0,0 @@
-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 "Login with RunKeeper! ";
-}
diff --git a/phpoauthlib/examples/scoopit.php b/phpoauthlib/examples/scoopit.php
deleted file mode 100644
index cc1c103..0000000
--- a/phpoauthlib/examples/scoopit.php
+++ /dev/null
@@ -1,57 +0,0 @@
-
- * @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: ' . print_r($result, true) . ' ';
-
-} 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 "Login with ScoopIt! ";
-}
diff --git a/phpoauthlib/examples/soundcloud.php b/phpoauthlib/examples/soundcloud.php
deleted file mode 100644
index 2629490..0000000
--- a/phpoauthlib/examples/soundcloud.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- * @author Pieter Hordijk
- * @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 "Login with SoundCloud! ";
-}
diff --git a/phpoauthlib/examples/tumblr.php b/phpoauthlib/examples/tumblr.php
deleted file mode 100644
index bde0521..0000000
--- a/phpoauthlib/examples/tumblr.php
+++ /dev/null
@@ -1,62 +0,0 @@
-
- * @author Pieter Hordijk
- * @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: ' . print_r($result, true) . ' ';
-
-} 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 "Login with Tumblr! ";
-}
diff --git a/phpoauthlib/examples/twitter.php b/phpoauthlib/examples/twitter.php
deleted file mode 100644
index 6b14a22..0000000
--- a/phpoauthlib/examples/twitter.php
+++ /dev/null
@@ -1,62 +0,0 @@
-
- * @author Pieter Hordijk
- * @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: ' . print_r($result, true) . ' ';
-
-} 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 "Login with Twitter! ";
-}
diff --git a/phpoauthlib/examples/yahoo.php b/phpoauthlib/examples/yahoo.php
deleted file mode 100644
index 549332e..0000000
--- a/phpoauthlib/examples/yahoo.php
+++ /dev/null
@@ -1,57 +0,0 @@
-
- * @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: ' . print_r($result, true) . ' ';
-
-} 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 "Login with Yahoo! ";
-}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidServiceConfigurationException.php b/phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidServiceConfigurationException.php
deleted file mode 100644
index 7650208..0000000
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidServiceConfigurationException.php
+++ /dev/null
@@ -1,16 +0,0 @@
-
- * Released under the MIT license.
- */
-
-namespace OAuth\OAuth2\Service\Exception;
-
-use OAuth\Common\Exception\Exception;
-
-/**
- * Exception thrown when service is not fully configured yet
- */
-class InvalidServiceConfigurationException extends Exception
-{
-}
\ No newline at end of file
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Generic.php b/phpoauthlib/src/OAuth/OAuth2/Service/Generic.php
deleted file mode 100644
index a01d466..0000000
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Generic.php
+++ /dev/null
@@ -1,107 +0,0 @@
-authorizationEndpoint)) {
- throw new InvalidServiceConfigurationException('No AuthorizationEndpoint set');
- }
- return $this->authorizationEndpoint;
- }
-
- /**
- * Set the authorization endpoint.
- *
- * has to be called before using the service
- *
- * @param $url
- */
- public function setAuthorizationEndpoint($url)
- {
- $this->authorizationEndpoint = new Uri($url);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getAccessTokenEndpoint()
- {
- if(is_null($this->accessTokenEndpoint)) {
- throw new InvalidServiceConfigurationException('No AccessTokenEndpoint set');
- }
- return $this->accessTokenEndpoint;
- }
-
- /**
- * Set the access token endpoint.
- *
- * has to be called before using the service
- *
- * @param $url
- */
- public function setAccessTokenEndpoint($url)
- {
- $this->accessTokenEndpoint = new Uri($url);
- }
-
- /**
- * {@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['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;
- }
-}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Keycloak.php b/phpoauthlib/src/OAuth/OAuth2/Service/Keycloak.php
deleted file mode 100644
index f7a041a..0000000
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Keycloak.php
+++ /dev/null
@@ -1,21 +0,0 @@
-determineRequestUriFromPath($path, $baseApiUri);
- }
-}
diff --git a/phpoauthlib/tests/Mocks/OAuth1/Service/Fake.php b/phpoauthlib/tests/Mocks/OAuth1/Service/Fake.php
deleted file mode 100644
index 5dac52e..0000000
--- a/phpoauthlib/tests/Mocks/OAuth1/Service/Fake.php
+++ /dev/null
@@ -1,57 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/AutoloaderTest.php b/phpoauthlib/tests/Unit/Common/AutoloaderTest.php
deleted file mode 100644
index eebc340..0000000
--- a/phpoauthlib/tests/Unit/Common/AutoloaderTest.php
+++ /dev/null
@@ -1,126 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Consumer/CredentialsTest.php b/phpoauthlib/tests/Unit/Common/Consumer/CredentialsTest.php
deleted file mode 100644
index 1a895fb..0000000
--- a/phpoauthlib/tests/Unit/Common/Consumer/CredentialsTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Http/Client/AbstractClientTest.php b/phpoauthlib/tests/Unit/Common/Http/Client/AbstractClientTest.php
deleted file mode 100644
index b353152..0000000
--- a/phpoauthlib/tests/Unit/Common/Http/Client/AbstractClientTest.php
+++ /dev/null
@@ -1,67 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Http/Client/CurlClientTest.php b/phpoauthlib/tests/Unit/Common/Http/Client/CurlClientTest.php
deleted file mode 100644
index e7ab5b2..0000000
--- a/phpoauthlib/tests/Unit/Common/Http/Client/CurlClientTest.php
+++ /dev/null
@@ -1,372 +0,0 @@
-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'));
-
- $client = new CurlClient();
-
- $response = $client->retrieveResponse(
- $endPoint,
- 'foo',
- array(),
- 'POST'
- );
-
- $response = json_decode($response, true);
-
- $this->assertSame('foo', $response['data']);
- }
-
- /**
- * @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'));
-
- $client = new CurlClient();
-
- $response = $client->retrieveResponse(
- $endPoint,
- 'foo',
- array(),
- 'PUT'
- );
-
- $response = json_decode($response, true);
-
- $this->assertSame('foo', $response['data']);
- }
-
- /**
- * @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'));
-
- $client = new CurlClient();
-
- $client->setMaxRedirects(0);
-
- $response = $client->retrieveResponse(
- $endPoint,
- 'foo',
- array(),
- 'PUT'
- );
-
- $response = json_decode($response, true);
-
- $this->assertSame('foo', $response['data']);
- }
-
- /**
- * @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/phpoauthlib/tests/Unit/Common/Http/Client/StreamClientTest.php b/phpoauthlib/tests/Unit/Common/Http/Client/StreamClientTest.php
deleted file mode 100644
index 6248979..0000000
--- a/phpoauthlib/tests/Unit/Common/Http/Client/StreamClientTest.php
+++ /dev/null
@@ -1,279 +0,0 @@
-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'));
-
- $client = new StreamClient();
-
- $response = $client->retrieveResponse(
- $endPoint,
- 'foo',
- array(),
- 'POST'
- );
-
- $response = json_decode($response, true);
-
- $this->assertSame('foo', $response['data']);
- }
-
- /**
- * @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'));
-
- $client = new StreamClient();
-
- $response = $client->retrieveResponse(
- $endPoint,
- 'foo',
- array(),
- 'PUT'
- );
-
- $response = json_decode($response, true);
-
- $this->assertSame('foo', $response['data']);
- }
-
- /**
- * @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/phpoauthlib/tests/Unit/Common/Http/HttpClientsTest.php b/phpoauthlib/tests/Unit/Common/Http/HttpClientsTest.php
deleted file mode 100644
index 6fa9eac..0000000
--- a/phpoauthlib/tests/Unit/Common/Http/HttpClientsTest.php
+++ /dev/null
@@ -1,171 +0,0 @@
-
- * @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/phpoauthlib/tests/Unit/Common/Http/Uri/UriFactoryTest.php b/phpoauthlib/tests/Unit/Common/Http/Uri/UriFactoryTest.php
deleted file mode 100644
index ea74350..0000000
--- a/phpoauthlib/tests/Unit/Common/Http/Uri/UriFactoryTest.php
+++ /dev/null
@@ -1,331 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Http/Uri/UriTest.php b/phpoauthlib/tests/Unit/Common/Http/Uri/UriTest.php
deleted file mode 100644
index bc158ff..0000000
--- a/phpoauthlib/tests/Unit/Common/Http/Uri/UriTest.php
+++ /dev/null
@@ -1,898 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Service/AbstractServiceTest.php b/phpoauthlib/tests/Unit/Common/Service/AbstractServiceTest.php
deleted file mode 100644
index 2d8bff4..0000000
--- a/phpoauthlib/tests/Unit/Common/Service/AbstractServiceTest.php
+++ /dev/null
@@ -1,171 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Storage/MemoryTest.php b/phpoauthlib/tests/Unit/Common/Storage/MemoryTest.php
deleted file mode 100644
index 93a01a7..0000000
--- a/phpoauthlib/tests/Unit/Common/Storage/MemoryTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Storage/RedisTest.php b/phpoauthlib/tests/Unit/Common/Storage/RedisTest.php
deleted file mode 100644
index 83e7a28..0000000
--- a/phpoauthlib/tests/Unit/Common/Storage/RedisTest.php
+++ /dev/null
@@ -1,102 +0,0 @@
-
- * @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/phpoauthlib/tests/Unit/Common/Storage/SessionTest.php b/phpoauthlib/tests/Unit/Common/Storage/SessionTest.php
deleted file mode 100644
index 72f38b1..0000000
--- a/phpoauthlib/tests/Unit/Common/Storage/SessionTest.php
+++ /dev/null
@@ -1,245 +0,0 @@
-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/phpoauthlib/tests/Unit/Common/Storage/StorageTest.php b/phpoauthlib/tests/Unit/Common/Storage/StorageTest.php
deleted file mode 100644
index 3fe1990..0000000
--- a/phpoauthlib/tests/Unit/Common/Storage/StorageTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-
- * @author Hannes Van De Vreken
- * @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/phpoauthlib/tests/Unit/Common/Storage/SymfonySessionTest.php b/phpoauthlib/tests/Unit/Common/Storage/SymfonySessionTest.php
deleted file mode 100644
index c643461..0000000
--- a/phpoauthlib/tests/Unit/Common/Storage/SymfonySessionTest.php
+++ /dev/null
@@ -1,111 +0,0 @@
-
- * @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/phpoauthlib/tests/Unit/Common/Token/AbstractTokenTest.php b/phpoauthlib/tests/Unit/Common/Token/AbstractTokenTest.php
deleted file mode 100644
index 54b3bb6..0000000
--- a/phpoauthlib/tests/Unit/Common/Token/AbstractTokenTest.php
+++ /dev/null
@@ -1,189 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/AbstractServiceTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/AbstractServiceTest.php
deleted file mode 100644
index ab5417b..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/AbstractServiceTest.php
+++ /dev/null
@@ -1,215 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/BitBucketTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/BitBucketTest.php
deleted file mode 100644
index 87be98b..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/BitBucketTest.php
+++ /dev/null
@@ -1,278 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/EtsyTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/EtsyTest.php
deleted file mode 100644
index bd015e0..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/EtsyTest.php
+++ /dev/null
@@ -1,278 +0,0 @@
-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()
- );
- }
-
- /**
- * @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/phpoauthlib/tests/Unit/OAuth1/Service/FitBitTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/FitBitTest.php
deleted file mode 100644
index a8b7ae2..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/FitBitTest.php
+++ /dev/null
@@ -1,278 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/FlickrTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/FlickrTest.php
deleted file mode 100644
index ee88f71..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/FlickrTest.php
+++ /dev/null
@@ -1,302 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/ScoopItTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/ScoopItTest.php
deleted file mode 100644
index 4ba83fa..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/ScoopItTest.php
+++ /dev/null
@@ -1,302 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/TumblrTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/TumblrTest.php
deleted file mode 100644
index f1467ad..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/TumblrTest.php
+++ /dev/null
@@ -1,278 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/TwitterTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/TwitterTest.php
deleted file mode 100644
index bb31fa2..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/TwitterTest.php
+++ /dev/null
@@ -1,307 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/XingTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/XingTest.php
deleted file mode 100644
index d3a5f4a..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/XingTest.php
+++ /dev/null
@@ -1,239 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Service/YahooTest.php b/phpoauthlib/tests/Unit/OAuth1/Service/YahooTest.php
deleted file mode 100644
index e8feb5d..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Service/YahooTest.php
+++ /dev/null
@@ -1,302 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Signature/SignatureTest.php b/phpoauthlib/tests/Unit/OAuth1/Signature/SignatureTest.php
deleted file mode 100644
index 44c731f..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Signature/SignatureTest.php
+++ /dev/null
@@ -1,325 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php b/phpoauthlib/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php
deleted file mode 100644
index 9b065b1..0000000
--- a/phpoauthlib/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php
+++ /dev/null
@@ -1,85 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/AbstractServiceTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/AbstractServiceTest.php
deleted file mode 100644
index 595db2a..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/AbstractServiceTest.php
+++ /dev/null
@@ -1,401 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/AmazonTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/AmazonTest.php
deleted file mode 100644
index f70fe40..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/AmazonTest.php
+++ /dev/null
@@ -1,207 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/BitlyTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/BitlyTest.php
deleted file mode 100644
index 9944b26..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/BitlyTest.php
+++ /dev/null
@@ -1,150 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/BoxTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/BoxTest.php
deleted file mode 100644
index b5b2a78..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/BoxTest.php
+++ /dev/null
@@ -1,207 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/DailymotionTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/DailymotionTest.php
deleted file mode 100644
index f3fbaa8..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/DailymotionTest.php
+++ /dev/null
@@ -1,230 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/DropboxTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/DropboxTest.php
deleted file mode 100644
index 8f052c6..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/DropboxTest.php
+++ /dev/null
@@ -1,231 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/FacebookTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/FacebookTest.php
deleted file mode 100644
index f2fed46..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/FacebookTest.php
+++ /dev/null
@@ -1,242 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/FoursquareTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/FoursquareTest.php
deleted file mode 100644
index 96356ec..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/FoursquareTest.php
+++ /dev/null
@@ -1,197 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/GitHubTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/GitHubTest.php
deleted file mode 100644
index edb0fee..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/GitHubTest.php
+++ /dev/null
@@ -1,220 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/GoogleTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/GoogleTest.php
deleted file mode 100644
index b55808d..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/GoogleTest.php
+++ /dev/null
@@ -1,195 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/HerokuTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/HerokuTest.php
deleted file mode 100644
index cc2c0f6..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/HerokuTest.php
+++ /dev/null
@@ -1,261 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/InstagramTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/InstagramTest.php
deleted file mode 100644
index bf9d764..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/InstagramTest.php
+++ /dev/null
@@ -1,193 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/LinkedinTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/LinkedinTest.php
deleted file mode 100644
index c7f5c76..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/LinkedinTest.php
+++ /dev/null
@@ -1,213 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/MailchimpTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/MailchimpTest.php
deleted file mode 100644
index e7f955e..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/MailchimpTest.php
+++ /dev/null
@@ -1,179 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/MicrosoftTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/MicrosoftTest.php
deleted file mode 100644
index 4001e1e..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/MicrosoftTest.php
+++ /dev/null
@@ -1,193 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/PaypalTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/PaypalTest.php
deleted file mode 100644
index 5396326..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/PaypalTest.php
+++ /dev/null
@@ -1,213 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/RedditTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/RedditTest.php
deleted file mode 100644
index e8741e6..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/RedditTest.php
+++ /dev/null
@@ -1,193 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/RunKeeperTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/RunKeeperTest.php
deleted file mode 100644
index 671bd0c..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/RunKeeperTest.php
+++ /dev/null
@@ -1,207 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/SoundCloudTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/SoundCloudTest.php
deleted file mode 100644
index ac988ba..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/SoundCloudTest.php
+++ /dev/null
@@ -1,159 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/VkontakteTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/VkontakteTest.php
deleted file mode 100644
index 7a8279b..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/VkontakteTest.php
+++ /dev/null
@@ -1,159 +0,0 @@
-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/phpoauthlib/tests/Unit/OAuth2/Service/YammerTest.php b/phpoauthlib/tests/Unit/OAuth2/Service/YammerTest.php
deleted file mode 100644
index 8644039..0000000
--- a/phpoauthlib/tests/Unit/OAuth2/Service/YammerTest.php
+++ /dev/null
@@ -1,187 +0,0 @@
-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/phpoauthlib/tests/Unit/ServiceFactoryTest.php b/phpoauthlib/tests/Unit/ServiceFactoryTest.php
deleted file mode 100644
index 26588dc..0000000
--- a/phpoauthlib/tests/Unit/ServiceFactoryTest.php
+++ /dev/null
@@ -1,311 +0,0 @@
-
- * @author Chris Heng
- * @author Pieter Hordijk
- * @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/phpoauthlib/tests/bootstrap.php b/phpoauthlib/tests/bootstrap.php
deleted file mode 100644
index 193b857..0000000
--- a/phpoauthlib/tests/bootstrap.php
+++ /dev/null
@@ -1,42 +0,0 @@
-
- * @author David Desberg
- * @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';
diff --git a/plugin.info.txt b/plugin.info.txt
index 36fb833..3006824 100644
--- a/plugin.info.txt
+++ b/plugin.info.txt
@@ -1,7 +1,7 @@
base oauth
author Andreas Gohr
email dokuwiki@cosmocode.de
-date 2020-06-04
+date 2024-11-02
name oauth plugin
desc Generic oAuth plugin to login via various services
url http://www.dokuwiki.org/plugin:oauth
diff --git a/style.less b/style.less
index e32485e..9ea16d5 100644
--- a/style.less
+++ b/style.less
@@ -1,57 +1,26 @@
-.plugin_oauth_button(@color) {
- border-top: 1px solid lighten(@color, 20%);
- border-left: 1px solid lighten(@color, 20%);
- border-right: 1px solid darken(@color, 20%);
- border-bottom: 1px solid darken(@color, 20%);
- background-color: @color;
-}
-
-#dw__login {
- .plugin_oauth {
-
- a {
- padding: 10px 20px;
- margin: 5px;
- line-height: 50px;
- background-position: 10px center;
- background-repeat: no-repeat;
- color: #fff;
- text-decoration: none;
- font-weight: bold;
- .plugin_oauth_button(#999);
- }
-
- a.plugin_oauth_Facebook {
- .plugin_oauth_button(#3b5998);
- background-image: url(images/facebook.png);
- padding-left: (20px+24px);
- }
-
- a.plugin_oauth_Auth0 {
- .plugin_oauth_button(#d0d2d3);
- background-image: url(https://cdn.auth0.com/styleguide/1.0.0/img/badge.png);
- padding-left: (20px+24px);
- background-size: 22px 24px;
- color:#5c666f;
+#dw__login .plugin_oauth div {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ gap: 0.5em;
+
+ a {
+ height: 2.5em;
+ padding: 0 0.5em;
+
+ color: #fff;
+ border: 1px outset;
+ text-decoration: none;
+ font-weight: bold;
+
+ display: flex;
+ align-items: center;
+
+ svg {
+ height: 2em;
+ width: 2em;
+ fill: #fff;
+ margin-right: 0.5em;
}
-
- a.plugin_oauth_Google {
- .plugin_oauth_button(#DC4A38);
- background-image: url(images/google.png);
- padding-left: (20px+24px);
- }
-
- a.plugin_oauth_Github {
- .plugin_oauth_button(#404041);
- background-image: url(images/github.png);
- padding-left: (20px+24px);
- }
-
- a.plugin_oauth_Yahoo {
- .plugin_oauth_button(#7B0099);
- background-image: url(images/yahoo.png);
- padding-left: (20px+24px);
- }
-
}
-}
\ No newline at end of file
+}
diff --git a/vendor/autoload.php b/vendor/autoload.php
new file mode 100644
index 0000000..8bbcff6
--- /dev/null
+++ b/vendor/autoload.php
@@ -0,0 +1,7 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Composer\Autoload\ClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->add('Symfony\Component', __DIR__.'/component');
+ * $loader->add('Symfony', __DIR__.'/framework');
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * // to enable searching the include path (eg. for PEAR packages)
+ * $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier
+ * @author Jordi Boggiano
+ * @see https://www.php-fig.org/psr/psr-0/
+ * @see https://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ /** @var ?string */
+ private $vendorDir;
+
+ // PSR-4
+ /**
+ * @var array[]
+ * @psalm-var array>
+ */
+ private $prefixLengthsPsr4 = array();
+ /**
+ * @var array[]
+ * @psalm-var array>
+ */
+ private $prefixDirsPsr4 = array();
+ /**
+ * @var array[]
+ * @psalm-var array
+ */
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ /**
+ * @var array[]
+ * @psalm-var array>
+ */
+ private $prefixesPsr0 = array();
+ /**
+ * @var array[]
+ * @psalm-var array
+ */
+ private $fallbackDirsPsr0 = array();
+
+ /** @var bool */
+ private $useIncludePath = false;
+
+ /**
+ * @var string[]
+ * @psalm-var array
+ */
+ private $classMap = array();
+
+ /** @var bool */
+ private $classMapAuthoritative = false;
+
+ /**
+ * @var bool[]
+ * @psalm-var array
+ */
+ private $missingClasses = array();
+
+ /** @var ?string */
+ private $apcuPrefix;
+
+ /**
+ * @var self[]
+ */
+ private static $registeredLoaders = array();
+
+ /**
+ * @param ?string $vendorDir
+ */
+ public function __construct($vendorDir = null)
+ {
+ $this->vendorDir = $vendorDir;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
+ }
+
+ return array();
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return array>
+ */
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return array
+ */
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return array
+ */
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ /**
+ * @return string[] Array of classname => path
+ * @psalm-var array
+ */
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param string[] $classMap Class to filename map
+ * @psalm-param array $classMap
+ *
+ * @return void
+ */
+ public function addClassMap(array $classMap)
+ {
+ if ($this->classMap) {
+ $this->classMap = array_merge($this->classMap, $classMap);
+ } else {
+ $this->classMap = $classMap;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix, either
+ * appending or prepending to the ones previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param string[]|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @return void
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ (array) $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace, either
+ * appending or prepending to the ones previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param string[]|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ (array) $paths
+ );
+ }
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+ // Register directories for a new namespace.
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix,
+ * replacing any others previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param string[]|string $paths The PSR-0 base directories
+ *
+ * @return void
+ */
+ public function set($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr0 = (array) $paths;
+ } else {
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace,
+ * replacing any others previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param string[]|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ *
+ * @return void
+ */
+ public function setPsr4($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr4 = (array) $paths;
+ } else {
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Turns on searching the include path for class files.
+ *
+ * @param bool $useIncludePath
+ *
+ * @return void
+ */
+ public function setUseIncludePath($useIncludePath)
+ {
+ $this->useIncludePath = $useIncludePath;
+ }
+
+ /**
+ * Can be used to check if the autoloader uses the include path to check
+ * for classes.
+ *
+ * @return bool
+ */
+ public function getUseIncludePath()
+ {
+ return $this->useIncludePath;
+ }
+
+ /**
+ * Turns off searching the prefix and fallback directories for classes
+ * that have not been registered with the class map.
+ *
+ * @param bool $classMapAuthoritative
+ *
+ * @return void
+ */
+ public function setClassMapAuthoritative($classMapAuthoritative)
+ {
+ $this->classMapAuthoritative = $classMapAuthoritative;
+ }
+
+ /**
+ * Should class lookup fail if not found in the current class map?
+ *
+ * @return bool
+ */
+ public function isClassMapAuthoritative()
+ {
+ return $this->classMapAuthoritative;
+ }
+
+ /**
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
+ *
+ * @param string|null $apcuPrefix
+ *
+ * @return void
+ */
+ public function setApcuPrefix($apcuPrefix)
+ {
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
+ }
+
+ /**
+ * The APCu prefix in use, or null if APCu caching is not enabled.
+ *
+ * @return string|null
+ */
+ public function getApcuPrefix()
+ {
+ return $this->apcuPrefix;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not
+ *
+ * @return void
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+
+ if (null === $this->vendorDir) {
+ return;
+ }
+
+ if ($prepend) {
+ self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
+ } else {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ self::$registeredLoaders[$this->vendorDir] = $this;
+ }
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ *
+ * @return void
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+
+ if (null !== $this->vendorDir) {
+ unset(self::$registeredLoaders[$this->vendorDir]);
+ }
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return true|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ includeFile($file);
+
+ return true;
+ }
+
+ return null;
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|false The path if found, false otherwise
+ */
+ public function findFile($class)
+ {
+ // class map lookup
+ if (isset($this->classMap[$class])) {
+ return $this->classMap[$class];
+ }
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
+ return false;
+ }
+ if (null !== $this->apcuPrefix) {
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
+ if ($hit) {
+ return $file;
+ }
+ }
+
+ $file = $this->findFileWithExtension($class, '.php');
+
+ // Search for Hack files if we are running on HHVM
+ if (false === $file && defined('HHVM_VERSION')) {
+ $file = $this->findFileWithExtension($class, '.hh');
+ }
+
+ if (null !== $this->apcuPrefix) {
+ apcu_add($this->apcuPrefix.$class, $file);
+ }
+
+ if (false === $file) {
+ // Remember that this class does not exist.
+ $this->missingClasses[$class] = true;
+ }
+
+ return $file;
+ }
+
+ /**
+ * Returns the currently registered loaders indexed by their corresponding vendor directories.
+ *
+ * @return self[]
+ */
+ public static function getRegisteredLoaders()
+ {
+ return self::$registeredLoaders;
+ }
+
+ /**
+ * @param string $class
+ * @param string $ext
+ * @return string|false
+ */
+ private function findFileWithExtension($class, $ext)
+ {
+ // PSR-4 lookup
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+ $first = $class[0];
+ if (isset($this->prefixLengthsPsr4[$first])) {
+ $subPath = $class;
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
+ $subPath = substr($subPath, 0, $lastPos);
+ $search = $subPath . '\\';
+ if (isset($this->prefixDirsPsr4[$search])) {
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ if (file_exists($file = $dir . $pathEnd)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-4 fallback dirs
+ foreach ($this->fallbackDirsPsr4 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 lookup
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+ } else {
+ // PEAR-like class name
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+ }
+
+ if (isset($this->prefixesPsr0[$first])) {
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($dirs as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-0 fallback dirs
+ foreach ($this->fallbackDirsPsr0 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 include paths.
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+ return $file;
+ }
+
+ return false;
+ }
+}
+
+/**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ *
+ * @param string $file
+ * @return void
+ * @private
+ */
+function includeFile($file)
+{
+ include $file;
+}
diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php
new file mode 100644
index 0000000..d50e0c9
--- /dev/null
+++ b/vendor/composer/InstalledVersions.php
@@ -0,0 +1,350 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer;
+
+use Composer\Autoload\ClassLoader;
+use Composer\Semver\VersionParser;
+
+/**
+ * This class is copied in every Composer installed project and available to all
+ *
+ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
+ *
+ * To require its presence, you can require `composer-runtime-api ^2.0`
+ */
+class InstalledVersions
+{
+ /**
+ * @var mixed[]|null
+ * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null
+ */
+ private static $installed;
+
+ /**
+ * @var bool|null
+ */
+ private static $canGetVendors;
+
+ /**
+ * @var array[]
+ * @psalm-var array}>
+ */
+ private static $installedByVendor = array();
+
+ /**
+ * Returns a list of all package names which are present, either by being installed, replaced or provided
+ *
+ * @return string[]
+ * @psalm-return list
+ */
+ public static function getInstalledPackages()
+ {
+ $packages = array();
+ foreach (self::getInstalled() as $installed) {
+ $packages[] = array_keys($installed['versions']);
+ }
+
+ if (1 === \count($packages)) {
+ return $packages[0];
+ }
+
+ return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
+ }
+
+ /**
+ * Returns a list of all package names with a specific type e.g. 'library'
+ *
+ * @param string $type
+ * @return string[]
+ * @psalm-return list
+ */
+ public static function getInstalledPackagesByType($type)
+ {
+ $packagesByType = array();
+
+ foreach (self::getInstalled() as $installed) {
+ foreach ($installed['versions'] as $name => $package) {
+ if (isset($package['type']) && $package['type'] === $type) {
+ $packagesByType[] = $name;
+ }
+ }
+ }
+
+ return $packagesByType;
+ }
+
+ /**
+ * Checks whether the given package is installed
+ *
+ * This also returns true if the package name is provided or replaced by another package
+ *
+ * @param string $packageName
+ * @param bool $includeDevRequirements
+ * @return bool
+ */
+ public static function isInstalled($packageName, $includeDevRequirements = true)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (isset($installed['versions'][$packageName])) {
+ return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks whether the given package satisfies a version constraint
+ *
+ * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
+ *
+ * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
+ *
+ * @param VersionParser $parser Install composer/semver to have access to this class and functionality
+ * @param string $packageName
+ * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
+ * @return bool
+ */
+ public static function satisfies(VersionParser $parser, $packageName, $constraint)
+ {
+ $constraint = $parser->parseConstraints($constraint);
+ $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
+
+ return $provided->matches($constraint);
+ }
+
+ /**
+ * Returns a version constraint representing all the range(s) which are installed for a given package
+ *
+ * It is easier to use this via isInstalled() with the $constraint argument if you need to check
+ * whether a given version of a package is installed, and not just whether it exists
+ *
+ * @param string $packageName
+ * @return string Version constraint usable with composer/semver
+ */
+ public static function getVersionRanges($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ $ranges = array();
+ if (isset($installed['versions'][$packageName]['pretty_version'])) {
+ $ranges[] = $installed['versions'][$packageName]['pretty_version'];
+ }
+ if (array_key_exists('aliases', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
+ }
+ if (array_key_exists('replaced', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
+ }
+ if (array_key_exists('provided', $installed['versions'][$packageName])) {
+ $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
+ }
+
+ return implode(' || ', $ranges);
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+ */
+ public static function getVersion($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['version'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['version'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
+ */
+ public static function getPrettyVersion($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['pretty_version'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['pretty_version'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
+ */
+ public static function getReference($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ if (!isset($installed['versions'][$packageName]['reference'])) {
+ return null;
+ }
+
+ return $installed['versions'][$packageName]['reference'];
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @param string $packageName
+ * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
+ */
+ public static function getInstallPath($packageName)
+ {
+ foreach (self::getInstalled() as $installed) {
+ if (!isset($installed['versions'][$packageName])) {
+ continue;
+ }
+
+ return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
+ }
+
+ throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
+ }
+
+ /**
+ * @return array
+ * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
+ */
+ public static function getRootPackage()
+ {
+ $installed = self::getInstalled();
+
+ return $installed[0]['root'];
+ }
+
+ /**
+ * Returns the raw installed.php data for custom implementations
+ *
+ * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
+ * @return array[]
+ * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}
+ */
+ public static function getRawData()
+ {
+ @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
+
+ if (null === self::$installed) {
+ // only require the installed.php file if this file is loaded from its dumped location,
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+ if (substr(__DIR__, -8, 1) !== 'C') {
+ self::$installed = include __DIR__ . '/installed.php';
+ } else {
+ self::$installed = array();
+ }
+ }
+
+ return self::$installed;
+ }
+
+ /**
+ * Returns the raw data of all installed.php which are currently loaded for custom implementations
+ *
+ * @return array[]
+ * @psalm-return list}>
+ */
+ public static function getAllRawData()
+ {
+ return self::getInstalled();
+ }
+
+ /**
+ * Lets you reload the static array from another file
+ *
+ * This is only useful for complex integrations in which a project needs to use
+ * this class but then also needs to execute another project's autoloader in process,
+ * and wants to ensure both projects have access to their version of installed.php.
+ *
+ * A typical case would be PHPUnit, where it would need to make sure it reads all
+ * the data it needs from this class, then call reload() with
+ * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
+ * the project in which it runs can then also use this class safely, without
+ * interference between PHPUnit's dependencies and the project's dependencies.
+ *
+ * @param array[] $data A vendor/composer/installed.php data set
+ * @return void
+ *
+ * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data
+ */
+ public static function reload($data)
+ {
+ self::$installed = $data;
+ self::$installedByVendor = array();
+ }
+
+ /**
+ * @return array[]
+ * @psalm-return list}>
+ */
+ private static function getInstalled()
+ {
+ if (null === self::$canGetVendors) {
+ self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
+ }
+
+ $installed = array();
+
+ if (self::$canGetVendors) {
+ foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
+ if (isset(self::$installedByVendor[$vendorDir])) {
+ $installed[] = self::$installedByVendor[$vendorDir];
+ } elseif (is_file($vendorDir.'/composer/installed.php')) {
+ $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
+ if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
+ self::$installed = $installed[count($installed) - 1];
+ }
+ }
+ }
+ }
+
+ if (null === self::$installed) {
+ // only require the installed.php file if this file is loaded from its dumped location,
+ // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
+ if (substr(__DIR__, -8, 1) !== 'C') {
+ self::$installed = require __DIR__ . '/installed.php';
+ } else {
+ self::$installed = array();
+ }
+ }
+ $installed[] = self::$installed;
+
+ return $installed;
+ }
+}
diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE
new file mode 100644
index 0000000..f27399a
--- /dev/null
+++ b/vendor/composer/LICENSE
@@ -0,0 +1,21 @@
+
+Copyright (c) Nils Adermann, Jordi Boggiano
+
+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/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
new file mode 100644
index 0000000..b26f1b1
--- /dev/null
+++ b/vendor/composer/autoload_classmap.php
@@ -0,0 +1,10 @@
+ $vendorDir . '/composer/InstalledVersions.php',
+);
diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php
new file mode 100644
index 0000000..95c4f01
--- /dev/null
+++ b/vendor/composer/autoload_namespaces.php
@@ -0,0 +1,11 @@
+ array($vendorDir . '/lusitanian/oauth/tests'),
+ 'OAuth' => array($vendorDir . '/lusitanian/oauth/src'),
+);
diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php
new file mode 100644
index 0000000..b265c64
--- /dev/null
+++ b/vendor/composer/autoload_psr4.php
@@ -0,0 +1,9 @@
+= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
+ if ($useStaticLoader) {
+ require __DIR__ . '/autoload_static.php';
+
+ call_user_func(\Composer\Autoload\ComposerStaticInitbf9d17ae7594f4d8d4505e1a2286056d::getInitializer($loader));
+ } else {
+ $map = require __DIR__ . '/autoload_namespaces.php';
+ foreach ($map as $namespace => $path) {
+ $loader->set($namespace, $path);
+ }
+
+ $map = require __DIR__ . '/autoload_psr4.php';
+ foreach ($map as $namespace => $path) {
+ $loader->setPsr4($namespace, $path);
+ }
+
+ $classMap = require __DIR__ . '/autoload_classmap.php';
+ if ($classMap) {
+ $loader->addClassMap($classMap);
+ }
+ }
+
+ $loader->register(true);
+
+ return $loader;
+ }
+}
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
new file mode 100644
index 0000000..bbfeb3c
--- /dev/null
+++ b/vendor/composer/autoload_static.php
@@ -0,0 +1,35 @@
+
+ array (
+ 'OAuth\\Unit' =>
+ array (
+ 0 => __DIR__ . '/..' . '/lusitanian/oauth/tests',
+ ),
+ 'OAuth' =>
+ array (
+ 0 => __DIR__ . '/..' . '/lusitanian/oauth/src',
+ ),
+ ),
+ );
+
+ public static $classMap = array (
+ 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
+ );
+
+ public static function getInitializer(ClassLoader $loader)
+ {
+ return \Closure::bind(function () use ($loader) {
+ $loader->prefixesPsr0 = ComposerStaticInitbf9d17ae7594f4d8d4505e1a2286056d::$prefixesPsr0;
+ $loader->classMap = ComposerStaticInitbf9d17ae7594f4d8d4505e1a2286056d::$classMap;
+
+ }, null, ClassLoader::class);
+ }
+}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
new file mode 100644
index 0000000..e1c4e46
--- /dev/null
+++ b/vendor/composer/installed.json
@@ -0,0 +1,76 @@
+{
+ "packages": [
+ {
+ "name": "lusitanian/oauth",
+ "version": "v0.8.11",
+ "version_normalized": "0.8.11.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Lusitanian/PHPoAuthLib.git",
+ "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Lusitanian/PHPoAuthLib/zipball/fc11a53db4b66da555a6a11fce294f574a8374f9",
+ "reference": "fc11a53db4b66da555a6a11fce294f574a8374f9",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.7.*",
+ "predis/predis": "0.8.*@dev",
+ "squizlabs/php_codesniffer": "2.*",
+ "symfony/http-foundation": "~2.1"
+ },
+ "suggest": {
+ "ext-openssl": "Allows for usage of secure connections with the stream-based HTTP client.",
+ "predis/predis": "Allows using the Redis storage backend.",
+ "symfony/http-foundation": "Allows using the Symfony Session storage backend."
+ },
+ "time": "2018-02-14T22:37:14+00:00",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.1-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "OAuth": "src",
+ "OAuth\\Unit": "tests"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "David Desberg",
+ "email": "david@daviddesberg.com"
+ },
+ {
+ "name": "Elliot Chance",
+ "email": "elliotchance@gmail.com"
+ },
+ {
+ "name": "Pieter Hordijk",
+ "email": "info@pieterhordijk.com"
+ }
+ ],
+ "description": "PHP 5.3+ oAuth 1/2 Library",
+ "keywords": [
+ "Authentication",
+ "authorization",
+ "oauth",
+ "security"
+ ],
+ "install-path": "../lusitanian/oauth"
+ }
+ ],
+ "dev": true,
+ "dev-package-names": []
+}
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
new file mode 100644
index 0000000..e102218
--- /dev/null
+++ b/vendor/composer/installed.php
@@ -0,0 +1,32 @@
+ array(
+ 'pretty_version' => 'dev-master',
+ 'version' => 'dev-master',
+ 'type' => 'project',
+ 'install_path' => __DIR__ . '/../../',
+ 'aliases' => array(),
+ 'reference' => 'd9be1cb5d4b89892fd7351309c9c9722836436f4',
+ 'name' => 'cosmocode/dokuwiki-plugin-oauth',
+ 'dev' => true,
+ ),
+ 'versions' => array(
+ 'cosmocode/dokuwiki-plugin-oauth' => array(
+ 'pretty_version' => 'dev-master',
+ 'version' => 'dev-master',
+ 'type' => 'project',
+ 'install_path' => __DIR__ . '/../../',
+ 'aliases' => array(),
+ 'reference' => 'd9be1cb5d4b89892fd7351309c9c9722836436f4',
+ 'dev_requirement' => false,
+ ),
+ 'lusitanian/oauth' => array(
+ 'pretty_version' => 'v0.8.11',
+ 'version' => '0.8.11.0',
+ 'type' => 'library',
+ 'install_path' => __DIR__ . '/../lusitanian/oauth',
+ 'aliases' => array(),
+ 'reference' => 'fc11a53db4b66da555a6a11fce294f574a8374f9',
+ 'dev_requirement' => false,
+ ),
+ ),
+);
diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php
new file mode 100644
index 0000000..7621d4f
--- /dev/null
+++ b/vendor/composer/platform_check.php
@@ -0,0 +1,26 @@
+= 50300)) {
+ $issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.0". You are running ' . PHP_VERSION . '.';
+}
+
+if ($issues) {
+ if (!headers_sent()) {
+ header('HTTP/1.1 500 Internal Server Error');
+ }
+ if (!ini_get('display_errors')) {
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
+ fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
+ } elseif (!headers_sent()) {
+ echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
+ }
+ }
+ trigger_error(
+ 'Composer detected issues in your platform: ' . implode(' ', $issues),
+ E_USER_ERROR
+ );
+}
diff --git a/phpoauthlib/LICENSE b/vendor/lusitanian/oauth/LICENSE
similarity index 100%
rename from phpoauthlib/LICENSE
rename to vendor/lusitanian/oauth/LICENSE
diff --git a/phpoauthlib/README.md b/vendor/lusitanian/oauth/README.md
similarity index 81%
rename from phpoauthlib/README.md
rename to vendor/lusitanian/oauth/README.md
index 0ae078d..2eebab7 100644
--- a/phpoauthlib/README.md
+++ b/vendor/lusitanian/oauth/README.md
@@ -1,5 +1,7 @@
PHPoAuthLib
===========
+**NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to it. However, I'm still going to keep trying to pay attention to PRs, etc.**
+
PHPoAuthLib provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client.
[](https://travis-ci.org/Lusitanian/PHPoAuthLib)
@@ -40,15 +42,17 @@ Features
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.
+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
+ - 500px
- BitBucket
- Etsy
- FitBit
- Flickr
+ - QuickBooks
- Scoop.it!
- Tumblr
- Twitter
@@ -57,25 +61,44 @@ Included service implementations
- OAuth2
- Amazon
- BitLy
+ - Bitrix24
- Box
+ - Buffer
- Dailymotion
+ - Delicious
+ - Deezer
+ - DeviantArt
- Dropbox
+ - Eve Online
- Facebook
- Foursquare
- GitHub
- Google
- Harvest
- Heroku
+ - Hubic
- Instagram
+ - Jawbone UP
- LinkedIn
- Mailchimp
- Microsoft
+ - Mondo
+ - Nest
+ - Netatmo
+ - Parrot Flower Power
- PayPal
+ - Pinterest
- Pocket
- Reddit
- RunKeeper
+ - Salesforce
- SoundCloud
+ - Spotify
+ - Strava
+ - Ustream
+ - Vimeo
- Vkontakte
+ - Yahoo
- Yammer
- more to come!
@@ -91,6 +114,8 @@ 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.
+* Laravel 5: Valentin Ivaşcu ported Dariusz Prząda's Laravel 4 library to [Laravel 5](https://github.com/oriceon/oauth-5-laravel).
+* Symfony: Alexander Pinnecke has written [a Symfony Bundle](https://github.com/apinnecke/OAuthBundle) for the library.
Extensions
----------
diff --git a/phpoauthlib/composer.json b/vendor/lusitanian/oauth/composer.json
similarity index 85%
rename from phpoauthlib/composer.json
rename to vendor/lusitanian/oauth/composer.json
index cc0bdcf..66fc46a 100644
--- a/phpoauthlib/composer.json
+++ b/vendor/lusitanian/oauth/composer.json
@@ -11,6 +11,10 @@
{
"name": "Pieter Hordijk",
"email": "info@pieterhordijk.com"
+ },
+ {
+ "name": "Elliot Chance",
+ "email": "elliotchance@gmail.com"
}
],
"require": {
@@ -19,7 +23,8 @@
"require-dev": {
"symfony/http-foundation": "~2.1",
"predis/predis": "0.8.*@dev",
- "phpunit/phpunit": "3.7.*"
+ "phpunit/phpunit": "3.7.*",
+ "squizlabs/php_codesniffer": "2.*"
},
"suggest": {
"symfony/http-foundation": "Allows using the Symfony Session storage backend.",
diff --git a/vendor/lusitanian/oauth/composer.lock b/vendor/lusitanian/oauth/composer.lock
new file mode 100644
index 0000000..42ceafe
--- /dev/null
+++ b/vendor/lusitanian/oauth/composer.lock
@@ -0,0 +1,610 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "This file is @generated automatically"
+ ],
+ "hash": "734ee27aca2b4b8a33857520f518ef0c",
+ "packages": [],
+ "packages-dev": [
+ {
+ "name": "phpunit/php-code-coverage",
+ "version": "1.2.18",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
+ "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
+ "reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "phpunit/php-file-iterator": ">=1.3.0@stable",
+ "phpunit/php-text-template": ">=1.2.0@stable",
+ "phpunit/php-token-stream": ">=1.1.3,<1.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "3.7.*@dev"
+ },
+ "suggest": {
+ "ext-dom": "*",
+ "ext-xdebug": ">=2.0.5"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "PHP/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
+ "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
+ "keywords": [
+ "coverage",
+ "testing",
+ "xunit"
+ ],
+ "time": "2014-09-02 10:13:14"
+ },
+ {
+ "name": "phpunit/php-file-iterator",
+ "version": "1.4.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
+ "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
+ "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.4.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "FilterIterator implementation that filters files based on a list of suffixes.",
+ "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
+ "keywords": [
+ "filesystem",
+ "iterator"
+ ],
+ "time": "2015-06-21 13:08:43"
+ },
+ {
+ "name": "phpunit/php-text-template",
+ "version": "1.2.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-text-template.git",
+ "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
+ "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Simple template engine.",
+ "homepage": "https://github.com/sebastianbergmann/php-text-template/",
+ "keywords": [
+ "template"
+ ],
+ "time": "2015-06-21 13:50:34"
+ },
+ {
+ "name": "phpunit/php-timer",
+ "version": "1.0.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-timer.git",
+ "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
+ "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Utility class for timing",
+ "homepage": "https://github.com/sebastianbergmann/php-timer/",
+ "keywords": [
+ "timer"
+ ],
+ "time": "2015-06-21 08:01:12"
+ },
+ {
+ "name": "phpunit/php-token-stream",
+ "version": "1.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/php-token-stream.git",
+ "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
+ "reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "php": ">=5.3.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.2-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "PHP/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Wrapper around PHP's tokenizer extension.",
+ "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
+ "keywords": [
+ "tokenizer"
+ ],
+ "time": "2014-03-03 05:10:30"
+ },
+ {
+ "name": "phpunit/phpunit",
+ "version": "3.7.38",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/phpunit.git",
+ "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6",
+ "reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6",
+ "shasum": ""
+ },
+ "require": {
+ "ext-ctype": "*",
+ "ext-dom": "*",
+ "ext-json": "*",
+ "ext-pcre": "*",
+ "ext-reflection": "*",
+ "ext-spl": "*",
+ "php": ">=5.3.3",
+ "phpunit/php-code-coverage": "~1.2",
+ "phpunit/php-file-iterator": "~1.3",
+ "phpunit/php-text-template": "~1.1",
+ "phpunit/php-timer": "~1.0",
+ "phpunit/phpunit-mock-objects": "~1.2",
+ "symfony/yaml": "~2.0"
+ },
+ "require-dev": {
+ "pear-pear.php.net/pear": "1.9.4"
+ },
+ "suggest": {
+ "phpunit/php-invoker": "~1.1"
+ },
+ "bin": [
+ "composer/bin/phpunit"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.7.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "PHPUnit/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ "",
+ "../../symfony/yaml/"
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sebastian@phpunit.de",
+ "role": "lead"
+ }
+ ],
+ "description": "The PHP Unit Testing framework.",
+ "homepage": "http://www.phpunit.de/",
+ "keywords": [
+ "phpunit",
+ "testing",
+ "xunit"
+ ],
+ "time": "2014-10-17 09:04:17"
+ },
+ {
+ "name": "phpunit/phpunit-mock-objects",
+ "version": "1.2.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
+ "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875",
+ "reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "phpunit/php-text-template": ">=1.1.1@stable"
+ },
+ "suggest": {
+ "ext-soap": "*"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "PHPUnit/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "include-path": [
+ ""
+ ],
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Sebastian Bergmann",
+ "email": "sb@sebastian-bergmann.de",
+ "role": "lead"
+ }
+ ],
+ "description": "Mock Object library for PHPUnit",
+ "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
+ "keywords": [
+ "mock",
+ "xunit"
+ ],
+ "time": "2013-01-13 10:24:48"
+ },
+ {
+ "name": "predis/predis",
+ "version": "0.8.x-dev",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nrk/predis.git",
+ "reference": "192dfd61e54c3d32c9526bba03365fff818e17e4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nrk/predis/zipball/192dfd61e54c3d32c9526bba03365fff818e17e4",
+ "reference": "192dfd61e54c3d32c9526bba03365fff818e17e4",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0"
+ },
+ "suggest": {
+ "ext-curl": "Allows access to Webdis when paired with phpiredis",
+ "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Predis": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Daniele Alessandri",
+ "email": "suppakilla@gmail.com",
+ "homepage": "http://clorophilla.net"
+ }
+ ],
+ "description": "Flexible and feature-complete PHP client library for Redis",
+ "homepage": "http://github.com/nrk/predis",
+ "keywords": [
+ "nosql",
+ "predis",
+ "redis"
+ ],
+ "time": "2015-07-07 17:11:00"
+ },
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "2.3.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+ "reference": "11a2545c44a5915f883e2e5ec12e14ed345e3ab2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/11a2545c44a5915f883e2e5ec12e14ed345e3ab2",
+ "reference": "11a2545c44a5915f883e2e5ec12e14ed345e3ab2",
+ "shasum": ""
+ },
+ "require": {
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=5.1.2"
+ },
+ "bin": [
+ "scripts/phpcs",
+ "scripts/phpcbf"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "classmap": [
+ "CodeSniffer.php",
+ "CodeSniffer/CLI.php",
+ "CodeSniffer/Exception.php",
+ "CodeSniffer/File.php",
+ "CodeSniffer/Fixer.php",
+ "CodeSniffer/Report.php",
+ "CodeSniffer/Reporting.php",
+ "CodeSniffer/Sniff.php",
+ "CodeSniffer/Tokens.php",
+ "CodeSniffer/Reports/",
+ "CodeSniffer/Tokenizers/",
+ "CodeSniffer/DocGenerators/",
+ "CodeSniffer/Standards/AbstractPatternSniff.php",
+ "CodeSniffer/Standards/AbstractScopeSniff.php",
+ "CodeSniffer/Standards/AbstractVariableSniff.php",
+ "CodeSniffer/Standards/IncorrectPatternException.php",
+ "CodeSniffer/Standards/Generic/Sniffs/",
+ "CodeSniffer/Standards/MySource/Sniffs/",
+ "CodeSniffer/Standards/PEAR/Sniffs/",
+ "CodeSniffer/Standards/PSR1/Sniffs/",
+ "CodeSniffer/Standards/PSR2/Sniffs/",
+ "CodeSniffer/Standards/Squiz/Sniffs/",
+ "CodeSniffer/Standards/Zend/Sniffs/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "lead"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "homepage": "http://www.squizlabs.com/php-codesniffer",
+ "keywords": [
+ "phpcs",
+ "standards"
+ ],
+ "time": "2015-09-09 00:18:50"
+ },
+ {
+ "name": "symfony/http-foundation",
+ "version": "v2.7.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/HttpFoundation.git",
+ "reference": "7253c2041652353e71560bbd300d6256d170ddaf"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/7253c2041652353e71560bbd300d6256d170ddaf",
+ "reference": "7253c2041652353e71560bbd300d6256d170ddaf",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "require-dev": {
+ "symfony/expression-language": "~2.4",
+ "symfony/phpunit-bridge": "~2.7"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\HttpFoundation\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony HttpFoundation Component",
+ "homepage": "https://symfony.com",
+ "time": "2015-08-27 06:45:45"
+ },
+ {
+ "name": "symfony/yaml",
+ "version": "v2.7.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Yaml.git",
+ "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661",
+ "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "~2.7"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.7-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Yaml\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Yaml Component",
+ "homepage": "https://symfony.com",
+ "time": "2015-08-24 07:13:45"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": {
+ "predis/predis": 20
+ },
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "php": ">=5.3.0"
+ },
+ "platform-dev": []
+}
diff --git a/phpoauthlib/phpunit.xml.dist b/vendor/lusitanian/oauth/phpunit.xml.dist
similarity index 100%
rename from phpoauthlib/phpunit.xml.dist
rename to vendor/lusitanian/oauth/phpunit.xml.dist
diff --git a/phpoauthlib/src/OAuth/Common/AutoLoader.php b/vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/AutoLoader.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/AutoLoader.php
diff --git a/phpoauthlib/src/OAuth/Common/Consumer/Credentials.php b/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Consumer/Credentials.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Consumer/Credentials.php
diff --git a/phpoauthlib/src/OAuth/Common/Consumer/CredentialsInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Consumer/CredentialsInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Consumer/CredentialsInterface.php
diff --git a/phpoauthlib/src/OAuth/Common/Exception/Exception.php b/vendor/lusitanian/oauth/src/OAuth/Common/Exception/Exception.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Exception/Exception.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Exception/Exception.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Client/AbstractClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/AbstractClient.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Client/AbstractClient.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/AbstractClient.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Client/ClientInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Client/ClientInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/ClientInterface.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Client/CurlClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/CurlClient.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Client/CurlClient.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/CurlClient.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Client/StreamClient.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php
similarity index 92%
rename from phpoauthlib/src/OAuth/Common/Http/Client/StreamClient.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php
index 7f3c524..d81fee8 100644
--- a/phpoauthlib/src/OAuth/Common/Http/Client/StreamClient.php
+++ b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Client/StreamClient.php
@@ -65,7 +65,10 @@ public function retrieveResponse(
if (false === $response) {
$lastError = error_get_last();
if (is_null($lastError)) {
- throw new TokenResponseException('Failed to request resource.');
+ throw new TokenResponseException(
+ 'Failed to request resource. HTTP Code: ' .
+ ((isset($http_response_header[0]))?$http_response_header[0]:'No response')
+ );
}
throw new TokenResponseException($lastError['message']);
}
diff --git a/phpoauthlib/src/OAuth/Common/Http/Exception/TokenResponseException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Exception/TokenResponseException.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Exception/TokenResponseException.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Uri/Uri.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/Uri.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Uri/Uri.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/Uri.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Uri/UriFactory.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Uri/UriFactory.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactory.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Uri/UriFactoryInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Uri/UriFactoryInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriFactoryInterface.php
diff --git a/phpoauthlib/src/OAuth/Common/Http/Uri/UriInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Http/Uri/UriInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Http/Uri/UriInterface.php
diff --git a/phpoauthlib/src/OAuth/Common/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/Common/Service/AbstractService.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Service/AbstractService.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Service/AbstractService.php
diff --git a/phpoauthlib/src/OAuth/Common/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Service/ServiceInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Service/ServiceInterface.php
diff --git a/phpoauthlib/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/AuthorizationStateNotFoundException.php
diff --git a/phpoauthlib/src/OAuth/Common/Storage/Exception/StorageException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/StorageException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Storage/Exception/StorageException.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/StorageException.php
diff --git a/phpoauthlib/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/Exception/TokenNotFoundException.php
diff --git a/phpoauthlib/src/OAuth/Common/Storage/Memory.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Memory.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Storage/Memory.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/Memory.php
diff --git a/phpoauthlib/src/OAuth/Common/Storage/Redis.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php
similarity index 98%
rename from phpoauthlib/src/OAuth/Common/Storage/Redis.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php
index 77318bd..5d3d9ae 100644
--- a/phpoauthlib/src/OAuth/Common/Storage/Redis.php
+++ b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Redis.php
@@ -145,7 +145,7 @@ public function retrieveAuthorizationState($service)
$val = $this->redis->hget($this->stateKey, $service);
- return $this->cachedStates[$service] = unserialize($val);
+ return $this->cachedStates[$service] = $val;
}
/**
diff --git a/phpoauthlib/src/OAuth/Common/Storage/Session.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php
similarity index 87%
rename from phpoauthlib/src/OAuth/Common/Storage/Session.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php
index e908a67..dd9aba7 100644
--- a/phpoauthlib/src/OAuth/Common/Storage/Session.php
+++ b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/Session.php
@@ -33,10 +33,10 @@ class Session implements TokenStorageInterface
*/
public function __construct(
$startSession = true,
- $sessionVariableName = 'lusitanian_oauth_token',
- $stateVariableName = 'lusitanian_oauth_state'
+ $sessionVariableName = 'lusitanian-oauth-token',
+ $stateVariableName = 'lusitanian-oauth-state'
) {
- if ($startSession && !isset($_SESSION)) {
+ if ($startSession && !$this->sessionHasStarted()) {
session_start();
}
@@ -185,4 +185,20 @@ public function __destruct()
session_write_close();
}
}
+
+ /**
+ * Determine if the session has started.
+ * @url http://stackoverflow.com/a/18542272/1470961
+ * @return bool
+ */
+ protected function sessionHasStarted()
+ {
+ // For more modern PHP versions we use a more reliable method.
+ if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
+ return session_status() != PHP_SESSION_NONE;
+ }
+
+ // Below PHP 5.4 we should test for the current session ID.
+ return session_id() !== '';
+ }
}
diff --git a/phpoauthlib/src/OAuth/Common/Storage/SymfonySession.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Storage/SymfonySession.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/SymfonySession.php
diff --git a/phpoauthlib/src/OAuth/Common/Storage/TokenStorageInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Storage/TokenStorageInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Storage/TokenStorageInterface.php
diff --git a/phpoauthlib/src/OAuth/Common/Token/AbstractToken.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/AbstractToken.php
similarity index 91%
rename from phpoauthlib/src/OAuth/Common/Token/AbstractToken.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Token/AbstractToken.php
index 8d448a1..7a36247 100644
--- a/phpoauthlib/src/OAuth/Common/Token/AbstractToken.php
+++ b/vendor/lusitanian/oauth/src/OAuth/Common/Token/AbstractToken.php
@@ -118,4 +118,11 @@ 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/phpoauthlib/src/OAuth/Common/Token/Exception/ExpiredTokenException.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Token/Exception/ExpiredTokenException.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Token/Exception/ExpiredTokenException.php
diff --git a/phpoauthlib/src/OAuth/Common/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/Common/Token/TokenInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/Common/Token/TokenInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/Common/Token/TokenInterface.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
similarity index 90%
rename from phpoauthlib/src/OAuth/OAuth1/Service/AbstractService.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
index 43c9c9f..64e1463 100644
--- a/phpoauthlib/src/OAuth/OAuth1/Service/AbstractService.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php
@@ -105,6 +105,15 @@ public function requestAccessToken($token, $verifier, $tokenSecret = null)
return $token;
}
+ /**
+ * Refreshes an OAuth1 access token
+ * @param TokenInterface $token
+ * @return TokenInterface $token
+ */
+ public function refreshAccessToken(TokenInterface $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.
@@ -197,19 +206,25 @@ protected function buildAuthorizationHeaderForAPIRequest(
$bodyParams = null
) {
$this->signature->setTokenSecret($token->getAccessTokenSecret());
- $parameters = $this->getBasicAuthorizationHeaderInfo();
- if (isset($parameters['oauth_callback'])) {
- unset($parameters['oauth_callback']);
+ $authParameters = $this->getBasicAuthorizationHeaderInfo();
+ if (isset($authParameters['oauth_callback'])) {
+ unset($authParameters['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);
+ $authParameters = array_merge($authParameters, array('oauth_token' => $token->getAccessToken()));
+
+ $signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters;
+ $authParameters['oauth_signature'] = $this->signature->getSignature($uri, $signatureParams, $method);
+
+ if (is_array($bodyParams) && isset($bodyParams['oauth_session_handle'])) {
+ $authParameters['oauth_session_handle'] = $bodyParams['oauth_session_handle'];
+ unset($bodyParams['oauth_session_handle']);
+ }
$authorizationHeader = 'OAuth ';
$delimiter = '';
- foreach ($parameters as $key => $value) {
+ foreach ($authParameters as $key => $value) {
$authorizationHeader .= $delimiter . rawurlencode($key) . '="' . rawurlencode($value) . '"';
$delimiter = ', ';
}
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/BitBucket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Service/BitBucket.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/BitBucket.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/Etsy.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
similarity index 77%
rename from phpoauthlib/src/OAuth/OAuth1/Service/Etsy.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
index 884358e..30dc331 100644
--- a/phpoauthlib/src/OAuth/OAuth1/Service/Etsy.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Etsy.php
@@ -13,6 +13,9 @@
class Etsy extends AbstractService
{
+
+ protected $scopes = array();
+
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
@@ -32,7 +35,14 @@ public function __construct(
*/
public function getRequestTokenEndpoint()
{
- return new Uri($this->baseApiUri . 'oauth/request_token');
+ $uri = new Uri($this->baseApiUri . 'oauth/request_token');
+ $scopes = $this->getScopes();
+
+ if (count($scopes)) {
+ $uri->setQuery('scope=' . implode('%20', $scopes));
+ }
+
+ return $uri;
}
/**
@@ -93,4 +103,30 @@ protected function parseAccessTokenResponse($responseBody)
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/phpoauthlib/src/OAuth/OAuth1/Service/FitBit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Service/FitBit.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FitBit.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php
new file mode 100644
index 0000000..ea7f9b3
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/FiveHundredPx.php
@@ -0,0 +1,120 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developers.500px.com/
+ */
+
+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;
+
+/**
+ * 500px service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developers.500px.com/
+ */
+class FiveHundredPx 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.500px.com/v1/');
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getRequestTokenEndpoint()
+ {
+ return new Uri('https://api.500px.com/v1/oauth/request_token');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://api.500px.com/v1/oauth/authorize');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://api.500px.com/v1/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/phpoauthlib/src/OAuth/OAuth1/Service/Flickr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
similarity index 72%
rename from phpoauthlib/src/OAuth/OAuth1/Service/Flickr.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
index f06d282..7ceee7d 100644
--- a/phpoauthlib/src/OAuth/OAuth1/Service/Flickr.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Flickr.php
@@ -13,7 +13,8 @@
class Flickr extends AbstractService
{
-
+ protected $format;
+
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
@@ -26,22 +27,22 @@ public function __construct(
$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);
@@ -52,7 +53,7 @@ protected function parseRequestTokenResponse($responseBody)
}
return $this->parseAccessTokenResponse($responseBody);
}
-
+
protected function parseAccessTokenResponse($responseBody)
{
parse_str($responseBody, $data);
@@ -61,7 +62,7 @@ protected function parseAccessTokenResponse($responseBody)
} 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']);
@@ -70,22 +71,63 @@ protected function parseAccessTokenResponse($responseBody)
$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);
-
+
+ if (!empty($this->format)) {
+ $uri->addToQuery('format', $this->format);
+
+ if ($this->format === 'json') {
+ $uri->addToQuery('nojsoncallback', 1);
+ }
+ }
+
$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);
}
+
+ public function requestRest($path, $method = 'GET', $body = null, array $extraHeaders = array())
+ {
+ return $this->request($path, $method, $body, $extraHeaders);
+ }
+
+ public function requestXmlrpc($path, $method = 'GET', $body = null, array $extraHeaders = array())
+ {
+ $this->format = 'xmlrpc';
+
+ return $this->request($path, $method, $body, $extraHeaders);
+ }
+
+ public function requestSoap($path, $method = 'GET', $body = null, array $extraHeaders = array())
+ {
+ $this->format = 'soap';
+
+ return $this->request($path, $method, $body, $extraHeaders);
+ }
+
+ public function requestJson($path, $method = 'GET', $body = null, array $extraHeaders = array())
+ {
+ $this->format = 'json';
+
+ return $this->request($path, $method, $body, $extraHeaders);
+ }
+
+ public function requestPhp($path, $method = 'GET', $body = null, array $extraHeaders = array())
+ {
+ $this->format = 'php_serial';
+
+ return $this->request($path, $method, $body, $extraHeaders);
+ }
}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php
new file mode 100644
index 0000000..0014ca8
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/QuickBooks.php
@@ -0,0 +1,120 @@
+baseApiUri = new Uri('https://quickbooks.api.intuit.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRequestTokenEndpoint()
+ {
+ return new Uri('https://oauth.intuit.com/oauth/v1/get_request_token');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://appcenter.intuit.com/Connect/Begin');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://oauth.intuit.com/oauth/v1/get_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'])) {
+ $message = 'Error in retrieving token: "' . $data['error'] . '"';
+ throw new TokenResponseException($message);
+ }
+
+ $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;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function request(
+ $path,
+ $method = 'GET',
+ $body = null,
+ array $extraHeaders = array()
+ ) {
+ $extraHeaders['Accept'] = 'application/json';
+ return parent::request($path, $method, $body, $extraHeaders);
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/Yahoo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php
similarity index 83%
rename from phpoauthlib/src/OAuth/OAuth1/Service/Yahoo.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php
index beda586..55f89a2 100644
--- a/phpoauthlib/src/OAuth/OAuth1/Service/Yahoo.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Redmine.php
@@ -11,19 +11,19 @@
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\Common\Http\Client\ClientInterface;
-class Yahoo extends AbstractService
+class Redmine extends AbstractService
{
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
TokenStorageInterface $storage,
SignatureInterface $signature,
- UriInterface $baseApiUri = null
+ UriInterface $baseApiUri
) {
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri);
if (null === $baseApiUri) {
- $this->baseApiUri = new Uri('https://social.yahooapis.com/v1/');
+ throw new \Exception('baseApiUri is a required argument.');
}
}
@@ -32,7 +32,7 @@ public function __construct(
*/
public function getRequestTokenEndpoint()
{
- return new Uri('https://api.login.yahoo.com/oauth/v2/get_request_token');
+ return new Uri($this->baseApiUri->getAbsoluteUri() . '/request_token');
}
/**
@@ -40,7 +40,7 @@ public function getRequestTokenEndpoint()
*/
public function getAuthorizationEndpoint()
{
- return new Uri('https://api.login.yahoo.com/oauth/v2/request_auth');
+ return new Uri($this->baseApiUri->getAbsoluteUri() . '/authorize');
}
/**
@@ -48,7 +48,7 @@ public function getAuthorizationEndpoint()
*/
public function getAccessTokenEndpoint()
{
- return new Uri('https://api.login.yahoo.com/oauth/v2/get_token');
+ return new Uri($this->baseApiUri->getAbsoluteUri() . '/access_token');
}
/**
@@ -93,9 +93,4 @@ protected function parseAccessTokenResponse($responseBody)
return $token;
}
-
- protected function getExtraApiHeaders() {
- return array('Accept' => 'application/json');
- }
-
}
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/ScoopIt.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Service/ScoopIt.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ScoopIt.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Service/ServiceInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/ServiceInterface.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/Tumblr.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Service/Tumblr.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Tumblr.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/Twitter.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
similarity index 94%
rename from phpoauthlib/src/OAuth/OAuth1/Service/Twitter.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
index f46c34e..dea680f 100644
--- a/phpoauthlib/src/OAuth/OAuth1/Service/Twitter.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Twitter.php
@@ -100,9 +100,11 @@ protected function parseAccessTokenResponse($responseBody)
parse_str($responseBody, $data);
if (null === $data || !is_array($data)) {
- throw new TokenResponseException('Unable to parse response.');
+ throw new TokenResponseException('Unable to parse response: ' . $responseBody);
} elseif (isset($data['error'])) {
throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
+ } elseif (!isset($data["oauth_token"]) || !isset($data["oauth_token_secret"])) {
+ throw new TokenResponseException('Invalid response. OAuth Token data not set: ' . $responseBody);
}
$token = new StdOAuth1Token();
diff --git a/phpoauthlib/src/OAuth/OAuth1/Service/Xing.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
similarity index 95%
rename from phpoauthlib/src/OAuth/OAuth1/Service/Xing.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
index 03e3357..e6824db 100644
--- a/phpoauthlib/src/OAuth/OAuth1/Service/Xing.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Xing.php
@@ -73,11 +73,12 @@ protected function parseRequestTokenResponse($responseBody)
protected function parseAccessTokenResponse($responseBody)
{
parse_str($responseBody, $data);
+ $errors = json_decode($responseBody);
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'] . '"');
+ } elseif ($errors) {
+ throw new TokenResponseException('Error in retrieving token: "' . $errors->error_name . '"');
}
$token = new StdOAuth1Token();
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php
new file mode 100644
index 0000000..50a825b
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/Yahoo.php
@@ -0,0 +1,131 @@
+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}
+ */
+ public function refreshAccessToken(TokenInterface $token)
+ {
+ $extraParams = $token->getExtraParams();
+ $bodyParams = array('oauth_session_handle' => $extraParams['oauth_session_handle']);
+
+ $authorizationHeader = array(
+ 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest(
+ 'POST',
+ $this->getAccessTokenEndpoint(),
+ $this->storage->retrieveAccessToken($this->service()),
+ $bodyParams
+ )
+ );
+
+
+
+ $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders(), array());
+
+ $responseBody = $this->httpClient->retrieveResponse($this->getAccessTokenEndpoint(), $bodyParams, $headers);
+
+ $token = $this->parseAccessTokenResponse($responseBody);
+ $this->storage->storeAccessToken($this->service(), $token);
+
+ return $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']);
+
+ if (isset($data['oauth_expires_in'])) {
+ $token->setLifetime($data['oauth_expires_in']);
+ } else {
+ $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES);
+ }
+
+ unset($data['oauth_token'], $data['oauth_token_secret']);
+ $token->setExtraParams($data);
+
+ return $token;
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Exception/UnsupportedHashAlgorithmException.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Signature/Signature.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Signature/Signature.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/Signature.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Signature/SignatureInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Signature/SignatureInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Signature/SignatureInterface.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Token/StdOAuth1Token.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Token/StdOAuth1Token.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/StdOAuth1Token.php
diff --git a/phpoauthlib/src/OAuth/OAuth1/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth1/Token/TokenInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth1/Token/TokenInterface.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php
similarity index 76%
rename from phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php
index 6458de4..e5c5878 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/AbstractService.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/AbstractService.php
@@ -3,17 +3,16 @@
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\Common\Service\AbstractService as BaseAbstractService;
+use OAuth\Common\Storage\TokenStorageInterface;
+use OAuth\Common\Token\Exception\ExpiredTokenException;
+use OAuth\Common\Token\TokenInterface;
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;
+use ReflectionClass;
abstract class AbstractService extends BaseAbstractService implements ServiceInterface
{
@@ -23,29 +22,28 @@ abstract class AbstractService extends BaseAbstractService implements ServiceInt
/** @var array */
protected $scopes;
- /** @var UriInterface|null */
+ /** @var null|UriInterface */
protected $baseApiUri;
/** @var bool */
protected $stateParameterInAuthUrl;
+ /** @var string */
+ protected $apiVersion;
+
/**
- * @param CredentialsInterface $credentials
- * @param ClientInterface $httpClient
- * @param TokenStorageInterface $storage
* @param array $scopes
- * @param UriInterface|null $baseApiUri
* @param bool $stateParameterInAutUrl
- *
- * @throws InvalidScopeException
+ * @param string $apiVersion
*/
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
TokenStorageInterface $storage,
- $scopes = array(),
- UriInterface $baseApiUri = null,
- $stateParameterInAutUrl = false
+ $scopes = [],
+ ?UriInterface $baseApiUri = null,
+ $stateParameterInAutUrl = false,
+ $apiVersion = ''
) {
parent::__construct($credentials, $httpClient, $storage);
$this->stateParameterInAuthUrl = $stateParameterInAutUrl;
@@ -59,24 +57,26 @@ public function __construct(
$this->scopes = $scopes;
$this->baseApiUri = $baseApiUri;
+
+ $this->apiVersion = $apiVersion;
}
/**
* {@inheritdoc}
*/
- public function getAuthorizationUri(array $additionalParameters = array())
+ public function getAuthorizationUri(array $additionalParameters = [])
{
$parameters = array_merge(
$additionalParameters,
- array(
- 'type' => 'web_server',
- 'client_id' => $this->credentials->getConsumerId(),
- 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ [
+ 'type' => 'web_server',
+ 'client_id' => $this->credentials->getConsumerId(),
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
'response_type' => 'code',
- )
+ ]
);
- $parameters['scope'] = implode(' ', $this->scopes);
+ $parameters['scope'] = implode($this->getScopesDelimiter(), $this->scopes);
if ($this->needsStateParameterInAuthUrl()) {
if (!isset($parameters['state'])) {
@@ -103,13 +103,13 @@ public function requestAccessToken($code, $state = null)
$this->validateAuthorizationState($state);
}
- $bodyParams = array(
- 'code' => $code,
- 'client_id' => $this->credentials->getConsumerId(),
+ $bodyParams = [
+ 'code' => $code,
+ 'client_id' => $this->credentials->getConsumerId(),
'client_secret' => $this->credentials->getConsumerSecret(),
- 'redirect_uri' => $this->credentials->getCallbackUrl(),
- 'grant_type' => 'authorization_code',
- );
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ 'grant_type' => 'authorization_code',
+ ];
$responseBody = $this->httpClient->retrieveResponse(
$this->getAccessTokenEndpoint(),
@@ -129,16 +129,13 @@ public function requestAccessToken($code, $state = null)
*
* @param string|UriInterface $path
* @param string $method HTTP method
- * @param array $body Request body if applicable.
+ * @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())
+ public function request($path, $method = 'GET', $body = null, array $extraHeaders = [])
{
$uri = $this->determineRequestUriFromPath($path, $this->baseApiUri);
$token = $this->storage->retrieveAccessToken($this->service());
@@ -158,15 +155,17 @@ public function request($path, $method = 'GET', $body = null, array $extraHeader
// 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);
+ $extraHeaders = array_merge(['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_QUERY_STRING_V4 === $this->getAuthorizationMethod()) {
+ $uri->addToQuery('auth', $token->getAccessToken());
} elseif (static::AUTHORIZATION_METHOD_HEADER_BEARER === $this->getAuthorizationMethod()) {
- $extraHeaders = array_merge(array('Authorization' => 'Bearer ' . $token->getAccessToken()), $extraHeaders);
+ $extraHeaders = array_merge(['Authorization' => 'Bearer ' . $token->getAccessToken()], $extraHeaders);
} elseif (static::AUTHORIZATION_METHOD_HEADER_TOKEN === $this->getAuthorizationMethod()) {
$extraHeaders = array_merge(array('Authorization' => 'token ' . $token->getAccessToken()), $extraHeaders);
}
@@ -177,7 +176,7 @@ public function request($path, $method = 'GET', $body = null, array $extraHeader
}
/**
- * Accessor to the storage adapter to be able to retrieve tokens
+ * Accessor to the storage adapter to be able to retrieve tokens.
*
* @return TokenStorageInterface
*/
@@ -189,11 +188,7 @@ public function getStorage()
/**
* Refreshes an OAuth2 access token.
*
- * @param TokenInterface $token
- *
* @return TokenInterface $token
- *
- * @throws MissingRefreshTokenException
*/
public function refreshAccessToken(TokenInterface $token)
{
@@ -203,13 +198,13 @@ public function refreshAccessToken(TokenInterface $token)
throw new MissingRefreshTokenException();
}
- $parameters = array(
- 'grant_type' => 'refresh_token',
- 'type' => 'web_server',
- 'client_id' => $this->credentials->getConsumerId(),
+ $parameters = [
+ '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(),
@@ -231,13 +226,13 @@ public function refreshAccessToken(TokenInterface $token)
*/
public function isValidScope($scope)
{
- $reflectionClass = new \ReflectionClass(get_class($this));
+ $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
+ * Check if the given service need to generate a unique state token to build the authorization url.
*
* @return bool
*/
@@ -247,12 +242,11 @@ public function needsStateParameterInAuthUrl()
}
/**
- * Validates the authorization state against a given one
+ * Validates the authorization state against a given one.
*
* @param string $state
- * @throws InvalidAuthorizationStateException
*/
- protected function validateAuthorizationState($state)
+ protected function validateAuthorizationState($state): void
{
if ($this->retrieveAuthorizationState() !== $state) {
throw new InvalidAuthorizationStateException();
@@ -260,17 +254,17 @@ protected function validateAuthorizationState($state)
}
/**
- * Generates a random string to be used as state
+ * Generates a random string to be used as state.
*
* @return string
*/
protected function generateAuthorizationState()
{
- return md5(rand());
+ return md5(mt_rand());
}
/**
- * Retrieves the authorization state for the current service
+ * Retrieves the authorization state for the current service.
*
* @return string
*/
@@ -280,11 +274,11 @@ protected function retrieveAuthorizationState()
}
/**
- * Stores a given authorization state into the storage
+ * Stores a given authorization state into the storage.
*
* @param string $state
*/
- protected function storeAuthorizationState($state)
+ protected function storeAuthorizationState($state): void
{
$this->storage->storeAuthorizationState($this->service(), $state);
}
@@ -296,7 +290,7 @@ protected function storeAuthorizationState($state)
*/
protected function getExtraOAuthHeaders()
{
- return array();
+ return [];
}
/**
@@ -306,7 +300,7 @@ protected function getExtraOAuthHeaders()
*/
protected function getExtraApiHeaders()
{
- return array();
+ return [];
}
/**
@@ -317,8 +311,6 @@ protected function getExtraApiHeaders()
* @param string $responseBody
*
* @return TokenInterface
- *
- * @throws TokenResponseException
*/
abstract protected function parseAccessTokenResponse($responseBody);
@@ -332,4 +324,26 @@ protected function getAuthorizationMethod()
{
return static::AUTHORIZATION_METHOD_HEADER_OAUTH;
}
+
+ /**
+ * Returns api version string if is set else retrun empty string.
+ *
+ * @return string
+ */
+ protected function getApiVersionString()
+ {
+ return !(empty($this->apiVersion)) ? '/' . $this->apiVersion : '';
+ }
+
+ /**
+ * Returns delimiter to scopes in getAuthorizationUri
+ * For services that do not fully respect the Oauth's RFC,
+ * and use scopes with commas as delimiter.
+ *
+ * @return string
+ */
+ protected function getScopesDelimiter()
+ {
+ return ' ';
+ }
}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Amazon.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Amazon.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Amazon.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/BattleNet.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/BattleNet.php
new file mode 100644
index 0000000..ec3fdad
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/BattleNet.php
@@ -0,0 +1,116 @@
+baseApiUri = new Uri( self::API_URI_US );
+ }
+ }
+
+ /** -----------------------------------------------------------------------
+ * Translates the current base API URI into an OAuth base URI.
+ *
+ * @returns string Base URI of oauth services.
+ */
+ private function GetOAuthBaseUri() {
+
+ // i love china
+ switch( $this->baseApiUri ) {
+ case self::API_URI_US: return 'https://us.battle.net/oauth/';
+ case self::API_URI_EU: return 'https://eu.battle.net/oauth/';
+ case self::API_URI_KR: return 'https://kr.battle.net/oauth/';
+ case self::API_URI_TW: return 'https://tw.battle.net/oauth/';
+ case self::API_URI_CN: return 'https://www.battlenet.com.cn/oauth/';
+ case self::API_URI_SEA: return 'https://sea.battle.net/oauth/';
+ }
+
+ }
+
+ /** -----------------------------------------------------------------------
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint() {
+ return new Uri( $this->GetOAuthBaseUri() . 'authorize' );
+ }
+
+ /** -----------------------------------------------------------------------
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint() {
+ return new Uri( $this->GetOAuthBaseUri() . 'token' );
+ }
+
+ /** -----------------------------------------------------------------------
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_QUERY_STRING;
+ }
+
+ /** -----------------------------------------------------------------------
+ * {@inheritdoc}
+ */
+ 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']) ) {
+ $err = $data['error'];
+ throw new TokenResponseException(
+ "Error in retrieving token: \"$err\"" );
+ }
+
+ $token = new StdOAuth2Token( $data['access_token'], null,
+ $data['expires_in'] );
+
+ unset( $data['access_token'] );
+ unset( $data['expires_in'] );
+
+ $token->setExtraParams( $data );
+
+ return $token;
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Bitly.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Bitly.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitly.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitrix24.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitrix24.php
new file mode 100644
index 0000000..b1fd45b
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Bitrix24.php
@@ -0,0 +1,126 @@
+baseApiUri));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri(sprintf('%s/oauth/token/', $this->baseApiUri));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_QUERY_STRING_V4;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function requestAccessToken($code, $state = null)
+ {
+ if (null !== $state) {
+ $this->validateAuthorizationState($state);
+ }
+
+ $responseBody = $this->httpClient->retrieveResponse(
+ $this->getAccessTokenUri($code),
+ array(),
+ $this->getExtraOAuthHeaders(),
+ 'GET'
+ );
+
+ $token = $this->parseAccessTokenResponse($responseBody);
+ $this->storage->storeAccessToken($this->service(), $token);
+
+ return $token;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenUri($code)
+ {
+ $parameters = array(
+ 'code' => $code,
+ 'client_id' => $this->credentials->getConsumerId(),
+ 'client_secret' => $this->credentials->getConsumerSecret(),
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ 'grant_type' => 'authorization_code',
+ 'scope' => $this->scopes
+ );
+
+ $parameters['scope'] = implode(' ', $this->scopes);
+
+ // Build the url
+ $url = $this->getAccessTokenEndpoint();
+ foreach ($parameters as $key => $val) {
+ $url->addToQuery($key, $val);
+ }
+
+ return $url;
+ }
+
+ /**
+ * {@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/phpoauthlib/src/OAuth/OAuth2/Service/Box.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Box.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Box.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php
new file mode 100644
index 0000000..3f3ca61
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Buffer.php
@@ -0,0 +1,151 @@
+
+ * @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, $state = null)
+ {
+ $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/phpoauthlib/src/OAuth/OAuth2/Service/Dailymotion.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Dailymotion.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dailymotion.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Deezer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Deezer.php
new file mode 100644
index 0000000..3e3965b
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Deezer.php
@@ -0,0 +1,121 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://developers.deezer.com/api/
+ */
+
+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;
+
+/**
+ * Deezer service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://developers.deezer.com/api/
+ */
+class Deezer extends AbstractService
+{
+ /**
+ * Defined scopes
+ * http://developers.deezer.com/api/permissions
+ */
+ const SCOPE_BASIC_ACCESS = 'basic_access'; // Access users basic information
+ const SCOPE_EMAIL = 'email'; // Get the user's email
+ const SCOPE_OFFLINE_ACCESS = 'offline_access'; // Access user data any time
+ const SCOPE_MANAGE_LIBRARY = 'manage_library'; // Manage users' library
+ const SCOPE_MANAGE_COMMUNITY = 'manage_community'; // Manage users' friends
+ const SCOPE_DELETE_LIBRARY = 'delete_library'; // Delete library items
+ const SCOPE_LISTENING_HISTORY = 'listening_history'; // Access the user's listening history
+
+ 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.deezer.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://connect.deezer.com/oauth/auth.php');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://connect.deezer.com/oauth/access_token.php');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_QUERY_STRING;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function parseAccessTokenResponse($responseBody)
+ {
+ parse_str($responseBody, $data);
+ if (null === $data || !is_array($data) || empty($data)) {
+ throw new TokenResponseException('Unable to parse response.');
+ } elseif (isset($data['error'])) {
+ throw new TokenResponseException(
+ 'Error in retrieving token: "' . $data['error'] . '"'
+ );
+ } elseif (isset($data['error_reason'])) {
+ throw new TokenResponseException(
+ 'Error in retrieving token: "' . $data['error_reason'] . '"'
+ );
+ }
+
+ $token = new StdOAuth2Token();
+ $token->setAccessToken($data['access_token']);
+ $token->setLifeTime($data['expires']);
+
+ // I hope one day Deezer add a refresh token :)
+ 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;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Delicious.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Delicious.php
new file mode 100644
index 0000000..eba6035
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Delicious.php
@@ -0,0 +1,139 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://github.com/SciDevs/delicious-api/blob/master/api/oauth.md
+ */
+
+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;
+
+/**
+ * Delicious service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://github.com/SciDevs/delicious-api/blob/master/api/oauth.md
+ */
+class Delicious 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.del.icio.us/v1/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://delicious.com/auth/authorize');
+
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://avosapi.delicious.com/api/v1/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'])) {
+ 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;
+ }
+
+
+ // Special, delicious didn't respect the oauth2 RFC and need a grant_type='code'
+ /**
+ * {@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' => 'code',
+ );
+
+ $responseBody = $this->httpClient->retrieveResponse(
+ $this->getAccessTokenEndpoint(),
+ $bodyParams,
+ $this->getExtraOAuthHeaders()
+ );
+
+ $token = $this->parseAccessTokenResponse($responseBody);
+ $this->storage->storeAccessToken($this->service(), $token);
+
+ return $token;
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/DeviantArt.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/DeviantArt.php
new file mode 100644
index 0000000..31e94b4
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/DeviantArt.php
@@ -0,0 +1,99 @@
+baseApiUri = new Uri('https://www.deviantart.com/api/v1/oauth2/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://www.deviantart.com/oauth2/authorize');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://www.deviantart.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']);
+ }
+
+ 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/phpoauthlib/src/OAuth/OAuth2/Service/Dropbox.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Dropbox.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Dropbox.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/EveOnline.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/EveOnline.php
new file mode 100644
index 0000000..76fafa6
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/EveOnline.php
@@ -0,0 +1,100 @@
+
+ */
+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 EveOnline
+ */
+class EveOnline 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://login.eveonline.com');
+ }
+ }
+
+ /**
+ * Returns the authorization API endpoint.
+ * @return UriInterface
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri($this->baseApiUri . '/oauth/authorize');
+ }
+
+ /**
+ * Returns the access token API endpoint.
+ * @return UriInterface
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri($this->baseApiUri . '/oauth/token');
+ }
+
+ /**
+ * Parses the access token response and returns a TokenInterface.
+ *
+ * @param string $responseBody
+ *
+ * @return TokenInterface
+ * @throws TokenResponseException
+ */
+ 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;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_HEADER_BEARER;
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAccessTypeException.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidAuthorizationStateException.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/InvalidScopeException.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Exception/MissingRefreshTokenException.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Facebook.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php
similarity index 86%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Facebook.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php
index 80b25c0..4202b8b 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Facebook.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Facebook.php
@@ -26,9 +26,11 @@ class Facebook extends AbstractService
* @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
+ // Default scope
+ const SCOPE_PUBLIC_PROFILE = 'public_profile';
+ // Email scopes
const SCOPE_EMAIL = 'email';
- // extended permissions
+ // Extended permissions
const SCOPE_READ_FRIENDLIST = 'read_friendlists';
const SCOPE_READ_INSIGHTS = 'read_insights';
const SCOPE_READ_MAILBOX = 'read_mailbox';
@@ -55,8 +57,10 @@ class Facebook extends AbstractService
const SCOPE_SMS = 'sms';
const SCOPE_STATUS_UPDATE = 'status_update';
// Extended Profile Properties
+ const SCOPE_USER_POSTS = 'user_posts';
const SCOPE_USER_FRIENDS = 'user_friends';
const SCOPE_USER_ABOUT = 'user_about_me';
+ const SCOPE_USER_TAGGED_PLACES = 'user_tagged_places';
const SCOPE_FRIENDS_ABOUT = 'friends_about_me';
const SCOPE_USER_ACTIVITIES = 'user_activities';
const SCOPE_FRIENDS_ACTIVITIES = 'friends_activities';
@@ -69,6 +73,7 @@ class Facebook extends AbstractService
const SCOPE_USER_EVENTS = 'user_events';
const SCOPE_FRIENDS_EVENTS = 'friends_events';
const SCOPE_USER_GROUPS = 'user_groups';
+ const SCOPE_USER_MANAGED_GROUPS = 'user_managed_groups';
const SCOPE_FRIENDS_GROUPS = 'friends_groups';
const SCOPE_USER_HOMETOWN = 'user_hometown';
const SCOPE_FRIENDS_HOMETOWN = 'friends_hometown';
@@ -115,18 +120,20 @@ class Facebook extends AbstractService
const SCOPE_FRIENDS_GAMES = 'friends_games_activity';
//Page Permissions
const SCOPE_PAGES = 'manage_pages';
+ const SCOPE_PUBLISH_PAGES = 'publish_pages';
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
TokenStorageInterface $storage,
$scopes = array(),
- UriInterface $baseApiUri = null
+ UriInterface $baseApiUri = null,
+ $apiVersion = ""
) {
- parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
+ parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true, $apiVersion);
if (null === $baseApiUri) {
- $this->baseApiUri = new Uri('https://graph.facebook.com/');
+ $this->baseApiUri = new Uri('https://graph.facebook.com'.$this->getApiVersionString().'/');
}
}
@@ -135,7 +142,7 @@ public function __construct(
*/
public function getAuthorizationEndpoint()
{
- return new Uri('https://www.facebook.com/dialog/oauth');
+ return new Uri('https://www.facebook.com'.$this->getApiVersionString().'/dialog/oauth');
}
/**
@@ -143,7 +150,7 @@ public function getAuthorizationEndpoint()
*/
public function getAccessTokenEndpoint()
{
- return new Uri('https://graph.facebook.com/oauth/access_token');
+ return new Uri('https://graph.facebook.com'.$this->getApiVersionString().'/oauth/access_token');
}
/**
@@ -151,8 +158,12 @@ public function getAccessTokenEndpoint()
*/
protected function parseAccessTokenResponse($responseBody)
{
- // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ?
- parse_str($responseBody, $data);
+ $data = @json_decode($responseBody, true);
+
+ // Facebook gives us a query string on old api (v2.0)
+ if (!$data) {
+ parse_str($responseBody, $data);
+ }
if (null === $data || !is_array($data)) {
throw new TokenResponseException('Unable to parse response.');
@@ -162,7 +173,7 @@ protected function parseAccessTokenResponse($responseBody)
$token = new StdOAuth2Token();
$token->setAccessToken($data['access_token']);
-
+
if (isset($data['expires'])) {
$token->setLifeTime($data['expires']);
}
@@ -186,8 +197,24 @@ public function getDialogUri($dialogPath, array $parameters)
throw new Exception("Redirect uri is mandatory for this request");
}
$parameters['app_id'] = $this->credentials->getConsumerId();
- $baseUrl = self::WWW_URL . 'dialog/' . $dialogPath;
+ $baseUrl = self::WWW_URL .$this->getApiVersionString(). '/dialog/' . $dialogPath;
$query = http_build_query($parameters);
return new Uri($baseUrl . '?' . $query);
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getApiVersionString()
+ {
+ return empty($this->apiVersion) ? '' : '/v' . $this->apiVersion;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getScopesDelimiter()
+ {
+ return ',';
+ }
}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Foursquare.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php
similarity index 96%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Foursquare.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php
index fdbabf9..981ff44 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Foursquare.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Foursquare.php
@@ -73,7 +73,7 @@ protected function parseAccessTokenResponse($responseBody)
*/
public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
{
- $uri = new Uri($this->baseApiUri . $path);
+ $uri = $this->determineRequestUriFromPath($path, $this->baseApiUri);
$uri->addToQuery('v', $this->apiVersionDate);
return parent::request($uri, $method, $body, $extraHeaders);
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/GitHub.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php
similarity index 76%
rename from phpoauthlib/src/OAuth/OAuth2/Service/GitHub.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php
index 897b342..55c7819 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/GitHub.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/GitHub.php
@@ -2,13 +2,13 @@
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\Exception\TokenResponseException;
+use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Http\Uri\UriInterface;
+use OAuth\Common\Storage\TokenStorageInterface;
+use OAuth\OAuth2\Token\StdOAuth2Token;
class GitHub extends AbstractService
{
@@ -17,7 +17,7 @@ class GitHub extends AbstractService
*/
/**
- * Public read-only access (includes public user profile info, public repo info, and gists)
+ * Public read-only access (includes public user profile info, public repo info, and gists).
*/
const SCOPE_READONLY = '';
@@ -50,6 +50,13 @@ class GitHub extends AbstractService
*/
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
@@ -71,28 +78,58 @@ class GitHub extends AbstractService
* 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
+ $scopes = [],
+ ?UriInterface $baseApiUri = null
) {
parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
@@ -150,13 +187,13 @@ protected function parseAccessTokenResponse($responseBody)
}
/**
- * Used to configure response type -- we want JSON from github, default is query string format
+ * 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');
+ return ['Accept' => 'application/json'];
}
/**
@@ -166,6 +203,14 @@ protected function getExtraOAuthHeaders()
*/
protected function getExtraApiHeaders()
{
- return array('Accept' => 'application/vnd.github.v3+json');
+ return ['Accept' => 'application/vnd.github.v3+json'];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getScopesDelimiter()
+ {
+ return ',';
}
}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Google.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php
similarity index 68%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Google.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php
index a22ec3b..1b6555f 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Google.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Google.php
@@ -2,6 +2,10 @@
namespace OAuth\OAuth2\Service;
+use OAuth\Common\Consumer\CredentialsInterface;
+use OAuth\Common\Http\Client\ClientInterface;
+use OAuth\Common\Http\Uri\UriInterface;
+use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\OAuth2\Token\StdOAuth2Token;
use OAuth\Common\Http\Exception\TokenResponseException;
use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException;
@@ -26,6 +30,12 @@ class Google extends AbstractService
// 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';
+ const SCOPE_EMAIL_PLUS = 'https://www.googleapis.com/auth/plus.profile.emails.read';
// Google Drive
const SCOPE_DOCUMENTSLIST = 'https://docs.google.com/feeds/';
@@ -40,23 +50,40 @@ class Google extends AbstractService
// Adwords
const SCOPE_ADSENSE = 'https://www.googleapis.com/auth/adsense';
- const SCOPE_ADWORDS = 'https://adwords.google.com/api/adwords/';
+ const SCOPE_ADWORDS = 'https://www.googleapis.com/auth/adwords';
+ const SCOPE_ADWORDS_DEPRECATED = 'https://www.googleapis.com/auth/adwords/'; //deprecated in v201406 API version
const SCOPE_GAN = 'https://www.googleapis.com/auth/gan'; // google affiliate network...?
+ //Doubleclick for Publishers
+ const SCOPE_DFP = 'https://www.googleapis.com/auth/dfp';
+ const SCOPE_DFP_TRAFFICKING = 'https://www.googleapis.com/auth/dfatrafficking';
+ const SCOPE_DFP_REPORTING = 'https://www.googleapis.com/auth/dfareporting';
+
// 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';
+ //Gmail
+ const SCOPE_GMAIL_MODIFY = 'https://www.googleapis.com/auth/gmail.modify';
+ const SCOPE_GMAIL_READONLY = 'https://www.googleapis.com/auth/gmail.readonly';
+ const SCOPE_GMAIL_COMPOSE = 'https://www.googleapis.com/auth/gmail.compose';
+ const SCOPE_GMAIL_SEND = 'https://www.googleapis.com/auth/gmail.send';
+ const SCOPE_GMAIL_INSERT = 'https://www.googleapis.com/auth/gmail.insert';
+ const SCOPE_GMAIL_LABELS = 'https://www.googleapis.com/auth/gmail.labels';
+ const SCOPE_GMAIL_FULL = 'https://mail.google.com/';
+
// 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_CONTACTS_RO = 'https://www.googleapis.com/auth/contacts.readonly';
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';
@@ -93,8 +120,29 @@ class Google extends AbstractService
// Android Publisher
const SCOPE_ANDROID_PUBLISHER = 'https://www.googleapis.com/auth/androidpublisher';
+ // Google Classroom
+ const SCOPE_CLASSROOM_COURSES = 'https://www.googleapis.com/auth/classroom.courses';
+ const SCOPE_CLASSROOM_COURSES_READONLY = 'https://www.googleapis.com/auth/classroom.courses.readonly';
+ const SCOPE_CLASSROOM_PROFILE_EMAILS = 'https://www.googleapis.com/auth/classroom.profile.emails';
+ const SCOPE_CLASSROOM_PROFILE_PHOTOS = 'https://www.googleapis.com/auth/classroom.profile.photos';
+ const SCOPE_CLASSROOM_ROSTERS = 'https://www.googleapis.com/auth/classroom.rosters';
+ const SCOPE_CLASSROOM_ROSTERS_READONLY = 'https://www.googleapis.com/auth/classroom.rosters.readonly';
+
protected $accessType = 'online';
+ 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://www.googleapis.com/oauth2/v1/');
+ }
+ }
public function setAccessType($accessType)
{
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php
new file mode 100644
index 0000000..96fb0f2
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Harvest.php
@@ -0,0 +1,157 @@
+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/phpoauthlib/src/OAuth/OAuth2/Service/Heroku.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Heroku.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Heroku.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Hubic.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Hubic.php
new file mode 100644
index 0000000..b995450
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Hubic.php
@@ -0,0 +1,155 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://api.hubic.com/docs/
+ */
+
+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;
+
+/**
+ * Hubic service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://api.hubic.com/docs/
+ */
+class Hubic extends AbstractService
+{
+
+ // Scopes
+ const SCOPE_USAGE_GET = 'usage.r';
+ const SCOPE_ACCOUNT_GET = 'account.r';
+ const SCOPE_GETALLLINKS_GET = 'getAllLinks.r';
+ const SCOPE_CREDENTIALS_GET = 'credentials.r';
+ const SCOPE_SPONSORCODE_GET = 'sponsorCode.r';
+ const SCOPE_ACTIVATE_POST = 'activate.w';
+ const SCOPE_SPONSORED_GET = 'sponsored.r';
+ const SCOPE_LINKS_GET = 'links.r';
+ const SCOPE_LINKS_POST = 'links.rw';
+ const SCOPE_LINKS_ALL = 'links.drw';
+
+ 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.hubic.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://api.hubic.com/oauth/auth');
+
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://api.hubic.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'])) {
+ 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}
+ */
+ 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',
+ )
+ );
+
+ // special, hubic use a param scope with commas
+ // between scopes instead of spaces
+ $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;
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Instagram.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php
similarity index 94%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Instagram.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php
index 49e9c8c..43fe181 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Instagram.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Instagram.php
@@ -17,9 +17,11 @@ class Instagram extends AbstractService
* @link http://instagram.com/developer/authentication/#scope
*/
const SCOPE_BASIC = 'basic';
+ const SCOPE_PUBLIC_CONTENT = 'public_content';
const SCOPE_COMMENTS = 'comments';
const SCOPE_RELATIONSHIPS = 'relationships';
const SCOPE_LIKES = 'likes';
+ const SCOPE_FOLLOWER_LIST = 'follower_list';
public function __construct(
CredentialsInterface $credentials,
@@ -28,7 +30,7 @@ public function __construct(
$scopes = array(),
UriInterface $baseApiUri = null
) {
- parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
+ parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
if (null === $baseApiUri) {
$this->baseApiUri = new Uri('https://api.instagram.com/v1/');
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/JawboneUP.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/JawboneUP.php
new file mode 100644
index 0000000..fad1125
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/JawboneUP.php
@@ -0,0 +1,144 @@
+
+ * @link https://jawbone.com/up/developer/authentication
+ */
+class JawboneUP extends AbstractService
+{
+ /**
+ * Defined scopes
+ *
+ *
+ * @link https://jawbone.com/up/developer/authentication
+ */
+ // general information scopes
+ const SCOPE_BASIC_READ = 'basic_read';
+ const SCOPE_EXTENDED_READ = 'extended_read';
+ const SCOPE_LOCATION_READ = 'location_read';
+ const SCOPE_FRIENDS_READ = 'friends_read';
+ // mood scopes
+ const SCOPE_MOOD_READ = 'mood_read';
+ const SCOPE_MOOD_WRITE = 'mood_write';
+ // move scopes
+ const SCOPE_MOVE_READ = 'move_read';
+ const SCOPE_MOVE_WRITE = 'move_write';
+ // sleep scopes
+ const SCOPE_SLEEP_READ = 'sleep_read';
+ const SCOPE_SLEEP_WRITE = 'sleep_write';
+ // meal scopes
+ const SCOPE_MEAL_READ = 'meal_read';
+ const SCOPE_MEAL_WRITE = 'meal_write';
+ // weight scopes
+ const SCOPE_WEIGHT_READ = 'weight_read';
+ const SCOPE_WEIGHT_WRITE = 'weight_write';
+ // generic event scopes
+ const SCOPE_GENERIC_EVENT_READ = 'generic_event_read';
+ const SCOPE_GENERIC_EVENT_WRITE = 'generic_event_write';
+
+
+ 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://jawbone.com/nudge/api/v.1.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://jawbone.com/auth/oauth2/auth');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://jawbone.com/auth/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/phpoauthlib/src/OAuth/OAuth2/Service/Linkedin.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php
similarity index 96%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Linkedin.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php
index bb801e6..65cfd94 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Linkedin.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Linkedin.php
@@ -31,6 +31,7 @@ class Linkedin extends AbstractService
const SCOPE_RW_COMPANY_ADMIN = 'rw_company_admin';
const SCOPE_RW_GROUPS = 'rw_groups';
const SCOPE_W_MESSAGES = 'w_messages';
+ const SCOPE_W_SHARE = 'w_share';
public function __construct(
CredentialsInterface $credentials,
@@ -67,7 +68,7 @@ public function getAccessTokenEndpoint()
*/
protected function getAuthorizationMethod()
{
- return static::AUTHORIZATION_METHOD_QUERY_STRING_V2;
+ return static::AUTHORIZATION_METHOD_HEADER_BEARER;
}
/**
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Mailchimp.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php
similarity index 99%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Mailchimp.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php
index 42abd3c..842153d 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Mailchimp.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mailchimp.php
@@ -12,7 +12,6 @@
class Mailchimp extends AbstractService
{
-
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
@@ -92,7 +91,7 @@ public function request($path, $method = 'GET', $body = null, array $extraHeader
/**
* Set the right base endpoint.
- *
+ *
* @param StdOAuth2Token $token
*/
protected function setBaseApiUri(StdOAuth2Token $token)
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Microsoft.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php
similarity index 99%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Microsoft.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php
index 183ef45..c815b22 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Microsoft.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Microsoft.php
@@ -35,6 +35,7 @@ class Microsoft extends AbstractService
const SCOPE_WORK_PROFILE = 'wl.work_profile';
const SCOPE_APPLICATIONS = 'wl.applications';
const SCOPE_APPLICATIONS_CREATE = 'wl.applications_create';
+ const SCOPE_IMAP = 'wl.imap';
/**
* MS uses some magical not officialy supported scope to get even moar info like full emailaddresses.
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Harvest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mondo.php
similarity index 70%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Harvest.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mondo.php
index 86e8993..e063045 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Harvest.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Mondo.php
@@ -10,9 +10,8 @@
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\Common\Http\Uri\UriInterface;
-class Harvest extends AbstractService
+class Mondo extends AbstractService
{
-
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
@@ -20,10 +19,10 @@ public function __construct(
$scopes = array(),
UriInterface $baseApiUri = null
) {
- parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
+ parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
if (null === $baseApiUri) {
- $this->baseApiUri = new Uri('https://api.github.com/');
+ $this->baseApiUri = new Uri('https://api.getmondo.co.uk');
}
}
@@ -32,7 +31,7 @@ public function __construct(
*/
public function getAuthorizationEndpoint()
{
- return new Uri('https://api.harvestapp.com/oauth2/authorize');
+ return new Uri('https://auth.getmondo.co.uk');
}
/**
@@ -40,7 +39,7 @@ public function getAuthorizationEndpoint()
*/
public function getAccessTokenEndpoint()
{
- return new Uri('https://api.harvestapp.com/oauth2/token');
+ return new Uri('https://api.getmondo.co.uk/oauth2/token');
}
/**
@@ -48,7 +47,7 @@ public function getAccessTokenEndpoint()
*/
protected function getAuthorizationMethod()
{
- return static::AUTHORIZATION_METHOD_QUERY_STRING;
+ return static::AUTHORIZATION_METHOD_HEADER_BEARER;
}
/**
@@ -58,15 +57,25 @@ protected function parseAccessTokenResponse($responseBody)
{
$data = json_decode($responseBody, true);
- if (null === $data || ! is_array($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']);
- $token->setEndOfLife($data['expires_in']);
+
+ 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']);
@@ -74,12 +83,4 @@ protected function parseAccessTokenResponse($responseBody)
return $token;
}
-
- /**
- * @return array
- */
- protected function getExtraOAuthHeaders()
- {
- return array('Accept' => 'application/json');
- }
}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Nest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Nest.php
new file mode 100644
index 0000000..7659e4f
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Nest.php
@@ -0,0 +1,106 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developer.nest.com/documentation
+ */
+
+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;
+
+/**
+ * Nest service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developer.nest.com/documentation
+ */
+class Nest 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://developer-api.nest.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://home.nest.com/login/oauth2');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://api.home.nest.com/oauth2/access_token');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_QUERY_STRING_V4;
+ }
+
+ /**
+ * {@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/Netatmo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Netatmo.php
new file mode 100644
index 0000000..eb5c68d
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Netatmo.php
@@ -0,0 +1,117 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://dev.netatmo.com/doc/
+ */
+
+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;
+
+/**
+ * Netatmo service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://dev.netatmo.com/doc/
+ */
+class Netatmo extends AbstractService
+{
+
+ // SCOPES
+ // @link https://dev.netatmo.com/doc/authentication/scopes
+
+ // Used to read weather station's data (devicelist, getmeasure)
+ const SCOPE_STATION_READ = 'read_station';
+ // Used to read thermostat's data (devicelist, getmeasure, getthermstate)
+ const SCOPE_THERMOSTAT_READ = 'read_thermostat';
+ // Used to configure the thermostat (syncschedule, setthermpoint)
+ const SCOPE_THERMOSTAT_WRITE = 'write_thermostat';
+
+ public function __construct(
+ CredentialsInterface $credentials,
+ ClientInterface $httpClient,
+ TokenStorageInterface $storage,
+ $scopes = array(),
+ UriInterface $baseApiUri = null
+ ) {
+ parent::__construct(
+ $credentials,
+ $httpClient,
+ $storage,
+ $scopes,
+ $baseApiUri,
+ true // use parameter state
+ );
+
+ if (null === $baseApiUri) {
+ $this->baseApiUri = new Uri('https://api.netatmo.net/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri($this->baseApiUri.'oauth2/authorize');
+
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri($this->baseApiUri.'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']);
+
+ 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/ParrotFlowerPower.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ParrotFlowerPower.php
new file mode 100644
index 0000000..78ef942
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ParrotFlowerPower.php
@@ -0,0 +1,142 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://flowerpowerdev.parrot.com/projects/flower-power-web-service-api/wiki
+ */
+
+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;
+use OAuth\OAuth2\Service\Exception\MissingRefreshTokenException;
+use OAuth\Common\Token\TokenInterface;
+
+/**
+ * ParrotFlowerPower service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://flowerpowerdev.parrot.com/projects/flower-power-web-service-api/wiki
+ */
+class ParrotFlowerPower 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://apiflowerpower.parrot.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri($this->baseApiUri.'oauth2/v1/authorize');
+
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri($this->baseApiUri.'user/v1/authenticate');
+ }
+
+ /**
+ * {@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;
+ }
+
+
+ /**
+ * Parrot use a different endpoint for refresh a token
+ *
+ * {@inheritdoc}
+ */
+ 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(
+ new Uri($this->baseApiUri.'user/v1/refresh'),
+ $parameters,
+ $this->getExtraOAuthHeaders()
+ );
+ $token = $this->parseAccessTokenResponse($responseBody);
+ $this->storage->storeAccessToken($this->service(), $token);
+
+ return $token;
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Paypal.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Paypal.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Paypal.php
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pinterest.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pinterest.php
new file mode 100644
index 0000000..e7ecd3c
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pinterest.php
@@ -0,0 +1,117 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developers.pinterest.com/docs/api/overview/
+ */
+
+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;
+
+/**
+ * Pinterest service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developers.pinterest.com/docs/api/overview/
+ */
+class Pinterest extends AbstractService
+{
+ /**
+ * Defined scopes - More scopes are listed here:
+ * https://developers.pinterest.com/docs/api/overview/
+ */
+ const SCOPE_READ_PUBLIC = 'read_public'; // read a user’s Pins, boards and likes
+ const SCOPE_WRITE_PUBLIC = 'write_public'; // write Pins, boards, likes
+ const SCOPE_READ_RELATIONSHIPS = 'read_relationships'; // read a user’s follows (boards, users, interests)
+ const SCOPE_WRITE_RELATIONSHIPS = 'write_relationships'; // follow boards, users and interests
+
+ 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.pinterest.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://api.pinterest.com/oauth/');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://api.pinterest.com/v1/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'])) {
+ 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']);
+ }
+ // I hope one day Pinterest add a refresh 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/phpoauthlib/src/OAuth/OAuth2/Service/Pocket.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php
similarity index 98%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Pocket.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php
index 8c95544..6c5cb7e 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Pocket.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Pocket.php
@@ -85,7 +85,7 @@ protected function parseRequestTokenResponse($responseBody)
return $data['code'];
}
- public function requestAccessToken($code)
+ public function requestAccessToken($code, $state = null)
{
$bodyParams = array(
'consumer_key' => $this->credentials->getConsumerId(),
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Reddit.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Reddit.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Reddit.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/RunKeeper.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/RunKeeper.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/RunKeeper.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Salesforce.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php
similarity index 95%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Salesforce.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php
index 583e434..5edc42c 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Salesforce.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Salesforce.php
@@ -11,7 +11,7 @@
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\Common\Http\Uri\UriInterface;
-class SalesforceService extends AbstractService
+class Salesforce extends AbstractService
{
/**
* Scopes
@@ -34,7 +34,7 @@ public function getAuthorizationEndpoint()
*/
public function getAccessTokenEndpoint()
{
- return new Uri('https://na1.salesforce.com/services/oauth2/token');
+ return new Uri('https://login.salesforce.com/services/oauth2/token');
}
/**
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php
new file mode 100644
index 0000000..d16ca80
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/ServiceInterface.php
@@ -0,0 +1,33 @@
+baseApiUri = new Uri('https://api.spotify.com/v1/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://accounts.spotify.com/authorize');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://accounts.spotify.com/api/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']);
+
+ 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;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraOAuthHeaders()
+ {
+ return array('Authorization' => 'Basic ' .
+ base64_encode($this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret()));
+ }
+}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Strava.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Strava.php
new file mode 100644
index 0000000..208ec63
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Strava.php
@@ -0,0 +1,147 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://strava.github.io/
+ * @link http://strava.github.io/api/v3/oauth/
+ */
+
+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;
+use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException;
+
+/**
+ * Strava service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link http://strava.github.io/
+ * @link http://strava.github.io/api/v3/oauth/
+ */
+class Strava extends AbstractService
+{
+ /**
+ * Scopes
+ */
+ // default
+ const SCOPE_PUBLIC = 'public';
+ // Modify activities, upload on the user’s behalf
+ const SCOPE_WRITE = 'write';
+ // View private activities and data within privacy zones
+ const SCOPE_VIEW_PRIVATE = 'view_private';
+
+ protected $approvalPrompt = 'auto';
+
+ public function __construct(
+ CredentialsInterface $credentials,
+ ClientInterface $httpClient,
+ TokenStorageInterface $storage,
+ $scopes = array(),
+ UriInterface $baseApiUri = null
+ ) {
+ if (empty($scopes)) {
+ $scopes = array(self::SCOPE_PUBLIC);
+ }
+
+ parent::__construct(
+ $credentials,
+ $httpClient,
+ $storage,
+ $scopes,
+ $baseApiUri,
+ true
+ );
+
+ if (null === $baseApiUri) {
+ $this->baseApiUri = new Uri('https://www.strava.com/api/v3/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://www.strava.com/oauth/authorize?approval_prompt=' . $this->approvalPrompt);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://www.strava.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'])) {
+ 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']);
+
+ 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;
+ }
+
+ public function setApprouvalPrompt($prompt)
+ {
+ if (!in_array($prompt, array('auto', 'force'), true)) {
+ // @todo Maybe could we rename this exception
+ throw new InvalidAccessTypeException('Invalid approuvalPrompt, expected either auto or force.');
+ }
+ $this->approvalPrompt = $prompt;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getScopesDelimiter()
+ {
+ return ',';
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Auth0.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php
similarity index 61%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Auth0.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php
index dd7c902..7e55815 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Auth0.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Ustream.php
@@ -2,7 +2,6 @@
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;
@@ -11,11 +10,15 @@
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\Common\Http\Uri\UriInterface;
-class Auth0 extends AbstractService
+class Ustream extends AbstractService
{
-
- const SCOPE_OPENID = 'openid profile email';
- protected $domain;
+ /**
+ * Scopes
+ *
+ * @var string
+ */
+ const SCOPE_OFFLINE = 'offline';
+ const SCOPE_BROADCASTER = 'broadcaster';
public function __construct(
CredentialsInterface $credentials,
@@ -24,35 +27,35 @@ public function __construct(
$scopes = array(),
UriInterface $baseApiUri = null
) {
- parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
-
- $hlp = plugin_load('helper', 'oauth');
- $this->domain = $hlp->getConf('auth0-domain');
+ parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
if (null === $baseApiUri) {
- $this->baseApiUri = new Uri("https://{$this->domain}/");
+ $this->baseApiUri = new Uri('https://api.ustream.tv/');
}
}
- protected function getAuthorizationMethod()
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
{
- return static::AUTHORIZATION_METHOD_HEADER_BEARER;
+ return new Uri('https://www.ustream.tv/oauth2/authorize');
}
/**
* {@inheritdoc}
*/
- public function getAuthorizationEndpoint()
+ public function getAccessTokenEndpoint()
{
- return new Uri("https://{$this->domain}/authorize/");
+ return new Uri('https://www.ustream.tv/oauth2/token');
}
/**
* {@inheritdoc}
*/
- public function getAccessTokenEndpoint()
+ protected function getAuthorizationMethod()
{
- return new Uri("https://{$this->domain}/oauth/token/");
+ return static::AUTHORIZATION_METHOD_HEADER_BEARER;
}
/**
@@ -60,8 +63,7 @@ public function getAccessTokenEndpoint()
*/
protected function parseAccessTokenResponse($responseBody)
{
- $JSON = new \JSON(JSON_LOOSE_TYPE);
- $data = $JSON->decode($responseBody);
+ $data = json_decode($responseBody, true);
if (null === $data || !is_array($data)) {
throw new TokenResponseException('Unable to parse response.');
@@ -71,10 +73,7 @@ protected function parseAccessTokenResponse($responseBody)
$token = new StdOAuth2Token();
$token->setAccessToken($data['access_token']);
-
- if (isset($data['expires'])) {
- $token->setLifeTime($data['expires']);
- }
+ $token->setLifeTime($data['expires_in']);
if (isset($data['refresh_token'])) {
$token->setRefreshToken($data['refresh_token']);
@@ -82,22 +81,18 @@ protected function parseAccessTokenResponse($responseBody)
}
unset($data['access_token']);
- unset($data['expires']);
+ unset($data['expires_in']);
$token->setExtraParams($data);
return $token;
}
- public function getDialogUri($dialogPath, array $parameters)
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraOAuthHeaders()
{
- if (!isset($parameters['redirect_uri'])) {
- throw new Exception("Redirect uri is mandatory for this request");
- }
-
- $parameters['client_id'] = $this->credentials->getConsumerId();
- $baseUrl = "https://{$this->domain}/authorize/";
- $query = http_build_query($parameters);
- return new Uri($baseUrl . '?' . $query);
+ return array('Authorization' => 'Basic ' . $this->credentials->getConsumerSecret());
}
}
diff --git a/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vimeo.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vimeo.php
new file mode 100644
index 0000000..2efe6b2
--- /dev/null
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vimeo.php
@@ -0,0 +1,156 @@
+
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developer.vimeo.com/
+ * @link https://developer.vimeo.com/api/authentication
+ */
+
+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;
+
+/**
+ * Vimeo service.
+ *
+ * @author Pedro Amorim
+ * @license http://www.opensource.org/licenses/mit-license.html MIT License
+ * @link https://developer.vimeo.com/
+ * @link https://developer.vimeo.com/api/authentication
+ */
+class Vimeo extends AbstractService
+{
+ // API version
+ const VERSION = '3.2';
+ // API Header Accept
+ const HEADER_ACCEPT = 'application/vnd.vimeo.*+json;version=3.2';
+
+ /**
+ * Scopes
+ * @see https://developer.vimeo.com/api/authentication#scope
+ */
+ // View public videos
+ const SCOPE_PUBLIC = 'public';
+ // View private videos
+ const SCOPE_PRIVATE = 'private';
+ // View Vimeo On Demand purchase history
+ const SCOPE_PURCHASED = 'purchased';
+ // Create new videos, groups, albums, etc.
+ const SCOPE_CREATE = 'create';
+ // Edit videos, groups, albums, etc.
+ const SCOPE_EDIT = 'edit';
+ // Delete videos, groups, albums, etc.
+ const SCOPE_DELETE = 'delete';
+ // Interact with a video on behalf of a user, such as liking
+ // a video or adding it to your watch later queue
+ const SCOPE_INTERACT = 'interact';
+ // Upload a video
+ const SCOPE_UPLOAD = 'upload';
+
+ 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.vimeo.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://api.vimeo.com/oauth/authorize');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://api.vimeo.com/oauth/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_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']);
+
+ 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;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraOAuthHeaders()
+ {
+ return array('Accept' => self::HEADER_ACCEPT);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraApiHeaders()
+ {
+ return array('Accept' => self::HEADER_ACCEPT);
+ }
+}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Vkontakte.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php
similarity index 98%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Vkontakte.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php
index ddf7a8e..4a7744e 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Vkontakte.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Vkontakte.php
@@ -17,6 +17,7 @@ class Vkontakte extends AbstractService
*
* @link http://vk.com/dev/permissions
*/
+ const SCOPE_EMAIL = 'email';
const SCOPE_NOTIFY = 'notify';
const SCOPE_FRIENDS = 'friends';
const SCOPE_PHOTOS = 'photos';
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Dataporten.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yahoo.php
similarity index 67%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Dataporten.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yahoo.php
index ccc8809..ee5e985 100644
--- a/phpoauthlib/src/OAuth/OAuth2/Service/Dataporten.php
+++ b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yahoo.php
@@ -4,36 +4,38 @@
use OAuth\OAuth2\Token\StdOAuth2Token;
use OAuth\Common\Http\Exception\TokenResponseException;
-use OAuth\OAuth2\Service\Exception\InvalidAccessTypeException;
use OAuth\Common\Http\Uri\Uri;
-class Dataporten extends AbstractService
+class Yahoo extends AbstractService
{
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function getAuthorizationEndpoint()
{
- return new Uri('https://auth.dataporten.no/oauth/authorization');
+ return new Uri('https://api.login.yahoo.com/oauth2/request_auth');
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function getAccessTokenEndpoint()
{
- return new Uri('https://auth.dataporten.no/oauth/token');
+ return new Uri('https://api.login.yahoo.com/oauth2/get_token');
}
+ /**
+ * {@inheritdoc}
+ */
protected function getAuthorizationMethod()
{
return static::AUTHORIZATION_METHOD_HEADER_BEARER;
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
protected function parseAccessTokenResponse($responseBody)
{
$data = json_decode($responseBody, true);
@@ -60,4 +62,15 @@ protected function parseAccessTokenResponse($responseBody)
return $token;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraOAuthHeaders()
+ {
+ $encodedCredentials = base64_encode(
+ $this->credentials->getConsumerId() . ':' . $this->credentials->getConsumerSecret()
+ );
+ return array('Authorization' => 'Basic ' . $encodedCredentials);
+ }
}
diff --git a/phpoauthlib/src/OAuth/OAuth2/Service/Yammer.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Service/Yammer.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Service/Yammer.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Token/StdOAuth2Token.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Token/StdOAuth2Token.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/StdOAuth2Token.php
diff --git a/phpoauthlib/src/OAuth/OAuth2/Token/TokenInterface.php b/vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/TokenInterface.php
similarity index 100%
rename from phpoauthlib/src/OAuth/OAuth2/Token/TokenInterface.php
rename to vendor/lusitanian/oauth/src/OAuth/OAuth2/Token/TokenInterface.php
diff --git a/phpoauthlib/src/OAuth/ServiceFactory.php b/vendor/lusitanian/oauth/src/OAuth/ServiceFactory.php
similarity index 92%
rename from phpoauthlib/src/OAuth/ServiceFactory.php
rename to vendor/lusitanian/oauth/src/OAuth/ServiceFactory.php
index 2be9c46..cdb2440 100644
--- a/phpoauthlib/src/OAuth/ServiceFactory.php
+++ b/vendor/lusitanian/oauth/src/OAuth/ServiceFactory.php
@@ -97,6 +97,7 @@ public function registerService($serviceName, $className)
* @param TokenStorageInterface $storage
* @param array|null $scopes If creating an oauth2 service, array of scopes
* @param UriInterface|null $baseApiUri
+ * @param string $apiVersion version of the api call
*
* @return ServiceInterface
*/
@@ -105,7 +106,8 @@ public function createService(
CredentialsInterface $credentials,
TokenStorageInterface $storage,
$scopes = array(),
- UriInterface $baseApiUri = null
+ UriInterface $baseApiUri = null,
+ $apiVersion = ""
) {
if (!$this->httpClient) {
// for backwards compatibility.
@@ -116,7 +118,14 @@ public function createService(
$fullyQualifiedServiceName = $this->getFullyQualifiedServiceName($serviceName, $version);
if (class_exists($fullyQualifiedServiceName)) {
- return $this->$buildMethod($fullyQualifiedServiceName, $credentials, $storage, $scopes, $baseApiUri);
+ return $this->$buildMethod(
+ $fullyQualifiedServiceName,
+ $credentials,
+ $storage,
+ $scopes,
+ $baseApiUri,
+ $apiVersion
+ );
}
}
@@ -160,14 +169,16 @@ private function buildV2Service(
CredentialsInterface $credentials,
TokenStorageInterface $storage,
array $scopes,
- UriInterface $baseApiUri = null
+ UriInterface $baseApiUri = null,
+ $apiVersion = ""
) {
return new $serviceName(
$credentials,
$this->httpClient,
$storage,
$this->resolveScopes($serviceName, $scopes),
- $baseApiUri
+ $baseApiUri,
+ $apiVersion
);
}
diff --git a/phpoauthlib/src/OAuth/bootstrap.php b/vendor/lusitanian/oauth/src/OAuth/bootstrap.php
similarity index 100%
rename from phpoauthlib/src/OAuth/bootstrap.php
rename to vendor/lusitanian/oauth/src/OAuth/bootstrap.php