Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Nov 2, 2023
1 parent 7f02399 commit 638f01a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 297 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ job-build-no-persist: &job-build-no-persist
command: docker compose exec -T cli vendor/bin/twigcs || [ "${DREVOPS_CI_TWIGCS_IGNORE_FAILURE:-0}" -eq 1 ]
- run:
name: Lint code with NPM linters
command: docker compose exec -T cli bash -c "npm run --prefix \${DREVOPS_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint" || [ "${DREVOPS_CI_NPM_LINT_IGNORE_FAILURE:-0}" -eq 1 ]
command: docker compose exec -T cli bash -c "npm run --prefix \${DREVOPS_WEBROOT}/themes/contrib/\${DRUPAL_THEME} lint" || [ "${DREVOPS_CI_NPM_LINT_IGNORE_FAILURE:-0}" -eq 1 ]
- run:
name: Run tooling tests
command: ./scripts/test-tooling.sh
Expand Down
296 changes: 0 additions & 296 deletions tests/phpunit/Drupal/SwitchableSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,150 +15,6 @@
*/
class SwitchableSettingsTest extends SettingsTestCase {

/**
* Test ClamAV configs in Daemon mode with defaults.
*/
public function testClamavDaemonCustom(): void {
$this->setEnvVars([
'DRUPAL_CLAMAV_ENABLED' => TRUE,
'DRUPAL_CLAMAV_MODE' => 'daemon',
'CLAMAV_HOST' => 'custom_clamav_host',
'CLAMAV_PORT' => 3333,
]);

$this->requireSettingsFile();

$config['clamav.settings']['scan_mode'] = 0;
$config['clamav.settings']['mode_daemon_tcpip']['hostname'] = 'custom_clamav_host';
$config['clamav.settings']['mode_daemon_tcpip']['port'] = 3333;

$this->assertConfigContains($config);
}

/**
* Test ClamAV configs in Executable mode.
*/
public function testClamavExecutable(): void {
$this->setEnvVars([
'DRUPAL_CLAMAV_ENABLED' => TRUE,
'CLAMAV_HOST' => 'custom_clamav_host',
'CLAMAV_PORT' => 3333,
]);

$this->requireSettingsFile();

$config['clamav.settings']['scan_mode'] = 1;
$config['clamav.settings']['executable_path'] = '/usr/bin/clamscan';

$this->assertConfigContains($config);
}

/**
* Test ClamAV configs in Daemon mode with defaults.
*/
public function testClamavDaemonDefaults(): void {
$this->setEnvVars([
'DRUPAL_CLAMAV_ENABLED' => TRUE,
'DRUPAL_CLAMAV_MODE' => 'daemon',
]);

$this->requireSettingsFile();

$config['clamav.settings']['scan_mode'] = 0;
$config['clamav.settings']['mode_daemon_tcpip']['hostname'] = 'clamav';
$config['clamav.settings']['mode_daemon_tcpip']['port'] = 3310;

$this->assertConfigContains($config);
}

/**
* Test Config Split config.
*
* @dataProvider dataProviderConfigSplit
*/
public function testConfigSplit(string $env, array $expected_present, array $expected_absent): void {
$this->setEnvVars([
'DRUPAL_ENVIRONMENT' => $env,
]);

$this->requireSettingsFile();

$this->assertConfigContains($expected_present);
$this->assertConfigNotContains($expected_absent);
}

/**
* Data provider for testConfigSplit().
*/
public function dataProviderConfigSplit(): array {
return [
[
static::ENVIRONMENT_LOCAL,
[
'config_split.config_split.local' => ['status' => TRUE],
],
[
'config_split.config_split.test' => NULL,
'config_split.config_split.dev' => NULL,
'config_split.config_split.ci' => NULL,
],
],
[
static::ENVIRONMENT_CI,
[
'config_split.config_split.ci' => ['status' => TRUE],
],
[
'config_split.config_split.test' => NULL,
'config_split.config_split.dev' => NULL,
'config_split.config_split.local' => NULL,
],
],
[
static::ENVIRONMENT_DEV,
[
'config_split.config_split.dev' => ['status' => TRUE],
],
[
'config_split.config_split.test' => NULL,
'config_split.config_split.ci' => NULL,
'config_split.config_split.local' => NULL,
],
],
[
static::ENVIRONMENT_TEST,
[
'config_split.config_split.test' => ['status' => TRUE],
],
[
'config_split.config_split.dev' => NULL,
'config_split.config_split.ci' => NULL,
'config_split.config_split.local' => NULL,
],
],
[
static::ENVIRONMENT_PROD,
[],
[
'config_split.config_split.test' => NULL,
'config_split.config_split.dev' => NULL,
'config_split.config_split.ci' => NULL,
'config_split.config_split.local' => NULL,
],
],
[
static::ENVIRONMENT_SUT,
[],
[
'config_split.config_split.test' => NULL,
'config_split.config_split.dev' => NULL,
'config_split.config_split.ci' => NULL,
'config_split.config_split.local' => NULL,
],
],
];
}

/**
* Test Environment Indicator config.
*
Expand Down Expand Up @@ -249,30 +105,6 @@ public function testRedis(): void {
$this->assertSettingsContains($settings);
}

/**
* Test Redis partial settings.
*/
public function testRedisPartial(): void {
$this->setEnvVars([
'DRUPAL_REDIS_ENABLED' => 1,
'REDIS_HOST' => 'redis_host',
'REDIS_SERVICE_PORT' => 1234,
'DREVOPS_REDIS_EXTENSION_LOADED' => 0,
]);

$this->requireSettingsFile();

$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['redis.connection']['host'] = 'redis_host';
$settings['redis.connection']['port'] = 1234;
$no_settings['cache']['default'] = 'cache.backend.redis';

$this->assertArrayNotHasKey('bootstrap_container_definition', $this->settings);

$this->assertSettingsContains($settings);
$this->assertSettingsNotContains($no_settings);
}

/**
* Test Shield config.
*
Expand Down Expand Up @@ -391,132 +223,4 @@ public function dataProviderShield(): array {
];
}

/**
* Test Stage File Proxy config.
*
* @dataProvider dataProviderStageFileProxy
*/
public function testStageFileProxy(string $env, array $vars, array $expected_present, array $expected_absent = []): void {
$this->setEnvVars($vars + ['DRUPAL_ENVIRONMENT' => $env]);

$this->requireSettingsFile();

$this->assertConfigContains($expected_present);
$this->assertConfigNotContains($expected_absent);
}

/**
* Data provider for testStageFileProxy().
*/
public function dataProviderStageFileProxy(): array {
return [
[
static::ENVIRONMENT_LOCAL,
[],
[],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://example.com/'],
],
],
[
static::ENVIRONMENT_LOCAL,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://example.com/'],
],
[],
],
[
static::ENVIRONMENT_LOCAL,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://drupal_shield_user:[email protected]/'],
],
[],
],
[
static::ENVIRONMENT_LOCAL,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://example.com/'],
],
[],
],

[
static::ENVIRONMENT_CI,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://drupal_shield_user:[email protected]/'],
],
[],
],

[
static::ENVIRONMENT_DEV,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://drupal_shield_user:[email protected]/'],
],
[],
],

[
static::ENVIRONMENT_TEST,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://drupal_shield_user:[email protected]/'],
],
[],
],

[
static::ENVIRONMENT_PROD,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass',
],
[],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://drupal_shield_user:[email protected]/'],
],
],

[
static::ENVIRONMENT_SUT,
[
'DRUPAL_STAGE_FILE_PROXY_ORIGIN' => 'https://example.com/',
'DRUPAL_SHIELD_USER' => 'drupal_shield_user',
'DRUPAL_SHIELD_PASS' => 'drupal_shield_pass',
],
[
'stage_file_proxy.settings' => ['hotlink' => FALSE, 'origin' => 'https://drupal_shield_user:[email protected]/'],
],
[],
],
];
}

}

0 comments on commit 638f01a

Please sign in to comment.