8000 [Messenger] Fixed check for allowed options in AwsSqs configuration by kroshilin · Pull Request #36873 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Fixed check for allowed options in AwsSqs configuration #36873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,36 @@

class ConnectionTest extends TestCase
{
public function testExtraOptions()
{
$this->expectException(\InvalidArgumentException::class);
Connection::fromDsn('sqs://default/queue', [
'extra_key',
]);
}

public function testExtraParamsInQuery()
{
$this->expectException(\InvalidArgumentException::class);
Connection::fromDsn('sqs://default/queue?extra_param=some_value');
}

public function testConfigureWithCredentials()
{
$awsKey = 'some_aws_access_key_value';
$awsSecret = 'some_aws_secret_value';
$region = 'eu-west-1';
$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
$this->assertEquals(
new Connection(['queue_name' => 'queue'], new SqsClient(['region' => $region, 'accessKeyId' => $awsKey, 'accessKeySecret' => $awsSecret], null, $httpClient)),
Connection::fromDsn('sqs://default/queue', [
& 8000 #39;access_key' => $awsKey,
'secret_key' => $awsSecret,
'region' => $region,
], $httpClient)
);
}

public function testFromInvalidDsn()
{
$this->expectException(\InvalidArgumentException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : null;

// check for extra keys in options
$optionsExtraKeys = array_diff(array_keys($options), array_keys($configuration));
$optionsExtraKeys = array_diff(array_keys($options), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($optionsExtraKeys)) {
throw new InvalidArgumentException(sprintf('Unknown option found : [%s]. Allowed options are [%s].', implode(', ', $optionsExtraKeys), implode(', ', array_keys(self::DEFAULT_OPTIONS))));
}

// check for extra keys in options
$queryExtraKeys = array_diff(array_keys($query), array_keys($configuration));
$queryExtraKeys = array_diff(array_keys($query), array_keys(self::DEFAULT_OPTIONS));
if (0 < \count($queryExtraKeys)) {
throw new InvalidArgumentException(sprintf('Unknown option found in DSN: [%s]. Allowed options are [%s].', implode(', ', $queryExtraKeys), implode(' 4323 ;, ', array_keys(self::DEFAULT_OPTIONS))));
}
Expand Down
0