mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-02 11:40:47 +05:30
So long codeception, you suck
This commit is contained in:
parent
2637af87ec
commit
806838b8e4
@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
// This is global bootstrap for autoloading
|
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Codeception\Module;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class AuthHelper extends \Codeception\Module
|
|
||||||
{
|
|
||||||
function seeJsonKeyExists($key)
|
|
||||||
{
|
|
||||||
$json = $this->getModule('REST')->grabResponse();
|
|
||||||
$array = json_decode($json);
|
|
||||||
$this->assertTrue(array_key_exists($key, $array));
|
|
||||||
}
|
|
||||||
|
|
||||||
function seeJsonKeyDoesNotExists($key)
|
|
||||||
{
|
|
||||||
$json = $this->getModule('REST')->grabResponse();
|
|
||||||
$array = json_decode($json);
|
|
||||||
$this->assertFalse(array_key_exists($key, $array));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Codeception\Module;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class AuthServerHelper extends \Codeception\Module
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Codeception\Module;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class ResourceServerHelper extends \Codeception\Module
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
class_name: AuthTester
|
|
||||||
modules:
|
|
||||||
enabled: [PhpBrowser, REST, AuthHelper]
|
|
||||||
config:
|
|
||||||
PhpBrowser:
|
|
||||||
url: http://localhost:8000/
|
|
||||||
REST:
|
|
||||||
url: http://localhost:8000/
|
|
@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new AuthTester($scenario);
|
|
||||||
$I->wantTo('get an access token with an authorization code');
|
|
||||||
$I->sendGET('authcode_grant.php/authorize?client_id=testclient&redirect_uri=http%3A%2F%2Fexample.com%2Fredirect&response_type=code&scope=basic');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeHttpHeader('Location');
|
|
||||||
|
|
||||||
$location = $I->grabHttpHeader('Location');
|
|
||||||
$urlParts = parse_url($location);
|
|
||||||
parse_str($urlParts['query'], $queryString);
|
|
||||||
|
|
||||||
$I->sendPOST('authcode_grant.php/access_token', [
|
|
||||||
'client_id' => 'testclient',
|
|
||||||
'redirect_uri' => 'http://example.com/redirect',
|
|
||||||
'client_secret' => 'secret',
|
|
||||||
'code' => $queryString['code'],
|
|
||||||
'grant_type' => 'authorization_code'
|
|
||||||
]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeJsonKeyExists('expires_in');
|
|
||||||
$I->seeJsonKeyExists('access_token');
|
|
||||||
$I->seeResponseContainsJson(['token_type' => 'Bearer']);
|
|
||||||
$I->seeJsonKeyDoesNotExists('foobar');
|
|
File diff suppressed because it is too large
Load Diff
@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new AuthTester($scenario);
|
|
||||||
$I->wantTo('get an access token with client credentials');
|
|
||||||
$I->sendPOST('other_grants.php/access_token', [
|
|
||||||
'client_id' => 'testclient',
|
|
||||||
'client_secret' => 'secret',
|
|
||||||
'grant_type' => 'client_credentials'
|
|
||||||
]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeJsonKeyExists('expires_in');
|
|
||||||
$I->seeJsonKeyExists('access_token');
|
|
||||||
$I->seeResponseContainsJson(['token_type' => 'Bearer']);
|
|
||||||
$I->seeJsonKeyDoesNotExists('foobar');
|
|
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new AuthTester($scenario);
|
|
||||||
$I->wantTo('get an access token with resource owner credentials');
|
|
||||||
$I->sendPOST('other_grants.php/access_token', [
|
|
||||||
'client_id' => 'testclient',
|
|
||||||
'client_secret' => 'secret',
|
|
||||||
'grant_type' => 'password',
|
|
||||||
'username' => 'alexbilbie'
|
|
||||||
]);
|
|
||||||
$I->seeResponseCodeIs(400);
|
|
||||||
$I->seeResponseIsJson();
|
|
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new AuthTester($scenario);
|
|
||||||
$I->wantTo('get an access token with resource owner credentials');
|
|
||||||
$I->sendPOST('other_grants.php/access_token', [
|
|
||||||
'client_id' => 'testclient',
|
|
||||||
'client_secret' => 'secret',
|
|
||||||
'grant_type' => 'password'
|
|
||||||
]);
|
|
||||||
$I->seeResponseCodeIs(400);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'error' => 'invalid_request',
|
|
||||||
'message' => 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter
|
|
||||||
more than once, or is otherwise malformed. Check the "username" parameter.'
|
|
||||||
]);
|
|
@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Here you can initialize variables that will be available to your tests
|
|
@ -1,8 +0,0 @@
|
|||||||
class_name: ResourceServerTester
|
|
||||||
modules:
|
|
||||||
enabled: [PhpBrowser, REST, ResourceServerHelper]
|
|
||||||
config:
|
|
||||||
PhpBrowser:
|
|
||||||
url: http://localhost:8000/
|
|
||||||
REST:
|
|
||||||
url: http://localhost:8000/
|
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new ResourceServerTester($scenario);
|
|
||||||
$I->wantTo('get all users with all fields');
|
|
||||||
$I->sendGET('api.php/users?access_token=iamgod');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
[
|
|
||||||
'username' => 'alexbilbie',
|
|
||||||
'name' => 'Alex Bilbie',
|
|
||||||
'email' => 'hello@alexbilbie.com',
|
|
||||||
'photo' => 'https://s.gravatar.com/avatar/14902eb1dac66b8458ebbb481d80f0a3'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'username' => 'philsturgeon',
|
|
||||||
'name' => 'Phil Sturgeon',
|
|
||||||
'email' => 'email@philsturgeon.co.uk',
|
|
||||||
'photo' => 'https://s.gravatar.com/avatar/14df293d6c5cd6f05996dfc606a6a951'
|
|
||||||
]
|
|
||||||
]);
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new ResourceServerTester($scenario);
|
|
||||||
$I->wantTo('get all users with all basic and email fields');
|
|
||||||
$I->sendGET('api.php/users?access_token=iamphil');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
[
|
|
||||||
'username' => 'alexbilbie',
|
|
||||||
'name' => 'Alex Bilbie',
|
|
||||||
'email' => 'hello@alexbilbie.com'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'username' => 'philsturgeon',
|
|
||||||
'name' => 'Phil Sturgeon',
|
|
||||||
'email' => 'email@philsturgeon.co.uk'
|
|
||||||
]
|
|
||||||
]);
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new ResourceServerTester($scenario);
|
|
||||||
$I->wantTo('get all users with basic and photo fields');
|
|
||||||
$I->sendGET('api.php/users?access_token=iamalex');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
[
|
|
||||||
'username' => 'alexbilbie',
|
|
||||||
'name' => 'Alex Bilbie',
|
|
||||||
'photo' => 'https://s.gravatar.com/avatar/14902eb1dac66b8458ebbb481d80f0a3'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'username' => 'philsturgeon',
|
|
||||||
'name' => 'Phil Sturgeon',
|
|
||||||
'photo' => 'https://s.gravatar.com/avatar/14df293d6c5cd6f05996dfc606a6a951'
|
|
||||||
]
|
|
||||||
]);
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new ResourceServerTester($scenario);
|
|
||||||
$I->wantTo('get all users with an invalid access token');
|
|
||||||
$I->sendGET('api.php/users?access_token=foobar');
|
|
||||||
$I->seeResponseCodeIs(401);
|
|
||||||
$I->seeResponseIsJson();
|
|
@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new ResourceServerTester($scenario);
|
|
||||||
$I->wantTo('get all users without an access token');
|
|
||||||
$I->sendGET('api.php/users');
|
|
||||||
$I->seeResponseCodeIs(400);
|
|
||||||
$I->seeResponseIsJson();
|
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
$I = new ResourceServerTester($scenario);
|
|
||||||
$I->wantTo('get all users with header access token');
|
|
||||||
$I->haveHttpHeader('Authorization', 'Bearer iamgod');
|
|
||||||
$I->sendGET('api.php/users');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
[
|
|
||||||
'username' => 'alexbilbie',
|
|
||||||
'name' => 'Alex Bilbie',
|
|
||||||
'email' => 'hello@alexbilbie.com',
|
|
||||||
'photo' => 'https://s.gravatar.com/avatar/14902eb1dac66b8458ebbb481d80f0a3'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'username' => 'philsturgeon',
|
|
||||||
'name' => 'Phil Sturgeon',
|
|
||||||
'email' => 'email@philsturgeon.co.uk',
|
|
||||||
'photo' => 'https://s.gravatar.com/avatar/14df293d6c5cd6f05996dfc606a6a951'
|
|
||||||
]
|
|
||||||
]);
|
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
// Here you can initialize variables that will be available to your tests
|
|
Loading…
Reference in New Issue
Block a user