| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Credentials;
- use PHPUnit\Framework\TestCase;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Credentials\StsCredential;
- /**
- * Class StsCredentialTest
- *
- * @package AlibabaCloud\Client\Tests\LowerthanVersion7_2\Unit\Credentials
- *
- * @coversDefaultClass \AlibabaCloud\Client\Credentials\StsCredential
- */
- class StsCredentialTest extends TestCase
- {
- /**
- * @throws ClientException
- */
- public function testConstruct()
- {
- // Setup
- $accessKeyId = 'accessKeyId';
- $accessKeySecret = 'accessKeySecret';
- $securityToken = 'securityToken';
- // Test
- $credential = new StsCredential($accessKeyId, $accessKeySecret, $securityToken);
- // Assert
- $this->assertEquals($accessKeyId, $credential->getAccessKeyId());
- $this->assertEquals($accessKeySecret, $credential->getAccessKeySecret());
- $this->assertEquals($securityToken, $credential->getSecurityToken());
- $this->assertEquals(
- "$accessKeyId#$accessKeySecret#$securityToken",
- (string)$credential
- );
- }
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID cannot be empty
- * @throws ClientException
- */
- public function testAccessKeyIdEmpty()
- {
- // Setup
- $accessKeyId = '';
- $accessKeySecret = 'accessKeySecret';
- $securityToken = 'securityToken';
- new StsCredential($accessKeyId, $accessKeySecret, $securityToken);
- }
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID must be a string
- * @throws ClientException
- */
- public function testAccessKeyIdFormat()
- {
- // Setup
- $accessKeyId = null;
- $accessKeySecret = 'accessKeySecret';
- $securityToken = 'securityToken';
- new StsCredential($accessKeyId, $accessKeySecret, $securityToken);
- }
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret cannot be empty
- * @throws ClientException
- */
- public function testAccessKeySecretEmpty()
- {
- // Setup
- $accessKeyId = 'accessKeyId';
- $accessKeySecret = '';
- $securityToken = 'securityToken';
- new StsCredential($accessKeyId, $accessKeySecret, $securityToken);
- }
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret must be a string
- * @throws ClientException
- */
- public function testAccessKeySecretFormat()
- {
- // Setup
- $accessKeyId = 'accessKeyId';
- $accessKeySecret = null;
- $securityToken = 'securityToken';
- new StsCredential($accessKeyId, $accessKeySecret, $securityToken);
- }
- }
|