-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #524 from php-enqueue/pr-515
[Redis] Add support of secure\TLS connections (based on PR 515)
- Loading branch information
Showing
5 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ public function testThrowNeitherArrayStringNorNullGivenAsConfig() | |
public function testThrowIfSchemeIsNotAmqp() | ||
{ | ||
$this->expectException(\LogicException::class); | ||
$this->expectExceptionMessage('The given DSN "http://example.com" is not supported. Must start with "redis:".'); | ||
$this->expectExceptionMessage('The given DSN "http://example.com" is not supported. Must start with "redis:" or "rediss:".'); | ||
|
||
new RedisConnectionFactory('http://example.com'); | ||
} | ||
|
@@ -57,6 +57,15 @@ public function testCouldBeCreatedWithRedisInstance() | |
$this->assertSame($redisMock, $context->getRedis()); | ||
} | ||
|
||
public function testThrowIfRedissConnectionUsedWithPhpRedisExtension() | ||
{ | ||
$factory = new RedisConnectionFactory('rediss:?vendor=phpredis'); | ||
|
||
$this->expectException(\LogicException::class); | ||
$this->expectExceptionMessage('The phpredis extension does not support secured connections. Try to use predis library as vendor.'); | ||
$factory->createContext(); | ||
} | ||
|
||
/** | ||
* @dataProvider provideConfigs | ||
* | ||
|
@@ -76,6 +85,7 @@ public static function provideConfigs() | |
null, | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'redis', | ||
'port' => 6379, | ||
'timeout' => null, | ||
'reserved' => null, | ||
|
@@ -92,6 +102,7 @@ public static function provideConfigs() | |
'redis:', | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'redis', | ||
'port' => 6379, | ||
'timeout' => null, | ||
'reserved' => null, | ||
|
@@ -108,6 +119,7 @@ public static function provideConfigs() | |
[], | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'redis', | ||
'port' => 6379, | ||
'timeout' => null, | ||
'reserved' => null, | ||
|
@@ -124,6 +136,7 @@ public static function provideConfigs() | |
'redis://localhost:1234?foo=bar&lazy=0&persisted=true&database=5', | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'redis', | ||
'port' => 1234, | ||
'timeout' => null, | ||
'reserved' => null, | ||
|
@@ -137,10 +150,49 @@ public static function provideConfigs() | |
], | ||
]; | ||
|
||
//check normal redis connection for predis library | ||
yield [ | ||
'redis://localhost:1234?foo=bar&lazy=0&vendor=predis', | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'redis', | ||
'port' => 1234, | ||
'timeout' => null, | ||
'reserved' => null, | ||
'retry_interval' => null, | ||
'vendor' => 'predis', | ||
'persisted' => false, | ||
'lazy' => false, | ||
'foo' => 'bar', | ||
'database' => 0, | ||
'redis' => null, | ||
], | ||
]; | ||
|
||
//check tls connection for predis library | ||
yield [ | ||
'rediss://localhost:1234?foo=bar&lazy=0&vendor=predis', | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'rediss', | ||
'port' => 1234, | ||
'timeout' => null, | ||
'reserved' => null, | ||
'retry_interval' => null, | ||
'vendor' => 'predis', | ||
'persisted' => false, | ||
'lazy' => false, | ||
'foo' => 'bar', | ||
'database' => 0, | ||
'redis' => null, | ||
], | ||
]; | ||
|
||
yield [ | ||
['host' => 'localhost', 'port' => 1234, 'foo' => 'bar'], | ||
[ | ||
'host' => 'localhost', | ||
'scheme' => 'redis', | ||
'port' => 1234, | ||
'timeout' => null, | ||
'reserved' => null, | ||
|
@@ -159,6 +211,7 @@ public static function provideConfigs() | |
'redis://h:[email protected]:111', | ||
[ | ||
'host' => 'ec2-111-1-1-1.compute-1.amazonaws.com', | ||
'scheme' => 'redis', | ||
'port' => 111, | ||
'timeout' => null, | ||
'reserved' => null, | ||
|