mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Support loading env vars from secret files
This commit is contained in:
@@ -17,12 +17,16 @@ class EnvVarsTest extends TestCase
|
||||
{
|
||||
putenv(EnvVars::BASE_PATH->value . '=the_base_path');
|
||||
putenv(EnvVars::DB_NAME->value . '=shlink');
|
||||
|
||||
$envFilePath = __DIR__ . '/../DB_PASSWORD.env';
|
||||
putenv(EnvVars::DB_PASSWORD->value . '_FILE=' . $envFilePath);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
putenv(EnvVars::BASE_PATH->value . '=');
|
||||
putenv(EnvVars::DB_NAME->value . '=');
|
||||
putenv(EnvVars::DB_PASSWORD->value . '_FILE=');
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideExistingEnvVars')]
|
||||
@@ -54,4 +58,10 @@ class EnvVarsTest extends TestCase
|
||||
yield 'DB_DRIVER without default' => [EnvVars::DB_DRIVER, null, null];
|
||||
yield 'DB_DRIVER with default' => [EnvVars::DB_DRIVER, 'foobar', 'foobar'];
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function fallsBackToReadEnvVarsFromFile(): void
|
||||
{
|
||||
self::assertEquals('this_is_the_password', EnvVars::DB_PASSWORD->loadFromEnv());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user