Skip to content

Commit

Permalink
Merge pull request #648 from winus/bugfix/ssl-context
Browse files Browse the repository at this point in the history
php-amqplib/php-amqplib takes context as a parameter
  • Loading branch information
mihaileu authored Jul 6, 2021
2 parents 9e5e0ad + fca8fad commit da40764
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RabbitMq/AMQPConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(
}

if (is_array($this->parameters['ssl_context'])) {
$this->parameters['ssl_context'] = ! empty($this->parameters['ssl_context'])
$this->parameters['context'] = ! empty($this->parameters['ssl_context'])
? stream_context_create(array('ssl' => $this->parameters['ssl_context']))
: null;
}
Expand Down
14 changes: 11 additions & 3 deletions Tests/RabbitMq/AMQPConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ public function testSSLConnectionParameters()
$this->assertArrayHasKey(6, $instance->constructParams);
$options = $instance->constructParams[6];
$this->assertArrayHasKey('ssl_context', $options);
$context = $options['ssl_context'];
$this->assertArrayHasKey('context', $options);
$context = $options['context'];
// unset to check whole array at once later
$instance->constructParams[6]['ssl_context'] = null;
$instance->constructParams[6]['context'] = null;
$this->assertIsResource($context);
$this->assertEquals('stream-context', get_resource_type($context));
$options = stream_context_get_options($context);
Expand All @@ -272,6 +274,7 @@ public function testSSLConnectionParameters()
'connection_timeout' => 3,
'read_write_timeout' => 3,
'ssl_context' => null, // context checked earlier
'context' => null, // context checked earlier
'keepalive' => false,
'heartbeat' => 0,
]
Expand Down Expand Up @@ -455,9 +458,11 @@ public function testSSLClusterConnectionParameters()
$this->assertArrayHasKey(6, $instance->constructParams);
$options = $instance->constructParams[6];
$this->assertArrayHasKey('ssl_context', $options);
$context = $options['ssl_context'];
$this->assertArrayHasKey('context', $options);
$context = $options['context'];
// unset to check whole array at once later
$instance->constructParams[6]['ssl_context'] = null;
$instance->constructParams[6]['context'] = null;
$this->assertIsResource($context);
$this->assertEquals('stream-context', get_resource_type($context));
$options = stream_context_get_options($context);
Expand All @@ -466,9 +471,10 @@ public function testSSLClusterConnectionParameters()
$this->assertArrayHasKey(1, $instance::$createConnectionParams);
$createConnectionOptions = $instance::$createConnectionParams[1];
$this->assertArrayHasKey('ssl_context', $createConnectionOptions);
$createConnectionContext = $createConnectionOptions['ssl_context'];
$createConnectionContext = $createConnectionOptions['context'];
// unset to check whole array at once later
$instance::$createConnectionParams[1]['ssl_context'] = null;
$instance::$createConnectionParams[1]['context'] = null;
$this->assertIsResource($createConnectionContext);
$this->assertEquals('stream-context', get_resource_type($createConnectionContext));
$createConnectionOptions = stream_context_get_options($createConnectionContext);
Expand All @@ -491,6 +497,7 @@ public function testSSLClusterConnectionParameters()
'connection_timeout' => 3,
'read_write_timeout' => 3,
'ssl_context' => null,
'context' => null,
'keepalive' => false,
'heartbeat' => 0,
]
Expand Down Expand Up @@ -524,6 +531,7 @@ public function testSSLClusterConnectionParameters()
'connection_timeout' => 3,
'read_write_timeout' => 3,
'ssl_context' => null, // context checked earlier
'context' => null, // context checked earlier
'keepalive' => false,
'heartbeat' => 0
]
Expand Down

0 comments on commit da40764

Please sign in to comment.