Skip to content

Commit

Permalink
Removed filter on username for redis configuration parameter. (#36299)
Browse files Browse the repository at this point in the history
  • Loading branch information
SPie authored Feb 17, 2021
1 parent e66fb52 commit 918db60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Redis/RedisManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function parseConnectionConfiguration($config)
}

return array_filter($parsed, function ($key) {
return ! in_array($key, ['driver', 'username'], true);
return ! in_array($key, ['driver'], true);
}, ARRAY_FILTER_USE_KEY);
}

Expand Down
23 changes: 23 additions & 0 deletions tests/Redis/RedisConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,27 @@ public function testScheme()
$this->assertSame("tcp://{$host}", $phpRedisClient->getHost());
$this->assertEquals($port, $phpRedisClient->getPort());
}

public function testPredisConfigurationWithUsername()
{
$host = env('REDIS_HOST', '127.0.0.1');
$port = env('REDIS_PORT', 6379);
$username = 'testuser';
$password = 'testpw';

$predis = new RedisManager(new Application, 'predis', [
'default' => [
'host' => $host,
'port' => $port,
'username' => $username,
'password' => $password,
'database' => 5,
'timeout' => 0.5,
],
]);
$predisClient = $predis->connection()->client();
$parameters = $predisClient->getConnection()->getParameters();
$this->assertEquals($username, $parameters->username);
$this->assertEquals($password, $parameters->password);
}
}

0 comments on commit 918db60

Please sign in to comment.