Add legacy api re-direction

- Listen to legacy api calls on the LegacyRedirectListener
- Add LegacyApiRedirectHandler to re-direct to legacy endpoint
-- Using 307 re-direction response to support post re-direction
-- Using api_paths.yaml with the configuration with paths to check

- Setup API tests using codeception
-- Add helper methods to login in v4 and v8 API
- Add Api test to create account using v4 api
- Add Api test to create account using v8 api
- Add unit test for LegacyApiRedirectHandler
This commit is contained in:
Clemente Raposo 2020-05-07 11:15:01 +01:00 committed by Dillon-Brown
parent 2a489cbc7e
commit 6c3e266b5d
18 changed files with 797 additions and 112 deletions

View file

@ -0,0 +1,57 @@
<?php namespace App\Tests;
use Codeception\Util\HttpCode;
use Exception;
class V8ApiAccountsCest
{
/**
* @var string
*/
protected $token;
/**
* @param ApiTester $I
* @throws Exception
*/
public function _before(ApiTester $I): void
{
$this->token = $I->v8Login($I->getConfig('client_id'), $I->getConfig('client_secret'));
}
/**
* Test account record creation
* @param ApiTester $I
*/
public function create(ApiTester $I): void
{
$I->amBearerAuthenticated($this->token);
$I->sendPOST($I->getV8Path('/V8/module'), [
'data' => [
'type' => 'Accounts',
'attributes' => [
'name' => 'V8 Api test Account'
]
]
]);
$I->seeResponseCodeIs(HttpCode::CREATED); // 200
$I->seeResponseIsJson();
$uuidTypeCheck = $I->getUuidJsonType();
$I->seeResponseContainsJson([
'type' => 'Account',
]);
$I->seeResponseMatchesJsonType([
'data' => [
'id' => $uuidTypeCheck,
]
]);
$I->seeResponseContainsJson([
'name' => 'V8 Api test Account'
]);
}
}