So long codeception, you suck

This commit is contained in:
Alex Bilbie 2014-08-04 15:18:44 +01:00
parent 2637af87ec
commit 806838b8e4
20 changed files with 0 additions and 4499 deletions

View File

@ -1,2 +0,0 @@
<?php
// This is global bootstrap for autoloading

View File

@ -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));
}
}

View File

@ -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
{
}

View File

@ -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
{
}

View File

@ -1,8 +0,0 @@
class_name: AuthTester
modules:
enabled: [PhpBrowser, REST, AuthHelper]
config:
PhpBrowser:
url: http://localhost:8000/
REST:
url: http://localhost:8000/

View File

@ -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

View File

@ -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');

View File

@ -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();

View File

@ -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.'
]);

View File

@ -1,2 +0,0 @@
<?php
// Here you can initialize variables that will be available to your tests

View File

@ -1,8 +0,0 @@
class_name: ResourceServerTester
modules:
enabled: [PhpBrowser, REST, ResourceServerHelper]
config:
PhpBrowser:
url: http://localhost:8000/
REST:
url: http://localhost:8000/

View File

@ -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'
]
]);

View File

@ -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'
]
]);

View File

@ -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'
]
]);

View File

@ -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();

View File

@ -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();

View File

@ -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

View File

@ -1,2 +0,0 @@
<?php
// Here you can initialize variables that will be available to your tests