| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Clients;
- use AlibabaCloud\Client\SDK;
- use PHPUnit\Framework\TestCase;
- use AlibabaCloud\Client\Clients\EcsRamRoleClient;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Exception\ServerException;
- use AlibabaCloud\Client\Signature\ShaHmac1Signature;
- use AlibabaCloud\Client\Credentials\EcsRamRoleCredential;
- /**
- * Class EcsRamRoleClientTest
- *
- * @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Clients
- */
- class EcsRamRoleClientTest extends TestCase
- {
- /**
- * @return EcsRamRoleClient
- * @throws ClientException
- */
- public function testConstruct()
- {
- // Setup
- $roleName = 'EcsRamRoleTest';
- // Test
- $client = new EcsRamRoleClient($roleName);
- // Assert
- self::assertEquals($roleName, $client->getCredential()->getRoleName());
- self::assertInstanceOf(EcsRamRoleCredential::class, $client->getCredential());
- self::assertInstanceOf(ShaHmac1Signature::class, $client->getSignature());
- return $client;
- }
- /**
- * @depends testConstruct
- *
- * @param EcsRamRoleClient $client
- *
- * @throws ServerException
- */
- public function testGetSessionCredential(EcsRamRoleClient $client)
- {
- try {
- $client->getSessionCredential(1);
- } catch (ClientException $exception) {
- self::assertEquals($exception->getErrorCode(), SDK::SERVER_UNREACHABLE);
- }
- }
- }
|