mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-30 02:33:14 +05:30
Fixed broken example tests
This commit is contained in:
parent
f40ada9ac7
commit
7067a35d3a
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@
|
|||||||
/examples/nosql/vendor
|
/examples/nosql/vendor
|
||||||
/examples/nosql/config/oauth2.sqlite3
|
/examples/nosql/config/oauth2.sqlite3
|
||||||
/examples/relational/composer.lock
|
/examples/relational/composer.lock
|
||||||
/tests/functional/tests/_log
|
/tests/functional/tests/_log
|
||||||
|
tests/_output/*
|
@ -19,14 +19,13 @@ before_script:
|
|||||||
- php -S localhost:8000 &
|
- php -S localhost:8000 &
|
||||||
- sleep 3
|
- sleep 3
|
||||||
- cd ../..
|
- cd ../..
|
||||||
- wget http://codeception.com/codecept.phar
|
- mkdir tests/functional/tests/_log
|
||||||
- mkdir tests/codecept/tests/_log
|
- chmod -R 777 tests/functional/tests/_log
|
||||||
- chmod -R 777 tests/codecept/tests/_log
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p build/logs
|
- mkdir -p build/logs
|
||||||
- phpunit --coverage-text
|
- phpunit --coverage-text
|
||||||
- php codecept.phar run api -c tests/codecept/codeception.yml
|
- ./vendor/bin/codecept run api -d
|
||||||
- ./vendor/bin/phpcs src --standard=psr2
|
- ./vendor/bin/phpcs src --standard=psr2
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
|
actor: Tester
|
||||||
paths:
|
paths:
|
||||||
tests: tests
|
tests: tests
|
||||||
log: tests/_log
|
log: tests/_output
|
||||||
data: tests/_data
|
data: tests/_data
|
||||||
helpers: tests/_helpers
|
helpers: tests/_support
|
||||||
settings:
|
settings:
|
||||||
bootstrap: _bootstrap.php
|
bootstrap: _bootstrap.php
|
||||||
suite_class: \PHPUnit_Framework_TestSuite
|
|
||||||
colors: true
|
colors: true
|
||||||
memory_limit: 1024M
|
memory_limit: 1024M
|
||||||
log: true
|
|
||||||
modules:
|
modules:
|
||||||
config:
|
config:
|
||||||
Db:
|
Db:
|
@ -13,7 +13,7 @@
|
|||||||
"mockery/mockery": "~0.9",
|
"mockery/mockery": "~0.9",
|
||||||
"league/phpunit-coverage-listener": "~1.0",
|
"league/phpunit-coverage-listener": "~1.0",
|
||||||
"squizlabs/php_codesniffer": "1.*",
|
"squizlabs/php_codesniffer": "1.*",
|
||||||
"codeception/codeception": "2.0.2"
|
"codeception/codeception": "2.0.*"
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
|
@ -24,9 +24,9 @@ class AccessTokenStorage extends Adapter implements AccessTokenInterface
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
if (count($result) === 1) {
|
if (count($result) === 1) {
|
||||||
$token = new AccessTokenEntity($this->server);
|
$token = (new AccessTokenEntity($this->server))
|
||||||
$token->setExpireTime($result[0]['expire_time']);
|
->setId($result[0]['access_token'])
|
||||||
$token->setToken($result[0]['access_token']);
|
->setExpireTime($result[0]['expire_time']);
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
@ -50,16 +50,17 @@ class AccessTokenStorage extends Adapter implements AccessTokenInterface
|
|||||||
$result = Capsule::table('oauth_access_token_scopes')
|
$result = Capsule::table('oauth_access_token_scopes')
|
||||||
->select(['oauth_scopes.id', 'oauth_scopes.description'])
|
->select(['oauth_scopes.id', 'oauth_scopes.description'])
|
||||||
->join('oauth_scopes', 'oauth_access_token_scopes.scope', '=', 'oauth_scopes.id')
|
->join('oauth_scopes', 'oauth_access_token_scopes.scope', '=', 'oauth_scopes.id')
|
||||||
->where('access_token', $token->getToken())
|
->where('access_token', $token->getId())
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$response = [];
|
$response = [];
|
||||||
|
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$scope = new ScopeEntity($this->server);
|
$scope = (new ScopeEntity($this->server))->hydrate([
|
||||||
$scope->setId($row['id']);
|
'id' => $row['id'],
|
||||||
$scope->setDescription($row['description']);
|
'description' => $row['description']
|
||||||
|
]);
|
||||||
$response[] = $scope;
|
$response[] = $scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class AuthCodeStorage extends Adapter implements AuthCodeInterface
|
|||||||
|
|
||||||
if (count($result) === 1) {
|
if (count($result) === 1) {
|
||||||
$token = new AuthCodeEntity($this->server);
|
$token = new AuthCodeEntity($this->server);
|
||||||
$token->setToken($result[0]['auth_code']);
|
$token->setId($result[0]['auth_code']);
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ use \League\OAuth2\Server\ResourceServer;
|
|||||||
use \RelationalExample\Storage;
|
use \RelationalExample\Storage;
|
||||||
use \RelationalExample\Model;
|
use \RelationalExample\Model;
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
|
use \League\Event\Emitter;
|
||||||
|
|
||||||
include __DIR__.'/vendor/autoload.php';
|
include __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"illuminate/database": "4.1.*",
|
"illuminate/database": "4.1.*",
|
||||||
"orno/route": "1.*",
|
"orno/route": "1.*",
|
||||||
"ircmaxell/password-compat": "1.0.2"
|
"ircmaxell/password-compat": "1.0.2",
|
||||||
|
"league/event": "0.2.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
10
tests/_support/ApiHelper.php
Normal file
10
tests/_support/ApiHelper.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
namespace Codeception\Module;
|
||||||
|
|
||||||
|
// here you can define custom actions
|
||||||
|
// all public methods declared in helper class will be available in $I
|
||||||
|
|
||||||
|
class ApiHelper extends \Codeception\Module
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
class_name: ApiGuy
|
class_name: ApiTester
|
||||||
modules:
|
modules:
|
||||||
enabled: [PhpBrowser, REST, ApiHelper]
|
enabled: [PhpBrowser, REST, ApiHelper]
|
||||||
config:
|
config:
|
2120
tests/api/ApiTester.php
Normal file
2120
tests/api/ApiTester.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$I = new ApiGuy($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get all users with all fields');
|
$I->wantTo('get all users with all fields');
|
||||||
$I->sendGET('api.php/users?access_token=iamgod');
|
$I->sendGET('api.php/users?access_token=iamgod');
|
||||||
$I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$I = new ApiGuy($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get all users with all basic and email fields');
|
$I->wantTo('get all users with all basic and email fields');
|
||||||
$I->sendGET('api.php/users?access_token=iamphil');
|
$I->sendGET('api.php/users?access_token=iamphil');
|
||||||
$I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$I = new ApiGuy($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get all users with basic and photo fields');
|
$I->wantTo('get all users with basic and photo fields');
|
||||||
$I->sendGET('api.php/users?access_token=iamalex');
|
$I->sendGET('api.php/users?access_token=iamalex');
|
||||||
$I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$I = new ApiGuy($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get all users with an invalid access token');
|
$I->wantTo('get all users with an invalid access token');
|
||||||
$I->sendGET('api.php/users?access_token=foobar');
|
$I->sendGET('api.php/users?access_token=foobar');
|
||||||
$I->seeResponseCodeIs(401);
|
$I->seeResponseCodeIs(401);
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$I = new ApiGuy($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get all users without an access token');
|
$I->wantTo('get all users without an access token');
|
||||||
$I->sendGET('api.php/users');
|
$I->sendGET('api.php/users');
|
||||||
$I->seeResponseCodeIs(400);
|
$I->seeResponseCodeIs(400);
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
$I = new ApiGuy($scenario);
|
$I = new ApiTester($scenario);
|
||||||
$I->wantTo('get all users with header access token');
|
$I->wantTo('get all users with header access token');
|
||||||
$I->haveHttpHeader('Authorization', 'Bearer iamgod');
|
$I->haveHttpHeader('Authorization', 'Bearer iamgod');
|
||||||
$I->sendGET('api.php/users');
|
$I->sendGET('api.php/users');
|
2
tests/api/_bootstrap.php
Normal file
2
tests/api/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
// Here you can initialize variables that will be available to your tests
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Codeception\Module;
|
|
||||||
|
|
||||||
// here you can define custom functions for ApiGuy
|
|
||||||
|
|
||||||
class ApiHelper extends \Codeception\Module
|
|
||||||
{
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Here you can initialize variables that will for your tests
|
|
Loading…
Reference in New Issue
Block a user