Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/Messenger/Bridge/Redis/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ CHANGELOG
-----

* Introduced the Redis bridge.
* Added TLS option in the DSN. Example: `redis://127.0.0.1?tls=1`
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\Component\Messenger\Bridge\Redis\Tests\Transport;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Exception\TransportException;
use Symfony\Component\Messenger\Bridge\Redis\Transport\Connection;
use Symfony\Component\Messenger\Exception\TransportException;

/**
* @requires extension redis >= 4.3.0
Expand Down Expand Up @@ -73,6 +73,28 @@ public function testFromDsnWithOptions()
);
}

public function testFromDsnWithTls()
{
$redis = $this->createMock(\Redis::class);
$redis->expects($this->once())
->method('connect')
->with('tls://127.0.0.1', 6379)
->willReturn(null);

Connection::fromDsn('redis://127.0.0.1?tls=1', [], $redis);
}

public function testFromDsnWithTlsOption()
{
$redis = $this->createMock(\Redis::class);
$redis->expects($this->once())
->method('connect')
->with('tls://127.0.0.1', 6379)
->willReturn(null);

Connection::fromDsn('redis://127.0.0.1', ['tls' => true], $redis);
}

public function testFromDsnWithQueryOptions()
{
$this->assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
unset($redisOptions['dbindex']);
}

$tls = false;
if (\array_key_exists('tls', $redisOptions)) {
$tls = filter_var($redisOptions['tls'], FILTER_VALIDATE_BOOLEAN);
unset($redisOptions['tls']);
}

$configuration = [
'stream' => $redisOptions['stream'] ?? null,
'group' => $redisOptions['group'] ?? null,
Expand All @@ -125,6 +131,9 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
$configuration['stream'] = $pathParts[1] ?? $configuration['stream'];
$configuration['group'] = $pathParts[2] ?? $configuration['group'];
$configuration['consumer'] = $pathParts[3] ?? $configuration['consumer'];
if ($tls) {
$connectionCredentials['host'] = 'tls://'.$connectionCredentials['host'];
}
} else {
$connectionCredentials = [
'host' => $parsedUrl['path'],
Expand Down