Bugfixing wrong typed password setting
This commit is contained in:
parent
4666b18e5b
commit
50d8dbb123
|
@ -95,8 +95,8 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
||||||
|
|
||||||
if ($this->hidePasswordOutput &&
|
if ($this->hidePasswordOutput &&
|
||||||
$key == 'password' &&
|
$key == 'password' &&
|
||||||
!empty($value)) {
|
!empty($value) && is_string($value)) {
|
||||||
$this->config[$cat][$key] = new HiddenString($value);
|
$this->config[$cat][$key] = new HiddenString((string) $value);
|
||||||
} else {
|
} else {
|
||||||
$this->config[$cat][$key] = $value;
|
$this->config[$cat][$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,14 +315,37 @@ class ConfigCacheTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testEmptyPassword()
|
public function testEmptyPassword()
|
||||||
{
|
{
|
||||||
$confiCache = new ConfigCache([
|
$configCache = new ConfigCache([
|
||||||
'database' => [
|
'database' => [
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'username' => '',
|
'username' => '',
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEmpty($confiCache->get('database', 'password'));
|
$this->assertEmpty($configCache->get('database', 'password'));
|
||||||
$this->assertEmpty($confiCache->get('database', 'username'));
|
$this->assertEmpty($configCache->get('database', 'username'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWrongTypePassword()
|
||||||
|
{
|
||||||
|
$configCache = new ConfigCache([
|
||||||
|
'database' => [
|
||||||
|
'password' => new \stdClass(),
|
||||||
|
'username' => '',
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($configCache->get('database', 'password'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'username'));
|
||||||
|
|
||||||
|
$configCache = new ConfigCache([
|
||||||
|
'database' => [
|
||||||
|
'password' => 23,
|
||||||
|
'username' => '',
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(23, $configCache->get('database', 'password'));
|
||||||
|
$this->assertEmpty($configCache->get('database', 'username'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue