Skip to content

Commit

Permalink
Fixing cn-north-1 endpoint for IAM
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Nov 19, 2014
1 parent 1c64304 commit 7509420
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG

## Next Release

* Fixing cn-north-1 endpoint for AWS Identity and Access Management.

## 2.7.5 - 2014-11-13

* Added support for AWS Lambda.
Expand Down
2 changes: 1 addition & 1 deletion src/Aws/Common/Client/ClientBuilder.php
Expand Up @@ -377,7 +377,7 @@ protected function updateConfigFromDescription(Collection $config)
throw new InvalidArgumentException(
'A region is required when using ' . $description->getData('serviceFullName')
);
} elseif ($global && (!$region || $description->getData('namespace') !== 'S3')) {
} elseif ($global && !$region) {
$region = 'us-east-1';
$config->set(Options::REGION, 'us-east-1');
}
Expand Down
19 changes: 18 additions & 1 deletion tests/Aws/Tests/Common/Client/ClientBuilderTest.php
Expand Up @@ -16,11 +16,11 @@

namespace Aws\Tests\Common\Client;

use Aws\Common\Aws;
use Aws\Common\Client\ClientBuilder;
use Aws\Common\Enum\ClientOptions as Options;
use Aws\Common\Exception\Parser\JsonQueryExceptionParser;
use Aws\Common\Credentials\Credentials;
use Aws\Common\Iterator\AwsResourceIterator;
use Aws\DynamoDb\DynamoDbClient;
use Guzzle\Common\Collection;
use Guzzle\Plugin\Backoff\BackoffPlugin;
Expand Down Expand Up @@ -68,8 +68,18 @@ public function testUsesGlobalEndpoint()
'service.description' => $this->stsDescription
))
->build();
$this->assertInstanceOf('Aws\Sts\StsClient', $client);
$this->assertEquals('https://sts.amazonaws.com', $client->getBaseUrl());

$client = ClientBuilder::factory('Aws\\Sts')
->setConfig(array('region' => 'cn-north-1'))
->setConfigDefaults(array(
'service' => 'sts',
'service.description' => $this->stsDescription
))
->build();
$this->assertInstanceOf('Aws\Sts\StsClient', $client);
$this->assertEquals('https://sts.cn-north-1.amazonaws.com.cn', $client->getBaseUrl());
}

public function testBuildAlternate()
Expand Down Expand Up @@ -382,4 +392,11 @@ public function testCanCreateNullCredentials()
$this->assertInstanceOf('Aws\\Common\\Signature\\SignatureV4', $client->getSignature());
$this->assertInstanceOf('Aws\\Common\\Credentials\\NullCredentials', $client->getCredentials());
}

public function testCanUseCnNorth1AndIam()
{
$sdk = Aws::factory();
$c = $sdk->get('iam', array('region' => 'cn-north-1'));
$this->assertEquals('https://iam.cn-north-1.amazonaws.com.cn', $c->getBaseUrl());
}
}

0 comments on commit 7509420

Please sign in to comment.