-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure we select region properly (#754)
* make sure we select region properly * Adding changelog
- Loading branch information
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AsyncAws\Core\Tests\Unit; | ||
|
||
use AsyncAws\Core\AbstractApi; | ||
use AsyncAws\Core\Configuration; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AbstractApiTest extends TestCase | ||
{ | ||
public function testGetEndpointRegion() | ||
{ | ||
$api = new DummyApi(); | ||
|
||
// Use default region | ||
$endpoint = $api->getEndpoint('/some/path', [], null); | ||
self::assertEquals('https://foobar.us-east-1.amazonaws.com/some/path', $endpoint); | ||
|
||
$endpoint = $api->getEndpoint('/some/path', [], 'eu-central-1'); | ||
self::assertEquals('https://foobar.eu-central-1.amazonaws.com/some/path', $endpoint); | ||
|
||
// Use region from config | ||
$api = new DummyApi(['region' => 'eu-north-1']); | ||
$endpoint = $api->getEndpoint('/some/path', [], null); | ||
self::assertEquals('https://foobar.eu-north-1.amazonaws.com/some/path', $endpoint); | ||
|
||
$endpoint = $api->getEndpoint('/some/path', [], 'eu-central-1'); | ||
self::assertEquals('https://foobar.eu-central-1.amazonaws.com/some/path', $endpoint); | ||
} | ||
} | ||
|
||
class DummyApi extends AbstractApi | ||
{ | ||
public function getEndpoint(string $uri, array $query, ?string $region): string | ||
{ | ||
return parent::getEndpoint($uri, $query, $region); | ||
} | ||
|
||
protected function getEndpointMetadata(?string $region): array | ||
{ | ||
if (null === $region) { | ||
$region = Configuration::DEFAULT_REGION; | ||
} | ||
|
||
return [ | ||
'endpoint' => "https://foobar.$region.amazonaws.com", | ||
'signRegion' => $region, | ||
'signService' => 'foobar', | ||
'signVersions' => ['v4'], | ||
]; | ||
} | ||
} |