Introduce HiddenString for Config-Values

This commit is contained in:
Philipp Holzer 2019-06-10 14:43:25 +02:00
parent f5606fb211
commit 357d9b5108
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
6 changed files with 121 additions and 24 deletions

View file

@ -275,4 +275,38 @@ class ConfigCacheTest extends MockedTest
$this->assertEmpty($configCache->keyDiff($diffConfig));
}
/**
* Test the default hiding of passwords inside the cache
*/
public function testPasswordHide()
{
$configCache = new ConfigCache([
'database' => [
'password' => 'supersecure',
'username' => 'notsecured',
],
]);
$this->assertEquals('supersecure', $configCache->get('database', 'password'));
$this->assertNotEquals('supersecure', print_r($configCache->get('database', 'password'), true));
$this->assertEquals('notsecured', print_r($configCache->get('database', 'username'), true));
}
/**
* Test disabling the hiding of passwords inside the cache
*/
public function testPasswordShow()
{
$configCache = new ConfigCache([
'database' => [
'password' => 'supersecure',
'username' => 'notsecured',
],
], false);
$this->assertEquals('supersecure', $configCache->get('database', 'password'));
$this->assertEquals('supersecure', print_r($configCache->get('database', 'password'), true));
$this->assertEquals('notsecured', print_r($configCache->get('database', 'username'), true));
}
}