Skip to content

Tests: SettingsTestCase::ALLOWED_ENV_VARS does not cover 'ENVIRONMENT_TYPE' #2796

Description

@AlexSkrypnyk

Summary

After the DRUPAL_ENVIRONMENT -> ENVIRONMENT_TYPE rename in 1.40, SettingsTestCase::ALLOWED_ENV_VARS no longer covers the environment-type variable, so a host-set ENVIRONMENT_TYPE is not unset between settings tests and can leak into cases that don't set it.

Observed in Vortex 1.40.2.

Details

ALLOWED_ENV_VARS is a list of prefixes:

const ALLOWED_ENV_VARS = [
  // Service variables.
  'DATABASE_', 'REDIS_', 'COMPOSE_', 'GITHUB_', 'PACKAGE_', 'DOCKER_',
  // Vortex and Drupal variables.
  'VORTEX_', 'DRUPAL_',
];

getRealEnvVarsFilteredNoValues() filters real environment variables with str_starts_with($key, $prefix) and unsets the matches during setEnvVars().

The old DRUPAL_ENVIRONMENT matched the DRUPAL_ prefix and was therefore cleared between tests. The de-namespaced ENVIRONMENT_TYPE matches none of the listed prefixes, so a value present in the real environment survives into EnvironmentSettingsTest cases that do not set it explicitly (for example testEnvironmentNoOverrides), making the environment-dependent assertions non-deterministic depending on the host/CI environment.

Suggested fix

Add the full variable name to the allow-list:

const ALLOWED_ENV_VARS = [
  // Service variables.
  'DATABASE_', 'REDIS_', 'COMPOSE_', 'GITHUB_', 'PACKAGE_', 'DOCKER_',
  // Vortex and Drupal variables.
  'VORTEX_', 'DRUPAL_',
  'ENVIRONMENT_TYPE',
];

str_starts_with($key, 'ENVIRONMENT_TYPE') only matches ENVIRONMENT_TYPE itself (it does not match LAGOON_ENVIRONMENT_TYPE), so no unrelated variables are affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A1Board worker 1

    Type

    No type

    Projects

    Status
    Release queue

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions