From 5ef85e53af4ab04579c839403bd35f4b8bd88159 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 1 Aug 2012 15:41:24 +0100 Subject: [PATCH 01/22] Removed old test file --- test/index.php | 84 -------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 test/index.php diff --git a/test/index.php b/test/index.php deleted file mode 100644 index 0ca23ac0..00000000 --- a/test/index.php +++ /dev/null @@ -1,84 +0,0 @@ - Date: Wed, 1 Aug 2012 15:41:41 +0100 Subject: [PATCH 02/22] Require PHPunit in dev composer mode --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f917cf1d..476135a6 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,10 @@ "homepage": "https://github.com/lncd/OAuth2", "license": "MIT", "require": { - "php": ">=5.3.0" + "php": ">=5.3.0", + }, + "require-dev": { + "EHER/PHPUnit": "*" }, "repositories": [ { From 9935cc5d2119ff8544013a0333a804e09b7a8438 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 1 Aug 2012 15:44:03 +0100 Subject: [PATCH 03/22] JSON error fix --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 476135a6..cff35e42 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "https://github.com/lncd/OAuth2", "license": "MIT", "require": { - "php": ">=5.3.0", + "php": ">=5.3.0" }, "require-dev": { "EHER/PHPUnit": "*" From d0bb79bd7cd04247229373779eeb33a1149f3d57 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 1 Aug 2012 17:15:16 +0100 Subject: [PATCH 04/22] Added phpunit.xml --- tests/phpunit.xml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/phpunit.xml diff --git a/tests/phpunit.xml b/tests/phpunit.xml new file mode 100644 index 00000000..d9d0d406 --- /dev/null +++ b/tests/phpunit.xml @@ -0,0 +1,21 @@ + + + + + ./authentication + + + + + PEAR_INSTALL_DIR + PHP_LIBDIR + + + \ No newline at end of file From 1409df6eb40b07ad33169777cd128b56f31c4bad Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 1 Aug 2012 17:15:29 +0100 Subject: [PATCH 05/22] Started adding tests for auth server --- tests/authentication/server_test.php | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/authentication/server_test.php diff --git a/tests/authentication/server_test.php b/tests/authentication/server_test.php new file mode 100644 index 00000000..f9d4df29 --- /dev/null +++ b/tests/authentication/server_test.php @@ -0,0 +1,37 @@ +oauth = new Oauth2\Authentication\Server(); + + //$this->oauth->registerDbAbstractor($this->oauthdb); + } + + function test_generateCode() + { + $reflector = new ReflectionClass($this->oauth); + $method = $reflector->getMethod('generateCode'); + $method->setAccessible(true); + + $result = $method->invoke($this->oauth); + $result2 = $method->invoke($this->oauth); + + $this->assertEquals(40, strlen($result)); + $this->assertNotEquals($result, $result2); + } + + function test_redirectUri() + { + $result1 = $this->oauth->redirectUri('http://example.com/foo'); + $result2 = $this->oauth->redirectUri('http://example.com/foo', array('foo' => 'bar')); + $result3 = $this->oauth->redirectUri('http://example.com/foo', array('foo' => 'bar'), '#'); + + $this->assertEquals('http://example.com/foo?', $result1); + $this->assertEquals('http://example.com/foo?foo=bar', $result2); + $this->assertEquals('http://example.com/foo#foo=bar', $result3); + } + + +} \ No newline at end of file From 0748ba379b830e4ca39b0c9fb94f8ba29bf3a8cb Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 1 Aug 2012 17:15:48 +0100 Subject: [PATCH 06/22] test executable --- test | 1 + 1 file changed, 1 insertion(+) create mode 100755 test diff --git a/test b/test new file mode 100755 index 00000000..f5147d16 --- /dev/null +++ b/test @@ -0,0 +1 @@ +vendor/bin/phpunit --coverage-text --configuration tests/phpunit.xml From bfab30061efba38a9215e33dff8a5cafc76b8fae Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 4 Aug 2012 09:11:39 +0100 Subject: [PATCH 07/22] Spacing fix --- src/Oauth2/Authentication/Server.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Oauth2/Authentication/Server.php b/src/Oauth2/Authentication/Server.php index a809bb08..7a88b9c9 100644 --- a/src/Oauth2/Authentication/Server.php +++ b/src/Oauth2/Authentication/Server.php @@ -151,8 +151,7 @@ class Server if ($clientDetails === false) { - throw new OAuthServerClientException( - $this->errors['invalid_client'], 8); + throw new OAuthServerClientException($this->errors['invalid_client'], 8); } // Response type From c17cd7b1cc01f65bd7d9755d94f08af7e1cd0d29 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 4 Aug 2012 09:12:12 +0100 Subject: [PATCH 08/22] Fixed variable reference bug --- src/Oauth2/Authentication/Server.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Oauth2/Authentication/Server.php b/src/Oauth2/Authentication/Server.php index 7a88b9c9..d5d7e764 100644 --- a/src/Oauth2/Authentication/Server.php +++ b/src/Oauth2/Authentication/Server.php @@ -174,10 +174,7 @@ class Server // Get and validate scopes if (isset($authParams['scope']) || isset($_GET['scope'])) { - $scopes = $_GET['scope']; - if (isset($authParams['client_id'])) { - $authParams['scope']; - } + $scopes = (isset($_GET['scope'])) ? $_GET['scope'] : $authParams['scope']; $scopes = explode($this->config['scope_delimeter'], $scopes); From a5f019ad19bc400ced6762a0efd85785a470f17c Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 10:59:20 +0100 Subject: [PATCH 09/22] Call database methods via the dbcall() method --- src/Oauth2/Authentication/Server.php | 43 ++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/Oauth2/Authentication/Server.php b/src/Oauth2/Authentication/Server.php index d5d7e764..67fc4e86 100644 --- a/src/Oauth2/Authentication/Server.php +++ b/src/Oauth2/Authentication/Server.php @@ -23,7 +23,7 @@ class Server * Reference to the database abstractor * @var object */ - private $db; + private $db = null; /** * Server configuration @@ -147,7 +147,7 @@ class Server } // Validate client ID and redirect URI - $clientDetails = $this->db->validateClient($params['client_id'], null, $params['redirect_uri']); + $clientDetails = $this->dbcall('validateClient', $params['client_id'], null, $params['redirect_uri']); if ($clientDetails === false) { @@ -196,7 +196,7 @@ class Server foreach ($scopes as $scope) { - $scopeDetails = $this->db->getScope($scope); + $scopeDetails = $this->dbcall('getScope', $scope); if ($scopeDetails === false) { @@ -223,7 +223,7 @@ class Server public function newAuthoriseRequest($type, $typeId, $authoriseParams) { // Remove any old sessions the user might have - $this->db->deleteSession( + $this->dbcall('deleteSession', $authoriseParams['client_id'], $type, $typeId @@ -272,7 +272,7 @@ class Server // new authorisation code otherwise create a new session if ($accessToken !== null) { - $this->db->updateSession( + $this->dbcall('updateSession', $clientId, $type, $typeId, @@ -284,10 +284,10 @@ class Server } else { // Delete any existing sessions just to be sure - $this->db->deleteSession($clientId, $type, $typeId); + $this->dbcall('deleteSession', $clientId, $type, $typeId); // Create a new session - $sessionId = $this->db->newSession( + $sessionId = $this->dbcall('newSession', $clientId, $redirectUri, $type, @@ -301,7 +301,7 @@ class Server // Add the scopes foreach ($scopes as $key => $scope) { - $this->db->addSessionScope($sessionId, $scope['scope']); + $this->dbcall('addSessionScope', $sessionId, $scope['scope']); } @@ -401,7 +401,7 @@ class Server } // Validate client ID and redirect URI - $clientDetails = $this->db->validateClient( + $clientDetails = $this->dbcall('validateClient', $params['client_id'], $params['client_secret'], $params['redirect_uri'] @@ -426,7 +426,7 @@ class Server // Verify the authorization code matches the client_id and the // request_uri - $session = $this->db->validateAuthCode( + $session = $this->dbcall('validateAuthCode', $params['client_id'], $params['redirect_uri'], $params['code'] @@ -445,7 +445,7 @@ class Server $accessTokenExpires = ($this->config['access_token_ttl'] === null) ? null : time() + $this->config['access_token_ttl']; - $this->db->updateSession( + $this->dbcall('updateSession', $session['id'], null, $accessToken, @@ -454,7 +454,7 @@ class Server ); // Update the session's scopes to reference the access token - $this->db->updateSessionScopeAccessToken( + $this->dbcall('updateSessionScopeAccessToken', $session['id'], $accessToken ); @@ -492,4 +492,23 @@ class Server return $redirectUri; } + + /** + * Call database methods from the abstractor + * + * @return mixed The query result + */ + private function dbcall() + { + if ($this->db === null) { + throw new OAuthServerException('No registered database abstractor'); + } + + $args = func_get_args(); + $method = $args[0]; + unset ($args[0]); + $params = $args; + + return call_user_func(array($this, $method), $args); + } } From 2e315fc257c584b5c11184afbab9f5cac65f54b6 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 10:59:36 +0100 Subject: [PATCH 10/22] New tests --- tests/authentication/server_test.php | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tests/authentication/server_test.php b/tests/authentication/server_test.php index f9d4df29..afe69bbc 100644 --- a/tests/authentication/server_test.php +++ b/tests/authentication/server_test.php @@ -33,5 +33,79 @@ class Server_test extends PHPUnit_Framework_TestCase { $this->assertEquals('http://example.com/foo#foo=bar', $result3); } + function test_checkClientAuthoriseParams() + { + // Test without passing params + $_GET['client_id'] = 'test'; + $_GET['redirect_uri'] = 'http://example.com/test'; + $_GET['response_type'] = 'code'; + $_GET['scope'] = 'test'; + + $this->assertEquals(array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'response_type' => 'code', + 'scopes' => array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + ) + ), $this->oauth->checkClientAuthoriseParams()); + + + // Test with passed params + unset($_GET['client_id']); + unset($_GET['redirect_uri']); + unset($_GET['response_type']); + unset($_GET['scope']); + + $params = array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'response_type' => 'code', + 'scope' => 'test' + ); + + $this->assertEquals(array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'response_type' => 'code', + 'scopes' => array(array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + )) + ), $this->oauth->checkClientAuthoriseParams($params)); + } + + function test_newAuthoriseRequest() + { + $result1 = $this->oauth->newAuthoriseRequest('user', '123', array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'scopes' => array(array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + )) + )); + + $result2 = $this->oauth->newAuthoriseRequest('user', '123', array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'scopes' => array(array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + )) + )); + + $this->assertEquals(40, strlen($result1)); + $this->assertNotEquals($result1, $result2); + } } \ No newline at end of file From 7ea3a045cd31b6880f4180e16b2260513f697bc8 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 14:42:02 +0100 Subject: [PATCH 11/22] Moved the phpunit.xml config file to the build folder --- {tests => build}/phpunit.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) rename {tests => build}/phpunit.xml (54%) diff --git a/tests/phpunit.xml b/build/phpunit.xml similarity index 54% rename from tests/phpunit.xml rename to build/phpunit.xml index d9d0d406..8287497a 100644 --- a/tests/phpunit.xml +++ b/build/phpunit.xml @@ -9,7 +9,7 @@ stopOnSkipped="false"> - ./authentication + ../tests/authentication @@ -18,4 +18,12 @@ PHP_LIBDIR + + + + + \ No newline at end of file From 983c1faf0a61fc7ba0bd83c2bf61928628ba79a9 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 14:42:18 +0100 Subject: [PATCH 12/22] Updated build.xml to run PHPUnit --- build.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.xml b/build.xml index 27bfda9f..5c481ea7 100644 --- a/build.xml +++ b/build.xml @@ -1,10 +1,10 @@ - + - + @@ -109,6 +109,13 @@ + + + + + + + From 95068c5176dae54fd49b565f0d1f2534d1f7e2f7 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 14:42:58 +0100 Subject: [PATCH 13/22] Lots of fixes following errors found from unit tests --- src/Oauth2/Authentication/Server.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Oauth2/Authentication/Server.php b/src/Oauth2/Authentication/Server.php index 67fc4e86..1e6ee1f5 100644 --- a/src/Oauth2/Authentication/Server.php +++ b/src/Oauth2/Authentication/Server.php @@ -197,7 +197,7 @@ class Server foreach ($scopes as $scope) { $scopeDetails = $this->dbcall('getScope', $scope); - + //die(var_dump($scopeDetails)); if ($scopeDetails === false) { throw new OAuthServerClientException(sprintf($this->errors['invalid_scope'], $scope), 4); @@ -504,11 +504,15 @@ class Server throw new OAuthServerException('No registered database abstractor'); } + if ( ! $this->db instanceof Database) { + throw new OAuthServerException('Registered database abstractor is not an instance of Oauth2\Authentication\Database'); + } + $args = func_get_args(); $method = $args[0]; - unset ($args[0]); - $params = $args; + unset($args[0]); + $params = array_values($args); - return call_user_func(array($this, $method), $args); + return call_user_func_array(array($this->db, $method), $args); } } From 770580556811fe93b2cf8dc55e14522811656099 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 15:32:11 +0100 Subject: [PATCH 14/22] build sh tool location fix --- test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test b/test index f5147d16..dae89d37 100755 --- a/test +++ b/test @@ -1 +1 @@ -vendor/bin/phpunit --coverage-text --configuration tests/phpunit.xml +vendor/bin/phpunit --coverage-text --configuration build/phpunit.xml From a9e816f336868e333b96c5ff2a5ecb7faaab2115 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 15:32:25 +0100 Subject: [PATCH 15/22] Updated name of project and build location --- build/phpunit.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/phpunit.xml b/build/phpunit.xml index 8287497a..4181c278 100644 --- a/build/phpunit.xml +++ b/build/phpunit.xml @@ -19,11 +19,11 @@ - - - + \ No newline at end of file From 30ef11c1d78294bc0ee0d9e39c9db6660c306c94 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 15:32:35 +0100 Subject: [PATCH 16/22] ALL OF THE TESTS! --- tests/authentication/database_mock.php | 191 +++++++++++++++++++++++++ tests/authentication/server_test.php | 76 ++++++++-- 2 files changed, 254 insertions(+), 13 deletions(-) create mode 100644 tests/authentication/database_mock.php diff --git a/tests/authentication/database_mock.php b/tests/authentication/database_mock.php new file mode 100644 index 00000000..955035ed --- /dev/null +++ b/tests/authentication/database_mock.php @@ -0,0 +1,191 @@ + array( + 'client_id' => 'test', + 'client_secret' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'name' => 'Test Client' + )); + + private $scopes = array('test' => array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + )); + + public function validateClient( + $clientId, + $clientSecret = null, + $redirectUri = null + ) + { + if ($clientId !== $this->clients[0]['client_id']) + { + return false; + } + + if ($clientSecret !== null && $clientSecret !== $this->clients[0]['client_secret']) + { + return false; + } + + if ($redirectUri !== null && $redirectUri !== $this->clients[0]['redirect_uri']) + { + return false; + } + + return $this->clients[0]; + } + + public function newSession( + $clientId, + $redirectUri, + $type = 'user', + $typeId = null, + $authCode = null, + $accessToken = null, + $accessTokenExpire = null, + $stage = 'requested' + ) + { + $id = count($this->sessions); + + $this->sessions[$id] = array( + 'id' => $id, + 'client_id' => $clientId, + 'redirect_uri' => $redirectUri, + 'owner_type' => $type, + 'owner_id' => $typeId, + 'auth_code' => $authCode, + 'access_token' => $accessToken, + 'access_token_expire' => $accessTokenExpire, + 'stage' => $stage + ); + + $this->sessions_client_type_id[$clientId . ':' . $type . ':' . $typeId] = $id; + $this->sessions_code[$clientId . ':' . $redirectUri . ':' . $authCode] = $id; + + return true; + } + + public function updateSession( + $sessionId, + $authCode = null, + $accessToken = null, + $accessTokenExpire = null, + $stage = 'requested' + ) + { + $this->sessions[$sessionId]['auth_code'] = $authCode; + $this->sessions[$sessionId]['access_token'] = $accessToken; + $this->sessions[$sessionId]['access_token_expire'] = $accessTokenExpire; + $this->sessions[$sessionId]['stage'] = $stage; + + return true; + } + + public function deleteSession( + $clientId, + $type, + $typeId + ) + { + $key = $clientId . ':' . $type . ':' . $typeId; + if (isset($this->sessions_client_type_id[$key])) + { + unset($this->sessions[$this->sessions_client_type_id[$key]]); + } + return true; + } + + public function validateAuthCode( + $clientId, + $redirectUri, + $authCode + ) + { + $key = $clientId . ':' . $redirectUri . ':' . $authCode; + + if (isset($this->sessions_code[$key])) + { + return $this->sessions[$this->sessions_code[$key]]; + } + + return false; + } + + public function hasSession( + $type, + $typeId, + $clientId + ) + { + die('not implemented hasSession'); + } + + public function getAccessToken($sessionId) + { + die('not implemented getAccessToken'); + } + + public function removeAuthCode($sessionId) + { + die('not implemented removeAuthCode'); + } + + public function setAccessToken( + $sessionId, + $accessToken + ) + { + die('not implemented setAccessToken'); + } + + public function addSessionScope( + $sessionId, + $scope + ) + { + if ( ! isset($this->session_scopes[$sessionId])) + { + $this->session_scopes[$sessionId] = array(); + } + + $this->session_scopes[$sessionId][] = $scope; + + return true; + } + + public function getScope($scope) + { + if ( ! isset($this->scopes[$scope])) + { + return false; + } + + return $this->scopes[$scope]; + } + + public function updateSessionScopeAccessToken( + $sessionId, + $accessToken + ) + { + return true; + } + + public function accessTokenScopes($accessToken) + { + die('not implemented accessTokenScopes'); + } +} \ No newline at end of file diff --git a/tests/authentication/server_test.php b/tests/authentication/server_test.php index afe69bbc..b479bfb4 100644 --- a/tests/authentication/server_test.php +++ b/tests/authentication/server_test.php @@ -2,11 +2,13 @@ class Server_test extends PHPUnit_Framework_TestCase { - function __construct() + function setUp() { $this->oauth = new Oauth2\Authentication\Server(); - //$this->oauth->registerDbAbstractor($this->oauthdb); + require_once('database_mock.php'); + $this->oauthdb = new OAuthdb(); + $this->oauth->registerDbAbstractor($this->oauthdb); } function test_generateCode() @@ -33,28 +35,34 @@ class Server_test extends PHPUnit_Framework_TestCase { $this->assertEquals('http://example.com/foo#foo=bar', $result3); } - function test_checkClientAuthoriseParams() + function test_checkClientAuthoriseParams_GET() { - // Test without passing params $_GET['client_id'] = 'test'; $_GET['redirect_uri'] = 'http://example.com/test'; $_GET['response_type'] = 'code'; $_GET['scope'] = 'test'; - $this->assertEquals(array( + $expect = array( 'client_id' => 'test', 'redirect_uri' => 'http://example.com/test', 'response_type' => 'code', 'scopes' => array( - 'id' => 1, - 'scope' => 'test', - 'name' => 'test', - 'description' => 'test' + 0 => array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + ) ) - ), $this->oauth->checkClientAuthoriseParams()); + ); + $result = $this->oauth->checkClientAuthoriseParams(); - // Test with passed params + $this->assertEquals($expect, $result); + } + + function test_checkClientAuthoriseParams_PassedParams() + { unset($_GET['client_id']); unset($_GET['redirect_uri']); unset($_GET['response_type']); @@ -71,7 +79,7 @@ class Server_test extends PHPUnit_Framework_TestCase { 'client_id' => 'test', 'redirect_uri' => 'http://example.com/test', 'response_type' => 'code', - 'scopes' => array(array( + 'scopes' => array(0 => array( 'id' => 1, 'scope' => 'test', 'name' => 'test', @@ -81,6 +89,22 @@ class Server_test extends PHPUnit_Framework_TestCase { } function test_newAuthoriseRequest() + { + $result = $this->oauth->newAuthoriseRequest('user', '123', array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'scopes' => array(array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + )) + )); + + $this->assertEquals(40, strlen($result)); + } + + function test_newAuthoriseRequest_isUnique() { $result1 = $this->oauth->newAuthoriseRequest('user', '123', array( 'client_id' => 'test', @@ -104,8 +128,34 @@ class Server_test extends PHPUnit_Framework_TestCase { )) )); - $this->assertEquals(40, strlen($result1)); $this->assertNotEquals($result1, $result2); } + function test_issueAccessToken_POST() + { + $auth_code = $this->oauth->newAuthoriseRequest('user', '123', array( + 'client_id' => 'test', + 'redirect_uri' => 'http://example.com/test', + 'scopes' => array(array( + 'id' => 1, + 'scope' => 'test', + 'name' => 'test', + 'description' => 'test' + )) + )); + + $_POST['client_id'] = 'test'; + $_POST['client_secret'] = 'test'; + $_POST['redirect_uri'] = 'http://example.com/test'; + $_POST['grant_type'] = 'authorization_code'; + $_POST['code'] = $auth_code; + + $result = $this->oauth->issueAccessToken(); + + $this->assertCount(3, $result); + $this->assertArrayHasKey('access_token', $result); + $this->assertArrayHasKey('token_type', $result); + $this->assertArrayHasKey('expires_in', $result); + } + } \ No newline at end of file From 7c7dfec4c45b804c545a61ac6cee76c95bd4bbcd Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 15:48:33 +0100 Subject: [PATCH 17/22] Execute the local phpunit --- build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.xml b/build.xml index 5c481ea7..e79d1880 100644 --- a/build.xml +++ b/build.xml @@ -111,7 +111,7 @@ - + From 9aa8f86f3ada2a7fe6036d4d1bafb846a04b9561 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 15:53:10 +0100 Subject: [PATCH 18/22] Remove the composer.lock file and the vendor folder --- build.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.xml b/build.xml index e79d1880..6b21e56c 100644 --- a/build.xml +++ b/build.xml @@ -25,6 +25,8 @@ + + From 095ea72b627af7a7e97a0d14970763e9f85c6c09 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 15:57:57 +0100 Subject: [PATCH 19/22] Added composer install --- build.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build.xml b/build.xml index 6b21e56c..675bc5e5 100644 --- a/build.xml +++ b/build.xml @@ -1,10 +1,11 @@ - + + - + @@ -112,6 +113,13 @@ + + + + + + + From 1a925788e61d7672f9d16fc5d64ff35705d25887 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 16:06:03 +0100 Subject: [PATCH 20/22] Fix for phpunit log paths --- build/phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/phpunit.xml b/build/phpunit.xml index 4181c278..68a07022 100644 --- a/build/phpunit.xml +++ b/build/phpunit.xml @@ -22,8 +22,8 @@ - - + \ No newline at end of file From d743412cf7b85095a2ad4dccc142de3331c3d6ec Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 16:10:22 +0100 Subject: [PATCH 21/22] Trying to get phpunit to log somewhere sensible --- build/phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/phpunit.xml b/build/phpunit.xml index 68a07022..4181c278 100644 --- a/build/phpunit.xml +++ b/build/phpunit.xml @@ -22,8 +22,8 @@ - - + \ No newline at end of file From 176c678c23879f039e4bcf5e035a1b92adf6f5fa Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 6 Aug 2012 16:13:27 +0100 Subject: [PATCH 22/22] Don't remove composer.json and vendor dir --- build.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.xml b/build.xml index 675bc5e5..8008f502 100644 --- a/build.xml +++ b/build.xml @@ -26,8 +26,6 @@ - -