fix: fix most of the tests
parent
9b7c693bb9
commit
4ebdbf8ba3
|
@ -56,7 +56,7 @@ class BroodsFixture extends TestFixture
|
|||
'id' => self::BROOD_WIREMOCK_ID,
|
||||
'uuid' => $faker->uuid(),
|
||||
'name' => 'wiremock',
|
||||
'url' => 'http://localhost:8080',
|
||||
'url' => sprintf('http://%s:%s', $_ENV['WIREMOCK_HOST'] ?? 'localhost', $_ENV['WIREMOCK_PORT'] ?? '8080'),
|
||||
'description' => $faker->text,
|
||||
'organisation_id' => OrganisationsFixture::ORGANISATION_B_ID,
|
||||
'trusted' => true,
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\Fixture;
|
||||
|
||||
use Cake\TestSuite\Fixture\TestFixture;
|
||||
|
||||
class MetaTemplateDirectoryFixture extends TestFixture
|
||||
{
|
||||
public $connection = 'test';
|
||||
|
||||
public const META_TEMPLATE_DIRECTORY_ID = 1;
|
||||
public const META_TEMPLATE_DIRECTORY_UUID = '99c7b7c0-23e2-4ba8-9ad4-97bcdadf4c81';
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
$this->records = [
|
||||
[
|
||||
'id' => self::META_TEMPLATE_DIRECTORY_ID,
|
||||
'uuid' => self::META_TEMPLATE_DIRECTORY_UUID,
|
||||
'name' => 'Test Meta Template Directory',
|
||||
'namespace' => 'cerebrate',
|
||||
'version' => '1'
|
||||
]
|
||||
];
|
||||
|
||||
parent::init();
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ class MetaTemplateFieldsFixture extends TestFixture
|
|||
'field' => 'test_field_1',
|
||||
'type' => 'text',
|
||||
'meta_template_id' => MetaTemplatesFixture::ENABLED_TEST_ORG_META_TEMPLATE_ID,
|
||||
'meta_template_directory_id' => MetaTemplateDirectoryFixture::META_TEMPLATE_DIRECTORY_ID,
|
||||
'regex' => null,
|
||||
'multiple' => 1,
|
||||
'enabled' => 1,
|
||||
|
|
|
@ -44,6 +44,7 @@ class MetaTemplatesFixture extends TestFixture
|
|||
$this->records = [
|
||||
[
|
||||
'id' => self::ENABLED_TEST_ORG_META_TEMPLATE_ID,
|
||||
'meta_template_directory_id' => MetaTemplateDirectoryFixture::META_TEMPLATE_DIRECTORY_ID,
|
||||
'scope' => 'organisation',
|
||||
'name' => 'Test Meta Template (enabled)',
|
||||
'namespace' => 'cerebrate',
|
||||
|
@ -58,6 +59,7 @@ class MetaTemplatesFixture extends TestFixture
|
|||
],
|
||||
[
|
||||
'id' => self::DISABLED_TEST_ORG_META_TEMPLATE_ID,
|
||||
'meta_template_directory_id' => MetaTemplateDirectoryFixture::META_TEMPLATE_DIRECTORY_ID,
|
||||
'scope' => 'organisation',
|
||||
'name' => 'Test Meta Template (disabled)',
|
||||
'namespace' => 'cerebrate',
|
||||
|
|
|
@ -15,16 +15,18 @@ trait WireMockTestTrait
|
|||
private $wiremock;
|
||||
|
||||
/** @var array<mixed> */
|
||||
private $config = [
|
||||
'hostname' => 'localhost',
|
||||
'port' => 8080
|
||||
];
|
||||
private $config;
|
||||
|
||||
public function initializeWireMock(): void
|
||||
{
|
||||
$this->config = [
|
||||
'hostname' => $_ENV['WIREMOCK_HOST'] ?? 'localhost',
|
||||
'port' => $_ENV['WIREMOCK_PORT'] ?? 8080
|
||||
];
|
||||
|
||||
$this->wiremock = WireMock::create(
|
||||
$_ENV['WIREMOCK_HOST'] ?? $this->config['hostname'],
|
||||
$_ENV['WIREMOCK_PORT'] ?? $this->config['port']
|
||||
$this->config['hostname'],
|
||||
$this->config['port']
|
||||
);
|
||||
|
||||
if (!$this->wiremock->isAlive()) {
|
||||
|
|
|
@ -31,20 +31,20 @@ class MispInterConnectionTest extends TestCase
|
|||
];
|
||||
|
||||
/** constants related to the local Cerebrate instance */
|
||||
private const LOCAL_CEREBRATE_URL = 'http://127.0.0.1';
|
||||
private const LOCAL_CEREBRATE_URL = 'http://localhost';
|
||||
|
||||
/** constants related to the local MISP instance */
|
||||
private const LOCAL_MISP_INSTANCE_URL = 'http://localhost:8080/MISP_LOCAL';
|
||||
private const LOCAL_MISP_INSTANCE_URL = '/MISP_LOCAL';
|
||||
private const LOCAL_MISP_ADMIN_USER_AUTHKEY = 'b17ce79ac0f05916f382ab06ea4790665dbc174c';
|
||||
|
||||
/** constants related to the remote Cerebrate instance */
|
||||
private const REMOTE_CEREBRATE_URL = 'http://127.0.0.1:8080/CEREBRATE_REMOTE';
|
||||
private const REMOTE_CEREBRATE_URL = '/CEREBRATE_REMOTE';
|
||||
private const REMOTE_CEREBRATE_AUTHKEY = 'a192ba3c749b545f9cec6b6bba0643736f6c3022';
|
||||
|
||||
/** constants related to the remote MISP instance */
|
||||
private const REMOTE_MISP_SYNC_USER_ID = 333;
|
||||
private const REMOTE_MISP_SYNC_USER_EMAIL = 'sync@misp.remote';
|
||||
private const REMOTE_MISP_INSTANCE_URL = 'http://localhost:8080/MISP_REMOTE';
|
||||
private const REMOTE_MISP_INSTANCE_URL = '/MISP_REMOTE';
|
||||
private const REMOTE_MISP_AUTHKEY = '19ca57ecebd2fe34c1c17d729980678eb648d541';
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ class MispInterConnectionTest extends TestCase
|
|||
'name' => 'MISP_LOCAL',
|
||||
'connector' => 'MispConnector',
|
||||
'settings' => json_encode([
|
||||
'url' => self::LOCAL_MISP_INSTANCE_URL,
|
||||
'url' => $this->getWireMockBaseUrl() . self::LOCAL_MISP_INSTANCE_URL,
|
||||
'authkey' => self::LOCAL_MISP_ADMIN_USER_AUTHKEY,
|
||||
'skip_ssl' => true,
|
||||
]),
|
||||
|
@ -90,7 +90,7 @@ class MispInterConnectionTest extends TestCase
|
|||
[
|
||||
'uuid' => $LOCAL_BROOD_UUID,
|
||||
'name' => 'Local Brood',
|
||||
'url' => self::REMOTE_CEREBRATE_URL,
|
||||
'url' => $this->getWireMockBaseUrl() . self::REMOTE_CEREBRATE_URL,
|
||||
'description' => $faker->text,
|
||||
'organisation_id' => OrganisationsFixture::ORGANISATION_A_ID,
|
||||
'trusted' => true,
|
||||
|
@ -228,10 +228,10 @@ class MispInterConnectionTest extends TestCase
|
|||
[
|
||||
'email' => self::REMOTE_MISP_SYNC_USER_EMAIL,
|
||||
'authkey' => self::REMOTE_MISP_AUTHKEY,
|
||||
'url' => self::REMOTE_MISP_INSTANCE_URL,
|
||||
'url' => $this->getWireMockBaseUrl() . self::REMOTE_MISP_INSTANCE_URL,
|
||||
'reflected_user_id' => self::REMOTE_MISP_SYNC_USER_ID,
|
||||
'connectorName' => 'MispConnector',
|
||||
'cerebrateURL' => self::REMOTE_CEREBRATE_URL,
|
||||
'cerebrateURL' => $this->getWireMockBaseUrl() . self::REMOTE_CEREBRATE_URL,
|
||||
'local_tool_id' => 1,
|
||||
'remote_tool_id' => 1,
|
||||
'tool_name' => 'MISP_REMOTE'
|
||||
|
@ -250,7 +250,7 @@ class MispInterConnectionTest extends TestCase
|
|||
self::LOCAL_MISP_ADMIN_USER_AUTHKEY,
|
||||
[
|
||||
'authkey' => self::REMOTE_MISP_AUTHKEY,
|
||||
'url' => self::REMOTE_MISP_INSTANCE_URL,
|
||||
'url' => $this->getWireMockBaseUrl() . self::REMOTE_MISP_INSTANCE_URL,
|
||||
'name' => 'MISP_REMOTE',
|
||||
'remote_org_id' => OrganisationsFixture::ORGANISATION_A_ID
|
||||
]
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Test\TestCase\Api\Users;
|
||||
|
||||
use Cake\Core\Configure;
|
||||
use Cake\TestSuite\TestCase;
|
||||
use App\Test\Fixture\AuthKeysFixture;
|
||||
use App\Test\Fixture\UsersFixture;
|
||||
|
@ -25,6 +26,7 @@ class DeleteUserApiTest extends TestCase
|
|||
|
||||
public function testDeleteUser(): void
|
||||
{
|
||||
Configure::write('user.allow-user-deletion', true);
|
||||
$this->setAuthToken(AuthKeysFixture::ADMIN_API_KEY);
|
||||
$url = sprintf('%s/%d', self::ENDPOINT, UsersFixture::USER_REGULAR_USER_ID);
|
||||
$this->delete($url);
|
||||
|
|
|
@ -40,14 +40,13 @@ class ApplicationTest extends IntegrationTestCase
|
|||
$app->bootstrap();
|
||||
$plugins = $app->getPlugins();
|
||||
|
||||
$this->assertCount(7, $plugins);
|
||||
$this->assertCount(6, $plugins);
|
||||
$this->assertSame('Bake', $plugins->get('Bake')->getName());
|
||||
$this->assertSame('DebugKit', $plugins->get('DebugKit')->getName());
|
||||
$this->assertSame('Migrations', $plugins->get('Migrations')->getName());
|
||||
$this->assertSame('Authentication', $plugins->get('Authentication')->getName());
|
||||
$this->assertSame('ADmad/SocialAuth', $plugins->get('ADmad/SocialAuth')->getName());
|
||||
$this->assertSame('Tags', $plugins->get('Tags')->getName());
|
||||
$this->assertSame('Cake/TwigView', $plugins->get('Cake/TwigView')->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue