Skip to content

Commit fc90a3b

Browse files
committed
[Messenger] fix ignore account & endpoint options amazon sqs connection
1 parent 08ff65f commit fc90a3b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ public function testFromDsnWithQueueNameOption()
139139
);
140140
}
141141

142+
public function testFromDsnWithAccountAndEndpointOption()
143+
{
144+
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
145+
146+
$this->assertEquals(
147+
new Connection(['account' => 12345], new SqsClient(['endpoint' => 'https://custom-endpoint.tld', 'region' => 'eu-west-1', 'accessKeyId' => null, 'accessKeySecret' => null], null, $httpClient)),
148+
Connection::fromDsn('sqs://default', ['endpoint' => 'https://custom-endpoint.tld', 'account' => 12345], $httpClient)
149+
);
150+
}
151+
142152
public function testKeepGettingPendingMessages()
143153
{
144154
$client = $this->createMock(SqsClient::class);

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
117117
$clientConfiguration['region'] = $matches[1];
118118
}
119119
unset($query['sslmode']);
120+
} elseif (self::DEFAULT_OPTIONS['endpoint'] !== $options['endpoint'] ?? self::DEFAULT_OPTIONS['endpoint']) {
121+
$clientConfiguration['endpoint'] = $options['endpoint'];
120122
}
121123

122124
$parsedPath = explode('/', ltrim($parsedUrl['path'] ?? '/', '/'));
123125
if (\count($parsedPath) > 0 && !empty($queueName = end($parsedPath))) {
124126
$configuration['queue_name'] = $queueName;
125127
}
126-
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : null;
128+
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : $options['account'] ?? self::DEFAULT_OPTIONS['account'];
127129

128130
// check for extra keys in options
129131
$optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy