forked from aws/aws-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEndpointV2SerializerTraitTest.php
More file actions
81 lines (73 loc) · 2.6 KB
/
Copy pathEndpointV2SerializerTraitTest.php
File metadata and controls
81 lines (73 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace Aws\Test\EndpointV2;
use Aws\Auth\Exception\UnresolvedAuthSchemeException;
use Aws\EndpointV2\EndpointDefinitionProvider;
use Aws\EndpointV2\EndpointProviderV2;
use Aws\Middleware;
use Aws\Test\UsesServiceTrait;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
class EndpointV2SerializerTraitTest extends TestCase
{
use UsesServiceTrait;
/**
* Ensures SDK-level config options used for ruleset evaluation
* are not overridden by a collision with a command argument
*/
public function testCommandEndpointDoesNotOverrideSdkEndpoint()
{
$clientArgs = [
'region' => 'us-east-1',
'endpoint' => 'https://foo.com'
];
$client = $this->getTestClient('sns', $clientArgs);
$this->addMockResults($client, [[]]);
$command = $client->getCommand(
'subscribe',
[
'TopicArn' => 'foo',
'Protocol' => 'https',
'Endpoint' => 'http://someurl.com'
]
);
$list = $client->getHandlerList();
$list->appendSign(Middleware::tap(function($cmd, $req) {
$this->assertStringContainsString(
'foo.com',
$req->getUri()->getHost()
);
}));
$handler = $list->resolve();
$handler($command)->wait();
}
/**
* Ensures SDK-level config options used for ruleset evaluation
* are not overridden by a collision with a command argument
*/
public function testThrowsExceptionForInvalidAuthScheme()
{
$this->expectException(UnresolvedAuthSchemeException::class);
$this->expectExceptionMessage(
'This operation requests `sigvfoo`, `sigvbar`, `sigvbaz` auth schemes,'
. ' but the client currently supports `sigv4`, `sigv4a`, `none`, `bearer`,'
. ' `sigv4-s3express`.'
);
$rulesetPath = __DIR__ . '/invalid-rules/invalid-scheme.json';
$rulesetDefinition = json_decode(file_get_contents($rulesetPath), true);
$partitions = EndpointDefinitionProvider::getPartitions();
$clientArgs = [
'region' => 'us-east-1',
'endpoint_provider' => new EndpointProviderV2($rulesetDefinition, $partitions)
];
$client = $this->getTestClient('s3', $clientArgs);
$this->addMockResults($client, [[]]);
$command = $client->getCommand(
'headBucket',
[
'Bucket' => 'foo',
]
);
$list = $client->getHandlerList();
$handler = $list->resolve();
$handler($command)->wait();
}
}