Skip to content
Permalink
Browse files

bug #32334 [Messenger] Fix authentication for redis transport (alexan…

…der-schranz)

This PR was merged into the 4.3 branch.

Discussion
----------

[Messenger] Fix authentication for redis transport

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32304
| License       | MIT
| Doc PR        | symfony/symfony-docs#... TODO

This will implement support for password in redis stream transport.

Commits
-------

bedae5d Fix authentication for redis transport
  • Loading branch information...
fabpot committed Jul 3, 2019
2 parents bed50fd + bedae5d commit 09e762e819dc601f40abb5dd93dc08e57c17c62f
@@ -79,6 +79,16 @@ public function testKeepGettingPendingMessages()
$this->assertNotNull($connection->get());
}
public function testAuth()
{
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();
$redis->expects($this->exactly(1))->method('auth')
->with('password');
Connection::fromDsn('redis://password@localhost/queue', [], $redis);
}
public function testFirstGetPendingMessagesThenNewMessages()
{
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();
@@ -51,6 +51,11 @@ public function __construct(array $configuration, array $connectionCredentials =
$this->connection = $redis ?: new \Redis();
$this->connection->connect($connectionCredentials['host'] ?? '127.0.0.1', $connectionCredentials['port'] ?? 6379);
$this->connection->setOption(\Redis::OPT_SERIALIZER, $redisOptions['serializer'] ?? \Redis::SERIALIZER_PHP);
if (isset($connectionCredentials['auth'])) {
$this->connection->auth($connectionCredentials['auth']);
}
$this->stream = $configuration['stream'] ?? self::DEFAULT_OPTIONS['stream'];
$this->group = $configuration['group'] ?? self::DEFAULT_OPTIONS['group'];
$this->consumer = $configuration['consumer'] ?? self::DEFAULT_OPTIONS['consumer'];
@@ -72,6 +77,7 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
$connectionCredentials = [
'host' => $parsedUrl['host'] ?? '127.0.0.1',
'port' => $parsedUrl['port'] ?? 6379,
'auth' => $parsedUrl['pass'] ?? $parsedUrl['user'] ?? null,
];
if (isset($parsedUrl['query'])) {

0 comments on commit 09e762e

Please sign in to comment.
You can’t perform that action at this time.