diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:41:47 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:41:47 -0500 |
commit | c80c15dcc33a70acc2b177691d33f088f8c2541e (patch) | |
tree | bc3e44e35b97b751c145cc5797a0faf356922244 /vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php | |
parent | c91ff61cdfa8b5eb76783927e5b8710f2a9f2601 (diff) |
Include all vendor files in the repo to be easier for people
Diffstat (limited to 'vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php')
-rw-r--r-- | vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php b/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php new file mode 100644 index 00000000..508aea00 --- /dev/null +++ b/vendor/lusitanian/oauth/tests/Mocks/OAuth2/Service/Mock.php @@ -0,0 +1,58 @@ +<?php + +namespace OAuthTest\Mocks\OAuth2\Service; + +use OAuth\OAuth2\Service\AbstractService; +use OAuth\Common\Http\Uri\Uri; +use OAuth\OAuth2\Token\StdOAuth2Token; + +class Mock extends AbstractService +{ + const SCOPE_MOCK = 'mock'; + const SCOPE_MOCK_2 = 'mock2'; + + private $authorizationMethod = null; + + public function getAuthorizationEndpoint() + { + return new Uri('http://pieterhordijk.com/auth'); + } + + public function getAccessTokenEndpoint() + { + return new Uri('http://pieterhordijk.com/access'); + } + + protected function parseAccessTokenResponse($responseBody) + { + return new StdOAuth2Token(); + } + + // this allows us to set different auth methods for tests + public function setAuthorizationMethod($method) + { + $this->authorizationMethod = $method; + } + + /** + * Returns a class constant from ServiceInterface defining the authorization method used for the API + * Header is the sane default. + * + * @return int + */ + protected function getAuthorizationMethod() + { + switch($this->authorizationMethod) { + case 'querystring': + return static::AUTHORIZATION_METHOD_QUERY_STRING; + + case 'querystring2': + return static::AUTHORIZATION_METHOD_QUERY_STRING_V2; + + case 'bearer': + return static::AUTHORIZATION_METHOD_HEADER_BEARER; + } + + return parent::getAuthorizationMethod(); + } +} |