123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Feature\Credentials;
- use PHPUnit\Framework\TestCase;
- use AlibabaCloud\Client\AlibabaCloud;
- use AlibabaCloud\Client\Exception\ServerException;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Tests\Mock\Services\Dds\DescribeRegionsRequest;
- /**
- * Class EcsRamRoleCredentialTest
- *
- * @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Feature\Credentials
- */
- class EcsRamRoleCredentialTest extends TestCase
- {
- /**
- * @var string
- */
- private $clientName = 'EcsRamRoleCredentialTest';
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- *
- * @throws ClientException
- */
- public function setUp()
- {
- $regionId = 'cn-hangzhou';
- $roleName = 'EcsRamRoleTest';
- AlibabaCloud::ecsRamRoleClient($roleName)
- ->regionId($regionId)
- ->name($this->clientName);
- }
- /**
- * Tears down the fixture, for example, close a network connection.
- * This method is called after a test is executed.
- *
- * @throws ClientException
- */
- public function tearDown()
- {
- AlibabaCloud::del($this->clientName);
- }
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Timeout or instance does not belong to Alibaba Cloud
- * @throws ClientException
- */
- public function testGetSessionCredential()
- {
- try {
- (new DescribeRegionsRequest())->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (ServerException $e) {
- self::assertContains(
- $e->getErrorMessage(),
- [
- 'Error in retrieving assume role credentials.',
- 'The role was not found in the instance',
- ]
- );
- }
- }
- }
|