[Messenger] [Redis] Make auth
option works
This commit is contained in:
parent
da1a33e4b5
commit
7dfdd383c9
@ -169,6 +169,39 @@ class ConnectionTest extends TestCase
|
||||
Connection::fromDsn('redis://password@localhost/queue', [], $redis);
|
||||
}
|
||||
|
||||
public function testAuthFromOptions()
|
||||
{
|
||||
$redis = $this->createMock(\Redis::class);
|
||||
|
||||
$redis->expects($this->exactly(1))->method('auth')
|
||||
->with('password')
|
||||
->willReturn(true);
|
||||
|
||||
Connection::fromDsn('redis://localhost/queue', ['auth' => 'password'], $redis);
|
||||
}
|
||||
|
||||
public function testAuthFromOptionsAndDsn()
|
||||
{
|
||||
$redis = $this->createMock(\Redis::class);
|
||||
|
||||
$redis->expects($this->exactly(1))->method('auth')
|
||||
->with('password2')
|
||||
->willReturn(true);
|
||||
|
||||
Connection::fromDsn('redis://password1@localhost/queue', ['auth' => 'password2'], $redis);
|
||||
}
|
||||
|
||||
public function testAuthAsUserInDsn()
|
||||
{
|
||||
$redis = $this->createMock(\Redis::class);
|
||||
|
||||
$redis->expects($this->exactly(1))->method('auth')
|
||||
->with('password')
|
||||
->willReturn(true);
|
||||
|
||||
Connection::fromDsn('redis://password:localhost/queue', [], $redis);
|
||||
}
|
||||
|
||||
public function testNoAuthWithEmptyPassword()
|
||||
{
|
||||
$redis = $this->createMock(\Redis::class);
|
||||
|
@ -200,7 +200,7 @@ class Connection
|
||||
$connectionCredentials = [
|
||||
'host' => $parsedUrl['host'] ?? '127.0.0.1',
|
||||
'port' => $parsedUrl['port'] ?? 6379,
|
||||
'auth' => $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
|
||||
'auth' => $redisOptions['auth'] ?? $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
|
||||
];
|
||||
|
||||
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));
|
||||
|
Reference in New Issue
Block a user