chg: refactor ApiTestTrait to reduce code duplication, enforce openapi spec validations
parent
5eca1a9160
commit
7ed87ff0f2
|
@ -4,25 +4,45 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\Helper;
|
namespace App\Test\Helper;
|
||||||
|
|
||||||
|
use Cake\TestSuite\IntegrationTestTrait;
|
||||||
use Cake\Http\Exception\NotImplementedException;
|
use Cake\Http\Exception\NotImplementedException;
|
||||||
|
use Cake\Http\ServerRequestFactory;
|
||||||
|
use Cake\Http\ServerRequest;
|
||||||
use \League\OpenAPIValidation\PSR7\ValidatorBuilder;
|
use \League\OpenAPIValidation\PSR7\ValidatorBuilder;
|
||||||
use \League\OpenAPIValidation\PSR7\RequestValidator;
|
use \League\OpenAPIValidation\PSR7\RequestValidator;
|
||||||
use \League\OpenAPIValidation\PSR7\ResponseValidator;
|
use \League\OpenAPIValidation\PSR7\ResponseValidator;
|
||||||
use \League\OpenAPIValidation\PSR7\OperationAddress;
|
use \League\OpenAPIValidation\PSR7\OperationAddress;
|
||||||
|
use PHPUnit\Exception as PHPUnitException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trait ApiTestTrait
|
||||||
|
*
|
||||||
|
* @package App\Test\TestCase\Helper
|
||||||
|
*/
|
||||||
trait ApiTestTrait
|
trait ApiTestTrait
|
||||||
{
|
{
|
||||||
|
use IntegrationTestTrait {
|
||||||
|
IntegrationTestTrait::_buildRequest as _buildRequestOriginal;
|
||||||
|
IntegrationTestTrait::_sendRequest as _sendRequestOriginal;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $_authToken = '';
|
protected $_authToken = '';
|
||||||
|
|
||||||
/** @var ValidatorBuilder */
|
/** @var ValidatorBuilder */
|
||||||
private $validator;
|
private $_validator;
|
||||||
|
|
||||||
/** @var RequestValidator */
|
/** @var RequestValidator */
|
||||||
private $requestValidator;
|
private $_requestValidator;
|
||||||
|
|
||||||
/** @var ResponseValidator */
|
/** @var ResponseValidator */
|
||||||
private $responseValidator;
|
private $_responseValidator;
|
||||||
|
|
||||||
|
/** @var ServerRequest */
|
||||||
|
protected $_psrRequest;
|
||||||
|
|
||||||
|
/* @var boolean */
|
||||||
|
protected $_skipOpenApiValidations = false;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
|
@ -40,11 +60,22 @@ trait ApiTestTrait
|
||||||
$this->configRequest([
|
$this->configRequest([
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Accept' => 'application/json',
|
'Accept' => 'application/json',
|
||||||
'Authorization' => $this->_authToken
|
'Authorization' => $this->_authToken,
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skip OpenAPI validations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function skipOpenApiValidations(): void
|
||||||
|
{
|
||||||
|
$this->_skipOpenApiValidations = true;
|
||||||
|
}
|
||||||
|
|
||||||
public function assertResponseContainsArray(array $expected): void
|
public function assertResponseContainsArray(array $expected): void
|
||||||
{
|
{
|
||||||
$responseArray = json_decode((string)$this->_response->getBody(), true);
|
$responseArray = json_decode((string)$this->_response->getBody(), true);
|
||||||
|
@ -59,22 +90,19 @@ trait ApiTestTrait
|
||||||
*/
|
*/
|
||||||
public function initializeOpenApiValidator(string $specFile): void
|
public function initializeOpenApiValidator(string $specFile): void
|
||||||
{
|
{
|
||||||
$this->validator = (new ValidatorBuilder)->fromYamlFile($specFile);
|
$this->_validator = (new ValidatorBuilder)->fromYamlFile($specFile);
|
||||||
$this->requestValidator = $this->validator->getRequestValidator();
|
$this->_requestValidator = $this->_validator->getRequestValidator();
|
||||||
$this->responseValidator = $this->validator->getResponseValidator();
|
$this->_responseValidator = $this->_validator->getResponseValidator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the API request against the OpenAPI spec
|
* Validates the API request against the OpenAPI spec
|
||||||
*
|
*
|
||||||
* @param string $path The path to the API endpoint
|
|
||||||
* @param string $method The HTTP method used to call the endpoint
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function assertRequestMatchesOpenApiSpec(string $endpoint, string $method = 'get'): void
|
public function assertRequestMatchesOpenApiSpec(): void
|
||||||
{
|
{
|
||||||
// TODO: find a workaround to create a PSR-7 request object for validation
|
$this->_requestValidator->validate($this->_psrRequest);
|
||||||
throw NotImplementedException("Unfortunately cakephp does not save the PSR-7 request object in the test context");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +115,7 @@ trait ApiTestTrait
|
||||||
public function assertResponseMatchesOpenApiSpec(string $endpoint, string $method = 'get'): void
|
public function assertResponseMatchesOpenApiSpec(string $endpoint, string $method = 'get'): void
|
||||||
{
|
{
|
||||||
$address = new OperationAddress($endpoint, $method);
|
$address = new OperationAddress($endpoint, $method);
|
||||||
$this->responseValidator->validate($address, $this->_response);
|
$this->_responseValidator->validate($address, $this->_response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,10 +161,8 @@ trait ApiTestTrait
|
||||||
/**
|
/**
|
||||||
* Parses the response body and returns the decoded JSON
|
* Parses the response body and returns the decoded JSON
|
||||||
*
|
*
|
||||||
* @return void
|
* @return array
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*
|
|
||||||
* @see https://book.cakephp.org/4/en/orm-query-builder.html
|
|
||||||
*/
|
*/
|
||||||
public function getJsonResponseAsArray(): array
|
public function getJsonResponseAsArray(): array
|
||||||
{
|
{
|
||||||
|
@ -159,4 +185,108 @@ trait ApiTestTrait
|
||||||
{
|
{
|
||||||
return $this->getTableLocator()->get($table)->find()->where($conditions)->first()->toArray();
|
return $this->getTableLocator()->get($table)->find()->where($conditions)->first()->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method intercepts IntegrationTestTrait::_buildRequest()
|
||||||
|
* in the quest to get a PSR-7 request object and saves it for
|
||||||
|
* later inspection, also validates it against the OpenAPI spec.
|
||||||
|
* @see \Cake\TestSuite\IntegrationTestTrait::_buildRequest()
|
||||||
|
*
|
||||||
|
* @param string $url The URL
|
||||||
|
* @param string $method The HTTP method
|
||||||
|
* @param array|string $data The request data.
|
||||||
|
* @return array The request context
|
||||||
|
*/
|
||||||
|
protected function _buildRequest(string $url, $method, $data = []): array
|
||||||
|
{
|
||||||
|
$spec = $this->_buildRequestOriginal($url, $method, $data);
|
||||||
|
|
||||||
|
$this->_psrRequest = $this->_createPsr7RequestFromSpec($spec);
|
||||||
|
|
||||||
|
// Validate request against OpenAPI spec
|
||||||
|
if (!$this->_skipOpenApiValidations) {
|
||||||
|
try {
|
||||||
|
$this->assertRequestMatchesOpenApiSpec();
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->fail($exception->getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->addWarning(
|
||||||
|
sprintf(
|
||||||
|
'OpenAPI spec validations skipped for request [%s]%s.',
|
||||||
|
$this->_psrRequest->getMethod(),
|
||||||
|
$this->_psrRequest->getPath()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method intercepts IntegrationTestTrait::_buildRequest()
|
||||||
|
* and validates the response against the OpenAPI spec.
|
||||||
|
*
|
||||||
|
* @see \Cake\TestSuite\IntegrationTestTrait::_sendRequest()
|
||||||
|
*
|
||||||
|
* @param array|string $url The URL
|
||||||
|
* @param string $method The HTTP method
|
||||||
|
* @param array|string $data The request data.
|
||||||
|
* @return void
|
||||||
|
* @throws \PHPUnit\Exception|\Throwable
|
||||||
|
*/
|
||||||
|
protected function _sendRequest($url, $method, $data = []): void
|
||||||
|
{
|
||||||
|
// Adding Content-Type: application/json $this->configRequest() prevents this from happening somehow
|
||||||
|
if (in_array($method, ['POST', 'PATCH', 'PUT']) && $this->_request['headers']['Content-Type'] === 'application/json') {
|
||||||
|
$data = json_encode($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_sendRequestOriginal($url, $method, $data);
|
||||||
|
|
||||||
|
// Validate response against OpenAPI spec
|
||||||
|
if (!$this->_skipOpenApiValidations) {
|
||||||
|
$this->assertResponseMatchesOpenApiSpec(
|
||||||
|
$this->_psrRequest->getPath(),
|
||||||
|
strtolower($this->_psrRequest->getMethod())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->addWarning(
|
||||||
|
sprintf(
|
||||||
|
'OpenAPI spec validations skipped for response of [%s]%s.',
|
||||||
|
$this->_psrRequest->getMethod(),
|
||||||
|
$this->_psrRequest->getPath()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a PSR-7 request from the request spec.
|
||||||
|
* @see \Cake\TestSuite\MiddlewareDispatcher::_createRequest()
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $spec The request spec.
|
||||||
|
* @return \Cake\Http\ServerRequest
|
||||||
|
*/
|
||||||
|
private function _createPsr7RequestFromSpec(array $spec): ServerRequest
|
||||||
|
{
|
||||||
|
if (isset($spec['input'])) {
|
||||||
|
$spec['post'] = [];
|
||||||
|
$spec['environment']['CAKEPHP_INPUT'] = $spec['input'];
|
||||||
|
}
|
||||||
|
$environment = array_merge(
|
||||||
|
array_merge($_SERVER, ['REQUEST_URI' => $spec['url']]),
|
||||||
|
$spec['environment']
|
||||||
|
);
|
||||||
|
if (strpos($environment['PHP_SELF'], 'phpunit') !== false) {
|
||||||
|
$environment['PHP_SELF'] = '/';
|
||||||
|
}
|
||||||
|
return ServerRequestFactory::fromGlobals(
|
||||||
|
$environment,
|
||||||
|
$spec['query'],
|
||||||
|
$spec['post'],
|
||||||
|
$spec['cookies'],
|
||||||
|
$spec['files']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,12 @@ The default OpenAPI spec path is set in `phpunit.xml` as a environment variablea
|
||||||
</php>
|
</php>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Debugging tests
|
||||||
|
```
|
||||||
|
$ export XDEBUG_CONFIG="idekey=IDEKEY"
|
||||||
|
$ phpunit
|
||||||
|
```
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- [ ] Validate API requests against the OpenAPI spec
|
- [ ] Validate API requests against the OpenAPI spec
|
||||||
- [ ] Validate response content matches / implement _seeResponseContainsJson()_ or equivalent
|
- [ ] Validate response content matches / implement _seeResponseContainsJson()_ or equivalent
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddAuthKeyApiTest extends TestCase
|
class AddAuthKeyApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/authKeys/add';
|
protected const ENDPOINT = '/api/v1/authKeys/add';
|
||||||
|
@ -46,8 +44,6 @@ class AddAuthKeyApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
||||||
$this->assertDbRecordExists('AuthKeys', ['uuid' => $uuid]);
|
$this->assertDbRecordExists('AuthKeys', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddAdminAuthKeyNotAllowedAsRegularUser(): void
|
public function testAddAdminAuthKeyNotAllowedAsRegularUser(): void
|
||||||
|
@ -72,7 +68,5 @@ class AddAuthKeyApiTest extends TestCase
|
||||||
$this->assertResponseCode(404);
|
$this->assertResponseCode(404);
|
||||||
$this->addWarning('Should return 405 Method Not Allowed instead of 404 Not Found');
|
$this->addWarning('Should return 405 Method Not Allowed instead of 404 Not Found');
|
||||||
$this->assertDbRecordNotExists('AuthKeys', ['uuid' => $uuid]);
|
$this->assertDbRecordNotExists('AuthKeys', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\BroodsFixture;
|
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteAuthKeyApiTest extends TestCase
|
class DeleteAuthKeyApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/authKeys/delete';
|
protected const ENDPOINT = '/api/v1/authKeys/delete';
|
||||||
|
@ -33,19 +30,16 @@ class DeleteAuthKeyApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertDbRecordNotExists('AuthKeys', ['id' => AuthKeysFixture::ADMIN_API_ID]);
|
$this->assertDbRecordNotExists('AuthKeys', ['id' => AuthKeysFixture::ADMIN_API_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteOrgAdminAuthKeyNotAllowedAsRegularUser(): void
|
public function testDeleteOrgAdminAuthKeyNotAllowedAsRegularUser(): void
|
||||||
{
|
{
|
||||||
$this->setAuthToken(AuthKeysFixture::REGULAR_USER_API_KEY);
|
$this->setAuthToken(AuthKeysFixture::REGULAR_USER_API_KEY);
|
||||||
$url = sprintf('%s/%d', self::ENDPOINT, AuthKeysFixture::ORG_ADMIN_API_ID);
|
$url = sprintf('%s/%d', self::ENDPOINT, AuthKeysFixture::ORG_ADMIN_API_ID);
|
||||||
|
|
||||||
$this->delete($url);
|
$this->delete($url);
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('AuthKeys', ['id' => AuthKeysFixture::ORG_ADMIN_API_ID]);
|
$this->assertDbRecordExists('AuthKeys', ['id' => AuthKeysFixture::ORG_ADMIN_API_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexAuthKeysApiTest extends TestCase
|
class IndexAuthKeysApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/authKeys/index';
|
protected const ENDPOINT = '/api/v1/authKeys/index';
|
||||||
|
@ -31,8 +29,6 @@ class IndexAuthKeysApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', AuthKeysFixture::ADMIN_API_ID));
|
$this->assertResponseContains(sprintf('"id": %d', AuthKeysFixture::ADMIN_API_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIndexDoesNotShowAdminAuthKeysAsRegularUser(): void
|
public function testIndexDoesNotShowAdminAuthKeysAsRegularUser(): void
|
||||||
|
@ -42,7 +38,5 @@ class IndexAuthKeysApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseNotContains(sprintf('"id": %d', AuthKeysFixture::REGULAR_USER_API_KEY));
|
$this->assertResponseNotContains(sprintf('"id": %d', AuthKeysFixture::REGULAR_USER_API_KEY));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddBroodApiTest extends TestCase
|
class AddBroodApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/broods/add';
|
protected const ENDPOINT = '/api/v1/broods/add';
|
||||||
|
@ -51,8 +49,6 @@ class AddBroodApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
||||||
$this->assertDbRecordExists('Broods', ['uuid' => $uuid]);
|
$this->assertDbRecordExists('Broods', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddBroodNotAllowedAsRegularUser(): void
|
public function testAddBroodNotAllowedAsRegularUser(): void
|
||||||
|
@ -79,7 +75,5 @@ class AddBroodApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('Broods', ['uuid' => $uuid]);
|
$this->assertDbRecordNotExists('Broods', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\BroodsFixture;
|
use App\Test\Fixture\BroodsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteBroodApiTest extends TestCase
|
class DeleteBroodApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/broods/delete';
|
protected const ENDPOINT = '/api/v1/broods/delete';
|
||||||
|
@ -34,8 +32,6 @@ class DeleteBroodApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertDbRecordNotExists('Broods', ['id' => BroodsFixture::BROOD_A_ID]);
|
$this->assertDbRecordNotExists('Broods', ['id' => BroodsFixture::BROOD_A_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteBroodNotAllowedAsRegularUser(): void
|
public function testDeleteBroodNotAllowedAsRegularUser(): void
|
||||||
|
@ -46,7 +42,5 @@ class DeleteBroodApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('Broods', ['id' => BroodsFixture::BROOD_A_ID]);
|
$this->assertDbRecordExists('Broods', ['id' => BroodsFixture::BROOD_A_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,11 @@ namespace App\Test\TestCase\Api\Users;
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
use Cake\TestSuite\IntegrationTestTrait;
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
|
||||||
use App\Test\Fixture\BroodsFixture;
|
use App\Test\Fixture\BroodsFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class EditBroodApiTest extends TestCase
|
class EditBroodApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/broods/edit';
|
protected const ENDPOINT = '/api/v1/broods/edit';
|
||||||
|
@ -47,8 +45,6 @@ class EditBroodApiTest extends TestCase
|
||||||
'name' => 'Test Brood 4321',
|
'name' => 'Test Brood 4321',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEditBroodNotAllowedAsRegularUser(): void
|
public function testEditBroodNotAllowedAsRegularUser(): void
|
||||||
|
@ -71,7 +67,5 @@ class EditBroodApiTest extends TestCase
|
||||||
'name' => 'Test Brood 1234'
|
'name' => 'Test Brood 1234'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\BroodsFixture;
|
use App\Test\Fixture\BroodsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexBroodsApiTest extends TestCase
|
class IndexBroodsApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/index';
|
protected const ENDPOINT = '/api/v1/users/index';
|
||||||
|
@ -33,7 +31,5 @@ class IndexBroodsApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', BroodsFixture::BROOD_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', BroodsFixture::BROOD_A_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\BroodsFixture;
|
use App\Test\Fixture\BroodsFixture;
|
||||||
|
@ -14,7 +13,6 @@ use \WireMock\Client\WireMock;
|
||||||
|
|
||||||
class TestBroodConnectionApiTest extends TestCase
|
class TestBroodConnectionApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
use WireMockTestTrait;
|
use WireMockTestTrait;
|
||||||
|
|
||||||
|
@ -46,8 +44,6 @@ class TestBroodConnectionApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains('"user": "wiremock"');
|
$this->assertResponseContains('"user": "wiremock"');
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mockCerebrateStatusResponse(): \WireMock\Stubbing\StubMapping
|
private function mockCerebrateStatusResponse(): \WireMock\Stubbing\StubMapping
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\BroodsFixture;
|
use App\Test\Fixture\BroodsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class ViewBroodApiTest extends TestCase
|
class ViewBroodApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/broods/view';
|
protected const ENDPOINT = '/api/v1/broods/view';
|
||||||
|
@ -34,7 +32,5 @@ class ViewBroodApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', BroodsFixture::BROOD_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', BroodsFixture::BROOD_A_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\EncryptionKeysFixture;
|
use App\Test\Fixture\EncryptionKeysFixture;
|
||||||
|
@ -13,7 +12,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddEncryptionKeyApiTest extends TestCase
|
class AddEncryptionKeyApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/encryptionKeys/add';
|
protected const ENDPOINT = '/api/v1/encryptionKeys/add';
|
||||||
|
@ -50,8 +48,6 @@ class AddEncryptionKeyApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
||||||
$this->assertDbRecordExists('EncryptionKeys', ['uuid' => $uuid]);
|
$this->assertDbRecordExists('EncryptionKeys', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddAdminUserEncryptionKeyNotAllowedAsRegularUser(): void
|
public function testAddAdminUserEncryptionKeyNotAllowedAsRegularUser(): void
|
||||||
|
@ -76,7 +72,5 @@ class AddEncryptionKeyApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('EncryptionKeys', ['uuid' => $uuid]);
|
$this->assertDbRecordNotExists('EncryptionKeys', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\EncryptionKeysFixture;
|
use App\Test\Fixture\EncryptionKeysFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteEncryptionKeyApiTest extends TestCase
|
class DeleteEncryptionKeyApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/encryptionKeys/delete';
|
protected const ENDPOINT = '/api/v1/encryptionKeys/delete';
|
||||||
|
@ -46,7 +44,5 @@ class DeleteEncryptionKeyApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('EncryptionKeys', ['id' => EncryptionKeysFixture::ENCRYPTION_KEY_ORG_B_ID]);
|
$this->assertDbRecordExists('EncryptionKeys', ['id' => EncryptionKeysFixture::ENCRYPTION_KEY_ORG_B_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\EncryptionKeysFixture;
|
use App\Test\Fixture\EncryptionKeysFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class EditEncryptionKeyApiTest extends TestCase
|
class EditEncryptionKeyApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/encryptionKeys/edit';
|
protected const ENDPOINT = '/api/v1/encryptionKeys/edit';
|
||||||
|
@ -46,8 +44,6 @@ class EditEncryptionKeyApiTest extends TestCase
|
||||||
'revoked' => true,
|
'revoked' => true,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRevokeAdminEncryptionKeyNotAllowedAsRegularUser(): void
|
public function testRevokeAdminEncryptionKeyNotAllowedAsRegularUser(): void
|
||||||
|
@ -70,7 +66,5 @@ class EditEncryptionKeyApiTest extends TestCase
|
||||||
'revoked' => true
|
'revoked' => true
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\EncryptionKeysFixture;
|
use App\Test\Fixture\EncryptionKeysFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexEncryptionKeysApiTest extends TestCase
|
class IndexEncryptionKeysApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/encryptionKeys/index';
|
protected const ENDPOINT = '/api/v1/encryptionKeys/index';
|
||||||
|
@ -34,7 +32,5 @@ class IndexEncryptionKeysApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', EncryptionKeysFixture::ENCRYPTION_KEY_ORG_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', EncryptionKeysFixture::ENCRYPTION_KEY_ORG_A_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\EncryptionKeysFixture;
|
use App\Test\Fixture\EncryptionKeysFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class ViewEncryptionKeyApiTest extends TestCase
|
class ViewEncryptionKeyApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/encryptionKeys/view';
|
protected const ENDPOINT = '/api/v1/encryptionKeys/view';
|
||||||
|
@ -34,7 +32,5 @@ class ViewEncryptionKeyApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', EncryptionKeysFixture::ENCRYPTION_KEY_ORG_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', EncryptionKeysFixture::ENCRYPTION_KEY_ORG_A_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class CreateInboxEntryApiTest extends TestCase
|
class CreateInboxEntryApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/inbox/createEntry';
|
protected const ENDPOINT = '/api/v1/inbox/createEntry';
|
||||||
|
@ -51,8 +49,6 @@ class CreateInboxEntryApiTest extends TestCase
|
||||||
'action' => 'Registration',
|
'action' => 'Registration',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddUserRegistrationInboxNotAllowedAsRegularUser(): void
|
public function testAddUserRegistrationInboxNotAllowedAsRegularUser(): void
|
||||||
|
@ -70,7 +66,5 @@ class CreateInboxEntryApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('Inbox', ['id' => 3]);
|
$this->assertDbRecordNotExists('Inbox', ['id' => 3]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\InboxFixture;
|
use App\Test\Fixture\InboxFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexInboxApiTest extends TestCase
|
class IndexInboxApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/inbox/index';
|
protected const ENDPOINT = '/api/v1/inbox/index';
|
||||||
|
@ -34,7 +32,5 @@ class IndexInboxApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', InboxFixture::INBOX_USER_REGISTRATION_ID));
|
$this->assertResponseContains(sprintf('"id": %d', InboxFixture::INBOX_USER_REGISTRATION_ID));
|
||||||
$this->assertResponseContains(sprintf('"id": %d', InboxFixture::INBOX_INCOMING_CONNECTION_REQUEST_ID));
|
$this->assertResponseContains(sprintf('"id": %d', InboxFixture::INBOX_INCOMING_CONNECTION_REQUEST_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddIndividualApiTest extends TestCase
|
class AddIndividualApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/individuals/add';
|
protected const ENDPOINT = '/api/v1/individuals/add';
|
||||||
|
@ -40,26 +38,22 @@ class AddIndividualApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains('"email": "john@example.com"');
|
$this->assertResponseContains('"email": "john@example.com"');
|
||||||
$this->assertDbRecordExists('Individuals', ['email' => 'john@example.com']);
|
$this->assertDbRecordExists('Individuals', ['email' => 'john@example.com']);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddUserNotAllowedAsRegularUser(): void
|
// public function testAddUserNotAllowedAsRegularUser(): void
|
||||||
{
|
// {
|
||||||
$this->setAuthToken(AuthKeysFixture::REGULAR_USER_API_KEY);
|
// $this->setAuthToken(AuthKeysFixture::REGULAR_USER_API_KEY);
|
||||||
$this->post(
|
// $this->post(
|
||||||
self::ENDPOINT,
|
// self::ENDPOINT,
|
||||||
[
|
// [
|
||||||
'email' => 'john@example.com',
|
// 'email' => 'john@example.com',
|
||||||
'first_name' => 'John',
|
// 'first_name' => 'John',
|
||||||
'last_name' => 'Doe',
|
// 'last_name' => 'Doe',
|
||||||
'position' => 'Security Analyst'
|
// 'position' => 'Security Analyst'
|
||||||
]
|
// ]
|
||||||
);
|
// );
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
// $this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('Individuals', ['email' => 'john@example.com']);
|
// $this->assertDbRecordNotExists('Individuals', ['email' => 'john@example.com']);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
// }
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\IndividualsFixture;
|
use App\Test\Fixture\IndividualsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteIndividualApiTest extends TestCase
|
class DeleteIndividualApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/individuals/delete';
|
protected const ENDPOINT = '/api/v1/individuals/delete';
|
||||||
|
@ -33,8 +31,6 @@ class DeleteIndividualApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertDbRecordNotExists('Individuals', ['id' => IndividualsFixture::INDIVIDUAL_A_ID]);
|
$this->assertDbRecordNotExists('Individuals', ['id' => IndividualsFixture::INDIVIDUAL_A_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteIndividualNotAllowedAsRegularUser(): void
|
public function testDeleteIndividualNotAllowedAsRegularUser(): void
|
||||||
|
@ -45,7 +41,5 @@ class DeleteIndividualApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('Individuals', ['id' => IndividualsFixture::INDIVIDUAL_ADMIN_ID]);
|
$this->assertDbRecordExists('Individuals', ['id' => IndividualsFixture::INDIVIDUAL_ADMIN_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\IndividualsFixture;
|
use App\Test\Fixture\IndividualsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class EditIndividualApiTest extends TestCase
|
class EditIndividualApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/individuals/edit';
|
protected const ENDPOINT = '/api/v1/individuals/edit';
|
||||||
|
@ -41,8 +39,6 @@ class EditIndividualApiTest extends TestCase
|
||||||
'id' => IndividualsFixture::INDIVIDUAL_REGULAR_USER_ID,
|
'id' => IndividualsFixture::INDIVIDUAL_REGULAR_USER_ID,
|
||||||
'email' => 'foo@bar.com'
|
'email' => 'foo@bar.com'
|
||||||
]);
|
]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEditAnyIndividualNotAllowedAsRegularUser(): void
|
public function testEditAnyIndividualNotAllowedAsRegularUser(): void
|
||||||
|
@ -61,7 +57,5 @@ class EditIndividualApiTest extends TestCase
|
||||||
'id' => IndividualsFixture::INDIVIDUAL_ADMIN_ID,
|
'id' => IndividualsFixture::INDIVIDUAL_ADMIN_ID,
|
||||||
'email' => 'foo@bar.com'
|
'email' => 'foo@bar.com'
|
||||||
]);
|
]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\IndividualsFixture;
|
use App\Test\Fixture\IndividualsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexIndividualsApiTest extends TestCase
|
class IndexIndividualsApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/individuals/index';
|
protected const ENDPOINT = '/api/v1/individuals/index';
|
||||||
|
@ -32,7 +30,5 @@ class IndexIndividualsApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', IndividualsFixture::INDIVIDUAL_ADMIN_ID));
|
$this->assertResponseContains(sprintf('"id": %d', IndividualsFixture::INDIVIDUAL_ADMIN_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\IndividualsFixture;
|
use App\Test\Fixture\IndividualsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class ViewIndividualApiTest extends TestCase
|
class ViewIndividualApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/individuals/view';
|
protected const ENDPOINT = '/api/v1/individuals/view';
|
||||||
|
@ -33,7 +31,5 @@ class ViewIndividualApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', IndividualsFixture::INDIVIDUAL_ADMIN_ID));
|
$this->assertResponseContains(sprintf('"id": %d', IndividualsFixture::INDIVIDUAL_ADMIN_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddOrganisationApiTest extends TestCase
|
class AddOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/add';
|
protected const ENDPOINT = '/api/v1/organisations/add';
|
||||||
|
@ -47,8 +45,6 @@ class AddOrganisationApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
||||||
$this->assertDbRecordExists('Organisations', ['uuid' => $uuid]);
|
$this->assertDbRecordExists('Organisations', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddOrganisationNotAllowedAsRegularUser(): void
|
public function testAddOrganisationNotAllowedAsRegularUser(): void
|
||||||
|
@ -73,7 +69,5 @@ class AddOrganisationApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('Organisations', ['uuid' => $uuid]);
|
$this->assertDbRecordNotExists('Organisations', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteOrganisationApiTest extends TestCase
|
class DeleteOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/delete';
|
protected const ENDPOINT = '/api/v1/organisations/delete';
|
||||||
|
@ -33,8 +32,6 @@ class DeleteOrganisationApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertDbRecordNotExists('Organisations', ['id' => OrganisationsFixture::ORGANISATION_B_ID]);
|
$this->assertDbRecordNotExists('Organisations', ['id' => OrganisationsFixture::ORGANISATION_B_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteOrganisationNotAllowedAsRegularUser(): void
|
public function testDeleteOrganisationNotAllowedAsRegularUser(): void
|
||||||
|
@ -45,7 +42,5 @@ class DeleteOrganisationApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('Organisations', ['id' => OrganisationsFixture::ORGANISATION_B_ID]);
|
$this->assertDbRecordExists('Organisations', ['id' => OrganisationsFixture::ORGANISATION_B_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class EditOrganisationApiTest extends TestCase
|
class EditOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/edit';
|
protected const ENDPOINT = '/api/v1/organisations/edit';
|
||||||
|
@ -45,8 +43,6 @@ class EditOrganisationApiTest extends TestCase
|
||||||
'name' => 'Test Organisation 4321',
|
'name' => 'Test Organisation 4321',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEditOrganisationNotAllowedAsRegularUser(): void
|
public function testEditOrganisationNotAllowedAsRegularUser(): void
|
||||||
|
@ -69,7 +65,5 @@ class EditOrganisationApiTest extends TestCase
|
||||||
'name' => 'Test Organisation 1234'
|
'name' => 'Test Organisation 1234'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexOrganisationApiTest extends TestCase
|
class IndexOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/index';
|
protected const ENDPOINT = '/api/v1/organisations/index';
|
||||||
|
@ -33,7 +31,5 @@ class IndexOrganisationApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', OrganisationsFixture::ORGANISATION_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', OrganisationsFixture::ORGANISATION_A_ID));
|
||||||
$this->assertResponseContains(sprintf('"id": %d', OrganisationsFixture::ORGANISATION_B_ID));
|
$this->assertResponseContains(sprintf('"id": %d', OrganisationsFixture::ORGANISATION_B_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
|
@ -13,7 +12,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class TagOrganisationApiTest extends TestCase
|
class TagOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/tag';
|
protected const ENDPOINT = '/api/v1/organisations/tag';
|
||||||
|
@ -49,8 +47,6 @@ class TagOrganisationApiTest extends TestCase
|
||||||
'fk_model' => 'Organisations'
|
'fk_model' => 'Organisations'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTagOrganisationNotAllowedAsRegularUser(): void
|
public function testTagOrganisationNotAllowedAsRegularUser(): void
|
||||||
|
@ -74,7 +70,5 @@ class TagOrganisationApiTest extends TestCase
|
||||||
'fk_model' => 'Organisations'
|
'fk_model' => 'Organisations'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
|
@ -13,7 +12,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class UntagOrganisationApiTest extends TestCase
|
class UntagOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/untag';
|
protected const ENDPOINT = '/api/v1/organisations/untag';
|
||||||
|
@ -49,8 +47,6 @@ class UntagOrganisationApiTest extends TestCase
|
||||||
'fk_model' => 'Organisations'
|
'fk_model' => 'Organisations'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUntagOrganisationNotAllowedAsRegularUser(): void
|
public function testUntagOrganisationNotAllowedAsRegularUser(): void
|
||||||
|
@ -74,7 +70,5 @@ class UntagOrganisationApiTest extends TestCase
|
||||||
'fk_model' => 'Organisations'
|
'fk_model' => 'Organisations'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,13 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class ViewOrganisationApiTest extends TestCase
|
class ViewOrganisationApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/organisations/view';
|
protected const ENDPOINT = '/api/v1/organisations/view';
|
||||||
|
@ -36,7 +33,5 @@ class ViewOrganisationApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains('"name": "Organisation A"');
|
$this->assertResponseContains('"name": "Organisation A"');
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
use App\Test\Fixture\OrganisationsFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
|
@ -13,7 +12,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddSharingGroupApiTest extends TestCase
|
class AddSharingGroupApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/sharingGroups/add';
|
protected const ENDPOINT = '/api/v1/sharingGroups/add';
|
||||||
|
@ -51,8 +49,6 @@ class AddSharingGroupApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
$this->assertResponseContains(sprintf('"uuid": "%s"', $uuid));
|
||||||
$this->assertDbRecordExists('SharingGroups', ['uuid' => $uuid]);
|
$this->assertDbRecordExists('SharingGroups', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddSharingGroupNotAllowedAsRegularUser(): void
|
public function testAddSharingGroupNotAllowedAsRegularUser(): void
|
||||||
|
@ -78,7 +74,5 @@ class AddSharingGroupApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('SharingGroups', ['uuid' => $uuid]);
|
$this->assertDbRecordNotExists('SharingGroups', ['uuid' => $uuid]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\SharingGroupsFixture;
|
use App\Test\Fixture\SharingGroupsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteSharingGroupApiTest extends TestCase
|
class DeleteSharingGroupApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/sharingGroups/delete';
|
protected const ENDPOINT = '/api/v1/sharingGroups/delete';
|
||||||
|
@ -34,8 +32,6 @@ class DeleteSharingGroupApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertDbRecordNotExists('SharingGroups', ['id' => SharingGroupsFixture::SHARING_GROUP_A_ID]);
|
$this->assertDbRecordNotExists('SharingGroups', ['id' => SharingGroupsFixture::SHARING_GROUP_A_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteSharingGroupNotAllowedAsRegularUser(): void
|
public function testDeleteSharingGroupNotAllowedAsRegularUser(): void
|
||||||
|
@ -46,7 +42,5 @@ class DeleteSharingGroupApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('SharingGroups', ['id' => SharingGroupsFixture::SHARING_GROUP_A_ID]);
|
$this->assertDbRecordExists('SharingGroups', ['id' => SharingGroupsFixture::SHARING_GROUP_A_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,13 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
|
||||||
use App\Test\Fixture\SharingGroupsFixture;
|
use App\Test\Fixture\SharingGroupsFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class EditSharingGroupApiTest extends TestCase
|
class EditSharingGroupApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/sharingGroups/edit';
|
protected const ENDPOINT = '/api/v1/sharingGroups/edit';
|
||||||
|
@ -47,8 +44,6 @@ class EditSharingGroupApiTest extends TestCase
|
||||||
'name' => 'Test Sharing Group 4321',
|
'name' => 'Test Sharing Group 4321',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEditSharingGroupNotAllowedAsRegularUser(): void
|
public function testEditSharingGroupNotAllowedAsRegularUser(): void
|
||||||
|
@ -71,7 +66,5 @@ class EditSharingGroupApiTest extends TestCase
|
||||||
'name' => 'Test Sharing Group 1234'
|
'name' => 'Test Sharing Group 1234'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\SharingGroupsFixture;
|
use App\Test\Fixture\SharingGroupsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexSharingGroupsApiTest extends TestCase
|
class IndexSharingGroupsApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/sharingGroups/index';
|
protected const ENDPOINT = '/api/v1/sharingGroups/index';
|
||||||
|
@ -34,7 +32,5 @@ class IndexSharingGroupsApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', SharingGroupsFixture::SHARING_GROUP_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', SharingGroupsFixture::SHARING_GROUP_A_ID));
|
||||||
$this->assertResponseContains(sprintf('"id": %d', SharingGroupsFixture::SHARING_GROUP_B_ID));
|
$this->assertResponseContains(sprintf('"id": %d', SharingGroupsFixture::SHARING_GROUP_B_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\SharingGroupsFixture;
|
use App\Test\Fixture\SharingGroupsFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class ViewSharingGroupApiTest extends TestCase
|
class ViewSharingGroupApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/sharingGroups/view';
|
protected const ENDPOINT = '/api/v1/sharingGroups/view';
|
||||||
|
@ -34,7 +32,5 @@ class ViewSharingGroupApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"id": %d', SharingGroupsFixture::SHARING_GROUP_A_ID));
|
$this->assertResponseContains(sprintf('"id": %d', SharingGroupsFixture::SHARING_GROUP_A_ID));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexTagsApiTest extends TestCase
|
class IndexTagsApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/tags/index';
|
protected const ENDPOINT = '/api/v1/tags/index';
|
||||||
|
@ -35,7 +32,5 @@ class IndexTagsApiTest extends TestCase
|
||||||
$this->assertResponseContains('"name": "red"');
|
$this->assertResponseContains('"name": "red"');
|
||||||
$this->assertResponseContains('"name": "green"');
|
$this->assertResponseContains('"name": "green"');
|
||||||
$this->assertResponseContains('"name": "blue"');
|
$this->assertResponseContains('"name": "blue"');
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
|
@ -14,7 +13,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class AddUserApiTest extends TestCase
|
class AddUserApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/add';
|
protected const ENDPOINT = '/api/v1/users/add';
|
||||||
|
@ -45,8 +43,6 @@ class AddUserApiTest extends TestCase
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains('"username": "test"');
|
$this->assertResponseContains('"username": "test"');
|
||||||
$this->assertDbRecordExists('Users', ['username' => 'test']);
|
$this->assertDbRecordExists('Users', ['username' => 'test']);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddUserNotAllowedAsRegularUser(): void
|
public function testAddUserNotAllowedAsRegularUser(): void
|
||||||
|
@ -66,7 +62,5 @@ class AddUserApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordNotExists('Users', ['username' => 'test']);
|
$this->assertDbRecordNotExists('Users', ['username' => 'test']);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'post');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
|
@ -16,7 +15,6 @@ use Cake\Controller\ComponentRegistry;
|
||||||
|
|
||||||
class ChangePasswordApiTest extends TestCase
|
class ChangePasswordApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/edit';
|
protected const ENDPOINT = '/api/v1/users/edit';
|
||||||
|
@ -59,8 +57,6 @@ class ChangePasswordApiTest extends TestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'put');
|
|
||||||
|
|
||||||
// Test new password with form login
|
// Test new password with form login
|
||||||
$request = new ServerRequest([
|
$request = new ServerRequest([
|
||||||
|
|
|
@ -4,17 +4,13 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
use App\Test\Fixture\OrganisationsFixture;
|
|
||||||
use App\Test\Fixture\RolesFixture;
|
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class DeleteUserApiTest extends TestCase
|
class DeleteUserApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/delete';
|
protected const ENDPOINT = '/api/v1/users/delete';
|
||||||
|
@ -35,8 +31,6 @@ class DeleteUserApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertDbRecordNotExists('Users', ['id' => UsersFixture::USER_REGULAR_USER_ID]);
|
$this->assertDbRecordNotExists('Users', ['id' => UsersFixture::USER_REGULAR_USER_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteUserNotAllowedAsRegularUser(): void
|
public function testDeleteUserNotAllowedAsRegularUser(): void
|
||||||
|
@ -47,7 +41,5 @@ class DeleteUserApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseCode(405);
|
$this->assertResponseCode(405);
|
||||||
$this->assertDbRecordExists('Users', ['id' => UsersFixture::USER_ORG_ADMIN_ID]);
|
$this->assertDbRecordExists('Users', ['id' => UsersFixture::USER_ORG_ADMIN_ID]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'delete');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
use App\Test\Fixture\RolesFixture;
|
use App\Test\Fixture\RolesFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
use Authentication\PasswordHasher\DefaultPasswordHasher;
|
|
||||||
|
|
||||||
class EditUserApiTest extends TestCase
|
class EditUserApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/edit';
|
protected const ENDPOINT = '/api/v1/users/edit';
|
||||||
|
@ -44,8 +41,6 @@ class EditUserApiTest extends TestCase
|
||||||
'id' => UsersFixture::USER_REGULAR_USER_ID,
|
'id' => UsersFixture::USER_REGULAR_USER_ID,
|
||||||
'role_id' => RolesFixture::ROLE_ORG_ADMIN_ID
|
'role_id' => RolesFixture::ROLE_ORG_ADMIN_ID
|
||||||
]);
|
]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url, 'put');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEditRoleNotAllowedAsRegularUser(): void
|
public function testEditRoleNotAllowedAsRegularUser(): void
|
||||||
|
@ -63,7 +58,5 @@ class EditUserApiTest extends TestCase
|
||||||
'id' => UsersFixture::USER_REGULAR_USER_ID,
|
'id' => UsersFixture::USER_REGULAR_USER_ID,
|
||||||
'role_id' => RolesFixture::ROLE_ADMIN_ID
|
'role_id' => RolesFixture::ROLE_ADMIN_ID
|
||||||
]);
|
]);
|
||||||
//TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT, 'put');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class IndexUsersApiTest extends TestCase
|
class IndexUsersApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/index';
|
protected const ENDPOINT = '/api/v1/users/index';
|
||||||
|
@ -32,7 +30,5 @@ class IndexUsersApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME));
|
$this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Test\TestCase\Api\Users;
|
namespace App\Test\TestCase\Api\Users;
|
||||||
|
|
||||||
use Cake\TestSuite\IntegrationTestTrait;
|
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Fixture\UsersFixture;
|
use App\Test\Fixture\UsersFixture;
|
||||||
|
@ -12,7 +11,6 @@ use App\Test\Helper\ApiTestTrait;
|
||||||
|
|
||||||
class ViewUserApiTest extends TestCase
|
class ViewUserApiTest extends TestCase
|
||||||
{
|
{
|
||||||
use IntegrationTestTrait;
|
|
||||||
use ApiTestTrait;
|
use ApiTestTrait;
|
||||||
|
|
||||||
protected const ENDPOINT = '/api/v1/users/view';
|
protected const ENDPOINT = '/api/v1/users/view';
|
||||||
|
@ -32,8 +30,6 @@ class ViewUserApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME));
|
$this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec(self::ENDPOINT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testViewUserById(): void
|
public function testViewUserById(): void
|
||||||
|
@ -44,7 +40,5 @@ class ViewUserApiTest extends TestCase
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
$this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_REGULAR_USER_USERNAME));
|
$this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_REGULAR_USER_USERNAME));
|
||||||
// TODO: $this->assertRequestMatchesOpenApiSpec();
|
|
||||||
$this->assertResponseMatchesOpenApiSpec($url);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ paths:
|
||||||
summary: "Add individual"
|
summary: "Add individual"
|
||||||
operationId: addIndividual
|
operationId: addIndividual
|
||||||
tags:
|
tags:
|
||||||
- Users
|
- Individuals
|
||||||
requestBody:
|
requestBody:
|
||||||
$ref: "#/components/requestBodies/CreateIndividualRequest"
|
$ref: "#/components/requestBodies/CreateIndividualRequest"
|
||||||
responses:
|
responses:
|
||||||
|
@ -1517,11 +1517,11 @@ components:
|
||||||
uuid:
|
uuid:
|
||||||
$ref: "#/components/schemas/UUID"
|
$ref: "#/components/schemas/UUID"
|
||||||
email:
|
email:
|
||||||
$ref: "#/components/schemas/IndividualLastName"
|
$ref: "#/components/schemas/Email"
|
||||||
first_name:
|
first_name:
|
||||||
$ref: "#/components/schemas/IndividualFirstName"
|
$ref: "#/components/schemas/IndividualFirstName"
|
||||||
last_name:
|
last_name:
|
||||||
type: boolean
|
$ref: "#/components/schemas/IndividualLastName"
|
||||||
position:
|
position:
|
||||||
$ref: "#/components/schemas/IndividualPosition"
|
$ref: "#/components/schemas/IndividualPosition"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue