ManageTraitTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Clients;
  3. use PHPUnit\Framework\TestCase;
  4. use AlibabaCloud\Client\AlibabaCloud;
  5. use AlibabaCloud\Client\Exception\ServerException;
  6. use AlibabaCloud\Client\Exception\ClientException;
  7. use AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Credentials\Ini\VirtualRsaKeyPairCredential;
  8. /**
  9. * Class ManageTraitTest
  10. *
  11. * @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Clients
  12. */
  13. class ManageTraitTest extends TestCase
  14. {
  15. /**
  16. * @throws ClientException
  17. * @throws ServerException
  18. */
  19. public function testRsaKeyPairClient()
  20. {
  21. AlibabaCloud::mockResponse(
  22. 200,
  23. [],
  24. [
  25. 'RequestId' => 'DDDDD-D2BB-4E66-B4BD-9349471769E2',
  26. 'SessionAccessKey' => [
  27. 'SessionAccessKeyId' => 'TMPSK.abcd',
  28. 'Expiration' => '2019-03-08T14:03:34.550Z',
  29. 'SessionAccessKeySecret' => 'eIK-ASD891281212.'
  30. ]
  31. ]
  32. );
  33. $client = AlibabaCloud::rsaKeyPairClient(
  34. 'id',
  35. VirtualRsaKeyPairCredential::privateKeyFileUrl()
  36. );
  37. $credential = $client->getSessionCredential();
  38. self::assertEquals('TMPSK.abcd', $credential->getAccessKeyId());
  39. AlibabaCloud::cancelMock();
  40. }
  41. }