Skip to content

Commit 0ae369d

Browse files
committed
UHF-11523: Adding environment variable to config processing for e2e test user.
1 parent a4ed3d3 commit 0ae369d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

public/sites/default/settings.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,21 @@ function drupal_get_env(string|array $variables) : mixed {
401401
$config['helfi_search.settings']['openai_model'] = getenv('OPENAI_MODEL');
402402
}
403403

404+
// E2E test users. We should never do this in production, so adding a failsafe
405+
// in case the environment variable would ever end up in production.
406+
if (getenv('APP_ENV') !== 'production' && $e2e_test_user = getenv('E2E_TEST_USER')) {
407+
$e2e_test_user = json_decode($e2e_test_user, TRUE);
408+
409+
// Make sure the user exists in Drupal.
410+
$config['helfi_api_base.api_accounts']['accounts'][] = $e2e_test_user;
411+
412+
// Some features need to be modified for the test user.
413+
// @see Drupal\helfi_tfa\Hook\UserHooks::userLogin().
414+
$config['helfi_platform_config.e2e_test_users']['users'][] = array_intersect_key($e2e_test_user, [
415+
"username" => TRUE,
416+
]);
417+
}
418+
404419
// Environment specific overrides.
405420
if (file_exists(__DIR__ . '/all.settings.php')) {
406421
// phpcs:ignore

0 commit comments

Comments
 (0)