Skip to content

Commit 6b92038

Browse files
committed
bug #37629 [Messenger] fix ignored account & endpoint options amazon sqs connection (surikman)
This PR was merged into the 5.1 branch. Discussion ---------- [Messenger] fix ignored account & endpoint options amazon sqs connection | Q | A | ------------- | --- | Branch? | 5.1<!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #37598 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch master. --> Commits ------- fc90a3b [Messenger] fix ignore account & endpoint options amazon sqs connection
2 parents ab29e07 + fc90a3b commit 6b92038

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