diff --git a/.github/workflows/ci_higher_than_or_equal_to_7.2.yml b/.github/workflows/ci.yml
similarity index 83%
rename from .github/workflows/ci_higher_than_or_equal_to_7.2.yml
rename to .github/workflows/ci.yml
index 5521ce8d..eca337d9 100644
--- a/.github/workflows/ci_higher_than_or_equal_to_7.2.yml
+++ b/.github/workflows/ci.yml
@@ -12,18 +12,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
+ php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
+ fail-fast: false
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- - uses: actions/setup-node@v1
+ - uses: actions/setup-node@v4
with:
node-version: 10.x
- name: Install Proxy
- run: npm install o_o -g --registry=https://registry.npm.taobao.org
+ run: npm install o_o -g --registry=https://registry.npmmirror.com
- name: Start Proxy
run: o_o &
@@ -44,7 +45,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run test case
- run: composer test4HighVersion
+ run: composer test
env:
REGION_ID: ${{ secrets.REGION_ID }}
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
diff --git a/.github/workflows/ci_lower_than_php7.2.yml b/.github/workflows/ci_lower_than_php7.2.yml
deleted file mode 100644
index e009bdc4..00000000
--- a/.github/workflows/ci_lower_than_php7.2.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-name: LowVersion CI
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
-
- build:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- php-versions: ['5.6', '7.0', '7.1']
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - uses: actions/setup-node@v1
- with:
- node-version: 10.x
-
- - name: Install Proxy
- run: npm install o_o -g --registry=https://registry.npm.taobao.org
-
- - name: Start Proxy
- run: o_o &
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-versions }}
- extensions: mbstring, intl
- ini-values: post_max_size=256M, max_execution_time=180
- coverage: xdebug
- tools: php-cs-fixer, phpunit
-
- - name: Validate composer.json and composer.lock
- run: composer validate
-
- - name: Install dependencies
- run: composer install --prefer-dist --no-progress --no-suggest
-
- - name: Run test case
- run: composer test4LowVersion
- env:
- REGION_ID: ${{ secrets.REGION_ID }}
- ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
- ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
- PRIVATE_KEY_LINE_1: ${{ secrets.PRIVATE_KEY_LINE_1 }}
- PUBLIC_KEY_ID: ${{ secrets.PUBLIC_KEY_ID }}
- IMAGE_SEARCH_ACCESS_KEY_ID: ${{ secrets.IMAGE_SEARCH_ACCESS_KEY_ID }}
- IMAGE_SEARCH_ACCESS_KEY_SECRET: ${{ secrets.IMAGE_SEARCH_ACCESS_KEY_SECRET }}
- IMAGE_SEARCH_INSTANCE_NAME: ${{ secrets.IMAGE_SEARCH_INSTANCE_NAME }}
-
- - name: CodeCov
- run: bash <(curl -s https://codecov.io/bash)
\ No newline at end of file
diff --git a/composer.json b/composer.json
index d70d6d0b..04d6e2de 100644
--- a/composer.json
+++ b/composer.json
@@ -97,29 +97,13 @@
"test": [
"phpunit --colors=always"
],
- "test4HighVersion": [
+ "unit": [
"@clearCache",
- "phpunit --testsuite=Test4HighVersion --colors=always"
+ "phpunit --testsuite=Unit --colors=always"
],
- "test4LowVersion": [
+ "feature": [
"@clearCache",
- "phpunit --testsuite=Test4LowVersion --colors=always"
- ],
- "unit4HighVersion": [
- "@clearCache",
- "phpunit --testsuite=Unit4HighVersion --colors=always"
- ],
- "unit4LowVersion": [
- "@clearCache",
- "phpunit --testsuite=Unit4LowVersion --colors=always"
- ],
- "feature4HighVersion": [
- "@clearCache",
- "phpunit --testsuite=Feature4HighVersion --colors=always"
- ],
- "feature4LowVersion": [
- "@clearCache",
- "phpunit --testsuite=Feature4LowVersion --colors=always"
+ "phpunit --testsuite=Feature --colors=always"
],
"coverage": "open cache/coverage/index.html",
"clearCache": "rm -rf cache/*",
diff --git a/phpunit.xml b/phpunit.xml
index dcb40ee6..20cfd7fe 100755
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -14,26 +14,12 @@
tests
-
- ./tests/HigherthanorEqualtoVersion7_2
-
-
- ./tests/LowerthanVersion7_2
-
-
- ./tests/HigherthanorEqualtoVersion7_2/Unit
-
-
-
- ./tests/HigherthanorEqualtoVersion7_2/Feature
-
-
-
- ./tests/LowerthanVersion7_2/Unit
+
+ ./tests/Unit
-
- ./tests/LowerthanVersion7_2/Feature
+
+ ./tests/Feature
diff --git a/tests/LowerthanVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php b/tests/Feature/Credentials/AccessKeyCredentialTest.php
similarity index 77%
rename from tests/LowerthanVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php
rename to tests/Feature/Credentials/AccessKeyCredentialTest.php
index 6ceb914c..2c3a862e 100644
--- a/tests/LowerthanVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php
+++ b/tests/Feature/Credentials/AccessKeyCredentialTest.php
@@ -1,6 +1,6 @@
regionId($regionId)
- ->name($this->clientName);
+ ->regionId($regionId)
+ ->name($this->clientName);
}
/**
+ * @after
* @throws ClientException
*/
- public function tearDown()
+ protected function finalize()
{
+ parent::tearDown();
AlibabaCloud::del($this->clientName);
}
@@ -51,6 +55,7 @@ public function tearDown()
*/
public function testEcs()
{
+
$result = (new DescribeAccessPointsRequest())
->client($this->clientName)
->connectTimeout(25)
@@ -58,6 +63,7 @@ public function testEcs()
->request();
static::assertArrayHasKey('AccessPointSet', $result);
+
}
/**
@@ -66,6 +72,7 @@ public function testEcs()
*/
public function testDds()
{
+
$result = (new DescribeRegionsRequest())
->client($this->clientName)
->connectTimeout(25)
@@ -73,23 +80,24 @@ public function testDds()
->request();
static::assertArrayHasKey('Regions', $result);
+
}
/**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/
* @throws ClientException
* @throws ServerException
*/
public function testCdn()
{
+
$result = (new DescribeCdnServiceRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();
- // static::assertArrayHasKey('ChangingChargeType', $result);
+ static::assertArrayHasKey('ChangingChargeType', $result);
+
}
/**
@@ -98,6 +106,7 @@ public function testCdn()
*/
public function testVpc()
{
+
$result = (new DescribeVpcsRequest())
->client($this->clientName)
->connectTimeout(25)
@@ -105,5 +114,6 @@ public function testVpc()
->request();
static::assertArrayHasKey('Vpcs', $result);
+
}
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/BearerTokenCredentialTest.php b/tests/Feature/Credentials/BearerTokenCredentialTest.php
similarity index 69%
rename from tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/BearerTokenCredentialTest.php
rename to tests/Feature/Credentials/BearerTokenCredentialTest.php
index 994ee1f4..45df19d1 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/BearerTokenCredentialTest.php
+++ b/tests/Feature/Credentials/BearerTokenCredentialTest.php
@@ -1,6 +1,6 @@
regionId($regionId)
- ->name($this->clientName);
+ ->regionId($regionId)
+ ->name($this->clientName);
}
/**
+ * @after
* @throws ClientException
*/
- public function tearDown(): void
+ protected function finalize()
{
+ parent::tearDown();
AlibabaCloud::del($this->clientName);
}
@@ -49,6 +53,7 @@ public function tearDown(): void
*/
public function testCCC()
{
+
try {
(new ListPhoneNumbersRequest())
->client($this->clientName)
@@ -57,8 +62,8 @@ public function testCCC()
->scheme('https')
->host('ccc.cn-shanghai.aliyuncs.com')
->options([
- 'verify' => false,
- ])
+ 'verify' => false,
+ ])
->connectTimeout(25)
->timeout(30)
->request();
@@ -69,6 +74,7 @@ public function testCCC()
$result['Message']
);
}
+
}
/**
@@ -76,13 +82,20 @@ public function testCCC()
*/
public function testEcs()
{
+
$this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches('/UnsupportedSignatureType: This signature type is not supported./');
+ $reg = '/UnsupportedSignatureType: This signature type is not supported./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
(new DescribeAccessPointsRequest())
->client($this->clientName)
->connectTimeout(25)
->timeout(30)
->request();
+
}
/**
@@ -90,11 +103,18 @@ public function testEcs()
*/
public function testCdn()
{
+
$this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches('/UnsupportedSignatureType: This signature type is not supported./');
+ $reg = '/UnsupportedSignatureType: This signature type is not supported./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
(new DescribeCdnServiceRequest())->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
+
}
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/EcsRamRoleCredentialTest.php b/tests/Feature/Credentials/EcsRamRoleCredentialTest.php
similarity index 76%
rename from tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/EcsRamRoleCredentialTest.php
rename to tests/Feature/Credentials/EcsRamRoleCredentialTest.php
index 404cdf59..89431ae3 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/EcsRamRoleCredentialTest.php
+++ b/tests/Feature/Credentials/EcsRamRoleCredentialTest.php
@@ -1,6 +1,6 @@
regionId($regionId)
- ->name($this->clientName);
+ ->regionId($regionId)
+ ->name($this->clientName);
}
/**
* Tears down the fixture, for example, close a network connection.
* This method is called after a test is executed.
*
+ * @after
* @throws ClientException
*/
- public function tearDown(): void
+ protected function finalize()
{
+ parent::tearDown();
AlibabaCloud::del($this->clientName);
}
@@ -52,13 +56,14 @@ public function tearDown(): void
*/
public function testGetSessionCredential()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage('Timeout or instance does not belong to Alibaba Cloud');
try {
(new DescribeRegionsRequest())->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
} catch (ServerException $e) {
self::assertContains(
$e->getErrorMessage(),
@@ -68,5 +73,6 @@ public function testGetSessionCredential()
]
);
}
+
}
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/IniCredentialFeatureTest.php b/tests/Feature/Credentials/IniCredentialFeatureTest.php
similarity index 84%
rename from tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/IniCredentialFeatureTest.php
rename to tests/Feature/Credentials/IniCredentialFeatureTest.php
index ccab96b6..319d1ce1 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/IniCredentialFeatureTest.php
+++ b/tests/Feature/Credentials/IniCredentialFeatureTest.php
@@ -1,40 +1,58 @@
expectException(ClientException::class);
$this->expectExceptionMessage('Format error: vfs://AlibabaCloud/credentials-1');
AlibabaCloud::load(VirtualAccessKeyCredential::badFormat());
+
}
public function testLoadCredentialsFile()
{
$this->expectException(ClientException::class);
$this->expectExceptionCode(0);
- $this->expectExceptionMessageMatches("/Credential file is not readable: \w+/");
+ $reg = '/Credential file is not readable: \w+/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
AlibabaCloud::load('no/file');
+
}
public function testLoadDirectory()
@@ -42,6 +60,7 @@ public function testLoadDirectory()
$this->expectException(ClientException::class);
$this->expectExceptionMessage('Credential file is not readable: /root/AlibabaCloud/NoneFile');
AlibabaCloud::load('/root/AlibabaCloud/NoneFile');
+
}
/**
@@ -51,6 +70,7 @@ public function testDisableClient()
{
AlibabaCloud::load(VirtualAccessKeyCredential::disable());
self::assertFalse(AlibabaCloud::has('phpunit'));
+
}
public function testNoType()
@@ -59,6 +79,7 @@ public function testNoType()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'type' option for 'phpunit'");
AlibabaCloud::load(VirtualAccessKeyCredential::noType());
+
}
public function testInvalidType()
@@ -67,6 +88,7 @@ public function testInvalidType()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Invalid type 'invalidType' for 'phpunit'");
AlibabaCloud::load(VirtualAccessKeyCredential::invalidType());
+
}
public function testNoKey()
@@ -75,6 +97,7 @@ public function testNoKey()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'access_key_id' option for 'phpunit'");
AlibabaCloud::load(VirtualAccessKeyCredential::noKey());
+
}
public function testNoSecret()
@@ -83,15 +106,7 @@ public function testNoSecret()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'access_key_secret' option for 'phpunit'");
AlibabaCloud::load(VirtualAccessKeyCredential::noSecret());
- }
-
- /**
- * @throws ClientException
- */
- public function tearDown(): void
- {
- AlibabaCloud::del('phpunit');
- IniCredential::forgetLoadedCredentialsFile();
+
}
/**
@@ -111,6 +126,7 @@ public function testAccessKeyOk()
self::assertEquals(['.mit.edu', 'foo.com'], $client->options['proxy']['no']);
self::assertEquals(['/path/server.pem', 'password'], $client->options['cert']);
self::assertEquals('cn-hangzhou', $client->regionId);
+
}
/**
@@ -120,6 +136,7 @@ public function testEcsRamRoleClient()
{
AlibabaCloud::load(VirtualEcsRamRoleCredential::client());
self::assertTrue(AlibabaCloud::has('phpunit'));
+
}
public function testEcsRamRoleClientNoRoleName()
@@ -128,6 +145,7 @@ public function testEcsRamRoleClientNoRoleName()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'role_name' option for 'phpunit'");
AlibabaCloud::load(VirtualEcsRamRoleCredential::noRoleName());
+
}
/**
@@ -137,6 +155,7 @@ public function testRamRoleArnClient()
{
AlibabaCloud::load(VirtualRamRoleArnCredential::client());
self::assertTrue(AlibabaCloud::has('phpunit'));
+
}
public function testRamRoleArnClientNoKey()
@@ -145,6 +164,7 @@ public function testRamRoleArnClientNoKey()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'access_key_id' option for 'phpunit'");
AlibabaCloud::load(VirtualRamRoleArnCredential::noKey());
+
}
public function testRamRoleArnClientNoSecret()
@@ -153,6 +173,7 @@ public function testRamRoleArnClientNoSecret()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'access_key_secret' option for 'phpunit'");
AlibabaCloud::load(VirtualRamRoleArnCredential::noSecret());
+
}
public function testRamRoleArnClientNoRoleArn()
@@ -161,6 +182,7 @@ public function testRamRoleArnClientNoRoleArn()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'role_arn' option for 'phpunit'");
AlibabaCloud::load(VirtualRamRoleArnCredential::noRoleArn());
+
}
public function testRamRoleArnClientNoRoleSessionName()
@@ -169,6 +191,7 @@ public function testRamRoleArnClientNoRoleSessionName()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'role_session_name' option for 'phpunit'");
AlibabaCloud::load(VirtualRamRoleArnCredential::noRoleSessionName());
+
}
/**
@@ -178,6 +201,7 @@ public function testBearerTokenClient()
{
AlibabaCloud::load(VirtualBearerTokenCredential::client());
self::assertTrue(AlibabaCloud::has('phpunit'));
+
}
public function testBearerTokenClientNoToken()
@@ -186,6 +210,7 @@ public function testBearerTokenClientNoToken()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'bearer_token' option for 'phpunit'");
AlibabaCloud::load(VirtualBearerTokenCredential::noToken());
+
}
/**
@@ -197,6 +222,7 @@ public function testAkClientWithAttributes()
AlibabaCloud::load(VirtualAccessKeyCredential::akClientWithAttributesNoCertPassword('NoCertPassword'));
static::assertTrue(AlibabaCloud::has('akClientWithAttributes'));
static::assertFalse(AlibabaCloud::has('NoCertPassword'));
+
}
/**
@@ -206,6 +232,7 @@ public function testAkClientWithAttributesNoCertPassword()
{
AlibabaCloud::load(VirtualAccessKeyCredential::akClientWithAttributesNoCertPassword('NoCertPassword'));
static::assertTrue(AlibabaCloud::has('NoCertPassword'));
+
}
public function testNoPublicKeyId()
@@ -214,6 +241,7 @@ public function testNoPublicKeyId()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'public_key_id' option for 'phpunit'");
AlibabaCloud::load(VirtualRsaKeyPairCredential::noPublicKeyId());
+
}
public function testNoPrivateKeyFile()
@@ -222,13 +250,20 @@ public function testNoPrivateKeyFile()
$this->expectExceptionCode(0);
$this->expectExceptionMessage("Missing required 'private_key_file' option for 'phpunit'");
AlibabaCloud::load(VirtualRsaKeyPairCredential::noPrivateKeyFile());
+
}
public function testBadPrivateKeyFilePath()
{
$this->expectException(ClientException::class);
$this->expectExceptionCode(0);
- $this->expectExceptionMessageMatches("/file_get_contents/");
+ $reg = '/file_get_contents/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
AlibabaCloud::load(VirtualRsaKeyPairCredential::badPrivateKeyFilePath());
+
}
}
diff --git a/tests/LowerthanVersion7_2/Feature/Credentials/RamRoleArnCredentialTest.php b/tests/Feature/Credentials/RamRoleArnCredentialTest.php
similarity index 82%
rename from tests/LowerthanVersion7_2/Feature/Credentials/RamRoleArnCredentialTest.php
rename to tests/Feature/Credentials/RamRoleArnCredentialTest.php
index e8c83fe0..fb19b6ec 100644
--- a/tests/LowerthanVersion7_2/Feature/Credentials/RamRoleArnCredentialTest.php
+++ b/tests/Feature/Credentials/RamRoleArnCredentialTest.php
@@ -1,6 +1,6 @@
clientName);
}
@@ -79,6 +83,7 @@ public function tearDown()
*/
public function testEcs()
{
+
try {
$result = (new DescribeAccessPointsRequest())
->client($this->clientName)
@@ -92,6 +97,7 @@ public function testEcs()
$e->getErrorMessage()
);
}
+
}
/**
@@ -99,13 +105,13 @@ public function testEcs()
*/
public function testPolicyAsArray()
{
- $regionId = 'cn-hangzhou';
- $accessKeyId = \getenv('ACCESS_KEY_ID');
+ $regionId = 'cn-hangzhou';
+ $accessKeyId = \getenv('ACCESS_KEY_ID');
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
- $roleArn = 'acs:ram::1325847523475998:role/ecsramroletest';
+ $roleArn = 'acs:ram::1325847523475998:role/ecsramroletest';
$roleSessionName = 'role_session_name';
- $policy = [
- 'Version' => '1',
+ $policy = [
+ 'Version' => '1',
'Statement' => [
],
@@ -130,5 +136,6 @@ public function testPolicyAsArray()
$e->getErrorMessage()
);
}
+
}
}
diff --git a/tests/Feature/Credentials/RsaKeyPairCredentialTest.php b/tests/Feature/Credentials/RsaKeyPairCredentialTest.php
new file mode 100644
index 00000000..1e6c1ce3
--- /dev/null
+++ b/tests/Feature/Credentials/RsaKeyPairCredentialTest.php
@@ -0,0 +1,130 @@
+regionId($regionId)
+ ->name($this->clientName);
+ }
+
+ /**
+ * @after
+ * @throws ClientException
+ */
+ protected function finalize()
+ {
+ parent::tearDown();
+ AlibabaCloud::del($this->clientName);
+ }
+
+ /**
+ * @throws ClientException
+ * @throws ServerException
+ */
+ public function testGetSessionCredential()
+ {
+
+ $this->expectException(ServerException::class);
+ $reg = '/InvalidAccessKeyId: Specified access key is not found or invalid./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
+ $credential = AlibabaCloud::get($this->clientName)
+ ->getSessionCredential(30, 25);
+ self::assertInstanceOf(StsCredential::class, $credential);
+
+ }
+
+ /**
+ * @throws ClientException
+ * @throws ServerException
+ */
+ public function testEcsInJapan()
+ {
+
+
+ $this->expectException(ServerException::class);
+ $reg = '/InvalidAccessKeyId: Specified access key is not found or invalid./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
+
+ $this->expectException(ServerException::class);
+ $reg = '/InvalidAccessKeyId: Specified access key is not found or invalid./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
+ $result = (new DescribeAccessPointsRequest())
+ ->client($this->clientName)
+ ->connectTimeout(20)
+ ->timeout(25)
+ ->request();
+
+ static::assertArrayHasKey('AccessPointSet', $result);
+
+ }
+
+ /**
+ * @throws ClientException
+ * @throws ServerException
+ */
+ public function testEcsNotInJapan()
+ {
+
+ $this->expectException(ServerException::class);
+ $reg = '/InvalidAccessKeyId: Specified access key is not found or invalid./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
+ // Setup
+ $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
+
+ // Test
+ (new DescribeAccessPointsRequest())
+ ->client($this->clientName)
+ ->regionId($regionId)
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
+
+ }
+}
diff --git a/tests/LowerthanVersion7_2/Feature/Product/RamTest.php b/tests/Feature/Product/RamTest.php
similarity index 87%
rename from tests/LowerthanVersion7_2/Feature/Product/RamTest.php
rename to tests/Feature/Product/RamTest.php
index 2e7947be..be1818a7 100644
--- a/tests/LowerthanVersion7_2/Feature/Product/RamTest.php
+++ b/tests/Feature/Product/RamTest.php
@@ -1,6 +1,6 @@
asDefaultClient();
}
@@ -23,6 +25,7 @@ public function setUp()
*/
public function testRamByCore()
{
+
$result = AlibabaCloud::rpc()
->product('ram')
->version('2015-05-01')
diff --git a/tests/LowerthanVersion7_2/Feature/Regions/EndpointTraitTest.php b/tests/Feature/Regions/EndpointTraitTest.php
similarity index 94%
rename from tests/LowerthanVersion7_2/Feature/Regions/EndpointTraitTest.php
rename to tests/Feature/Regions/EndpointTraitTest.php
index 13440971..1372d47c 100644
--- a/tests/LowerthanVersion7_2/Feature/Regions/EndpointTraitTest.php
+++ b/tests/Feature/Regions/EndpointTraitTest.php
@@ -1,6 +1,6 @@
url();
+ $file = (new VirtualAccessKeyCredential($content, 'testDefaultProviderOnInstance'))->url();
putenv("ALIBABA_CLOUD_CREDENTIALS_FILE=$file");
AlibabaCloud::flush();
@@ -50,14 +62,14 @@ public function testDefaultProviderOnInstance()
AlibabaCloud::setDefaultRegionId('cn-hangzhou');
try {
AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->debug(true)
- ->request();
+ ->method('POST')
+ ->product('Cdn')
+ ->version('2014-11-11')
+ ->action('DescribeCdnService')
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->debug(true)
+ ->request();
} catch (ClientException $e) {
self::assertEquals(SDK::SERVER_UNREACHABLE, $e->getErrorCode());
}
@@ -70,10 +82,9 @@ public function testDefaultProviderOnInstance()
*/
public function testDefaultProviderOnEnv()
{
- $this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/");
+
// Setup
- $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
+ $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
$secret = \AlibabaCloud\Client\env('ACCESS_KEY_SECRET');
putenv("ALIBABA_CLOUD_ACCESS_KEY_ID=$id");
putenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET=$secret");
@@ -81,13 +92,13 @@ public function testDefaultProviderOnEnv()
// Test
AlibabaCloud::setDefaultRegionId('cn-hangzhou');
$result = AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->method('POST')
+ ->product('Cdn')
+ ->version('2014-11-11')
+ ->action('DescribeCdnService')
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
// self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
}
@@ -99,11 +110,17 @@ public function testDefaultProviderOnEnv()
*/
public function testDefaultProviderOnIni()
{
+
$this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/");
+ $reg = "/Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/";
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
// Setup
- $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
- $secret = \AlibabaCloud\Client\env('ACCESS_KEY_SECRET');
+ $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
+ $secret = \AlibabaCloud\Client\env('ACCESS_KEY_SECRET');
$content = <<client('testDefaultProviderOnIni')
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->client('testDefaultProviderOnIni')
+ ->method('POST')
+ ->product('Cdn')
+ ->version('2014-11-11')
+ ->action('DescribeCdnService')
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
// self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
}
- protected function setUp(): void
- {
- AlibabaCloud::flush();
- CredentialsProvider::flush();
- }
}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php b/tests/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
similarity index 58%
rename from tests/LowerthanVersion7_2/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
rename to tests/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
index e1f38bd2..e7eaa6a5 100644
--- a/tests/LowerthanVersion7_2/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
+++ b/tests/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
@@ -1,6 +1,6 @@
regionId('cn-shanghai')
- ->asDefaultClient();
+ ->regionId('cn-shanghai')
+ ->asDefaultClient();
}
/**
@@ -29,16 +31,17 @@ public function setUp()
*/
public function testInvalidAccessKeySecret()
{
+
try {
AlibabaCloud::roa()
- ->pathPattern('/pop/2018-05-18/tokens')
- ->product('nls-cloud-meta')
- ->version('2018-05-18')
- ->method('POST')
- ->action('CreateToken')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->pathPattern('/pop/2018-05-18/tokens')
+ ->product('nls-cloud-meta')
+ ->version('2018-05-18')
+ ->method('POST')
+ ->action('CreateToken')
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
} catch (ServerException $e) {
self::assertEquals('Specified Access Key Secret is not valid.', $e->getErrorMessage());
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/ImageSearch.jpg b/tests/Feature/Request/ImageSearch.jpg
similarity index 100%
rename from tests/HigherthanorEqualtoVersion7_2/Feature/Request/ImageSearch.jpg
rename to tests/Feature/Request/ImageSearch.jpg
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/ProxyTest.php b/tests/Feature/Request/ProxyTest.php
similarity index 92%
rename from tests/HigherthanorEqualtoVersion7_2/Feature/Request/ProxyTest.php
rename to tests/Feature/Request/ProxyTest.php
index 40c2fa8a..a226febc 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/ProxyTest.php
+++ b/tests/Feature/Request/ProxyTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
- $this->expectExceptionMessageMatches("/cURL error/");
+ $reg = '/cURL error/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
// Setup
$nameClient = 'name';
$regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
diff --git a/tests/LowerthanVersion7_2/Feature/Request/RequestAsyncTest.php b/tests/Feature/Request/RequestAsyncTest.php
similarity index 61%
rename from tests/LowerthanVersion7_2/Feature/Request/RequestAsyncTest.php
rename to tests/Feature/Request/RequestAsyncTest.php
index 3aa478fd..10a16449 100644
--- a/tests/LowerthanVersion7_2/Feature/Request/RequestAsyncTest.php
+++ b/tests/Feature/Request/RequestAsyncTest.php
@@ -1,6 +1,6 @@
asDefaultClient()->regionId('cn-hangzhou');
$promise = AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->requestAsync();
+ ->method('POST')
+ ->product('Cdn')
+ ->version('2014-11-11')
+ ->action('DescribeCdnService')
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->requestAsync();
$promise->then(
static function (Result $result) {
- self::assertArrayHasKey('Code', $result);
- self::assertEquals(
- 'Forbidden.RAM',
- $result['Code']
- );
+ self::assertArrayHasKey('ChangingChargeType', $result);
self::assertNotEmpty(
- 403,
+ 200,
$result->getStatusCode()
);
@@ -76,13 +72,13 @@ public function testRpAsyncTimeout()
)->asDefaultClient()->regionId('cn-hangzhou');
$promise = AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(0.001)
- ->timeout(30)
- ->requestAsync();
+ ->method('POST')
+ ->product('Cdn')
+ ->version('2014-11-11')
+ ->action('DescribeCdnService')
+ ->connectTimeout(0.001)
+ ->timeout(30)
+ ->requestAsync();
$promise->then(
static function (ResponseInterface $res) {
@@ -91,7 +87,7 @@ static function (ResponseInterface $res) {
return $res;
},
static function (Exception $e) {
- self::assertTrue(Stringy::contains($e->getMessage(), 'cURL error'));
+ self::assertTrue(Stringy::create($e->getMessage())->contains('cURL error'));
}
)->wait();
}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/RequestDebugTest.php b/tests/Feature/Request/RequestDebugTest.php
similarity index 93%
rename from tests/LowerthanVersion7_2/Feature/Request/RequestDebugTest.php
rename to tests/Feature/Request/RequestDebugTest.php
index 384a66d1..9a5f53f2 100644
--- a/tests/LowerthanVersion7_2/Feature/Request/RequestDebugTest.php
+++ b/tests/Feature/Request/RequestDebugTest.php
@@ -1,6 +1,6 @@
asDefaultClient()->regionId(\AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou'));
+ }
+
/**
* @throws ClientException
*/
public function testConstruct()
{
+
// Setup
- $request = new DescribeClusterServicesRequest();
+ $request = new DescribeClusterServicesRequest();
$clusterId = \time();
$request->withClusterId($clusterId);
// Test
try {
$request->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->timeout(30)
+ ->request();
} catch (ServerException $e) {
// Assert
self::assertEquals('ErrorClusterNotFound', $e->getErrorCode());
@@ -41,16 +55,17 @@ public function testConstruct()
*/
public function testWithBearerTokenCredential()
{
+
// Setup
- $regionId = 'cn-hangzhou';
+ $regionId = 'cn-hangzhou';
$bearerToken = 'BEARER_TOKEN';
AlibabaCloud::bearerTokenClient($bearerToken)
- ->name('BEARER_TOKEN')
- ->regionId($regionId);
+ ->name('BEARER_TOKEN')
+ ->regionId($regionId);
// Test
try {
- (new DescribeClusterServicesRequest())
+ (new DescribeClusterServicesRequest())
->client('BEARER_TOKEN')
->withClusterId(\time())
->connectTimeout(25)
@@ -67,17 +82,18 @@ public function testWithBearerTokenCredential()
*/
public function testInvalidUrl()
{
+
// Setup
- $regionId = 'cn-hangzhou';
- $accessKeyId = \getenv('ACCESS_KEY_ID');
+ $regionId = 'cn-hangzhou';
+ $accessKeyId = \getenv('ACCESS_KEY_ID');
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId($regionId)
- ->name(__METHOD__);
+ ->regionId($regionId)
+ ->name(__METHOD__);
// Test
try {
- (new DescribeClusterServicesRequest())
+ (new DescribeClusterServicesRequest())
->connectTimeout(25)
->timeout(30)
->client(__METHOD__)
@@ -94,15 +110,16 @@ public function testInvalidUrl()
*/
public function testROA()
{
+
// Setup
- $request = new DescribeClusterServicesRequest();
+ $request = new DescribeClusterServicesRequest();
$request->withClusterId(\time());
// Test
try {
$request->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->timeout(30)
+ ->request();
// Assert
} catch (ServerException $exception) {
// Assert
@@ -115,6 +132,7 @@ public function testROA()
*/
public function testAccept()
{
+
// Setup
$roa = AlibabaCloud::roa();
$rpc = AlibabaCloud::rpc();
@@ -128,14 +146,4 @@ public function testAccept()
self::assertEquals('accept', $rpc->options['headers']['Accept']);
}
- /**
- * @throws ClientException
- */
- protected function setUp()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId(\AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou'));
- }
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RetryByClientTest.php b/tests/Feature/Request/RetryByClientTest.php
similarity index 94%
rename from tests/HigherthanorEqualtoVersion7_2/Feature/Request/RetryByClientTest.php
rename to tests/Feature/Request/RetryByClientTest.php
index cb64acdf..077cef67 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RetryByClientTest.php
+++ b/tests/Feature/Request/RetryByClientTest.php
@@ -1,6 +1,6 @@
expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/ServiceUnavailable: The request has failed due to a temporary failure of the server./");
+ $reg = '/InvalidAction.NotFound: Specified api is not found, please check your url and method./';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
AlibabaCloud::accessKeyClient(
\getenv('ACCESS_KEY_ID'),
\getenv('ACCESS_KEY_SECRET')
diff --git a/tests/LowerthanVersion7_2/Feature/Request/RpcRequestTest.php b/tests/Feature/Request/RpcRequestTest.php
similarity index 60%
rename from tests/LowerthanVersion7_2/Feature/Request/RpcRequestTest.php
rename to tests/Feature/Request/RpcRequestTest.php
index e50558bc..2777fd3f 100644
--- a/tests/LowerthanVersion7_2/Feature/Request/RpcRequestTest.php
+++ b/tests/Feature/Request/RpcRequestTest.php
@@ -1,6 +1,6 @@
regionId($regionId)
- ->name($nameClient);
+ ->regionId($regionId)
+ ->name($nameClient);
// Assert
$result = (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
static::assertNotNull($result->RequestId);
static::assertNotNull($result->Regions->Region[0]->LocalName);
@@ -53,13 +53,13 @@ public function testWithCredential()
public function testWithBearerTokenCredential()
{
// Setup
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
+ $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
$bearerToken = 'BEARER_TOKEN';
// Test
AlibabaCloud::bearerTokenClient($bearerToken)
- ->regionId($regionId)
- ->name($bearerToken);
+ ->regionId($regionId)
+ ->name($bearerToken);
// Assert
try {
@@ -67,7 +67,7 @@ public function testWithBearerTokenCredential()
$request->options(
[
'query' => [
- 'test_true' => 1,
+ 'test_true' => 1,
'test_false' => 1,
],
]
@@ -75,8 +75,8 @@ public function testWithBearerTokenCredential()
static::assertEquals(1, $request->options['query']['test_true']);
static::assertEquals(1, $request->options['query']['test_false']);
$result = $request->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->timeout(30)
+ ->request();
self::assertArrayHasKey('Regions', $result);
} catch (ServerException $e) {
static::assertEquals('UnsupportedSignatureType', $e->getErrorCode());
@@ -84,26 +84,25 @@ public function testWithBearerTokenCredential()
}
/**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/
- * @throws ClientException
* @throws ServerException
+ * @throws ClientException
*/
public function testRpc()
{
+
AlibabaCloud::accessKeyClient(
\getenv('ACCESS_KEY_ID'),
\getenv('ACCESS_KEY_SECRET')
)->asDefaultClient()->regionId('cn-hangzhou');
$result = (new RpcRequest())->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
+ ->product('Cdn')
+ ->version('2014-11-11')
+ ->action('DescribeCdnService')
+ ->connectTimeout(25)
+ ->timeout(30)
+ ->request();
- // self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
+ self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
}
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php
deleted file mode 100644
index ec19538b..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/AccessKeyCredentialTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-regionId($regionId)
- ->name($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function tearDown(): void
- {
- AlibabaCloud::del($this->clientName);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testEcs()
- {
- $result = (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- static::assertArrayHasKey('AccessPointSet', $result);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testDds()
- {
- $result = (new DescribeRegionsRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- static::assertArrayHasKey('Regions', $result);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testCdn()
- {
- $this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/");
- $result = (new DescribeCdnServiceRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- // static::assertArrayHasKey('ChangingChargeType', $result);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testVpc()
- {
- $result = (new DescribeVpcsRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- static::assertArrayHasKey('Vpcs', $result);
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/RamRoleArnCredentialTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/RamRoleArnCredentialTest.php
deleted file mode 100644
index 1a50b451..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/RamRoleArnCredentialTest.php
+++ /dev/null
@@ -1,134 +0,0 @@
-regionId($regionId)->name($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function tearDown(): void
- {
- AlibabaCloud::del($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function testEcs()
- {
- try {
- $result = (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- static::assertTrue(isset($result['AccessPointSet']));
- } catch (ServerException $e) {
- self::assertEquals(
- 'You are not authorized to do this action. You should be authorized by RAM.',
- $e->getErrorMessage()
- );
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testPolicyAsArray()
- {
- $regionId = 'cn-hangzhou';
- $accessKeyId = \getenv('ACCESS_KEY_ID');
- $accessKeySecret = \getenv('ACCESS_KEY_SECRET');
- $roleArn = 'acs:ram::1325847523475998:role/ecsramroletest';
- $roleSessionName = 'role_session_name';
- $policy = [
- 'Version' => '1',
- 'Statement' => [
-
- ],
- ];
- AlibabaCloud::ramRoleArnClient(
- $accessKeyId,
- $accessKeySecret,
- $roleArn,
- $roleSessionName,
- $policy
- )->regionId($regionId)->name($this->clientName);
- try {
- $result = (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- static::assertTrue(isset($result['AccessPointSet']));
- } catch (ServerException $e) {
- self::assertEquals(
- 'You are not authorized to do this action. You should be authorized by RAM.',
- $e->getErrorMessage()
- );
- }
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/RsaKeyPairCredentialTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/RsaKeyPairCredentialTest.php
deleted file mode 100644
index 5f806493..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Credentials/RsaKeyPairCredentialTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
-regionId($regionId)
- ->name($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function tearDown(): void
- {
- AlibabaCloud::del($this->clientName);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testGetSessionCredential()
- {
- $this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/NoPermission: You are not authorized to do this action. You should be authorized by RAM./");
- $credential = AlibabaCloud::get($this->clientName)
- ->getSessionCredential(30, 25);
- self::assertInstanceOf(StsCredential::class, $credential);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testEcsInJapan()
- {
- $this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/NoPermission: You are not authorized to do this action. You should be authorized by RAM./");
- $result = (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->connectTimeout(20)
- ->timeout(25)
- ->request();
-
- static::assertArrayHasKey('AccessPointSet', $result);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testEcsNotInJapan()
- {
- $this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/NoPermission: You are not authorized to do this action. You should be authorized by RAM./");
- // Setup
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
-
- // Test
- (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->regionId($regionId)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Product/RamTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Product/RamTest.php
deleted file mode 100644
index ebc44827..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Product/RamTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-asDefaultClient();
- }
-
- /**
- * @throws ClientException
- * @throws \AlibabaCloud\Client\Exception\ServerException
- */
- public function testRamByCore()
- {
- $result = AlibabaCloud::rpc()
- ->product('ram')
- ->version('2015-05-01')
- ->method('POST')
- ->action('ListAccessKeys')
- ->scheme('https')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- self::assertTrue(isset($result['AccessKeys']));
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Regions/EndpointTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Regions/EndpointTraitTest.php
deleted file mode 100644
index 31af468f..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Regions/EndpointTraitTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-regionId('cn-hangzhou')
- ->asDefaultClient();
-
- // Test
- $request = new RpcRequest();
- $request->connectTimeout(25)->timeout(30);
- $request->product = $productName;
- $request->serviceCode = $serviceCode;
-
- // Assert
- $host = LocationService::resolveHost($request);
- self::assertContains($host, $expectedHost);
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
deleted file mode 100644
index 8e9791a4..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/DistinguishSignatureAndCredentialErrorsTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-regionId('cn-shanghai')
- ->asDefaultClient();
- }
-
- /**
- * @throws ClientException
- */
- public function testInvalidAccessKeySecret()
- {
- try {
- AlibabaCloud::roa()
- ->pathPattern('/pop/2018-05-18/tokens')
- ->product('nls-cloud-meta')
- ->version('2018-05-18')
- ->method('POST')
- ->action('CreateToken')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (ServerException $e) {
- self::assertEquals('Specified Access Key Secret is not valid.', $e->getErrorMessage());
- }
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestAsyncTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestAsyncTest.php
deleted file mode 100644
index 0614bc96..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestAsyncTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-asDefaultClient()->regionId('cn-hangzhou');
-
- $promise = AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->requestAsync();
-
- $promise->then(
- static function (Result $result) {
- self::assertArrayHasKey('Code', $result);
- self::assertEquals(
- 'Forbidden.RAM',
- $result['Code']
- );
-
- self::assertNotEmpty(
- 403,
- $result->getStatusCode()
- );
-
- return $result;
- },
- static function (RequestException $e) {
- self::assertEquals(
- 'POST',
- $e->getRequest()->getMethod()
- );
- }
- )->wait();
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRpAsyncTimeout()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- $promise = AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(0.001)
- ->timeout(30)
- ->requestAsync();
-
- $promise->then(
- static function (ResponseInterface $res) {
- self::assertNotEmpty(200, $res->getStatusCode());
-
- return $res;
- },
- static function (Exception $e) {
- self::assertTrue(Stringy::contains($e->getMessage(), 'cURL error'));
- }
- )->wait();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestDebugTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestDebugTest.php
deleted file mode 100644
index f4848ff1..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestDebugTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-regionId($regionId)
- ->name($nameClient);
-
- $request = (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(25)
- ->timeout(30);
- $request->request();
-
- // Assert
- self::assertArrayHasKey('debug', $request->options);
- self::assertTrue($request->options['debug']);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testOption()
- {
- // Setup
- $nameClient = 'name';
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
- $accessKeyId = \getenv('ACCESS_KEY_ID');
- $accessKeySecret = \getenv('ACCESS_KEY_SECRET');
- putenv('DEBUG=false');
-
- // Test
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId($regionId)
- ->name($nameClient);
-
- // Assert
- $request = (new DescribeRegionsRequest())->client($nameClient)
- ->debug(true)
- ->connectTimeout(25)
- ->timeout(30);
- $request->request();
-
- self::assertArrayHasKey('debug', $request->options);
- self::assertTrue($request->options['debug']);
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestTest.php
deleted file mode 100644
index 25189a09..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RequestTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-withClusterId($clusterId);
-
- // Test
- try {
- $request->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (ServerException $e) {
- // Assert
- self::assertEquals('ErrorClusterNotFound', $e->getErrorCode());
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testWithBearerTokenCredential()
- {
- // Setup
- $regionId = 'cn-hangzhou';
- $bearerToken = 'BEARER_TOKEN';
- AlibabaCloud::bearerTokenClient($bearerToken)
- ->name('BEARER_TOKEN')
- ->regionId($regionId);
-
- // Test
- try {
- (new DescribeClusterServicesRequest())
- ->client('BEARER_TOKEN')
- ->withClusterId(\time())
- ->connectTimeout(25)
- ->timeout(50)
- ->request();
- } catch (ServerException $e) {
- // Assert
- static::assertEquals('UnsupportedSignatureType', $e->getErrorCode());
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testInvalidUrl()
- {
- // Setup
- $regionId = 'cn-hangzhou';
- $accessKeyId = \getenv('ACCESS_KEY_ID');
- $accessKeySecret = \getenv('ACCESS_KEY_SECRET');
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId($regionId)
- ->name(__METHOD__);
-
- // Test
- try {
- (new DescribeClusterServicesRequest())
- ->connectTimeout(25)
- ->timeout(30)
- ->client(__METHOD__)
- ->withClusterId(\time())
- ->request();
- } catch (ServerException $e) {
- // Assert
- self::assertEquals('ErrorClusterNotFound', $e->getErrorCode());
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testROA()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
- $request->withClusterId(\time());
-
- // Test
- try {
- $request->connectTimeout(25)
- ->timeout(30)
- ->request();
- // Assert
- } catch (ServerException $exception) {
- // Assert
- static::assertEquals('ErrorClusterNotFound', $exception->getErrorCode());
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testAccept()
- {
- // Setup
- $roa = AlibabaCloud::roa();
- $rpc = AlibabaCloud::rpc();
-
- // Test
- $roa->accept('accept');
- $rpc->accept('accept');
-
- // Assert
- self::assertEquals('accept', $roa->options['headers']['Accept']);
- self::assertEquals('accept', $rpc->options['headers']['Accept']);
- }
-
- /**
- * @throws ClientException
- */
- protected function setUp(): void
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId(\AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou'));
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RpcRequestTest.php b/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RpcRequestTest.php
deleted file mode 100644
index 8fb3958c..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Feature/Request/RpcRequestTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-regionId($regionId)
- ->name($nameClient);
-
- // Assert
-
- $result = (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- static::assertNotNull($result->RequestId);
- static::assertNotNull($result->Regions->Region[0]->LocalName);
- static::assertNotNull($result->Regions->Region[0]->RegionId);
- }
-
- /**
- * @covers \AlibabaCloud\Client\Request\Request::setQueryParameters
- * @throws ClientException
- */
- public function testWithBearerTokenCredential()
- {
- // Setup
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
- $bearerToken = 'BEARER_TOKEN';
-
- // Test
- AlibabaCloud::bearerTokenClient($bearerToken)
- ->regionId($regionId)
- ->name($bearerToken);
-
- // Assert
- try {
- $request = new DescribeRegionsRequest();
- $request->options(
- [
- 'query' => [
- 'test_true' => 1,
- 'test_false' => 1,
- ],
- ]
- );
- static::assertEquals(1, $request->options['query']['test_true']);
- static::assertEquals(1, $request->options['query']['test_false']);
- $result = $request->connectTimeout(25)
- ->timeout(30)
- ->request();
- self::assertArrayHasKey('Regions', $result);
- } catch (ServerException $e) {
- static::assertEquals('UnsupportedSignatureType', $e->getErrorCode());
- }
- }
-
- /**
- * @throws ServerException
- * @throws ClientException
- */
- public function testRpc()
- {
- $this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/");
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- $result = (new RpcRequest())->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- // self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/AlibabaCloudTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/AlibabaCloudTest.php
deleted file mode 100644
index fa8ab44d..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/AlibabaCloudTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-expectException(ClientException::class);
- $this->expectExceptionMessageMatches('/May not yet support product/');
- AlibabaCloud::Ecs();
- }
-
- public function tearDown(): void
- {
- AlibabaCloud::flush();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/AccessKeyClientTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/AccessKeyClientTest.php
deleted file mode 100644
index 426dc6a3..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/AccessKeyClientTest.php
+++ /dev/null
@@ -1,53 +0,0 @@
-getCredential()->getAccessKeyId());
- self::assertEquals($accessKeySecret, $client->getCredential()->getAccessKeySecret());
- self::assertInstanceOf(ShaHmac1Signature::class, $client->getSignature());
-
- return $client;
- }
-
- /**
- * @depends testConstruct
- *
- * @param AccessKeyClient $client
- *
- * @throws ClientException
- * @throws ServerException
- */
- public function testGetSessionCredential(AccessKeyClient $client)
- {
- self::assertInstanceOf(AccessKeyCredential::class, $client->getSessionCredential());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/BearerTokenClientTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/BearerTokenClientTest.php
deleted file mode 100644
index b7903f65..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/BearerTokenClientTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-getCredential()->getBearerToken());
- self::assertInstanceOf(BearerTokenSignature::class, $client->getSignature());
-
- return $client;
- }
-
- /**
- * @depends testConstruct
- *
- * @param BearerTokenClient $client
- *
- * @throws ClientException
- * @throws ServerException
- */
- public function testGetSessionCredential(BearerTokenClient $client)
- {
- self::assertInstanceOf(BearerTokenCredential::class, $client->getSessionCredential());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/EcsRamRoleClientTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/EcsRamRoleClientTest.php
deleted file mode 100644
index 54e6d7a2..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/EcsRamRoleClientTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-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);
- }
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/ManageTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/ManageTraitTest.php
deleted file mode 100644
index 9b316ce2..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/ManageTraitTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
- 'DDDDD-D2BB-4E66-B4BD-9349471769E2',
- 'SessionAccessKey' => [
- 'SessionAccessKeyId' => 'TMPSK.abcd',
- 'Expiration' => '2019-03-08T14:03:34.550Z',
- 'SessionAccessKeySecret' => 'eIK-ASD891281212.'
- ]
- ]
- );
- $client = AlibabaCloud::rsaKeyPairClient(
- 'id',
- VirtualRsaKeyPairCredential::privateKeyFileUrl()
- );
- $credential = $client->getSessionCredential();
- self::assertEquals('TMPSK.abcd', $credential->getAccessKeyId());
- AlibabaCloud::cancelMock();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/RamRoleArnClientTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/RamRoleArnClientTest.php
deleted file mode 100644
index 871048ad..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/RamRoleArnClientTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-getSignature());
- self::assertInstanceOf(RamRoleArnCredential::class, $client->getCredential());
- self::assertEquals($accessKeyId, $client->getCredential()->getAccessKeyId());
- self::assertEquals($accessKeySecret, $client->getCredential()->getAccessKeySecret());
- self::assertEquals($roleArn, $client->getCredential()->getRoleArn());
- self::assertEquals($roleSessionName, $client->getCredential()->getRoleSessionName());
-
- return $client;
- }
-
- /**
- * @depends testConstruct
- *
- * @param RamRoleArnClient $client
- */
- public function testGetSessionCredential(RamRoleArnClient $client)
- {
- try {
- $client->getSessionCredential();
- } catch (ServerException $exception) {
- self::assertEquals('Specified access key is not found or invalid.', $exception->getErrorMessage());
- } catch (ClientException $exception) {
- self::assertStringStartsWith('cURL error', $exception->getErrorMessage());
- }
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/RsaKeyPairClientTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/RsaKeyPairClientTest.php
deleted file mode 100644
index 462eef04..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/RsaKeyPairClientTest.php
+++ /dev/null
@@ -1,39 +0,0 @@
-getCredential()->getPublicKeyId());
- self::assertStringEqualsFile(
- $privateKeyFile,
- $client->getCredential()->getPrivateKey()
- );
- self::assertInstanceOf(ShaHmac1Signature::class, $client->getSignature());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/StsClientTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/StsClientTest.php
deleted file mode 100644
index 0e193c9d..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Clients/StsClientTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-getCredential()->getAccessKeyId());
- self::assertEquals($accessKeySecret, $client->getCredential()->getAccessKeySecret());
- self::assertEquals($securityToken, $client->getCredential()->getSecurityToken());
- self::assertInstanceOf(ShaHmac1Signature::class, $client->getSignature());
- self::assertInstanceOf(StsCredential::class, $client->getCredential());
-
- return $client;
- }
-
- /**
- * @depends testConstruct
- *
- * @param StsClient $client
- *
- * @throws ClientException
- * @throws ServerException
- */
- public function testGetSessionCredential(StsClient $client)
- {
- self::assertInstanceOf(StsCredential::class, $client->getSessionCredential());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Config/ConfigTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Config/ConfigTest.php
deleted file mode 100644
index adf3983d..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Config/ConfigTest.php
+++ /dev/null
@@ -1,94 +0,0 @@
-getProperty('configManager');
- $property->setAccessible(true);
- $property->setValue($value);
- }
-
- /**
- * @throws ReflectionException
- */
- public function testGetConfigManager()
- {
- $ref = new \ReflectionClass(Config::class);
- $method = $ref->getMethod('getConfigManager');
- $method->setAccessible(true);
- self::assertInstanceOf(ConfigManager::class, $method->invoke(null));
- }
-
- /**
- * @depends testGetConfigManager
- * @throws ReflectionException
- * @throws Exception
- */
- public function testSetAndGet()
- {
- self::setStaticProperty(new ConfigManager(self::file()->url()));
- Config::set('vfs', __METHOD__);
- self::assertEquals(Config::get('vfs'), __METHOD__);
- }
-
- /**
- * @return vfsStreamFile|string
- */
- private static function file()
- {
- if (self::$vfs !== null) {
- return self::$vfs;
- }
-
- $content = <<withContent($content)
- ->at($root);
-
- return self::$vfs;
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/CreateTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/CreateTraitTest.php
deleted file mode 100644
index d97138d0..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/CreateTraitTest.php
+++ /dev/null
@@ -1,456 +0,0 @@
-setAccessible(true);
- try {
- $result = $ref->invokeArgs($object, [$clientName, $credential]);
- self::assertFalse($result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function createClient()
- {
- return [
- [
- 'disable',
- [
- ],
- false,
- ],
- [
- 'enable',
- [
- 'enable' => true,
- ],
- "Missing required 'type' option for 'enable'",
- ],
- [
- 'enable',
- [
- 'enable' => true,
- 'type' => 'badType',
- ],
- "Invalid type 'badType' for 'enable'",
- ],
- ];
- }
-
- /**
- * @param string $clientName
- * @param array $credential
- *
- * @param string $errorMessage
- *
- * @throws ReflectionException
- * @dataProvider createClientByType
- */
- public function testCreateClientByType($clientName, array $credential, $errorMessage)
- {
- $object = new IniCredential();
- $ref = new \ReflectionMethod(
- IniCredential::class,
- 'createClientByType'
- );
- $ref->setAccessible(true);
- try {
- $ref->invokeArgs($object, [$clientName, $credential]);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function createClientByType()
- {
- return [
- [
- 'access_key',
- [
- 'type' => 'access_key',
- ],
- "Missing required 'access_key_id' option for 'access_key'",
- ],
- [
- 'ecs_ram_role',
- [
- 'type' => 'ecs_ram_role',
- ],
- "Missing required 'role_name' option for 'ecs_ram_role'",
- ],
- [
- 'ram_role_arn',
- [
- 'type' => 'ram_role_arn',
- ],
- "Missing required 'access_key_id' option for 'ram_role_arn'",
- ],
- [
- 'bearer_token',
- [
- 'type' => 'bearer_token',
- ],
- "Missing required 'bearer_token' option for 'bearer_token'",
- ],
- [
- 'rsa_key_pair',
- [
- 'type' => 'rsa_key_pair',
- ],
- "Missing required 'public_key_id' option for 'rsa_key_pair'",
- ],
- [
- 'enable',
- [
- 'enable' => true,
- 'type' => 'badType',
- ],
- "Invalid type 'badType' for 'enable'",
- ],
- ];
- }
-
- /**
- * @param string $clientName
- * @param array $credential
- *
- * @param string $errorMessage
- *
- * @throws ReflectionException
- * @dataProvider rsaKeyPairClient
- */
- public function testRsaKeyPairClient($clientName, array $credential, $errorMessage)
- {
- $object = new IniCredential();
- $ref = new \ReflectionMethod(
- IniCredential::class,
- 'rsaKeyPairClient'
- );
- $ref->setAccessible(true);
- try {
- $result = $ref->invokeArgs($object, [$clientName, $credential]);
- self::assertInstanceOf(RsaKeyPairClient::class, $result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function rsaKeyPairClient()
- {
- return [
- [
- 'enable',
- [
- ],
- "Missing required 'public_key_id' option for 'enable'",
- ],
- [
- 'enable',
- [
- 'public_key_id' => 'id',
- 'type' => 'rsa_key_pair',
- ],
- "Missing required 'private_key_file' option for 'enable'",
- ],
- [
- 'enable',
- [
- 'public_key_id' => 'id',
- 'private_key_file' => __FILE__,
- ],
- 'success',
- ],
- ];
- }
-
- /**
- * @param string $clientName
- * @param array $credential
- *
- * @param string $errorMessage
- *
- * @throws ReflectionException
- * @dataProvider accessKeyClient
- */
- public function testAccessKeyClient($clientName, array $credential, $errorMessage)
- {
- $object = new IniCredential();
- $ref = new \ReflectionMethod(
- IniCredential::class,
- 'accessKeyClient'
- );
- $ref->setAccessible(true);
- try {
- $result = $ref->invokeArgs($object, [$clientName, $credential]);
- self::assertInstanceOf(AccessKeyClient::class, $result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function accessKeyClient()
- {
- return [
- [
- 'no_access_key_id',
- [
- ],
- "Missing required 'access_key_id' option for 'no_access_key_id'",
- ],
- [
- 'no_access_key_secret',
- [
- 'access_key_id' => 'id',
- ],
- "Missing required 'access_key_secret' option for 'no_access_key_secret'",
- ],
- [
- 'success',
- [
- 'access_key_id' => 'foo',
- 'access_key_secret' => 'bar',
- ],
- 'success',
- ],
- ];
- }
-
- /**
- * @param string $clientName
- * @param array $credential
- *
- * @param string $errorMessage
- *
- * @dataProvider ecsRamRoleClient
- *
- * @throws ReflectionException
- */
- public function testEcsRamRoleClient($clientName, array $credential, $errorMessage)
- {
- $object = new IniCredential();
- $ref = new \ReflectionMethod(
- IniCredential::class,
- 'ecsRamRoleClient'
- );
- $ref->setAccessible(true);
- try {
- $result = $ref->invokeArgs($object, [$clientName, $credential]);
- self::assertInstanceOf(EcsRamRoleClient::class, $result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function ecsRamRoleClient()
- {
- return [
- [
- 'no_role_name',
- [
- ],
- "Missing required 'role_name' option for 'no_role_name'",
- ],
- [
- 'ok',
- [
- 'role_name' => 'foo',
- ],
- 'success',
- ],
- ];
- }
-
- /**
- * @param string $clientName
- * @param array $credential
- *
- * @param string $errorMessage
- *
- * @dataProvider ramRoleArnClient
- *
- * @throws ReflectionException
- */
- public function testRamRoleArnClient($clientName, array $credential, $errorMessage)
- {
- $object = new IniCredential();
- $ref = new \ReflectionMethod(
- IniCredential::class,
- 'ramRoleArnClient'
- );
- $ref->setAccessible(true);
- try {
- $result = $ref->invokeArgs($object, [$clientName, $credential]);
- self::assertInstanceOf(RamRoleArnClient::class, $result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function ramRoleArnClient()
- {
- return [
- [
- 'no_access_key_id',
- [
- ],
- "Missing required 'access_key_id' option for 'no_access_key_id'",
- ],
- [
- 'no_access_key_secret',
- [
- 'access_key_id' => 'foo',
- ],
- "Missing required 'access_key_secret' option for 'no_access_key_secret'",
- ],
- [
- 'no_role_arn',
- [
- 'access_key_id' => 'foo',
- 'access_key_secret' => 'bar',
- ],
- "Missing required 'role_arn' option for 'no_role_arn'",
- ],
- [
- 'no_role_session_name',
- [
- 'access_key_id' => 'foo',
- 'access_key_secret' => 'bar',
- 'role_arn' => 'role_arn',
- ],
- "Missing required 'role_session_name' option for 'no_role_session_name'",
- ],
- [
- 'ok',
- [
- 'access_key_id' => 'foo',
- 'access_key_secret' => 'bar',
- 'role_arn' => 'role_arn',
- 'role_session_name' => 'role_session_name',
- ],
- 'success',
- ],
- ];
- }
-
- /**
- * @param string $clientName
- * @param array $credential
- *
- * @param string $errorMessage
- *
- * @dataProvider bearerTokenClient
- *
- * @throws ReflectionException
- */
- public function testBearerTokenClient($clientName, array $credential, $errorMessage)
- {
- $object = new IniCredential();
- $ref = new \ReflectionMethod(
- IniCredential::class,
- 'bearerTokenClient'
- );
- $ref->setAccessible(true);
- try {
- $result = $ref->invokeArgs($object, [$clientName, $credential]);
- self::assertInstanceOf(BearerTokenClient::class, $result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $errorMessage . ' in ' . $object->getFilename(),
- $exception->getErrorMessage()
- );
- }
- }
-
- /**
- * @return array
- */
- public function bearerTokenClient()
- {
- return [
- [
- 'no_bearer_token',
- [
- ],
- "Missing required 'bearer_token' option for 'no_bearer_token'",
- ],
- [
- 'ok',
- [
- 'bearer_token' => 'token',
- ],
- 'success',
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/OptionsTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/OptionsTraitTest.php
deleted file mode 100644
index 53f4448c..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/OptionsTraitTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-getMethod('setCert');
- $method->setAccessible(true);
-
- $method->invokeArgs($object, [$configures, $client]);
- self::assertEquals($expectedCert, $client->options['cert']);
- }
-
- /**
- * @return array
- */
- public function setCert()
- {
- return [
- [
- [
- 'cert_file' => '/file/file.pem',
- ],
- '/file/file.pem',
- ],
- [
- [
- 'cert_file' => '/file/file.pem',
- 'cert_password' => 'password',
- ],
- [
- '/file/file.pem',
- 'password',
- ],
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualBearerTokenCredential.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualBearerTokenCredential.php
deleted file mode 100644
index a065556d..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualBearerTokenCredential.php
+++ /dev/null
@@ -1,54 +0,0 @@
-url();
- }
-
- /**
- * @return string
- */
- public static function client()
- {
- $content = <<url();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualEcsRamRoleCredential.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualEcsRamRoleCredential.php
deleted file mode 100644
index e90820c5..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualEcsRamRoleCredential.php
+++ /dev/null
@@ -1,43 +0,0 @@
-url();
- }
-
- /**
- * @return string
- */
- public static function client()
- {
- $content = <<url();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualRamRoleArnCredential.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualRamRoleArnCredential.php
deleted file mode 100644
index aa406950..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualRamRoleArnCredential.php
+++ /dev/null
@@ -1,99 +0,0 @@
-url();
- }
-
- /**
- * @return string
- */
- public static function noSecret()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function noRoleArn()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function noRoleSessionName()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function client()
- {
- $content = <<url();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualRsaKeyPairCredential.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualRsaKeyPairCredential.php
deleted file mode 100644
index be93341a..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Ini/VirtualRsaKeyPairCredential.php
+++ /dev/null
@@ -1,118 +0,0 @@
-url();
- }
-
- /**
- * @return string
- */
- public static function noPrivateKeyFile()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function badPrivateKeyFilePath()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function privateKeyFileUrl()
- {
- $line1 = \AlibabaCloud\Client\env('PRIVATE_KEY_LINE_1');
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function badPrivateKey()
- {
- $content = <<url();
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/ProviderTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/ProviderTest.php
deleted file mode 100644
index da63852f..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/ProviderTest.php
+++ /dev/null
@@ -1,222 +0,0 @@
-setAccessible(true);
- $actual = $method->invoke($provider);
-
- // Assert
- self::assertEquals($key, $actual);
- }
-
- /**
- * @return array
- * @throws ClientException
- */
- public function key()
- {
- return [
- [
- new AccessKeyClient('foo', 'bar'),
- 'foo#bar',
- ],
- [
- new BearerTokenClient('token'),
- 'bearerToken#token',
- ],
- [
- new Client(
- new AccessKeyCredential('foo', 'bar'),
- new ShaHmac1Signature()
- ),
- 'foo#bar',
- ],
- [
- new EcsRamRoleClient('name'),
- 'roleName#name',
- ],
- [
- new RamRoleArnClient('foo', 'bar', 'arn', 'name'),
- 'foo#bar#arn#name',
- ],
- [
- new RsaKeyPairClient('foo', VirtualRsaKeyPairCredential::ok()),
- 'publicKeyId#foo',
- ],
- [
- new StsClient('foo', 'bar', 'token'),
- 'foo#bar#token',
- ],
- ];
- }
-
- /**
- * @param Client $client
- * @param array $result
- *
- * @throws \ReflectionException
- * @dataProvider cache
- */
- public function testCache(Client $client, array $result)
- {
- // Setup
- $provider = new Provider($client);
-
- // Test
- $cacheMethod = new \ReflectionMethod(
- Provider::class,
- 'cache'
- );
- $cacheMethod->setAccessible(true);
- $cacheMethod->invokeArgs($provider, [$result]);
-
- $keyMethod = new \ReflectionMethod(
- Provider::class,
- 'key'
- );
- $keyMethod->setAccessible(true);
- $key = $keyMethod->invoke($provider);
-
- $property = new \ReflectionProperty(
- Provider::class,
- 'credentialsCache'
- );
- $property->setAccessible(true);
- $actual = $property->getValue();
-
- // Assert
- self::assertEquals($result, $actual[$key]);
- }
-
- /**
- * @param Client $client
- * @param array $credential
- * @param array|null $result
- *
- * @throws \ReflectionException
- * @dataProvider cache
- */
- public function testGetCredentialsInCache(Client $client, array $credential, $result)
- {
- // Setup
- $provider = new Provider($client);
-
- // Test
- $cacheMethod = new \ReflectionMethod(
- Provider::class,
- 'cache'
- );
- $cacheMethod->setAccessible(true);
- $cacheMethod->invokeArgs($provider, [$credential]);
-
- $cacheResult = $provider->getCredentialsInCache();
-
- // Assert
- self::assertEquals($cacheResult, $result);
- }
-
- /**
- * @return array
- * @throws ClientException
- */
- public function cache()
- {
- return [
- [
- new AccessKeyClient('foo', 'bar'),
- [
- 'Expiration' => '2049-10-01 11:11:11',
- ],
- [
- 'Expiration' => '2049-10-01 11:11:11',
- ],
- ],
- [
- new BearerTokenClient('token'),
- [
- 'Expiration' => \date('Y-m-d H:i:s', \time() + 4),
- ],
- null,
- ],
- [
- new Client(
- new AccessKeyCredential('foo', 'bar'),
- new ShaHmac1Signature()
- ),
- [
- 'Expiration' => '2017-02-02 11:11:11',
- ],
- null,
- ],
- [
- new EcsRamRoleClient('name'),
- [
- 'Expiration' => '2017-02-02 11:11:11',
- ],
- null,
- ],
- [
- new RamRoleArnClient('foo', 'bar', 'arn', 'name'),
- [
- 'Expiration' => '2017-02-02 11:11:11',
- ],
- null,
- ],
- [
- new RsaKeyPairClient('foo', VirtualRsaKeyPairCredential::ok()),
- [
- 'Expiration' => '2017-02-02 11:11:11',
- ],
- null,
- ],
- [
- new StsClient('foo', 'bar', 'token'),
- [
- 'Expiration' => '2017-02-02 11:11:11',
- ],
- null,
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Exception/ClientExceptionTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Exception/ClientExceptionTest.php
deleted file mode 100644
index cdddfda9..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Exception/ClientExceptionTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-getErrorMessage());
- static::assertEquals($errorCode, $exception->getErrorCode());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Exception/ServerExceptionTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Exception/ServerExceptionTest.php
deleted file mode 100644
index 8b671128..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Exception/ServerExceptionTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
- 'message',
- 'code' => 'code',
- 'Message' => 'Message',
- 'Code' => 'Code',
- 'errorMsg' => 'errorMsg',
- 'errorCode' => 'errorCode',
- 'requestId' => 'requestId',
- 'RequestId' => 'RequestId',
- ]
- );
- $result = new Result(new Response(200, [], $body));
-
- // Test
- $exception = new ServerException($result, $errorMessage, $errorCode);
-
- // Assert
- static::assertEquals($errorMessage, $exception->getErrorMessage());
- static::assertEquals($errorCode, $exception->getErrorCode());
- static::assertEquals('RequestId', $exception->getRequestId());
- static::assertInstanceOf(Result::class, $exception->getResult());
- static::assertEquals('message', $exception->getResult()->toArray()['message']);
- static::assertEquals('code', $exception->getResult()->toArray()['code']);
- static::assertEquals('Message', $exception->getResult()->toArray()['Message']);
- static::assertEquals('Code', $exception->getResult()->toArray()['Code']);
- static::assertEquals('errorMsg', $exception->getResult()->toArray()['errorMsg']);
- static::assertEquals('errorCode', $exception->getResult()->toArray()['errorCode']);
- static::assertEquals('requestId', $exception->getResult()->toArray()['requestId']);
- static::assertEquals('RequestId', $exception->getResult()->toArray()['RequestId']);
- }
-
- public function testNoContentAndParameter()
- {
- // Setup
- $body = \json_encode(
- [
- '1' => '1'
- ]
- );
- $result = new Result(new Response(200, [], $body));
-
- // Test
- $exception = new ServerException($result);
-
- // Assert
- static::assertEquals('{"1":"1"}', $exception->getErrorMessage());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/ApiFilterTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/ApiFilterTest.php
deleted file mode 100644
index f1e857be..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/ApiFilterTest.php
+++ /dev/null
@@ -1,101 +0,0 @@
-getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function endpointSuffix()
- {
- return [
- [
- 1,
- 1,
- 'Endpoint Suffix must be a string',
- ],
- [
- '',
- '',
- 'Endpoint Suffix cannot be empty',
- ],
- [
- 'EndpointSuffix中文',
- 'EndpointSuffix中文',
- 'Invalid Endpoint Suffix',
- ],
- [
- 'suffix',
- 'suffix',
- '',
- ]
- ];
- }
-
- /**
- * @dataProvider network
- *
- * @param $expected
- * @param $contentType
- * @param $exceptionMessage
- */
- public function testNetwork($expected, $contentType, $exceptionMessage)
- {
- try {
- self::assertEquals($expected, ApiFilter::network($contentType));
- } catch (ClientException $exception) {
- self::assertEquals($exceptionMessage, $exception->getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function network()
- {
- return [
- [
- 1,
- 1,
- 'Network Suffix must be a string',
- ],
- [
- '',
- '',
- 'Network Suffix cannot be empty',
- ],
- [
- 'Network中文',
- 'Network中文',
- 'Invalid Network Suffix',
- ],
- [
- 'share',
- 'share',
- '',
- ]
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/ClientFilterTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/ClientFilterTest.php
deleted file mode 100644
index d5d2f4b6..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/ClientFilterTest.php
+++ /dev/null
@@ -1,136 +0,0 @@
-getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function retry()
- {
- return [
- [
- '',
- '',
- 'Retry must be a int',
- ],
- [
- 1,
- 1,
- 'Retry must be a int',
- ],
- [
- 'a',
- 'a',
- 'Retry must be a int',
- ],
- ];
- }
-
- /**
- * @dataProvider regionId
- *
- * @param $expected
- * @param $contentType
- * @param $exceptionMessage
- */
- public function testRegionId($expected, $contentType, $exceptionMessage)
- {
- try {
- self::assertEquals($expected, ClientFilter::regionId($contentType));
- } catch (ClientException $exception) {
- self::assertEquals($exceptionMessage, $exception->getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function regionId()
- {
- return [
- [
- 1,
- 1,
- 'Region ID must be a string',
- ],
- [
- '',
- '',
- 'Region ID cannot be empty',
- ],
- [
- 'regionId中文',
- 'regionId中文',
- 'Invalid Region ID',
- ],
- [
- 'cn-hangzhou',
- 'cn-hangzhou',
- '',
- ]
- ];
- }
-
- /**
- * @dataProvider accept
- *
- * @param $expected
- * @param $contentType
- * @param $exceptionMessage
- */
- public function testAccept($expected, $contentType, $exceptionMessage)
- {
- try {
- self::assertEquals($expected, HttpFilter::accept($contentType));
- } catch (ClientException $exception) {
- self::assertEquals($exceptionMessage, $exception->getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function accept()
- {
- return [
- [
- '',
- '',
- 'Accept cannot be empty',
- ],
- [
- 1,
- 1,
- 'Accept must be a string',
- ],
- [
- 'a',
- 'a',
- 'a',
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/CredentialFilterTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/CredentialFilterTest.php
deleted file mode 100644
index 6865f0fc..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/CredentialFilterTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function accessKey()
- {
- return [
- [
- '',
- 'AccessKeySecret',
- 'AccessKey ID cannot be empty',
- ],
- [
- 'AccessKey',
- 1,
- 'AccessKey Secret must be a string',
- ],
- [
- 'AccessKey',
- '',
- 'AccessKey Secret cannot be empty',
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/HttpFilterTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/HttpFilterTest.php
deleted file mode 100644
index 7de182d7..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Filter/HttpFilterTest.php
+++ /dev/null
@@ -1,92 +0,0 @@
-getMessage());
- }
- }
-
- /**
- * @return array
- */
- public function contentType()
- {
- return [
- [
- '',
- '',
- 'Content-Type cannot be empty',
- ],
- [
- 1,
- 1,
- 'Content-Type must be a string',
- ],
- [
- 'a',
- 'a',
- 'a',
- ],
- ];
- }
-
-
- /**
- * @dataProvider accept
- *
- * @param $expected
- * @param $contentType
- * @param $exceptionMessage
- */
- public function testAccept($expected, $contentType, $exceptionMessage)
- {
- try {
- self::assertEquals($expected, HttpFilter::accept($contentType));
- } catch (ClientException $exception) {
- self::assertEquals($exceptionMessage, $exception->getMessage());
- }
- }
-
-
- /**
- * @return array
- */
- public function accept()
- {
- return [
- [
- '',
- '',
- 'Accept cannot be empty',
- ],
- [
- 1,
- 1,
- 'Accept must be a string',
- ],
- [
- 'a',
- 'a',
- 'a',
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Request/ArrayAccessTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Request/ArrayAccessTraitTest.php
deleted file mode 100644
index 22077407..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Request/ArrayAccessTraitTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-object));
- $request->object = 'object';
- self::assertTrue(isset($request->object));
- self::assertEquals('object', $request->object);
-
- self::assertFalse(isset($request['array']));
- $request['array'] = 'array';
- self::assertTrue(isset($request['array']));
- self::assertEquals('array', $request['array']);
-
- self::assertEquals(null, $request['not_exists']);
-
- unset($request['array']);
- self::assertFalse(isset($request['array']));
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Request/DeprecatedTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Request/DeprecatedTraitTest.php
deleted file mode 100644
index 6fad325a..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Request/DeprecatedTraitTest.php
+++ /dev/null
@@ -1,121 +0,0 @@
-options['form_params']) ? $request->options['form_params'] : []);
- }
-
- /**
- * @throws ClientException
- */
- public function testGetLocationEndpointType()
- {
- // Setup
- $request = new RpcRequest();
-
- // Assert
- self::assertEquals('openAPI', $request->endpointType);
- $endpointType = 'test';
-
- // Test
- $request->endpointType = $endpointType;
-
- // Assert
- self::assertEquals($endpointType, $request->endpointType);
- }
-
- /**
- * @throws ClientException
- */
- public function testGetLocationServiceCode()
- {
- // Setup
- $request = new RpcRequest();
-
- // Assert
- self::assertEquals(null, $request->serviceCode);
- $content = 'test';
-
- // Test
- $request->serviceCode = $content;
-
- // Assert
- self::assertEquals($content, $request->serviceCode);
- }
-
- /**
- * @dataProvider encode
- *
- * @param array $array
- * @param string $expected
- */
- public function testEncode(array $array, $expected)
- {
- // Assert
- self::assertEquals(
- $expected,
- Encode::create($array)->toString()
- );
- }
-
- /**
- * @return array
- */
- public function encode()
- {
- return [
- [
- [1, 2, 3],
- '0=1&1=2&2=3',
- ],
- [
- [
- 'a' => 'a',
- 'b' => 'b',
- 'c' => 'c',
- ],
- 'a=a&b=b&c=c',
- ],
- [
- [
- 'a' => 'a',
- 'b' => 'b',
- 3,
- 4,
- ],
- 'a=a&b=b&0=3&1=4',
- ],
- [
- [
- 'a' => 'a',
- 'b' => 'b ',
- 3,
- 4,
- ],
- 'a=a&b=b%20&0=3&1=4',
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Result/ResultTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Result/ResultTest.php
deleted file mode 100644
index 338631f7..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Result/ResultTest.php
+++ /dev/null
@@ -1,168 +0,0 @@
- [
- 'name' => 'value',
- ],
- ],
- (new RpcRequest())->format('json'),
- ],
- [
- [
- 'key' => [
- 'name' => 'value',
- ],
- ],
- (new RpcRequest())->format('xml'),
- ],
- [
- [
- 'key' => [
- 'name' => 'value',
- ],
- ],
- (new RpcRequest())->format('RAW'),
- ],
- [
- [
- 'key' => [
- 'name' => 'value',
- ],
- ],
- (new RpcRequest())->format('unknown'),
- ],
- ];
- }
-
- /**
- * @dataProvider requests
- *
- * @param array $data
- * @param Request $request
- */
- public function testGetRequest(array $data, Request $request)
- {
- // Setup
- $response = new Response(200, [], \json_encode($data));
- $result = new Result($response, $request);
-
- // Assert
- self::assertInstanceOf(Request::class, $result->getRequest());
- }
-
- public function testGetResponse()
- {
- // Setup
- $result = new Result(new Response());
-
- // Assert
- self::assertInstanceOf(Response::class, $result);
- self::assertInstanceOf(Result::class, $result);
- }
-
- /**
- * @dataProvider responses
- *
- * @param Response $response
- * @param bool $bool
- */
- public function testIsSuccess(Response $response, $bool)
- {
- // Setup
- $result = new Result($response);
-
- // Assert
- self::assertEquals($bool, $result->isSuccess());
- }
-
- /**
- * @return array
- */
- public function responses()
- {
- return [
- [
- new Response(),
- true,
- ],
- [
- new Response(301),
- false,
- ],
- [
- new Response(199),
- false,
- ],
- ];
- }
-
- public function testToString()
- {
- // Setup
- $result = new Result(new Response());
-
- // Assert
- self::assertEquals('', (string)$result);
- }
-
- /**
- * @dataProvider issetData
- *
- * @param array $data
- * @param string $name
- * @param string $expected
- */
- public function testIsset(array $data, $name, $expected)
- {
- // Setup
- $response = new Response(200, [], \json_encode($data));
- $result = new Result($response);
-
- // Assert
- self::assertEquals($expected, isset($result->$name));
- }
-
- /**
- * @return array
- */
- public function issetData()
- {
- return [
- [
- ['key' => 'value'],
- 'key',
- true,
- ],
- [
- [],
- 'null',
- false,
- ],
- ];
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/BearerTokenSignatureTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/BearerTokenSignatureTest.php
deleted file mode 100644
index 41661a42..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/BearerTokenSignatureTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-sign($string, $accessKeySecret));
- static::assertEquals('', $signature->getMethod());
- static::assertEquals('1.0', $signature->getVersion());
- static::assertEquals('BEARERTOKEN', $signature->getType());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/ShaHmac1SignatureTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/ShaHmac1SignatureTest.php
deleted file mode 100644
index 6ea05c4c..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/ShaHmac1SignatureTest.php
+++ /dev/null
@@ -1,41 +0,0 @@
-getMethod());
- static::assertEquals('1.0', $signature->getVersion());
- static::assertEquals('', $signature->getType());
- static::assertEquals($expected, $signature->sign($string, $accessKeySecret));
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/ShaHmac256SignatureTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/ShaHmac256SignatureTest.php
deleted file mode 100644
index 7ee9a6af..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Signature/ShaHmac256SignatureTest.php
+++ /dev/null
@@ -1,44 +0,0 @@
-getMethod());
- static::assertEquals('1.0', $signature->getVersion());
- static::assertEquals('', $signature->getType());
- static::assertEquals(
- $expected,
- $signature->sign($string, $accessKeySecret)
- );
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Support/ArraysTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Support/ArraysTest.php
deleted file mode 100644
index a59552d7..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Support/ArraysTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
- 'abc'];
- $array2 = ['a', 'b'];
- $params = Arrays::merge(
- [
- $array1,
- $array2
- ]
- );
-
- self::assertEquals(
- [
- 0 => 'abc',
- 1 => 'a',
- 2 => 'b'
- ],
- $params
- );
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Support/SignTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Support/SignTest.php
deleted file mode 100644
index 52b18106..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Support/SignTest.php
+++ /dev/null
@@ -1,14 +0,0 @@
-dot($data);
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/HasDataTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/HasDataTraitTest.php
deleted file mode 100644
index d060c91a..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/HasDataTraitTest.php
+++ /dev/null
@@ -1,530 +0,0 @@
-search($expression));
- }
-
- /**
- * @return array
- */
- public function searchData()
- {
- return [
- [
- // Data
- [
- 'key' => [
- 'name' => 'value',
- ],
- ],
- // Expression
- 'key.name',
- // Expected
- 'value',
- ],
- [
- // Data
- [
- 'key' => [
- 'name' => 'value',
- ],
- ],
- // Expression
- 'key',
- // Expected
- ['name' => 'value',],
- ],
- [
- // Data
- [
- 'key' => [
- 'name' => [
- 'value',
- ],
- ],
- ],
- // Expression
- 'key.name',
- // Expected
- ['value'],
- ],
- [
- // Data
- [
- 'key' => [
- 'name' => [
- 'a',
- 'b',
- 'c',
- ],
- ],
- ],
- // Expression
- 'key.name[2]',
- // Expected
- 'c',
- ],
- ];
- }
-
- public function testAdd()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Assert
- self::assertEquals([], $result->all());
-
- // Test
- $result->add('a.b.c', 'value');
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => [
- 'c' => 'value',
- ],
- ],
- ],
- $result->all()
- );
-
- // Test
- $result->add('b');
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => [
- 'c' => 'value',
- ],
- ],
- 'b' => null,
- ],
- $result->all()
- );
- }
-
- public function testClear()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->add('a.b.c', 'value');
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => [
- 'c' => 'value',
- ],
- ],
- ],
- $result->all()
- );
-
- // Test
- $result->clear('a.b');
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => [],
- ],
- ],
- $result->all()
- );
-
- // Test
- $result->clear('a');
-
- // Assert
- self::assertEquals(['a' => [],], $result->all());
-
- // Test
- $result->clear();
-
- // Assert
- self::assertEquals([], $result->all());
- }
-
- public function testDelete()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->add('a.b.c', 'value');
- $result->delete('a.b.c');
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => [],
- ],
- ],
- $result->all()
- );
- }
-
- public function testFlatten()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->add('a.b.c', 'value');
- $result->add('b.c.d.e', 'value');
-
- // Assert
- self::assertEquals(
- [
- 'a.b.c' => 'value',
- 'b.c.d.e' => 'value',
- ],
- $result->flatten()
- );
- }
-
- public function testGet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->add('a.b.c', 'value');
- $result->add('b.c.d.e', 'value');
-
- // Assert
- self::assertEquals(null, $result->get('null'));
-
- // Assert
- self::assertEquals(
- [
- 'b' => [
- 'c' => 'value',
- ],
- ],
- $result->get('a')
- );
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => [
- 'c' => 'value',
- ],
- ],
- 'b' => [
- 'c' => [
- 'd' => [
- 'e' => 'value',
- ],
- ],
- ],
- ],
- $result->get()
- );
- }
-
- public function testHas()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->add('a.b.c', 'value');
- $result->add('b.c.d.e', 'value');
-
- // Assert
- self::assertEquals(true, $result->has('a'));
- self::assertEquals(true, $result->has('a.b'));
- self::assertEquals(true, $result->has('a.b.c'));
- self::assertEquals(true, $result->has('b'));
- self::assertEquals(true, $result->has('b.c'));
- self::assertEquals(true, $result->has('b.c.d'));
- self::assertEquals(true, $result->has('b.c.d.e'));
- self::assertEquals(false, $result->has('e'));
-
- $result->clear();
- self::assertEquals(false, $result->has('a'));
- }
-
- public function testSetAndIsEmpty()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
-
- // Assert
- self::assertEquals('value', $result->get('a.b.c'));
- self::assertEquals(false, $result->isEmpty('a.b.c'));
- self::assertEquals(true, $result->isEmpty('a.b.c.d'));
-
- // Test
- $result->set('b.c.d.e', 'value');
-
- // Assert
- self::assertEquals('value', $result->get('b.c.d.e'));
- self::assertEquals(false, $result->isEmpty('b.c.d.e'));
- }
-
- public function testSetReference()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
-
- $array = [1, 2, 3];
- $result->setReference($array);
-
- // Assert
- self::assertEquals($array, $result->all());
- }
-
- public function testToJson()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
-
- // Assert
- self::assertEquals('{"a":{"b":{"c":"value"}}}', $result->toJson());
- }
-
- public function testToArray()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
-
- // Assert
- self::assertEquals($result->all(), $result->toArray());
- }
-
- public function testOffsetExists()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
-
- // Assert
- self::assertEquals(true, isset($result['a']));
- self::assertEquals(true, isset($result['a.b.c']));
- self::assertEquals(false, isset($result['b']));
- }
-
- public function testOffsetGet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
-
- // Assert
- self::assertEquals('value', $result['a.b.c']);
- self::assertEquals(null, $result['b']);
- }
-
- public function testOffsetSet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result->set('a.b.c', 'value');
- $result['d'] = 'd';
- $result['d.e.f'] = 'f';
-
- // Assert
- self::assertEquals('value', $result['a.b.c']);
- self::assertEquals(
- [
- 'e' => [
- 'f' => 'f',
- ],
- ],
- $result['d']
- );
- self::assertEquals('f', $result['d.e.f']);
- }
-
- public function testOffsetUnSet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Test
- $result['d.e.f'] = 'f';
-
- // Assert
- self::assertEquals(
- [
- 'e' => [
- 'f' => 'f',
- ],
- ],
- $result['d']
- );
-
- // Test
- unset($result['d.e.f']);
-
- // Assert
- self::assertEquals(
- [
- 'e' => [
- ],
- ],
- $result['d']
- );
-
- // Test
- unset($result['d.e']);
-
- // Assert
- self::assertEquals([], $result['d']);
- }
-
- public function testCount()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Assert
- self::assertEquals(0, $result->count());
-
- // Test
- $result['d.e.f'] = 'f';
-
- // Assert
- self::assertEquals(1, $result->count());
-
- // Test
- $result['e'] = 'e';
-
- // Assert
- self::assertEquals(2, $result->count());
- }
-
- public function testGetIterator()
- {
- // Setup
- $result = new HasDataTraitClass([]);
-
- // Assert
- self::assertInstanceOf(\ArrayIterator::class, $result->getIterator());
- }
-
- public function testJsonSerialize()
- {
- // Setup
- $result = new HasDataTraitClass([]);
- $result['a.b'] = 'c';
-
- // Assert
- self::assertEquals(
- [
- 'a' => [
- 'b' => 'c',
- ],
- ],
- $result->jsonSerialize()
- );
- }
-
- public function testObjectGet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
- $result['a.b'] = 'c';
- $result['d'] = 'e';
-
- // Assert
- self::assertEquals('c', $result->a->b);
- self::assertEquals('e', $result->d);
- self::assertEquals(null, $result->null);
- }
-
- public function testObjectSet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
- $result->a = 'a';
- $result->b = 'b';
-
- // Assert
- self::assertEquals('a', $result->a);
- self::assertEquals('b', $result->b);
- }
-
- public function testObjectIsSet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
- $result->a = 'a';
-
- // Assert
- self::assertEquals(true, isset($result->a));
- self::assertEquals(false, isset($result->b));
- }
-
- public function testObjectUnSet()
- {
- // Setup
- $result = new HasDataTraitClass([]);
- $result->a = 'a';
-
- // Assert
- self::assertEquals(true, isset($result->a));
-
- // Test
- unset($result->a);
-
- // Assert
- self::assertEquals(false, isset($result->a));
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/HistoryTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/HistoryTraitTest.php
deleted file mode 100644
index 3f5d5556..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/HistoryTraitTest.php
+++ /dev/null
@@ -1,88 +0,0 @@
- 'Bar'];
- $body = [
- 'Code' => 'code',
- 'Message' => 'message',
- ];
-
- AlibabaCloud::mockResponse(200, $header, $body);
- AlibabaCloud::mockResponse(200, $header, $body);
-
- AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
-
- AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
- self::assertCount(2, AlibabaCloud::getHistory());
- self::assertEquals(2, AlibabaCloud::countHistory());
- }
-
- /**
- * @depends testCountHistory
- */
- public function testFlushHistory()
- {
- AlibabaCloud::forgetHistory();
- self::assertCount(0, AlibabaCloud::getHistory());
- self::assertEquals(0, AlibabaCloud::countHistory());
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testNotRememberHistory()
- {
- AlibabaCloud::forgetHistory();
- AlibabaCloud::notRememberHistory();
- $header = ['X-Foo' => 'Bar'];
- $body = [
- 'Code' => 'code',
- 'Message' => 'message',
- ];
-
- AlibabaCloud::mockResponse(200, $header, $body);
- AlibabaCloud::mockResponse(200, $header, $body);
-
- AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
-
- AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
- self::assertCount(0, AlibabaCloud::getHistory());
- self::assertEquals(0, AlibabaCloud::countHistory());
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/LogTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/LogTraitTest.php
deleted file mode 100644
index 78ab6cc1..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/LogTraitTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-pushHandler(new StreamHandler($logFile));
- AlibabaCloud::setLogger($logger);
- AlibabaCloud::setLogFormat('{start_time} "{method} {uri} HTTP/{version}" {code} {cost} {hostname} {pid} Custom field');
-
- // Setup
- $regionId = 'cn-hangzhou';
- $bearerToken = 'BEARER_TOKEN';
- AlibabaCloud::bearerTokenClient($bearerToken)
- ->name('BEARER_TOKEN')
- ->regionId($regionId);
-
- // Test
- try {
- (new DescribeClusterServicesRequest())
- ->client('BEARER_TOKEN')
- ->withClusterId(\time())
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (ServerException $e) {
- // Assert
- static::assertEquals('UnsupportedSignatureType', $e->getErrorCode());
- }
-
- $logContent = file_get_contents($logFile);
- self::assertNotFalse(strpos($logContent, 'Version=2015-12-15'));
- self::assertNotFalse(strpos($logContent, 'Custom field'));
- }
-}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/RegionTraitTest.php b/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/RegionTraitTest.php
deleted file mode 100644
index 013d69f2..00000000
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/RegionTraitTest.php
+++ /dev/null
@@ -1,33 +0,0 @@
-regionId($regionId)
- ->name($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function tearDown()
- {
- AlibabaCloud::del($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function testCCC()
- {
- try {
- (new ListPhoneNumbersRequest())
- ->client($this->clientName)
- ->withInstanceId(\getenv('CC_INSTANCE_ID'))
- ->withOutboundOnly(true)
- ->scheme('https')
- ->host('ccc.cn-shanghai.aliyuncs.com')
- ->options([
- 'verify' => false,
- ])
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (ServerException $e) {
- $result = $e->getResult();
- self::assertEquals(
- 'InvalidBearerTokenException: Bearertoken has expired',
- $result['Message']
- );
- }
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /UnsupportedSignatureType: This signature type is not supported./
- * @throws ClientException
- */
- public function testEcs()
- {
- (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /UnsupportedSignatureType: This signature type is not supported./
- * @throws ClientException
- */
- public function testCdn()
- {
- (new DescribeCdnServiceRequest())->client($this->clientName)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Credentials/EcsRamRoleCredentialTest.php b/tests/LowerthanVersion7_2/Feature/Credentials/EcsRamRoleCredentialTest.php
deleted file mode 100644
index 8548aaa7..00000000
--- a/tests/LowerthanVersion7_2/Feature/Credentials/EcsRamRoleCredentialTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-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',
- ]
- );
- }
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Credentials/IniCredentialFeatureTest.php b/tests/LowerthanVersion7_2/Feature/Credentials/IniCredentialFeatureTest.php
deleted file mode 100644
index 806eb0ed..00000000
--- a/tests/LowerthanVersion7_2/Feature/Credentials/IniCredentialFeatureTest.php
+++ /dev/null
@@ -1,266 +0,0 @@
-getCredential()->getAccessKeyId());
- self::assertEquals('bar', $client->getCredential()->getAccessKeySecret());
- self::assertEquals(0.2, $client->options['timeout']);
- self::assertEquals(0.03, $client->options['connect_timeout']);
- self::assertEquals(true, $client->options['debug']);
- self::assertEquals('tcp://localhost:8125', $client->options['proxy']['http']);
- self::assertEquals('tcp://localhost:9124', $client->options['proxy']['https']);
- self::assertEquals(['.mit.edu', 'foo.com'], $client->options['proxy']['no']);
- self::assertEquals(['/path/server.pem', 'password'], $client->options['cert']);
- self::assertEquals('cn-hangzhou', $client->regionId);
- }
-
- /**
- * @throws ClientException
- */
- public function testEcsRamRoleClient()
- {
- AlibabaCloud::load(VirtualEcsRamRoleCredential::client());
- self::assertTrue(AlibabaCloud::has('phpunit'));
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'role_name' option for 'phpunit'
- */
- public function testEcsRamRoleClientNoRoleName()
- {
- AlibabaCloud::load(VirtualEcsRamRoleCredential::noRoleName());
- }
-
- /**
- * @throws ClientException
- */
- public function testRamRoleArnClient()
- {
- AlibabaCloud::load(VirtualRamRoleArnCredential::client());
- self::assertTrue(AlibabaCloud::has('phpunit'));
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'access_key_id' option for 'phpunit'
- */
- public function testRamRoleArnClientNoKey()
- {
- AlibabaCloud::load(VirtualRamRoleArnCredential::noKey());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'access_key_secret' option for 'phpunit'
- */
- public function testRamRoleArnClientNoSecret()
- {
- AlibabaCloud::load(VirtualRamRoleArnCredential::noSecret());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'role_arn' option for 'phpunit'
- */
- public function testRamRoleArnClientNoRoleArn()
- {
- AlibabaCloud::load(VirtualRamRoleArnCredential::noRoleArn());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'role_session_name' option for 'phpunit'
- */
- public function testRamRoleArnClientNoRoleSessionName()
- {
- AlibabaCloud::load(VirtualRamRoleArnCredential::noRoleSessionName());
- }
-
- /**
- * @throws ClientException
- */
- public function testBearerTokenClient()
- {
- AlibabaCloud::load(VirtualBearerTokenCredential::client());
- self::assertTrue(AlibabaCloud::has('phpunit'));
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'bearer_token' option for 'phpunit'
- */
- public function testBearerTokenClientNoToken()
- {
- AlibabaCloud::load(VirtualBearerTokenCredential::noToken());
- }
-
- /**
- * @throws ClientException
- */
- public function testAkClientWithAttributes()
- {
- AlibabaCloud::load(VirtualAccessKeyCredential::akClientWithAttributes('akClientWithAttributes'));
- AlibabaCloud::load(VirtualAccessKeyCredential::akClientWithAttributesNoCertPassword('NoCertPassword'));
- static::assertTrue(AlibabaCloud::has('akClientWithAttributes'));
- static::assertFalse(AlibabaCloud::has('NoCertPassword'));
- }
-
- /**
- * @throws ClientException
- */
- public function testAkClientWithAttributesNoCertPassword()
- {
- AlibabaCloud::load(VirtualAccessKeyCredential::akClientWithAttributesNoCertPassword('NoCertPassword'));
- static::assertTrue(AlibabaCloud::has('NoCertPassword'));
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'public_key_id' option for 'phpunit'
- */
- public function testNoPublicKeyId()
- {
- AlibabaCloud::load(VirtualRsaKeyPairCredential::noPublicKeyId());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage Missing required 'private_key_file' option for 'phpunit'
- */
- public function testNoPrivateKeyFile()
- {
- AlibabaCloud::load(VirtualRsaKeyPairCredential::noPrivateKeyFile());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage file_get_contents(/bad/path.pem): failed to open stream: No such file or
- * directory
- */
- public function testBadPrivateKeyFilePath()
- {
- AlibabaCloud::load(VirtualRsaKeyPairCredential::badPrivateKeyFilePath());
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Credentials/RsaKeyPairCredentialTest.php b/tests/LowerthanVersion7_2/Feature/Credentials/RsaKeyPairCredentialTest.php
deleted file mode 100644
index 60f8b9be..00000000
--- a/tests/LowerthanVersion7_2/Feature/Credentials/RsaKeyPairCredentialTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
-regionId($regionId)
- ->name($this->clientName);
- }
-
- /**
- * @throws ClientException
- */
- public function tearDown()
- {
- AlibabaCloud::del($this->clientName);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /NoPermission: You are not authorized to do this action. You should be authorized by RAM./
- * @throws ClientException
- * @throws ServerException
- */
- public function testGetSessionCredential()
- {
- $credential = AlibabaCloud::get($this->clientName)
- ->getSessionCredential(30, 25);
- self::assertInstanceOf(StsCredential::class, $credential);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /NoPermission: You are not authorized to do this action. You should be authorized by RAM./
- * @throws ClientException
- * @throws ServerException
- */
- public function testEcsInJapan()
- {
- $result = (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->connectTimeout(20)
- ->timeout(25)
- ->request();
-
- static::assertArrayHasKey('AccessPointSet', $result);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /NoPermission: You are not authorized to do this action. You should be authorized by RAM./
- * @throws ClientException
- * @throws ServerException
- */
- public function testEcsNotInJapan()
- {
- // Setup
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
-
- // Test
- (new DescribeAccessPointsRequest())
- ->client($this->clientName)
- ->regionId($regionId)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/ChainProviderRequestTest.php b/tests/LowerthanVersion7_2/Feature/Request/ChainProviderRequestTest.php
deleted file mode 100644
index fdfdd974..00000000
--- a/tests/LowerthanVersion7_2/Feature/Request/ChainProviderRequestTest.php
+++ /dev/null
@@ -1,138 +0,0 @@
-url();
- putenv("ALIBABA_CLOUD_CREDENTIALS_FILE=$file");
- AlibabaCloud::flush();
-
- // Test
- AlibabaCloud::setDefaultRegionId('cn-hangzhou');
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->debug(true)
- ->request();
- } catch (ClientException $e) {
- self::assertEquals(SDK::SERVER_UNREACHABLE, $e->getErrorCode());
- }
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/
- * @throws ClientException
- * @throws ServerException
- */
- public function testDefaultProviderOnEnv()
- {
- // Setup
- $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
- $secret = \AlibabaCloud\Client\env('ACCESS_KEY_SECRET');
- putenv("ALIBABA_CLOUD_ACCESS_KEY_ID=$id");
- putenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET=$secret");
-
- // Test
- AlibabaCloud::setDefaultRegionId('cn-hangzhou');
- $result = AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- // self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
- }
-
- /**
- * @depends testDefaultProviderOnEnv
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /Forbidden.RAM: User not authorized to operate on the specified resource, or this API doesn't support RAM/
- * @throws ServerException
- * @throws ClientException
- */
- public function testDefaultProviderOnIni()
- {
- // Setup
- $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
- $secret = \AlibabaCloud\Client\env('ACCESS_KEY_SECRET');
- $content = <<url();
- putenv("ALIBABA_CLOUD_CREDENTIALS_FILE=$file");
-
- // Test
- AlibabaCloud::setDefaultRegionId('cn-hangzhou');
- $result = AlibabaCloud::rpc()
- ->client('testDefaultProviderOnIni')
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- // self::assertNotEmpty('PayByTraffic', $result['ChangingChargeType']);
- }
-
- protected function setUp()
- {
- AlibabaCloud::flush();
- CredentialsProvider::flush();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/ImageSearch.jpg b/tests/LowerthanVersion7_2/Feature/Request/ImageSearch.jpg
deleted file mode 100644
index 2ccc3a07..00000000
Binary files a/tests/LowerthanVersion7_2/Feature/Request/ImageSearch.jpg and /dev/null differ
diff --git a/tests/LowerthanVersion7_2/Feature/Request/ProxyTest.php b/tests/LowerthanVersion7_2/Feature/Request/ProxyTest.php
deleted file mode 100644
index c3eca457..00000000
--- a/tests/LowerthanVersion7_2/Feature/Request/ProxyTest.php
+++ /dev/null
@@ -1,145 +0,0 @@
-regionId($regionId)
- ->name($nameClient);
-
- // Test
- $result = (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- // Assert
- $headers = $result->getHeaders();
- static::assertArrayNotHasKey('Via', $headers);
- }
-
- /**
- * @throws ServerException
- * @throws ClientException
- */
- public function testProxyWithoutPassword()
- {
- // Setup
- $nameClient = 'name';
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
- $accessKeyId = \getenv('ACCESS_KEY_ID');
- $accessKeySecret = \getenv('ACCESS_KEY_SECRET');
-
- // Test
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId($regionId)
- ->name($nameClient);
-
- // Test
- $result = (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(25)
- ->timeout(30)
- ->proxy([
- 'http' => 'http://localhost:8989',
- ])
- ->request();
-
- // Assert
- $headers = $result->getHeaders();
- static::assertArrayHasKey('Via', $headers);
- static::assertEquals('HTTP/1.1 o_o', $headers['Via'][0]);
- static::assertNotNull($result->RequestId);
- static::assertNotNull($result->Regions->Region[0]->LocalName);
- static::assertNotNull($result->Regions->Region[0]->RegionId);
- }
-
- /**
- * @throws ServerException
- * @throws ClientException
- */
- public function testProxyWithPassword()
- {
- // Setup
- $nameClient = 'name';
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
- $accessKeyId = \getenv('ACCESS_KEY_ID');
- $accessKeySecret = \getenv('ACCESS_KEY_SECRET');
-
- // Test
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId($regionId)
- ->name($nameClient);
-
- // Test
- $result = (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(25)
- ->timeout(30)
- ->proxy([
- 'http' => 'http://username:password@localhost:8989',
- ])
- ->request();
-
- // Assert
- $headers = $result->getHeaders();
- static::assertArrayHasKey('Via', $headers);
- static::assertEquals('HTTP/1.1 o_o', $headers['Via'][0]);
- static::assertNotNull($result->RequestId);
- static::assertNotNull($result->Regions->Region[0]->LocalName);
- static::assertNotNull($result->Regions->Region[0]->RegionId);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessageRegExp /cURL error/
- * @throws ClientException
- * @throws ServerException
- */
- public function testProxyNotSet()
- {
- // Setup
- $nameClient = 'name';
- $regionId = \AlibabaCloud\Client\env('REGION_ID', 'cn-hangzhou');
- $accessKeyId = \getenv('ACCESS_KEY_ID');
- $accessKeySecret = \getenv('ACCESS_KEY_SECRET');
-
- // Test
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId($regionId)
- ->name($nameClient);
-
- // Assert
- (new DescribeRegionsRequest())->client($nameClient)
- ->connectTimeout(1)
- ->timeout(2)
- ->proxy([
- 'http' => 'http://localhost:55657',
- ])
- ->request();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/RetryByClientTest.php b/tests/LowerthanVersion7_2/Feature/Request/RetryByClientTest.php
deleted file mode 100644
index f6c7665e..00000000
--- a/tests/LowerthanVersion7_2/Feature/Request/RetryByClientTest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(0.001)
- ->timeout(0.001)
- ->request();
- } catch (Exception $exception) {
- self::assertTrue(Stringy::contains($exception->getMessage(), 'timed'));
- self::assertEquals(1, AlibabaCloud::countHistory());
- }
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRetryWithTimeout()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(0.001)
- ->timeout(0.001)
- ->retryByClient(3, ['timed'])
- ->request();
- } catch (Exception $exception) {
- self::assertTrue(Stringy::contains($exception->getMessage(), 'timed'));
- self::assertEquals(4, AlibabaCloud::countHistory());
- }
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRetryWithCode()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(0.001)
- ->timeout(0.001)
- ->retryByClient(3, [], [0])
- ->request();
- } catch (Exception $exception) {
- self::assertTrue(Stringy::contains($exception->getMessage(), 'timed'));
- self::assertEquals(4, AlibabaCloud::countHistory());
- }
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRetryWithFalse()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(0.001)
- ->timeout(0.001)
- ->retryByClient(3, [])
- ->request();
- } catch (Exception $exception) {
- self::assertTrue(Stringy::contains($exception->getMessage(), 'timed'));
- self::assertEquals(1, AlibabaCloud::countHistory());
- }
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/RetryByServerTest.php b/tests/LowerthanVersion7_2/Feature/Request/RetryByServerTest.php
deleted file mode 100644
index 8292f932..00000000
--- a/tests/LowerthanVersion7_2/Feature/Request/RetryByServerTest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnServiceNotFound')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (Exception $exception) {
- self::assertFalse(Stringy::contains($exception->getMessage(), 'Action or Version'));
- self::assertEquals(1, AlibabaCloud::countHistory());
- }
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRetryWithStrings()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnServiceNotFound')
- ->connectTimeout(25)
- ->timeout(30)
- ->retryByServer(3, ['Action or Version'])
- ->request();
- } catch (Exception $exception) {
- self::assertFalse(Stringy::contains($exception->getMessage(), 'Action or Version'));
- self::assertEquals(1, AlibabaCloud::countHistory());
- }
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRetryWithStatusCode()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnServiceNotFound')
- ->connectTimeout(25)
- ->timeout(30)
- ->retryByServer(3, [], [404])
- ->request();
- } catch (Exception $exception) {
- self::assertFalse(Stringy::contains($exception->getMessage(), 'Action or Version'));
- self::assertEquals(4, AlibabaCloud::countHistory());
- }
- }
-
- /**
- * @throws ClientException
- * @throws Exception
- */
- public function testRetryWithFalse()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnServiceNotFound')
- ->connectTimeout(25)
- ->timeout(30)
- ->retryByServer(3, [], [])
- ->request();
- } catch (Exception $exception) {
- self::assertFalse(Stringy::contains($exception->getMessage(), 'Action or Version'));
- self::assertEquals(1, AlibabaCloud::countHistory());
- }
- }
-}
diff --git a/tests/LowerthanVersion7_2/Feature/Request/RoaRequestTest.php b/tests/LowerthanVersion7_2/Feature/Request/RoaRequestTest.php
deleted file mode 100644
index f92f90ff..00000000
--- a/tests/LowerthanVersion7_2/Feature/Request/RoaRequestTest.php
+++ /dev/null
@@ -1,120 +0,0 @@
-asDefaultClient()->regionId('cn-hangzhou');
-
- $result = AlibabaCloud::roa()
- ->pathPattern('/clusters/[ClusterId]/services')
- ->method('GET')
- ->product('CS')
- ->version('2015-12-15')
- ->action('DescribeClusterServices')
- ->pathParameter('ClusterId', $clusterId)
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
-
- self::assertNotEmpty($result->toArray());
- } catch (ServerException $e) {
- self::assertEquals(
- "cluster ($clusterId) not found in our records",
- $e->getErrorMessage()
- );
- }
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /ServiceUnavailable: The request has failed due to a temporary failure of the server./
- * @throws ClientException
- * @throws ServerException
- */
- public function testRoaContent()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->name('content')->regionId('cn-shanghai');
-
- $request = new NlpRequest();
- $request->pathParameter('Domain', 'general');
- $request->jsonBody([
- 'lang' => 'ZH',
- 'text' => 'Iphone专用数据线'
- ]);
-
- $result = $request->client('content')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- self::assertEquals('Iphone', $result['data'][0]['word']);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testSearchImage()
- {
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->regionId('cn-shanghai')->name('im');
-
- $request = AlibabaCloud::roa()
- ->connectTimeout(40)
- ->timeout(50)
- ->client('im')
- ->product('ImageSearch')
- ->version('2019-03-25')
- ->method('POST')
- ->action('SearchImage')
- ->pathPattern('/v2/image/search')
- ->accept('application/json')
- ->contentType('application/x-www-form-urlencoded; charset=UTF-8');
-
- $content = file_get_contents(__DIR__ . '/ImageSearch.jpg');
-
- try {
- $result = $request->options([
- 'form_params' => [
- 'InstanceName' => getenv('IMAGE_SEARCH_INSTANCE_NAME'),
- 'PicContent' => base64_encode($content),
- 'Start' => 0,
- 'Num' => 10
- ]
- ])
- ->request();
- self::assertArrayHasKey('Actions', $result);
- } catch (ServerException $e) {
- self::assertEquals(400, $e->getCode());
- }
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/AlibabaCloudTest.php b/tests/LowerthanVersion7_2/Unit/AlibabaCloudTest.php
deleted file mode 100644
index 3d14f325..00000000
--- a/tests/LowerthanVersion7_2/Unit/AlibabaCloudTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-getSignature());
- self::assertEquals($credential, $client->getCredential());
- self::assertEquals($accessKeyId, $client->getCredential()->getAccessKeyId());
- self::assertEquals($accessKeySecret, $client->getCredential()->getAccessKeySecret());
-
- return $client;
- }
-
- /**
- * @depends testConstruct
- *
- * @param Client $client
- *
- * @throws ClientException
- */
- public function testName(Client $client)
- {
- // Setup
- $name = \uniqid('', true);
-
- // Test
- $client->name($name);
-
- // Assert
- self::assertEquals($client, AlibabaCloud::get($name));
- }
-
- /**
- * @depends testConstruct
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name cannot be empty
- *
- * @param Client $client
- *
- * @throws ClientException
- */
- public function testNameEmpty(Client $client)
- {
- $client->name('');
- }
-
- /**
- * @depends testConstruct
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name must be a string
- *
- * @param Client $client
- *
- * @throws ClientException
- */
- public function testNameFormat(Client $client)
- {
- $client->name(null);
- }
-
- /**
- * @depends testConstruct
- *
- * @param Client $client
- *
- * @throws ClientException
- */
- public function testAsDefaultClient(Client $client)
- {
- // Setup
- $name = CredentialsProvider::getDefaultName();
-
- // Test
- $client->asDefaultClient();
-
- // Assert
- self::assertEquals($client, AlibabaCloud::get($name));
- }
-
- /**
- * @depends testConstruct
- *
- * @param Client $client
- */
- public function testIsDebug(Client $client)
- {
- // Assert
- self::assertEquals(false, $client->isDebug());
-
- // Test
- $client->debug(true);
-
- // Assert
- self::assertEquals(true, $client->isDebug());
- }
-
- /**
- * @depends testConstruct
- *
- * @param Client $client
- *
- * @throws ClientException
- * @throws ServerException
- */
- public function testGetSessionCredential(Client $client)
- {
- self::assertInstanceOf(AccessKeyCredential::class, $client->getSessionCredential());
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/AccessKeyCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/AccessKeyCredentialTest.php
deleted file mode 100644
index c0833ca1..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/AccessKeyCredentialTest.php
+++ /dev/null
@@ -1,94 +0,0 @@
-assertEquals($accessKeyId, $credential->getAccessKeyId());
- $this->assertEquals($accessKeySecret, $credential->getAccessKeySecret());
- $this->assertEquals("$accessKeyId#$accessKeySecret", (string)$credential);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID cannot be empty
- * @throws ClientException
- */
- public function testAccessKeyIdEmpty()
- {
- // Setup
- $accessKeyId = '';
- $accessKeySecret = 'bar';
-
- new AccessKeyCredential($accessKeyId, $accessKeySecret);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID must be a string
- * @throws ClientException
- */
- public function testAccessKeyIdFormat()
- {
- // Setup
- $accessKeyId = null;
- $accessKeySecret = 'bar';
-
- new AccessKeyCredential($accessKeyId, $accessKeySecret);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret cannot be empty
- * @throws ClientException
- */
- public function testAccessKeySecretEmpty()
- {
- // Setup
- $accessKeyId = 'foo';
- $accessKeySecret = '';
-
- // Test
- new AccessKeyCredential($accessKeyId, $accessKeySecret);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret must be a string
- * @throws ClientException
- */
- public function testAccessKeySecretFormat()
- {
- // Setup
- $accessKeyId = 'foo';
- $accessKeySecret = null;
-
- // Test
- new AccessKeyCredential($accessKeyId, $accessKeySecret);
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/BearerTokenCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/BearerTokenCredentialTest.php
deleted file mode 100644
index 294b3f8a..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/BearerTokenCredentialTest.php
+++ /dev/null
@@ -1,65 +0,0 @@
-assertEquals($bearerToken, $credential->getBearerToken());
- $this->assertEquals('', $credential->getAccessKeyId());
- $this->assertEquals('', $credential->getAccessKeySecret());
- $this->assertEquals($expected, (string)$credential);
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/EcsRamRoleCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/EcsRamRoleCredentialTest.php
deleted file mode 100644
index 82e1735d..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/EcsRamRoleCredentialTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-assertEquals($roleName, $credential->getRoleName());
- $this->assertEquals($expected, (string)$credential);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Role Name cannot be empty
- * @throws ClientException
- */
- public function testRoleNameEmpty()
- {
- // Setup
- $roleName = '';
-
- // Test
- new EcsRamRoleCredential($roleName);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Role Name must be a string
- * @throws ClientException
- */
- public function testRoleNameFormat()
- {
- // Setup
- $roleName = null;
-
- // Test
- new EcsRamRoleCredential($roleName);
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Ini/IniCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/Ini/IniCredentialTest.php
deleted file mode 100644
index 3d11a806..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Ini/IniCredentialTest.php
+++ /dev/null
@@ -1,310 +0,0 @@
- '',
- ],
- 'key',
- false,
- ],
- [
- [
- 'key' => 'false',
- ],
- 'key',
- true,
- ],
- [
- [
- 'key' => true,
- ],
- 'key',
- true,
- ],
- [
- [
- 'key' => 'value',
- ],
- 'key',
- true,
- ],
- ];
- }
-
- /**
- * @throws ClientException
- */
- public static function testInOpenBaseDir()
- {
- if (!\AlibabaCloud\Client\isWindows()) {
- $dirs = 'vfs://AlibabaCloud:/home:/Users:/private:/a/b:/d';
- ini_set('open_basedir', $dirs);
- self::assertEquals($dirs, ini_get('open_basedir'));
- self::assertTrue(\AlibabaCloud\Client\inOpenBasedir('/Users/alibabacloud'));
- self::assertTrue(\AlibabaCloud\Client\inOpenBasedir('/private/alibabacloud'));
- self::assertFalse(\AlibabaCloud\Client\inOpenBasedir('/no/permission'));
- self::assertFalse(\AlibabaCloud\Client\inOpenBasedir('/a'));
- self::assertTrue(\AlibabaCloud\Client\inOpenBasedir('/a/b/'));
- self::assertTrue(\AlibabaCloud\Client\inOpenBasedir('/a/b/c'));
- self::assertFalse(\AlibabaCloud\Client\inOpenBasedir('/b'));
- self::assertFalse(\AlibabaCloud\Client\inOpenBasedir('/b/'));
- self::assertFalse(\AlibabaCloud\Client\inOpenBasedir('/x/d/c.txt'));
- self::assertFalse(\AlibabaCloud\Client\inOpenBasedir('/a/b.php'));
- }
- if (\AlibabaCloud\Client\isWindows()) {
- $dirs = 'C:\\projects;C:\\Users';
- ini_set('open_basedir', $dirs);
- self::assertEquals($dirs, ini_get('open_basedir'));
- }
- }
-
- /**
- * Independent method, the file must exist.
- *
- * @return array
- */
- public static function parseFile()
- {
- return [
- [
- VirtualAccessKeyCredential::ok(),
- 'Format error: vfs://AlibabaCloud/credentials-2',
- ],
- ];
- }
-
- /**
- * @covers ::__construct
- * @covers ::getDefaultFile
- * @covers ::getFilename
- * @dataProvider getFilename
- *
- * @param string $fileName
- * @param string $getFileName
- */
- public function testGetFilename($fileName, $getFileName)
- {
- $object = new IniCredential($fileName);
- self::assertEquals($getFileName, $object->getFilename());
- }
-
- /**
- * @return array
- */
- public function getFilename()
- {
- return [
- [
- '',
- (new IniCredential())->getDefaultFile(),
- ],
- [
- '/no/no/no',
- '/no/no/no',
- ],
- ];
- }
-
- /**
- * @dataProvider isNotEmpty
- *
- * @param array $array
- * @param string $key
- * @param bool $bool
- *
- * @throws ReflectionException
- */
- public function testIsNotEmpty($array, $key, $bool)
- {
- $object = new IniCredential();
- $ref = new ReflectionClass(
- IniCredential::class
- );
- $method = $ref->getMethod('isNotEmpty');
- $method->setAccessible(true);
- $result = $method->invokeArgs($object, [$array, $key]);
- self::assertEquals($result, $bool);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessageRegExp /Missing required 'key' option for 'name'/
- */
- public function testMissingRequired()
- {
- $object = new IniCredential();
- $object->missingRequired('key', 'name');
- }
-
- /**
- * @throws ReflectionException
- */
- public function testForgetLoadedCredentialsFile()
- {
- $reflectedClass = new ReflectionClass(IniCredential::class);
- $reflectedProperty = $reflectedClass->getProperty('hasLoaded');
- $reflectedProperty->setAccessible(true);
- $reflectedProperty->setValue([
- 'FILE' => 'FILE',
- ]);
- self::assertArrayHasKey('FILE', $reflectedClass->getStaticProperties()['hasLoaded']);
-
- IniCredential::forgetLoadedCredentialsFile();
-
- self::assertEquals([], $reflectedClass->getStaticProperties()['hasLoaded']);
- }
-
- /**
- * @throws ClientException
- */
- public function testLoad()
- {
- $object = new IniCredential(VirtualAccessKeyCredential::ok());
- self::assertEquals($object->load(), $object->load());
- }
-
- /**
- * @dataProvider loadFile
- *
- * @param string $fileName
- *
- * @throws ReflectionException
- */
- public function testLoadFile($fileName)
- {
- $object = new IniCredential($fileName);
- $method = new ReflectionMethod(
- IniCredential::class,
- 'loadFile'
- );
- $method->setAccessible(true);
- try {
- $result = $method->invoke($object);
- self::assertInternalType('array', $result);
- } catch (ClientException $exception) {
- self::assertEquals(
- $exception->getErrorMessage(),
- 'Credential file is not readable: /no/no.no'
- );
- }
- }
-
- /**
- * @return array
- */
- public function loadFile()
- {
- return [
- [''],
- ['/no/no.no'],
- ];
- }
-
- /**
- * @param string $fileName
- * @param string $exceptionMessage
- *
- * @throws ReflectionException
- * @dataProvider parseFile
- */
- public function testParseFile($fileName, $exceptionMessage)
- {
- $object = new IniCredential($fileName);
- $method = new ReflectionMethod(
- IniCredential::class,
- 'parseFile'
- );
- $method->setAccessible(true);
- try {
- self::assertArrayHasKey('ok', $method->invoke($object));
- } catch (ClientException $exception) {
- self::assertEquals(
- $exception->getErrorMessage(),
- $exceptionMessage
- );
- }
- }
-
- /**
- * @throws ReflectionException
- * @dataProvider parseFile
- */
- public function testParseFileBadFormat()
- {
- $object = new IniCredential(VirtualAccessKeyCredential::badFormat());
- $method = new ReflectionMethod(
- IniCredential::class,
- 'parseFile'
- );
- $method->setAccessible(true);
- try {
- self::assertArrayHasKey('ok', $method->invoke($object));
- } catch (ClientException $exception) {
- self::assertEquals(
- $exception->getErrorMessage(),
- 'Format error: vfs://AlibabaCloud/credentials-2-badFormat'
- );
- }
- }
-
- /**
- * @throws ReflectionException
- * @covers ::getHomeDirectory
- * @depends testParseFile
- */
- public function testGetsHomeDirectoryForWindowsUser()
- {
- putenv('HOME=');
- putenv('HOMEDRIVE=C:');
- putenv('HOMEPATH=\\Users\\Alibaba');
- $ref = new ReflectionClass(IniCredential::class);
- $method = $ref->getMethod('getHomeDirectory');
- $method->setAccessible(true);
- $this->assertEquals('C:\\Users\\Alibaba', $method->invoke(null));
- }
-
- /**
- * @throws ReflectionException
- * @covers ::getHomeDirectory
- * @depends testGetsHomeDirectoryForWindowsUser
- */
- public function testGetsHomeDirectoryForLinuxUser()
- {
- putenv('HOME=/root');
- putenv('HOMEDRIVE=');
- putenv('HOMEPATH=');
- $ref = new ReflectionClass(IniCredential::class);
- $method = $ref->getMethod('getHomeDirectory');
- $method->setAccessible(true);
- $this->assertEquals('/root', $method->invoke(null));
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Ini/VirtualAccessKeyCredential.php b/tests/LowerthanVersion7_2/Unit/Credentials/Ini/VirtualAccessKeyCredential.php
deleted file mode 100644
index 245974dd..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Ini/VirtualAccessKeyCredential.php
+++ /dev/null
@@ -1,228 +0,0 @@
-content = $content;
- $this->fileName = $fileName;
- }
-
- /**
- * @param string $clineName
- *
- * @return string
- */
- public static function akClientWithAttributes($clineName = 'phpunit')
- {
- $content = <<url();
- }
-
- /**
- * @return string Virtual Credential Filename
- */
- public function url()
- {
- $fileName = 'credentials-2';
- if ($this->fileName) {
- $fileName .= "-$this->fileName";
- }
-
- return vfsStream::newFile($fileName)
- ->withContent($this->content)
- ->at(vfsStream::setup('AlibabaCloud'))
- ->url();
- }
-
- /**
- * @param string $clineName
- *
- * @return string
- */
- public static function akClientWithAttributesNoCertPassword($clineName = 'phpunit')
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function noType()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function noSecret()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function badFormat()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function disable()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function invalidType()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function noKey()
- {
- $content = <<url();
- }
-
- /**
- * @return string
- */
- public static function ok()
- {
- $content = <<url();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/CredentialsProviderTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/Providers/CredentialsProviderTest.php
deleted file mode 100644
index 0fc775a6..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/CredentialsProviderTest.php
+++ /dev/null
@@ -1,218 +0,0 @@
-get();
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- * @throws ReflectionException
- */
- public function testGetInCache()
- {
- // Setup
- $client = new EcsRamRoleClient(
- 'foo'
- );
- $provider = new EcsRamRoleProvider($client);
-
- // Test
- $cacheMethod = new \ReflectionMethod(
- RsaKeyPairProvider::class,
- 'cache'
- );
- $cacheMethod->setAccessible(true);
- $result = [
- 'Expiration' => '2049-10-01 11:11:11',
- 'AccessKeyId' => 'foo',
- 'AccessKeySecret' => 'bar',
- 'SecurityToken' => 'token',
- ];
- $cacheMethod->invokeArgs($provider, [$result]);
- $actual = $provider->get();
-
- // Assert
- self::assertInstanceOf(StsCredential::class, $actual);
- }
-
- /**
- * @throws ServerException
- * @throws ClientException
- */
- public function testServerUnreachable()
- {
- // Setup
- $roleName = 'EcsRamRoleTest';
- $client = new EcsRamRoleClient($roleName);
-
- // Test
- $credential = new EcsRamRoleProvider($client);
-
- // Assert
- try {
- $credential->get();
- } catch (ClientException $e) {
- $this->assertEquals($e->getErrorCode(), SDK::SERVER_UNREACHABLE);
- }
- }
-
- /**
- * @throws ClientException
- */
- public function estInvalidCredential()
- {
- // Setup
- $roleName = 'EcsRamRoleTest';
- $client = new EcsRamRoleClient($roleName);
-
- // Test
- $provider = new EcsRamRoleProvider($client);
-
- // Assert
- try {
- $provider->get();
- } catch (ServerException $e) {
- $this->assertEquals(
- $e->getErrorCode(),
- SDK::INVALID_CREDENTIAL
- );
- }
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testOk()
- {
- AlibabaCloud::mockResponse(
- 200,
- [],
- '{
- "AccessKeyId" : "STS.*******",
- "AccessKeySecret" : "*******",
- "Expiration" : "2019-01-28T15:15:56Z",
- "SecurityToken" : "****",
- "LastUpdated" : "2019-01-28T09:15:55Z",
- "Code" : "Success"
-}'
- );
- $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
- $credential = $provider->get();
- self::assertInstanceOf(StsCredential::class, $credential);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessage SDK.InvalidCredential: Result contains no credentials RequestId:
- * @throws ClientException
- * @throws ServerException
- */
- public function testNoCredentials()
- {
- AlibabaCloud::mockResponse();
- $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
- $provider->get();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage The role was not found in the instance
- * @throws ClientException
- * @throws ServerException
- */
- public function test404()
- {
- AlibabaCloud::mockResponse(404);
- $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
- $provider->get();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessage SDK.InvalidCredential: Error retrieving credentials from result RequestId:
- * @throws ClientException
- * @throws ServerException
- */
- public function testErrorRetrieving()
- {
- AlibabaCloud::mockResponse(500);
- $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
- $provider->get();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Error
- * @throws ClientException
- * @throws ServerException
- */
- public function testRequestException()
- {
- AlibabaCloud::mockRequestException('Error', new Request('GET', 'test'));
- $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
- $provider->get();
- }
-
- protected function tearDown()
- {
- AlibabaCloud::cancelMock();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/RamRoleArnProviderTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/Providers/RamRoleArnProviderTest.php
deleted file mode 100644
index 9d027222..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/RamRoleArnProviderTest.php
+++ /dev/null
@@ -1,136 +0,0 @@
-get();
- self::assertInstanceOf(StsCredential::class, $actual);
- } catch (ClientException $e) {
- self::assertEquals(SDK::SERVER_UNREACHABLE, $e->getErrorCode());
- } catch (ServerException $e) {
- self::assertEquals('InvalidAccessKeyId.NotFound', $e->getErrorCode());
- }
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- * @throws ReflectionException
- */
- public function testGetInCache()
- {
- // Setup
- $client = new RamRoleArnClient(
- 'foo',
- 'bar',
- 'arn',
- 'name'
- );
- $provider = new RamRoleArnProvider($client);
-
- // Test
- $cacheMethod = new \ReflectionMethod(
- RamRoleArnProvider::class,
- 'cache'
- );
- $cacheMethod->setAccessible(true);
- $result = [
- 'Expiration' => '2049-10-01 11:11:11',
- 'AccessKeyId' => 'foo',
- 'AccessKeySecret' => 'bar',
- 'SecurityToken' => 'token',
- ];
- $cacheMethod->invokeArgs($provider, [$result]);
-
- $actual = $provider->get();
-
- // Assert
- self::assertInstanceOf(StsCredential::class, $actual);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessage SDK.InvalidCredential: Result contains no credentials RequestId:
- * @throws ClientException
- * @throws ServerException
- */
- public function testNoCredentials()
- {
- AlibabaCloud::mockResponse();
-
- $client = AlibabaCloud::ramRoleArnClient('id', 'secret', 'arn', 'session');
-
- $provider = new RamRoleArnProvider($client);
- $provider->get();
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testOk()
- {
- AlibabaCloud::mockResponse(
- 200,
- [],
- '{
- "RequestId": "88FEA385-EF5D-4A8A-8C00-A07DAE3BFD44",
- "AssumedRoleUser": {
- "AssumedRoleId": "********************",
- "Arn": "********************"
- },
- "Credentials": {
- "AccessKeySecret": "********************",
- "AccessKeyId": "STS.**************",
- "Expiration": "2020-02-25T03:56:19Z",
- "SecurityToken": "**************"
- }
-}'
- );
-
- $client = AlibabaCloud::ramRoleArnClient('id', 'secret', 'arn', 'session');
-
- $provider = new RamRoleArnProvider($client);
- $credential = $provider->get();
- self::assertInstanceOf(StsCredential::class, $credential);
- }
-
- protected function tearDown()
- {
- AlibabaCloud::cancelMock();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/RsaKeyPairProviderTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
deleted file mode 100644
index 659b5a55..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
+++ /dev/null
@@ -1,139 +0,0 @@
-get();
-
- // Assert
- self::assertInstanceOf(AccessKeyCredential::class, $actual);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- * @throws \ReflectionException
- */
- public function testGetInCache()
- {
- // Setup
- $client = new RsaKeyPairClient(
- 'foo',
- VirtualRsaKeyPairCredential::ok()
- );
- $provider = new RsaKeyPairProvider($client);
-
- // Test
- $cacheMethod = new \ReflectionMethod(
- RsaKeyPairProvider::class,
- 'cache'
- );
- $cacheMethod->setAccessible(true);
- $result = [
- 'Expiration' => '2049-10-01 11:11:11',
- 'SessionAccessKeyId' => 'foo',
- 'SessionAccessKeySecret' => 'bar',
- ];
- $cacheMethod->invokeArgs($provider, [$result]);
-
- $actual = $provider->get();
-
- // Assert
- self::assertInstanceOf(StsCredential::class, $actual);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessage SDK.InvalidCredential: Result contains no credentials RequestId:
- * @throws ClientException
- * @throws ServerException
- */
- public function testNoCredentials()
- {
- AlibabaCloud::mockResponse();
-
- $client = AlibabaCloud::rsaKeyPairClient(
- 'publicKeyId',
- VirtualRsaKeyPairCredential::privateKeyFileUrl()
- );
-
- $provider = new RsaKeyPairProvider($client);
- $provider->get();
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testSuccess()
- {
- AlibabaCloud::mockResponse(
- 200,
- [],
- '{
- "RequestId": "F702286E-F231-4F40-BB86-XXXXXX",
- "SessionAccessKey": {
- "SessionAccessKeyId": "TMPSK.**************",
- "Expiration": "2019-02-19T07:02:36.225Z",
- "SessionAccessKeySecret": "**************"
- }
-}'
- );
-
- $client = AlibabaCloud::rsaKeyPairClient(
- 'public_key_id',
- VirtualRsaKeyPairCredential::privateKeyFileUrl()
- );
-
- $provider = new RsaKeyPairProvider($client);
- $credential = $provider->get();
-
- self::assertInstanceOf(StsCredential::class, $credential);
- }
-
- protected function setUp()
- {
- AlibabaCloud::cancelMock();
- }
-
- protected function tearDown()
- {
- AlibabaCloud::cancelMock();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/RamRoleArnCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/RamRoleArnCredentialTest.php
deleted file mode 100644
index 29c310d1..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/RamRoleArnCredentialTest.php
+++ /dev/null
@@ -1,113 +0,0 @@
-assertEquals($accessKeyId, $credential->getAccessKeyId());
- $this->assertEquals($accessKeySecret, $credential->getAccessKeySecret());
- $this->assertEquals($arn, $credential->getRoleArn());
- $this->assertEquals($sessionName, $credential->getRoleSessionName());
- $this->assertEquals($policy, $credential->getPolicy());
- $this->assertEquals(
- "$accessKeyId#$accessKeySecret#$arn#$sessionName",
- (string)$credential
- );
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID cannot be empty
- * @throws ClientException
- */
- public function testAccessKeyIdEmpty()
- {
- // Setup
- $accessKeyId = '';
- $accessKeySecret = 'access_key_secret';
- $arn = 'role_arn';
- $sessionName = 'role_session_name';
-
- // Test
- new RamRoleArnCredential($accessKeyId, $accessKeySecret, $arn, $sessionName);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID must be a string
- * @throws ClientException
- */
- public function testAccessKeyIdFormat()
- {
- // Setup
- $accessKeyId = null;
- $accessKeySecret = 'access_key_secret';
- $arn = 'role_arn';
- $sessionName = 'role_session_name';
-
- // Test
- new RamRoleArnCredential($accessKeyId, $accessKeySecret, $arn, $sessionName);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret cannot be empty
- * @throws ClientException
- */
- public function testAccessKeySecretEmpty()
- {
- // Setup
- $accessKeyId = 'access_key_id';
- $accessKeySecret = '';
- $arn = 'role_arn';
- $sessionName = 'role_session_name';
-
- // Test
- new RamRoleArnCredential($accessKeyId, $accessKeySecret, $arn, $sessionName);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret must be a string
- * @throws ClientException
- */
- public function testAccessKeySecretFormat()
- {
- // Setup
- $accessKeyId = 'access_key_id';
- $accessKeySecret = null;
- $arn = 'role_arn';
- $sessionName = 'role_session_name';
-
- // Test
- new RamRoleArnCredential($accessKeyId, $accessKeySecret, $arn, $sessionName);
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/RsaKeyPairCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/RsaKeyPairCredentialTest.php
deleted file mode 100644
index 4b8d5462..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/RsaKeyPairCredentialTest.php
+++ /dev/null
@@ -1,144 +0,0 @@
-getErrorMessage()
- );
- }
- }
-
- public static function testOpenBasedirException()
- {
- // Setup
- $publicKeyId = 'PUBLIC_KEY_ID';
- if (\AlibabaCloud\Client\isWindows()) {
- $dirs = 'C:\\projects;C:\\Users';
- $privateKeyFile = 'C:\\AlibabaCloud\\no.no';
- } else {
- $dirs = 'vfs://AlibabaCloud:/home:/Users:/private:/a/b';
- $privateKeyFile = '/dev/no.no';
- }
-
- // Test
- ini_set('open_basedir', $dirs);
- try {
- new RsaKeyPairCredential($publicKeyId, $privateKeyFile);
- } catch (ClientException $e) {
- self::assertEquals(
- "file_get_contents(): open_basedir restriction in effect. File($privateKeyFile) is not within the allowed path(s): ($dirs)",
- $e->getErrorMessage()
- );
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testConstruct()
- {
- // Setup
- $publicKeyId = 'public_key_id';
- $privateKeyFile = VirtualRsaKeyPairCredential::privateKeyFileUrl();
-
- // Test
- $credential = new RsaKeyPairCredential($publicKeyId, $privateKeyFile);
-
- // Assert
- $this->assertEquals($publicKeyId, $credential->getPublicKeyId());
- $this->assertStringEqualsFile($privateKeyFile, $credential->getPrivateKey());
- $this->assertEquals(
- "publicKeyId#$publicKeyId",
- (string)$credential
- );
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Public Key ID cannot be empty
- * @throws ClientException
- */
- public function testPublicKeyIdEmpty()
- {
- // Setup
- $publicKeyId = '';
- $privateKeyFile = VirtualRsaKeyPairCredential::privateKeyFileUrl();
-
- // Test
- new RsaKeyPairCredential($publicKeyId, $privateKeyFile);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Public Key ID must be a string
- * @throws ClientException
- */
- public function testPublicKeyIdFormat()
- {
- // Setup
- $publicKeyId = null;
- $privateKeyFile = VirtualRsaKeyPairCredential::privateKeyFileUrl();
-
- // Test
- new RsaKeyPairCredential($publicKeyId, $privateKeyFile);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Private Key File cannot be empty
- * @throws ClientException
- */
- public function testPrivateKeyFileEmpty()
- {
- // Setup
- $publicKeyId = 'publicKeyId';
- $privateKeyFile = '';
-
- // Test
- new RsaKeyPairCredential($publicKeyId, $privateKeyFile);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Private Key File must be a string
- * @throws ClientException
- */
- public function testPrivateKeyFileFormat()
- {
- // Setup
- $publicKeyId = 'publicKeyId';
- $privateKeyFile = null;
-
- // Test
- new RsaKeyPairCredential($publicKeyId, $privateKeyFile);
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/StsCredentialTest.php b/tests/LowerthanVersion7_2/Unit/Credentials/StsCredentialTest.php
deleted file mode 100644
index 8124b71b..00000000
--- a/tests/LowerthanVersion7_2/Unit/Credentials/StsCredentialTest.php
+++ /dev/null
@@ -1,101 +0,0 @@
-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);
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/FunctionsTest.php b/tests/LowerthanVersion7_2/Unit/FunctionsTest.php
deleted file mode 100644
index a7a62b83..00000000
--- a/tests/LowerthanVersion7_2/Unit/FunctionsTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-regionId($regionId)->product($product);
- LocationService::addHost($product, $host, $regionId);
-
- // Assert
- self::assertEquals(LocationService::resolveHost($request), $host);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessageRegExp /Not found Region ID in location.aliyuncs.com/
- */
- public function testResolveHostWithServiceUnknownError()
- {
- AlibabaCloud::mockResponse();
- $request = AlibabaCloud::rpc()->product(__METHOD__)
- ->regionId('regionId');
-
- $host = LocationService::resolveHost($request);
- self::assertEquals('', $host);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Not found Region ID in location.aliyuncs.com
- * @throws ClientException
- * @throws ServerException
- */
- public function testResolveHostNotFound()
- {
- AlibabaCloud::mockResponse();
-
- $request = AlibabaCloud::rpc()->product(__METHOD__)->regionId('regionId');
-
- LocationService::resolveHost($request);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testResolveHostSuccess()
- {
- $body = [
- 'Endpoints' => [
- 'Endpoint' => [
- 0 => [
- 'Endpoint' => 'cdn.aliyun.com',
- ],
- ],
- ],
- ];
-
- AlibabaCloud::mockResponse(200, [], $body);
-
- $request = AlibabaCloud::rpc()->product(__METHOD__)->regionId('regionId');
-
- $host = LocationService::resolveHost($request);
-
- self::assertEquals('cdn.aliyun.com', $host);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Product cannot be empty
- * @throws ClientException
- */
- public function testAddHostWithProductEmpty()
- {
- LocationService::addHost('', 'host', 'regionId');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Product must be a string
- * @throws ClientException
- */
- public function testAddHostWithProductFormat()
- {
- LocationService::addHost(null, 'host', 'regionId');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Host cannot be empty
- * @throws ClientException
- */
- public function testAddHostWithHostEmpty()
- {
- LocationService::addHost('product', '', 'regionId');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Host must be a string
- * @throws ClientException
- */
- public function testAddHostWithHostFormat()
- {
- LocationService::addHost('product', null, 'regionId');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Region ID cannot be empty
- * @throws ClientException
- */
- public function testAddHostWithRegionIdEmpty()
- {
- LocationService::addHost('product', 'host', '');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Region ID must be a string
- * @throws ClientException
- */
- public function testAddHostWithRegionIdFormat()
- {
- LocationService::addHost('product', 'host', null);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ServerException
- * @expectedExceptionMessageRegExp /Specified access key is not found/
- * @throws ClientException
- * @throws ServerException
- */
- public function testLocationServiceException()
- {
- // Setup
- AlibabaCloud::accessKeyClient('key', 'secret')->asDefaultClient();
-
- AlibabaCloud::mockResponse(
- 401,
- [],
- [
- 'message' => 'Specified access key is not found',
- ]
- );
-
- $request = (new DeleteDatabaseRequest())
- ->regionId('cn-hangzhou')
- ->connectTimeout(25)
- ->timeout(30);
-
- // Test
- LocationService::resolveHost($request);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessageRegExp /cURL error 6: Could not resolve/
- * @throws ClientException
- * @throws ServerException
- */
- public function testLocationServiceWithBadServiceDomain()
- {
- AlibabaCloud::accessKeyClient('key', 'secret')->asDefaultClient();
- $request = (new DeleteDatabaseRequest())->regionId('cn-hangzhou');
- LocationService::resolveHost($request, 'not.alibaba.com');
- }
-
- /**
- * @throws ClientException
- */
- protected function setUp()
- {
- AlibabaCloud::accessKeyClient('foo', 'bar')->asDefaultClient();
- }
-
- protected function tearDown()
- {
- AlibabaCloud::cancelMock();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/AcsTraitTest.php b/tests/LowerthanVersion7_2/Unit/Request/AcsTraitTest.php
deleted file mode 100644
index ba895864..00000000
--- a/tests/LowerthanVersion7_2/Unit/Request/AcsTraitTest.php
+++ /dev/null
@@ -1,595 +0,0 @@
-action($action);
-
- // Assert
- self::assertEquals($action, $request->action);
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Action cannot be empty
- */
- public function testActionWithEmpty()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->action('');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Action must be a string
- */
- public function testActionWithFormat()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->action(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testVersion()
- {
- // Setup
- $version = 'version';
- $request = new RpcRequest();
-
- // Test
- $request->version($version);
-
- // Assert
- self::assertEquals($version, $request->version);
- }
-
- /**
- * @throws ClientException
- * @expectedExceptionMessage Version cannot be empty
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- */
- public function testVersionWithEmpty()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->version('');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Version must be a string
- */
- public function testVersionWithFormat()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->version(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testProduct()
- {
- // Setup
- $product = 'product';
- $request = new RpcRequest();
-
- // Test
- $request->product($product);
-
- // Assert
- self::assertEquals($product, $request->product);
- }
-
- public function testNetwork()
- {
- // Setup
- $network = 'vpc';
- $request = new RpcRequest();
-
- // Test
- $request->network($network);
-
- // Assert
- self::assertEquals($network, $request->network);
- }
-
- /**
- * @throws ClientException
- * @expectedExceptionMessage Product cannot be empty
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- */
- public function testProductWithEmpty()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->product('');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Product must be a string
- */
- public function testProductWithFormat()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->product(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testLocationEndpointType()
- {
- // Setup
- $endpointType = 'endpointType';
- $request = new RpcRequest();
-
- // Test
- $request->endpointType($endpointType);
-
- // Assert
- self::assertEquals(
- $endpointType,
- $request->endpointType
- );
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Endpoint Type cannot be empty
- */
- public function testLocationEndpointTypeEmpty()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->endpointType('');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Endpoint Type must be a string
- */
- public function testLocationEndpointTypeFormat()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->endpointType(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testLocationServiceCode()
- {
- // Setup
- $serviceCode = 'serviceCode';
- $request = new RpcRequest();
-
- // Test
- $request->serviceCode($serviceCode);
-
- // Assert
- self::assertEquals(
- $serviceCode,
- $request->serviceCode
- );
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Service Code cannot be empty
- */
- public function testServiceCodeEmpty()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->serviceCode('');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Service Code must be a string
- */
- public function testServiceCodeFormat()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->serviceCode(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testRealRegionIdOnRequest()
- {
- // Setup
- $regionId = 'regionId';
- $request = new RpcRequest();
-
- // Test
- $request->regionId($regionId);
-
- // Assert
- self::assertEquals(
- strtolower($regionId),
- $request->realRegionId()
- );
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Region ID cannot be empty
- * @throws ClientException
- */
- public function testRegionIdEmpty()
- {
- // Setup
- $regionId = '';
- $request = new RpcRequest();
-
- // Test
- $request->regionId($regionId);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Region ID must be a string
- * @throws ClientException
- */
- public function testRegionIdFormat()
- {
- // Setup
- $regionId = null;
- $request = new RpcRequest();
-
- // Test
- $request->regionId($regionId);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Timeout cannot be empty
- * @throws ClientException
- */
- public function testTimeoutEmpty()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->timeout('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Connect Timeout cannot be empty
- * @throws ClientException
- */
- public function testConnectTimeout()
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $request->connectTimeout('');
- }
-
- /**
- * @throws ClientException
- */
- public function testRealRegionIdOnClient()
- {
- // Setup
- $regionId = 'regionId';
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->regionId($regionId)
- ->name('regionId');
- $request = new RpcRequest();
-
- // Test
- $request->client('regionId');
-
- // Assert
- self::assertEquals(
- strtolower($regionId),
- $request->realRegionId()
- );
- }
-
- /**
- * @throws ClientException
- */
- public function testRealRegionIdOnDefault()
- {
- // Setup
- $regionId = 'regionId';
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
- AlibabaCloud::setDefaultRegionId($regionId);
-
- // Test
- $request = new RpcRequest();
- $request->client('regionId');
-
- // Assert
- self::assertEquals(
- strtolower($regionId),
- $request->realRegionId()
- );
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testEndpointMap()
- {
- // Setup
- $request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
- $request->regionId($region);
- $request->endpointMap[$region] = 'b.com';
-
- // Test
- $request->resolveHost();
- self::assertEquals('http://b.com', (string)$request->uri);
-
- // Setup
- $request = AlibabaCloud::rpc();
- $region = 'cn-shanghai';
- $request->regionId($region);
- $request->product('ecs');
-
- // Test
- $request->resolveHost();
- self::assertEquals('http://ecs-cn-hangzhou.aliyuncs.com', (string)$request->uri);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testEndpointRegional()
- {
- // Setup
- $request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
- $request->regionId($region);
- $request->product('ecs');
- $request->endpointRegional = 'regional';
-
- // Test
- $request->resolveHost();
- self::assertEquals('http://ecs.cn-hangzhou.aliyuncs.com', (string)$request->uri);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testEndpointCentral()
- {
- // Setup
- $request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
- $request->regionId($region);
- $request->product('ecs');
- $request->endpointRegional = 'central';
-
- // Test
- $request->resolveHost();
- self::assertEquals('http://ecs.aliyuncs.com', (string)$request->uri);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage endpointRegional is invalid.
- */
- public function testEndpointRegionalRnvalid()
- {
- // Setup
- $request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
- $request->regionId($region);
- $request->product('ecs');
- $request->endpointRegional = 'invalid';
-
- // Test
- $request->resolveHost();
- }
-
- /**
- * @expectedExceptionMessage Missing required 'RegionId' for Request
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @throws ClientException
- */
- public function testRealRegionIdException()
- {
- // Setup
- AlibabaCloud::flush();
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
-
- // Test
- $request = new RpcRequest();
- $request->client('regionId');
- $request->realRegionId();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Region ID must be a string
- * @throws ClientException
- */
- public function testSetDefaultRegionIdNull()
- {
- // Test
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
- AlibabaCloud::setDefaultRegionId(null);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Region ID cannot be empty
- * @throws ClientException
- */
- public function testSetDefaultRegionIdEmpty()
- {
- // Test
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
- AlibabaCloud::setDefaultRegionId('');
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testFindDomainInConfig()
- {
- // Setup
- $request = new RpcRequest();
- $request->product('ecs');
- $request->regionId('eu-central-1');
-
- // Test
- $request->resolveHost();
-
- // Assert
- self::assertEquals(
- 'ecs.eu-central-1.aliyuncs.com',
- $request->uri->getHost()
- );
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testFindDomainOnLocationService()
- {
- // Setup
- $body = [
- 'Endpoints' => [
- 'Endpoint' => [
- 0 => [
- 'Endpoint' => 'ecs-cn-hangzhou.aliyuncs.com',
- ],
- ],
- ],
- ];
-
- AlibabaCloud::mockResponse(200, [], $body);
- AlibabaCloud::accessKeyClient('foo', 'bar')->asDefaultClient()->regionId('cn-hangzhou');
-
- // Test
- $request = new RpcRequest();
- $request->product('ecs2');
- $request->serviceCode('ecs');
-
- // Assert
- $request->resolveHost();
- self::assertEquals('ecs-cn-hangzhou.aliyuncs.com', $request->uri->getHost());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage No host found for no in the cn-hangzhou, you can specify host by host() method. Like
- * $request->host('xxx.xxx.aliyuncs.com')
- * @throws ClientException
- * @throws ServerException
- */
- public function testFindDomainOnLocationServiceWithEmpty()
- {
- // Setup
- $body = [
- 'Endpoints' => [
- 'Endpoint' => [
- 0 => [
- 'Endpoint' => '',
- ],
- ],
- ],
- ];
-
- AlibabaCloud::mockResponse(200, [], $body);
- AlibabaCloud::setDefaultRegionId('cn-hangzhou');
- AlibabaCloud::accessKeyClient('ak', 'bar')->asDefaultClient();
-
- // Test
- $request = new RpcRequest();
- $request->product('no');
- $request->serviceCode('no');
-
- // Assert
- $request->resolveHost();
- self::assertEquals('ecs-cn-hangzhou.aliyuncs.com', $request->uri->getHost());
- }
-
- protected function tearDown()
- {
- AlibabaCloud::cancelMock();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/RequestTest.php b/tests/LowerthanVersion7_2/Unit/Request/RequestTest.php
deleted file mode 100644
index d86177e0..00000000
--- a/tests/LowerthanVersion7_2/Unit/Request/RequestTest.php
+++ /dev/null
@@ -1,465 +0,0 @@
-object));
-
- // Set
- $request->object = 'object';
-
- // Isset
- self::assertTrue(isset($request->object));
- self::assertEquals('object', $request->object);
-
- // Unset
- unset($request->object);
- self::assertEquals(null, $request->object);
- }
-
- /**
- * @throws ClientException
- */
- public static function testRequest()
- {
- // Setup
- $request = new RpcRequest();
-
- // Assert
- self::assertArrayNotHasKey('verify', $request->options);
-
- // Test
- $request->verify(true);
-
- // Assert
- self::assertTrue($request->options['verify']);
- }
-
- /**
- * @throws ClientException
- */
- public function testConstruct()
- {
- // Setup
- $options = ['testConstruct' => __METHOD__];
- putenv('DEBUG=sdk');
-
- // Test
- $rpcRequest = new RpcRequest($options);
- $roaRequest = new RoaRequest($options);
-
- // Assert
- self::assertEquals(__METHOD__, $rpcRequest->options['testConstruct']);
- self::assertEquals(__METHOD__, $roaRequest->options['testConstruct']);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name cannot be empty
- * @throws ClientException
- */
- public function testAppendUserAgentWithNameEmpty()
- {
- $request = new RpcRequest();
- $request->appendUserAgent('', 'value');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name must be a string
- * @throws ClientException
- */
- public function testAppendUserAgentWithNameFormat()
- {
- $request = new RpcRequest();
- $request->appendUserAgent(null, 'value');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value cannot be empty
- * @throws ClientException
- */
- public function testAppendUserAgentWithValueEmpty()
- {
- $request = new RpcRequest();
- $request->appendUserAgent('name', '');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value must be a string
- * @throws ClientException
- */
- public function testAppendUserAgentWithValueFormat()
- {
- $request = new RpcRequest();
- $request->appendUserAgent('name', null);
- }
-
- /**
- * @throws ClientException
- */
- public function testFormat()
- {
- // Setup
- $format = 'rss';
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->format($format);
- $roaRequest->format($format);
-
- // Assert
- self::assertEquals(\strtoupper($format), $rpcRequest->format);
- self::assertEquals(\strtoupper($format), $roaRequest->format);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Format cannot be empty
- * @throws ClientException
- */
- public function testFormatWithEmpty()
- {
- $request = new RpcRequest();
- $request->format('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Format must be a string
- * @throws ClientException
- */
- public function testFormatWithNull()
- {
- $request = new RpcRequest();
- $request->format(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testBody()
- {
- // Setup
- $body = 'rss';
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->body($body);
- $roaRequest->body($body);
-
- // Assert
- self::assertEquals($body, $rpcRequest->options['body']);
- self::assertEquals($body, $roaRequest->options['body']);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Body cannot be empty
- * @throws ClientException
- */
- public function testBodyEmpty()
- {
- $request = new RpcRequest();
- $request->body('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Body must be a string
- * @throws ClientException
- */
- public function testBodyNotString()
- {
- $request = new RpcRequest();
- $request->body(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testJsonBody()
- {
- // Setup
- $body = ['test' => 'test'];
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->jsonBody($body);
- $roaRequest->jsonBody($body);
-
- // Assert
- self::assertEquals('{"test":"test"}', $rpcRequest->options['body']);
- self::assertEquals('{"test":"test"}', $roaRequest->options['body']);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage jsonBody only accepts an array or object
- * @throws ClientException
- */
- public function testJsonBodyFormat()
- {
- $request = new RpcRequest();
-
- $request->jsonBody(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testScheme()
- {
- // Setup
- $scheme = 'no';
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->scheme($scheme);
- $roaRequest->scheme($scheme);
-
- // Assert
- self::assertEquals($scheme, $rpcRequest->uri->getScheme());
-
- self::assertEquals($scheme, $roaRequest->uri->getScheme());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Scheme must be a string
- * @throws ClientException
- */
- public function testSchemeFormat()
- {
- $request = new RpcRequest();
- $request->scheme(null);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Scheme cannot be empty
- * @throws ClientException
- */
- public function testSchemeEmpty()
- {
- $request = new RpcRequest();
- $request->scheme('');
- }
-
- /**
- * @throws ClientException
- */
- public function testHost()
- {
- // Setup
- $host = 'domain';
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->host($host);
- $roaRequest->host($host);
-
- // Assert
- self::assertEquals($host, $rpcRequest->uri->getHost());
- self::assertEquals($host, $roaRequest->uri->getHost());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Host must be a string
- * @throws ClientException
- */
- public function testHostFormat()
- {
- $request = new RpcRequest();
- $request->host(null);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Host cannot be empty
- * @throws ClientException
- */
- public function testHostEmpty()
- {
- $request = new RpcRequest();
- $request->host('');
- }
-
- /**
- * @throws ClientException
- */
- public function testMethod()
- {
- // Setup
- $method = 'method';
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->method($method);
- $roaRequest->method($method);
-
- // Assert
- self::assertEquals(\strtoupper($method), $rpcRequest->method);
- self::assertEquals(\strtoupper($method), $roaRequest->method);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Method cannot be empty
- * @throws ClientException
- */
- public function testMethodEmpty()
- {
- $request = new RpcRequest();
- $request->method('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Method must be a string
- * @throws ClientException
- */
- public function testMethodFormat()
- {
- $request = new RpcRequest();
- $request->method(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testClient()
- {
- // Setup
- $clientName = 'clientName';
- $rpcRequest = new RpcRequest();
- $roaRequest = new RoaRequest();
-
- // Test
- $rpcRequest->client($clientName);
- $roaRequest->client($clientName);
-
- // Assert
- self::assertEquals(strtolower($clientName), $rpcRequest->client);
- self::assertEquals(strtolower($clientName), $roaRequest->client);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client Name cannot be empty
- * @throws ClientException
- */
- public function testClientEmpty()
- {
- $request = new RpcRequest();
- $request->client('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client Name must be a string
- * @throws ClientException
- */
- public function testClientFormat()
- {
- $request = new RpcRequest();
- $request->client(null);
- }
-
- /**
- * @throws ClientException
- */
- public function testIsDebug()
- {
- AlibabaCloud::accessKeyClient('key', 'secret')
- ->name('temp');
- $request = (new DeleteDatabaseRequest())->client('temp')
- ->debug(false);
- self::assertFalse($request->isDebug());
-
- unset($request->options['debug']);
- AlibabaCloud::get('temp')->debug(false);
- self::assertFalse($request->isDebug());
-
- unset($request->options['debug'], AlibabaCloud::get('temp')->options['debug']);
- self::assertFalse($request->isDebug());
- }
-
- /**
- * @throws ClientException
- */
- public function testRequestWithServiceException()
- {
- // Setup
- $request = new DeleteDatabaseRequest();
- AlibabaCloud::accessKeyClient('key', 'secret')
- ->regionId('cn-hangzhou')
- ->connectTimeout(15)
- ->timeout(10)
- ->name('temp');
-
- try {
- $request->client('temp')
- ->request();
- } catch (ServerException $e) {
- self::assertEquals('Specified access key is not found.', $e->getErrorMessage());
- } catch (ClientException $e) {
- self::assertStringStartsWith('cURL error', $e->getErrorMessage());
- }
- }
-
- /**
- * @throws ServerException
- * @throws ClientException
- */
- public function testRequestWithClientException()
- {
- // Setup
- $request = new DeleteDatabaseRequest();
- AlibabaCloud::accessKeyClient('key', 'secret')
- ->regionId('cn-hangzhou')
- ->name('temp');
-
- try {
- $request->client('temp')
- ->timeout(0.01)
- ->request();
- } catch (ClientException $e) {
- self::assertStringStartsWith('cURL error', $e->getErrorMessage());
- }
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/RoaRequestTest.php b/tests/LowerthanVersion7_2/Unit/Request/RoaRequestTest.php
deleted file mode 100644
index a925bea3..00000000
--- a/tests/LowerthanVersion7_2/Unit/Request/RoaRequestTest.php
+++ /dev/null
@@ -1,496 +0,0 @@
-withClusterId($clusterId);
- $method = new ReflectionMethod(
- Path::class,
- 'assign'
- );
- $actual = $method->invokeArgs($request, [$request->pathPattern, $request->pathParameters]);
-
- // Assert
- self::assertEquals($expected, $actual);
- }
-
- /**
- * @throws ReflectionException
- * @throws ClientException
- */
- public function testAssignPathParametersWithOption()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
- $clusterId = \time();
- $expected = '/clusters/' . $clusterId . '/services';
-
- // Test
- $request->pathParameter('ClusterId', $clusterId);
- $method = new ReflectionMethod(
- Path::class,
- 'assign'
- );
- $actual = $method->invokeArgs($request, [$request->pathPattern, $request->pathParameters]);
-
- // Assert
- self::assertEquals($expected, $actual);
- }
-
- /**
- * @throws ReflectionException
- * @throws ClientException
- */
- public function testConstructAcsHeader()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
- $request->withClusterId(\time());
- $request->regionId('cn-hangzhou');
- $clusterId = \time();
- $request->resolveParameter();
- $expected = "x-acs-region-id:cn-hangzhou\n" .
- "x-acs-signature-method:HMAC-SHA1\n";
-
- // Test
- $request->pathParameter('ClusterId', $clusterId);
- $method = new ReflectionMethod(
- Sign::class,
- 'acsHeaderString'
- );
- $method->setAccessible(true);
-
- $requestPsr = new Request(
- $request->method,
- $request->uri,
- $request->getHeaders()
- );
-
- $actual = $method->invokeArgs($request, [$requestPsr->getHeaders()]);
-
- // Assert
- self::assertTrue(Stringy::contains($actual, $expected));
- }
-
- /**
- * @param array $query
- * @param string $expected
- *
- * @dataProvider buildQueryString
- * @throws ClientException
- */
- public function testBuildQueryString(array $query, $expected)
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->regionId('cn-hangzhou')
- ->asDefaultClient();
-
- // Test
- $request->options(['query' => $query]);
- $request->resolveParameter();
-
- // Assert
- self::assertEquals($expected, Encode::create($request->options['query'])->ksort()->toString());
- }
-
- /**
- * @return array
- */
- public function buildQueryString()
- {
- return [
- [
- [
- 'a' => 'a',
- 'b' => 'b',
- ],
- 'Version=2015-12-15&a=a&b=b',
- ],
- [
- [
- 'b' => 'b',
- 'c' => 'c',
- ],
- 'Version=2015-12-15&b=b&c=c',
- ],
- [
- [
- 'b' => 'b',
- 'c' => 'c',
- 'd' => '',
- ],
- 'Version=2015-12-15&b=b&c=c&d',
- ],
- ];
- }
-
- /**
- * @param $format
- * @param $expected
- *
- * @dataProvider contentType
- */
- public function testContentType($format, $expected)
- {
- self::assertEquals($expected, Accept::create($format)->toString());
- }
-
- /**
- * @return array
- */
- public function contentType()
- {
- return [
- ['JSON', 'application/json',],
- ['XML', 'application/xml',],
- ['RAW', 'application/octet-stream',],
- ['NON', 'application/octet-stream',],
- ['FORM', 'application/x-www-form-urlencoded',],
- ];
- }
-
- /**
- * @param string $key
- * @param string $value
- *
- * @dataProvider pathParameter
- * @throws ClientException
- */
- public function testPathParameter($key, $value)
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathParameter($key, $value);
-
- // Assert
- self::assertEquals($value, $request->pathParameters[$key]);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name cannot be empty
- * @throws ClientException
- */
- public function testPathParameterWithNameEmpty()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathParameter('', 'value');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name must be a string
- * @throws ClientException
- */
- public function testPathParameterWithNameFormat()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathParameter(null, 'value');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value cannot be empty
- * @throws ClientException
- */
- public function testPathParameterWithValueEmpty()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathParameter('name', '');
- }
-
- /**
- * @return array
- */
- public function pathParameter()
- {
- return [
- ['1', '1'],
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ];
- }
-
- /**
- * @param $pattern
- *
- * @dataProvider pathPattern
- * @throws ClientException
- */
- public function testPathPattern($pattern)
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathPattern($pattern);
-
- // Assert
- self::assertEquals($pattern, $request->pathPattern);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Pattern cannot be empty
- * @throws ClientException
- */
- public function testPathPatternWithEmpty()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathPattern('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Pattern must be a string
- * @throws ClientException
- */
- public function testPathPatternWithFormat()
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
-
- // Test
- $request->pathPattern(null);
- }
-
- /**
- * @return array
- */
- public function pathPattern()
- {
- return [
- ['1'],
- ['2'],
- ['3'],
- ['4'],
- ];
- }
-
- /**
- * @param $version
- *
- * @dataProvider version
- * @throws ClientException
- */
- public function testVersion($version)
- {
- // Setup
- $request = new DescribeClusterServicesRequest();
- AlibabaCloud::accessKeyClient('foo', 'bar')
- ->regionId('cn-hangzhou')
- ->asDefaultClient();
-
- // Test
- $request->version($version);
- $request->resolveParameter();
-
- // Assert
- self::assertEquals($version, $request->version);
- self::assertEquals($version, $request->options['query']['Version']);
- self::assertEquals($version, $request->options['headers']['x-acs-version']);
- }
-
- /**
- * @return array
- */
- public function version()
- {
- return [
- ['1'],
- ['2'],
- ['3'],
- ['4'],
- ];
- }
-
- /**
- * @return array
- * @throws ClientException
- */
- public function resolveQuery()
- {
- return [
- [
- new StsCredential('foo', 'bar', 'token'),
- ],
- [
- new BearerTokenCredential('token'),
- ],
- ];
- }
-
- /**
- * @throws ClientException
- * @dataProvider resolveQuery
- */
- public function testResolveParameters()
- {
- // Setup
- AlibabaCloud::bearerTokenClient('token')->name('token');
- $clusterId = time();
- $request = new DescribeClusterServicesRequest();
- $request->withClusterId($clusterId);
- $request->client('token');
- $request->options(
- [
- 'form_params' => [
- 'test' => 'test',
- ],
- ]
- );
- $request->regionId('cn-hangzhou');
- $request->method('post');
- $request->options(
- [
- 'query' => [
- 'A' => 'A',
- ],
- ]
- );
- $expected = "http://localhost/clusters/{$clusterId}/services?A=A&Version=2015-12-15";
-
- // Test
- $request->resolveParameter();
-
- // Assert
- self::assertEquals($expected, (string)$request->uri);
- }
-
- /**
- * @throws ClientException
- */
- public function testCall()
- {
- $request = new RoaRequest();
- self::assertEquals([], $request->pathParameters);
-
- $request->withPrefix('with');
- self::assertEquals('with', $request->getPrefix());
- self::assertEquals(['Prefix' => 'with',], $request->pathParameters);
-
- $request->withprefix('with');
- self::assertEquals('with', $request->getprefix());
- self::assertEquals(['Prefix' => 'with', 'prefix' => 'with',], $request->pathParameters);
- }
-
- /**
- * @expectedException RuntimeException
- * @expectedExceptionMessage Call to undefined method AlibabaCloud\Client\Request\RoaRequest::nowithvalue()
- * @throws ClientException
- */
- public function testCallException()
- {
- $request = new RoaRequest();
- $request->nowithvalue('value');
- }
-
- /**
- * @expectedException RuntimeException
- * @expectedExceptionMessage Please use withParameter instead of setParameter
- * @throws ClientException
- */
- public function testExceptionWithSet()
- {
- $request = AlibabaCloud::roa();
- $request->setParameter();
- }
-
- /**
- * @covers \AlibabaCloud\Client\Request\RoaRequest::resolveSecurityToken
- * @throws ReflectionException
- * @throws ClientException
- */
- public function testResolveSecurityToken()
- {
- // Setup
- $request = AlibabaCloud::roa();
- $object = new ReflectionObject($request);
- AlibabaCloud::stsClient('foo', 'bar', 'token')->asDefaultClient();
-
- // Test
- $method = $object->getMethod('resolveSecurityToken');
- $method->setAccessible(true);
- $method->invoke($request);
-
- // Assert
- self::assertEquals('token', $request->options['headers']['x-acs-security-token']);
- }
-
- /**
- * @covers \AlibabaCloud\Client\Request\RoaRequest::resolveSecurityToken
- * @throws ReflectionException
- * @throws ClientException
- */
- public function testNoSecurityToken()
- {
- // Setup
- $request = AlibabaCloud::roa();
- $object = new ReflectionObject($request);
- AlibabaCloud::stsClient('foo', 'bar')->asDefaultClient();
-
- // Test
- $method = $object->getMethod('resolveSecurityToken');
- $method->setAccessible(true);
- $method->invoke($request);
-
- // Assert
- self::assertFalse(isset($request->options['headers']['x-acs-security-token']));
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/RpcRequestTest.php b/tests/LowerthanVersion7_2/Unit/Request/RpcRequestTest.php
deleted file mode 100644
index 13567857..00000000
--- a/tests/LowerthanVersion7_2/Unit/Request/RpcRequestTest.php
+++ /dev/null
@@ -1,320 +0,0 @@
-setAccessible(true);
- $actual = $method->invokeArgs($request, [$value]);
-
- // Assert
- self::assertEquals($expected, $actual);
- }
-
- /**
- * @param CredentialsInterface $credential
- *
- * @throws ReflectionException
- * @throws ClientException
- * @dataProvider resolveQuery
- */
- public function testResolveCommonParameters($credential)
- {
- // Setup
- AlibabaCloud::bearerTokenClient('token')->name('token');
- $request = new RpcRequest();
- $request->client('token');
- $request->regionId('cn-hangzhou');
- $request->options(
- [
- 'query' => [
- 'A' => 'A',
- ],
- ]
- );
-
- // Test
- $method = new ReflectionMethod(
- RpcRequest::class,
- 'resolveCommonParameters'
- );
- $method->setAccessible(true);
- $method->invokeArgs($request, [$credential]);
-
- // Assert
- self::assertInternalType('array', $request->options['query']);
- self::assertEquals('A', $request->options['query']['A']);
- }
-
- /**
- * @return array
- * @throws ClientException
- */
- public function resolveQuery()
- {
- return [
- [
- new StsCredential('foo', 'bar', 'token'),
- ],
- [
- new BearerTokenCredential('token'),
- ],
- ];
- }
-
- /**
- * @param CredentialsInterface $credential
- *
- * @throws ReflectionException
- * @throws ClientException
- * @dataProvider resolveQuery
- */
- public function testResolveParameters($credential)
- {
- // Setup
- AlibabaCloud::bearerTokenClient('token')->name('token');
- $request = new RpcRequest();
- $request->client('token');
- $request->regionId('cn-hangzhou');
- $request->method('post');
- $request->options(
- [
- 'query' => [
- 'A' => 'A',
- ],
- ]
- );
-
- // Test
- $method = new ReflectionMethod(
- RpcRequest::class,
- 'resolveParameter'
- );
- $method->setAccessible(true);
- $method->invokeArgs($request, [$credential]);
-
- // Assert
- self::assertFalse(isset($request->options['query']));
- self::assertEquals('http://localhost', (string)$request->uri);
- }
-
- /**
- * @param $value
- * @param $expected
- *
- * @throws ReflectionException
- * @throws ClientException
- * @dataProvider percentEncode
- */
- public function testPercentEncode($value, $expected)
- {
- // Setup
- $request = new RpcRequest();
-
- // Test
- $method = new ReflectionMethod(
- Sign::class,
- 'percentEncode'
- );
- $method->setAccessible(true);
- $actual = $method->invokeArgs($request, [$value]);
-
- // Assert
- self::assertEquals($expected, $actual);
- }
-
- /**
- * @return array
- */
- public function percentEncode()
- {
- return [
- ['2018-12-26T05:36:28Z', '2018-12-26T05%3A36%3A28Z'],
- [
- 'AccessKeyId=LTAIfoSsg3EaQoip&Action=ListAccessKeys&Format=JSON&RegionId=cn-hangzhou&SignatureMethod=HMAC-SHA1&SignatureNonce=4b22e3fd9f3746ea487b298800b44572&SignatureVersion=1.0&Timestamp=2018-12-26T05%3A36%3A26Z&UserName=1545802586&Version=2015-05-01',
- 'AccessKeyId%3DLTAIfoSsg3EaQoip%26Action%3DListAccessKeys%26Format%3DJSON%26RegionId%3Dcn-hangzhou%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D4b22e3fd9f3746ea487b298800b44572%26SignatureVersion%3D1.0%26Timestamp%3D2018-12-26T05%253A36%253A26Z%26UserName%3D1545802586%26Version%3D2015-05-01',
- ],
- [
- 'AccessKeyId=LTAIfoSsg3EaQoip&Action=AssumeRole&DurationSeconds=3600&Format=JSON&RegionId=cn-hangzhou&RoleArn=acs%3Aram%3A%3A1483445875618637%3Arole%2Ftest&RoleSessionName=session_name&SignatureMethod=HMAC-SHA1&SignatureNonce=5e87f2b001977f40d261a3b59758048f&SignatureVersion=1.0&Timestamp=2018-12-26T05%3A36%3A23Z&Version=2015-04-01',
- 'AccessKeyId%3DLTAIfoSsg3EaQoip%26Action%3DAssumeRole%26DurationSeconds%3D3600%26Format%3DJSON%26RegionId%3Dcn-hangzhou%26RoleArn%3Dacs%253Aram%253A%253A1483445875618637%253Arole%252Ftest%26RoleSessionName%3Dsession_name%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D5e87f2b001977f40d261a3b59758048f%26SignatureVersion%3D1.0%26Timestamp%3D2018-12-26T05%253A36%253A23Z%26Version%3D2015-04-01',
- ],
- ];
- }
-
- /**
- * @param $parameters
- * @param $expected
- *
- * @throws ReflectionException
- * @throws ClientException
- * @dataProvider signature
- */
- public function testSignature($parameters, $expected)
- {
- // Setup
- $request = new RpcRequest();
- $request->options['query'] = $parameters;
-
- // Test
- $method = new ReflectionMethod(
- RpcRequest::class,
- 'signature'
- );
- $method->setAccessible(true);
- $actual = $method->invokeArgs($request, []);
-
- // Assert
- self::assertEquals($expected, $actual);
- }
-
- /**
- * @return array
- */
- public function signature()
- {
- return [
- [
- [1, 2],
- 'liZ2rLCylB5dy2kwxbuTa/BY5Uw=',
- ],
- [
- [3, 4],
- 'gAQmuhD1C77I3WEgo4j1k+bFfss=',
- ],
- ];
- }
-
- /**
- * @throws ClientException
- */
- public function testCall()
- {
- $request = new RpcRequest();
-
- $request->withPrefix('with');
- self::assertEquals('with', $request->getPrefix());
- self::assertEquals(['Prefix' => 'with',], $request->options['query']);
-
- $request->withprefix('with');
- self::assertEquals('with', $request->getprefix());
- self::assertEquals(['Prefix' => 'with', 'prefix' => 'with',], $request->options['query']);
- }
-
- /**
- * @expectedException RuntimeException
- * @expectedExceptionMessage Call to undefined method AlibabaCloud\Client\Request\RpcRequest::nowithvalue()
- * @throws ClientException
- */
- public function testCallException()
- {
- $request = new RpcRequest();
- $request->nowithvalue('value');
- }
-
- /**
- * @expectedException RuntimeException
- * @expectedExceptionMessage Please use withParameter instead of setParameter
- */
- public function testExceptionWithSet()
- {
- $request = AlibabaCloud::rpc();
- $request->setParameter();
- }
-
- /**
- * @covers \AlibabaCloud\Client\Request\RpcRequest::resolveSecurityToken
- * @throws ReflectionException
- * @throws ClientException
- */
- public function testResolveSecurityToken()
- {
- // Setup
- AlibabaCloud::stsClient('foo', 'bar', 'token')->name('resolveSecurityToken');
- $request = AlibabaCloud::rpc()->client('resolveSecurityToken');
- $object = new ReflectionObject($request);
-
- // Test
- $method = $object->getMethod('resolveSecurityToken');
- $method->setAccessible(true);
- $method->invoke($request);
-
- // Assert
- self::assertEquals('token', $request->options['query']['SecurityToken']);
- }
-
- /**
- * @covers \AlibabaCloud\Client\Request\RoaRequest::resolveSecurityToken
- * @throws ReflectionException
- * @throws ClientException
- */
- public function testNoSecurityToken()
- {
- // Setup
- $request = AlibabaCloud::rpc();
- $object = new ReflectionObject($request);
- AlibabaCloud::stsClient('foo', 'bar')->asDefaultClient();
-
- // Test
- $method = $object->getMethod('resolveSecurityToken');
- $method->setAccessible(true);
- $method->invoke($request);
-
- // Assert
- self::assertFalse(isset($request->options['query']['SecurityToken']));
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/Traits/ClientTraitTest.php b/tests/LowerthanVersion7_2/Unit/Request/Traits/ClientTraitTest.php
deleted file mode 100644
index c2b1a322..00000000
--- a/tests/LowerthanVersion7_2/Unit/Request/Traits/ClientTraitTest.php
+++ /dev/null
@@ -1,236 +0,0 @@
-asDefaultClient()
- ->regionId('cn-hangzhou')
- ->name($clientName);
-
- $request = (new DescribeCdnServiceRequest())->client($clientName);
-
- // Assert
- self::assertEquals('key', $request->credential()->getAccessKeyId());
- self::assertEquals('secret', $request->credential()->getAccessKeySecret());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID format is invalid
- * @throws ClientException
- */
- public function testAccessKeyId()
- {
- AlibabaCloud::accessKeyClient(' ', 'secret');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret format is invalid
- * @throws ClientException
- */
- public function testAccessKeySecret()
- {
- AlibabaCloud::accessKeyClient('key', ' ');
- }
-
- /**
- * @throws ClientException
- */
- public function testHttpClientWithCustomChain()
- {
- $name = 'testHttpClientWithCustomChain';
- AlibabaCloud::flush();
- CredentialsProvider::chain(
- static function () use ($name) {
- AlibabaCloud::ecsRamRoleClient('role')->name($name);
- }
- );
- $request = AlibabaCloud::rpc()->client($name);
- self::assertInstanceOf(EcsRamRoleClient::class, $request->httpClient());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client 'defaultprovider' not found
- * @throws ClientException
- */
- public function testHttpClientWithDefaultProvider()
- {
- CredentialsProvider::flush();
- $request = AlibabaCloud::rpc()->client('DefaultProvider');
- $request->httpClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client 'no' not found
- * @throws ClientException
- */
- public function testHttpClient()
- {
- $request = AlibabaCloud::rpc()->client('no');
- $request->httpClient();
- }
-
- /**
- * @throws ClientException
- */
- public function testMergeOptionsIntoClient()
- {
- // Setup
- $clientName = __METHOD__;
- $expected = 'i \'m request';
-
- // Test
- AlibabaCloud::accessKeyClient('key', 'secret')
- ->asDefaultClient()
- ->regionId('cn-hangzhou')
- ->options(
- [
- 'headers' => [
- 'client' => 'client',
- ],
- ]
- )
- ->name($clientName);
-
- $request = (new DescribeCdnServiceRequest())->client($clientName)
- ->options(['request1' => 'request'])
- ->options(['request2' => 'request2'])
- ->options(
- [
- 'headers' => [
- 'client' => $expected,
- ],
- ]
- );
- $request->mergeOptionsIntoClient();
-
- // Assert
- $this->assertEquals($expected, $request->options['headers']['client']);
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testCredentialOnAssumeRole()
- {
- // Setup
- $clientName = __METHOD__;
-
- // Test
- AlibabaCloud::accessKeyClient('key', 'secret')
- ->asDefaultClient()
- ->regionId('cn-hangzhou')
- ->name($clientName);
-
- $request = (new AssumeRole(
- new RamRoleArnCredential(
- 'key',
- 'secret',
- 'arn',
- 'name'
- )
- ))->client($clientName);
-
- // Assert
- self::assertEquals('key', $request->credential()->getAccessKeyId());
- self::assertEquals('secret', $request->credential()->getAccessKeySecret());
- }
-
- /**
- * @throws ClientException
- * @throws ServerException
- */
- public function testCredentialOnGenerateSessionAccessKey()
- {
- // Setup
- $clientName = __METHOD__;
-
- // Test
- AlibabaCloud::accessKeyClient('key', 'secret')
- ->asDefaultClient()
- ->regionId('cn-hangzhou')
- ->name($clientName);
-
- $request = (new GenerateSessionAccessKey(
- new RsaKeyPairCredential(
- 'key',
- VirtualRsaKeyPairCredential::ok()
- )
- ))->client($clientName);
-
- // Assert
- self::assertEquals('key', $request->credential()->getAccessKeyId());
- self::assertEquals('secret', $request->credential()->getAccessKeySecret());
- }
-
- /**
- * Only versions greater than 5.6 will take effect.
- *
- * @throws ClientException
- * @throws ServerException
- */
- public function testConfig()
- {
- Request::config([
- 'curl' => [CURLOPT_RESOLVE => ['cdn.aliyuncs.com:80:127.0.0.1']],
- ]);
-
- AlibabaCloud::accessKeyClient(
- \getenv('ACCESS_KEY_ID'),
- \getenv('ACCESS_KEY_SECRET')
- )->asDefaultClient()->regionId('cn-hangzhou');
-
- try {
- AlibabaCloud::rpc()
- ->method('POST')
- ->product('Cdn')
- ->version('2014-11-11')
- ->action('DescribeCdnService')
- ->connectTimeout(25)
- ->timeout(30)
- ->request();
- } catch (ClientException $exception) {
- self::assertTrue(
- Stringy::contains($exception->getMessage(), 'Failed to connect to cdn.aliyuncs.com')
- );
- }
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/UserAgentTest.php b/tests/LowerthanVersion7_2/Unit/Request/UserAgentTest.php
deleted file mode 100644
index f1ec12db..00000000
--- a/tests/LowerthanVersion7_2/Unit/Request/UserAgentTest.php
+++ /dev/null
@@ -1,249 +0,0 @@
- '1.0.0',
- 'Append2' => '2.0.0',
- 'PHP' => '2.0.0',
- ]);
-
- self::assertStringStartsWith('AlibabaCloud', $userAgent);
- self::assertStringEndsWith('Append/1.0.0 Append2/2.0.0', $userAgent);
- }
-
- public static function testUserAgentAppend()
- {
- UserAgent::append('Append', '1.0.0');
- $userAgent = UserAgent::toString();
- self::assertStringEndsWith('Append/1.0.0', $userAgent);
- }
-
- public static function testUserAgentWith()
- {
- UserAgent::with([
- 'Append' => '1.0.0',
- 'Append2' => '2.0.0',
- ]);
- $userAgent = UserAgent::toString();
- self::assertStringEndsWith('Append/1.0.0 Append2/2.0.0', $userAgent);
- }
-
- /**
- * @throws ClientException
- */
- public static function testGuard()
- {
- UserAgent::append('PHP', '7.3');
- self::assertStringEndsNotWith('PHP/7.3', UserAgent::toString());
- UserAgent::append('Client', '1.0.0');
- self::assertStringEndsNotWith('Client/1.0.0', UserAgent::toString());
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name cannot be empty
- */
- public static function testGuardWithNameEmpty()
- {
- UserAgent::append('', '7.3');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name must be a string
- */
- public static function testGuardWithNameFormat()
- {
- UserAgent::append(null, '7.3');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value cannot be empty
- */
- public static function testGuardWithValueEmpty()
- {
- UserAgent::append('PHP', '');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value must be a string
- */
- public static function testGuardWithValueFormat()
- {
- UserAgent::append('PHP', null);
- }
-
- /**
- * @throws ClientException
- */
- public static function testAppendGlobalUserAgent()
- {
- AlibabaCloud::appendUserAgent('cli', '1.0.0');
- AlibabaCloud::appendUserAgent('cmp', 'fit2cloud');
- self::assertStringEndsWith('cli/1.0.0 cmp/fit2cloud', UserAgent::toString());
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name cannot be empty
- */
- public static function testAppendUserAgentWithNameEmpty()
- {
- AlibabaCloud::appendUserAgent('', '1.0.0');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Name must be a string
- */
- public static function testAppendUserAgentWithNameFormat()
- {
- AlibabaCloud::appendUserAgent(null, '1.0.0');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value cannot be empty
- */
- public static function testAppendUserAgentWithValueEmpty()
- {
- AlibabaCloud::appendUserAgent('cli', '');
- }
-
- /**
- * @throws ClientException
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Value must be a string
- */
- public static function testAppendUserAgentWithValueFormat()
- {
- AlibabaCloud::appendUserAgent('cli', null);
- }
-
- public static function testWithGlobalUserAgent()
- {
- AlibabaCloud::withUserAgent([
- 'Append' => '1.0.0',
- 'Append2' => '2.0.0',
- ]);
-
- self::assertStringEndsWith('Append/1.0.0 Append2/2.0.0', UserAgent::toString());
-
- AlibabaCloud::withUserAgent([]);
-
- self::assertStringEndsWith('PHP/' . PHP_VERSION, UserAgent::toString());
- }
-
- /**
- * @throws ClientException
- */
- public static function testAppendForRequest()
- {
- AlibabaCloud::appendUserAgent('cli', '1.0.0');
-
- $request = new RpcRequest();
- $request->appendUserAgent('cmp', 'fit2cloud');
-
- // Execution request to get UA information, expected exception.
- try {
- $request->request();
- } catch (\Exception $exception) {
- }
-
- self::assertStringEndsWith('cli/1.0.0 cmp/fit2cloud', $request->options['headers']['User-Agent']);
- self::assertStringEndsWith('cli/1.0.0', UserAgent::toString());
- }
-
- /**
- * @throws ClientException
- */
- public static function testWithForRequest()
- {
- AlibabaCloud::appendUserAgent('cli', '1.0.0');
- $request = new RpcRequest();
- $request->withUserAgent([
- 'Append' => '1.0.0',
- 'Append2' => '2.0.0',
- ]);
-
- // Execution request to get UA information, expected exception.
- try {
- $request->request();
- } catch (\Exception $exception) {
- }
-
- self::assertStringEndsWith(
- 'cli/1.0.0 Append/1.0.0 Append2/2.0.0',
- $request->options['headers']['User-Agent']
- );
- self::assertStringEndsWith('cli/1.0.0', UserAgent::toString());
- }
-
- /**
- * @throws ClientException
- */
- public static function testRequestFirst()
- {
- AlibabaCloud::appendUserAgent('cli', '1.0.0');
- $request = new RpcRequest();
- $request->withUserAgent([
- 'Append' => '1.0.0',
- 'cli' => '2.0.0',
- ]);
-
- // Execution request to get UA information, expected exception.
- try {
- $request->request();
- } catch (\Exception $exception) {
- }
-
- self::assertStringEndsWith(
- 'cli/2.0.0 Append/1.0.0',
- $request->options['headers']['User-Agent']
- );
- self::assertStringEndsWith('cli/1.0.0', UserAgent::toString());
- }
-
- public static function testNull()
- {
- AlibabaCloud::withUserAgent([
- 'Append' => null,
- ]);
-
- self::assertStringEndsWith('Append', UserAgent::toString());
- }
-
- protected function tearDown()
- {
- UserAgent::clear();
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Signature/ShaHmac256WithRsaSignatureTest.php b/tests/LowerthanVersion7_2/Unit/Signature/ShaHmac256WithRsaSignatureTest.php
deleted file mode 100644
index fd7447ed..00000000
--- a/tests/LowerthanVersion7_2/Unit/Signature/ShaHmac256WithRsaSignatureTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-getMethod());
- static::assertEquals('1.0', $signature->getVersion());
- static::assertEquals('PRIVATEKEY', $signature->getType());
- static::assertEquals(
- $expected,
- $signature->sign($string, \file_get_contents($privateKeyFile))
- );
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionCode 0
- * @expectedExceptionMessage openssl_sign(): supplied key param cannot be coerced into a private key
- */
- public function testShaHmac256SignatureBadPrivateKey()
- {
- // Setup
- $string = 'string';
- $privateKeyFile = VirtualRsaKeyPairCredential::badPrivateKey();
-
- // Test
- $signature = new ShaHmac256WithRsaSignature();
-
- // Assert
- $signature->sign($string, \file_get_contents($privateKeyFile));
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Traits/ClientTraitTest.php b/tests/LowerthanVersion7_2/Unit/Traits/ClientTraitTest.php
deleted file mode 100644
index 98209b08..00000000
--- a/tests/LowerthanVersion7_2/Unit/Traits/ClientTraitTest.php
+++ /dev/null
@@ -1,616 +0,0 @@
-name('client');
-
- self::assertInstanceOf(ShaHmac256WithRsaSignature::class, AlibabaCloud::get('client')->getSignature());
- }
-
- /**
- * @throws ClientException
- */
- public function testAccessKeyClient()
- {
- AlibabaCloud::accessKeyClient(self::$accessKeyId, self::$accessKeyId)->asDefaultClient();
- $credential = AlibabaCloud::getDefaultClient()->getCredential();
- self::assertInstanceOf(AccessKeyCredential::class, $credential);
- self::assertEquals(self::$accessKeyId, $credential->getAccessKeyId());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID cannot be empty
- * @throws ClientException
- */
- public function testAccessKeyClientWithAccessKeyIdEmpty()
- {
- AlibabaCloud::accessKeyClient(
- '',
- self::$accessKeySecret
- )->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID format is invalid
- * @throws ClientException
- */
- public function testAccessKeyClientWithAccessKeyIdFormat()
- {
- AlibabaCloud::accessKeyClient(
- null,
- self::$accessKeySecret
- )->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret cannot be empty
- * @throws ClientException
- */
- public function testAccessKeyClientWithAccessKeySecretEmpty()
- {
- AlibabaCloud::accessKeyClient(
- self::$accessKeyId,
- ''
- )->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret format is invalid
- * @throws ClientException
- */
- public function testAccessKeyClientWithAccessKeySecretFormat()
- {
- AlibabaCloud::accessKeyClient(
- self::$accessKeyId,
- null
- )->asDefaultClient();
- }
-
- /**
- * @throws ClientException
- */
- public function testRamRoleArnClient()
- {
- AlibabaCloud::ramRoleArnClient(
- self::$accessKeyId,
- self::$accessKeySecret,
- self::$roleArn,
- self::$roleSessionName
- )->asDefaultClient();
-
- $credential = AlibabaCloud::getDefaultClient()->getCredential();
- self::assertInstanceOf(RamRoleArnCredential::class, $credential);
- self::assertEquals(self::$accessKeyId, $credential->getAccessKeyId());
- self::assertEquals(self::$accessKeySecret, $credential->getAccessKeySecret());
- self::assertEquals(self::$roleArn, $credential->getRoleArn());
- self::assertEquals(self::$roleSessionName, $credential->getRoleSessionName());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID cannot be empty
- * @throws ClientException
- */
- public function testRamRoleArnClientWithAccessKeyIdEmpty()
- {
- AlibabaCloud::ramRoleArnClient(
- '',
- self::$accessKeySecret,
- self::$roleArn,
- self::$roleSessionName
- )->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID must be a string
- * @throws ClientException
- */
- public function testRamRoleArnClientWithAccessKeyIdFormat()
- {
- AlibabaCloud::ramRoleArnClient(
- null,
- self::$accessKeySecret,
- self::$roleArn,
- self::$roleSessionName
- )->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret cannot be empty
- * @throws ClientException
- */
- public function testRamRoleArnClientWithAccessKeySecretEmpty()
- {
- AlibabaCloud::ramRoleArnClient(
- self::$accessKeyId,
- '',
- self::$roleArn,
- self::$roleSessionName
- )->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret must be a string
- * @throws ClientException
- */
- public function testRamRoleArnClientWithAccessKeySecretFormat()
- {
- AlibabaCloud::ramRoleArnClient(
- self::$accessKeyId,
- null,
- self::$roleArn,
- self::$roleSessionName
- )->asDefaultClient();
- }
-
- /**
- * @throws ClientException
- */
- public function testEcsRamRoleClient()
- {
- AlibabaCloud::ecsRamRoleClient(self::$roleName)->asDefaultClient();
- $credential = AlibabaCloud::getDefaultClient()->getCredential();
- self::assertInstanceOf(EcsRamRoleCredential::class, $credential);
- self::assertEquals(self::$roleName, $credential->getRoleName());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Role Name cannot be empty
- * @throws ClientException
- */
- public function testEcsRamRoleClientEmpty()
- {
- AlibabaCloud::ecsRamRoleClient('')->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Role Name must be a string
- * @throws ClientException
- */
- public function testEcsRamRoleClientFormat()
- {
- AlibabaCloud::ecsRamRoleClient(null)->asDefaultClient();
- }
-
- /**
- * @throws ClientException
- */
- public function testBearerTokenClient()
- {
- AlibabaCloud::bearerTokenClient(self::$bearerToken)->asDefaultClient();
-
- $credential = AlibabaCloud::getDefaultClient()->getCredential();
- self::assertInstanceOf(BearerTokenCredential::class, $credential);
- self::assertEquals('', $credential->getAccessKeyId());
- self::assertEquals('', $credential->getAccessKeySecret());
- self::assertEquals(self::$bearerToken, $credential->getBearerToken());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Bearer Token cannot be empty
- * @throws ClientException
- */
- public function testBearerTokenClientEmpty()
- {
- AlibabaCloud::bearerTokenClient('')->asDefaultClient();
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Bearer Token must be a string
- * @throws ClientException
- */
- public function testBearerTokenClientFormat()
- {
- AlibabaCloud::bearerTokenClient(null)->asDefaultClient();
- }
-
- /**
- * @throws ClientException
- */
- public function testStsClient()
- {
- AlibabaCloud::stsClient('key', 'secret', 'token')->name('sts');
- self::assertInstanceOf(StsCredential::class, AlibabaCloud::get('sts')->getCredential());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID cannot be empty
- * @throws ClientException
- */
- public function testStsClientWithPublicKeyIdEmpty()
- {
- AlibabaCloud::stsClient('', 'secret')
- ->name('sts');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey ID must be a string
- * @throws ClientException
- */
- public function testStsClientWithPublicKeyIdFormat()
- {
- AlibabaCloud::stsClient(null, 'secret')
- ->name('sts');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret cannot be empty
- * @throws ClientException
- */
- public function testStsClientWithPrivateKeyFileEmpty()
- {
- AlibabaCloud::stsClient('key', '')
- ->name('sts');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage AccessKey Secret must be a string
- * @throws ClientException
- */
- public function testStsClientWithPrivateKeyFileFormat()
- {
- AlibabaCloud::stsClient('key', null)
- ->name('sts');
- }
-
- /**
- * @throws ClientException
- */
- public function testRsaKeyPairClient()
- {
- AlibabaCloud::rsaKeyPairClient('key', VirtualAccessKeyCredential::ok())
- ->name('rsa');
-
- self::assertInstanceOf(
- RsaKeyPairCredential::class,
- AlibabaCloud::get('rsa')->getCredential()
- );
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Public Key ID cannot be empty
- * @throws ClientException
- */
- public function testRsaKeyPairClientWithPublicKeyIdEmpty()
- {
- AlibabaCloud::rsaKeyPairClient('', 'privateKeyFile')
- ->name('rsa');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Public Key ID must be a string
- * @throws ClientException
- */
- public function testRsaKeyPairClientWithPublicKeyIdFormat()
- {
- AlibabaCloud::rsaKeyPairClient(null, 'privateKeyFile')
- ->name('rsa');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Private Key File cannot be empty
- * @throws ClientException
- */
- public function testRsaKeyPairClientWithPrivateKeyFileEmpty()
- {
- AlibabaCloud::rsaKeyPairClient('publicKeyId', '')
- ->name('rsa');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Private Key File must be a string
- * @throws ClientException
- */
- public function testRsaKeyPairClientWithPrivateKeyFileFormat()
- {
- AlibabaCloud::rsaKeyPairClient('publicKeyId', null)
- ->name('rsa');
- }
-
- /**
- * @throws ClientException
- */
- public function testGet()
- {
- // setup
- $accessKeyId = uniqid('', true);
- $accessKeySecret = uniqid('', true);
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
- static::assertEquals(
- $accessKeyId,
- AlibabaCloud::get('client1')->getCredential()->getAccessKeyId()
- );
-
- try {
- AlibabaCloud::get('None')->getCredential()->getAccessKeyId();
- } catch (ClientException $e) {
- static::assertEquals(SDK::CLIENT_NOT_FOUND, $e->getErrorCode());
- }
- }
-
- /**
- * @throws ClientException
- */
- public function testIsDebug()
- {
- $accessKeyId = uniqid('', true);
- $accessKeySecret = uniqid('', true);
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
- AlibabaCloud::get('client1')->debug(true);
- self::assertTrue(AlibabaCloud::get('client1')->isDebug());
- }
-
- /**
- * @throws ClientException
- */
- public function testGetSignature()
- {
- $accessKeyId = uniqid('', true);
- $accessKeySecret = uniqid('', true);
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
- static::assertInstanceOf(ShaHmac1Signature::class, AlibabaCloud::get('client1')->getSignature());
- }
-
- /**
- * @throws ClientException
- */
- public function testDel()
- {
- // Setup
- $clientName = 'test';
- $accessKeyId = uniqid('', true);
- $accessKeySecret = uniqid('', true);
-
- // Test
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name($clientName);
- static::assertEquals(true, AlibabaCloud::has($clientName));
- AlibabaCloud::del($clientName);
- static::assertEquals(false, AlibabaCloud::has($clientName));
- }
-
- /**
- * @throws ClientException
- */
- public function testAll()
- {
- $accessKeyId = uniqid('', true);
- $accessKeySecret = uniqid('', true);
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client2');
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client3');
- static::assertArrayHasKey('client3', AlibabaCloud::all());
- }
-
- /**
- * @throws ClientException
- */
- public function testLoadWithFiles()
- {
- AlibabaCloud::load(
- VirtualRsaKeyPairCredential::ok(),
- VirtualAccessKeyCredential::ok()
- );
- static::assertNotNull(AlibabaCloud::all());
- }
-
- /**
- * @throws ClientException
- */
- public function testLoad()
- {
- AlibabaCloud::load();
- static::assertNotNull(AlibabaCloud::all());
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client Name cannot be empty
- *
- * @throws ClientException
- */
- public function testDelEmpty()
- {
- AlibabaCloud::del('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client Name must be a string
- *
- * @throws ClientException
- */
- public function testDelFormat()
- {
- AlibabaCloud::del(null);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client Name cannot be empty
- *
- * @throws ClientException
- */
- public function testHasEmpty()
- {
- AlibabaCloud::has('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Client Name must be a string
- *
- * @throws ClientException
- */
- public function testHasFormat()
- {
- AlibabaCloud::has(null);
- }
-
- /**
- * @expectedExceptionMessage Client Name cannot be empty
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- *
- * @throws ClientException
- */
- public function testSetEmpty()
- {
- AlibabaCloud::set('', AlibabaCloud::bearerTokenClient('token'));
- }
-
- /**
- * @expectedExceptionMessage Client Name must be a string
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- *
- * @throws ClientException
- */
- public function testSetFormat()
- {
- AlibabaCloud::set(null, AlibabaCloud::bearerTokenClient('token'));
- }
-
- /**
- * @throws ClientException
- */
- public function testSet()
- {
- $name = uniqid('', true);
- AlibabaCloud::set($name, AlibabaCloud::bearerTokenClient('token'));
- self::assertTrue(AlibabaCloud::has($name));
- AlibabaCloud::del($name);
- }
-
- /**
- * @expectedExceptionMessage Client Name cannot be empty
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- *
- * @throws ClientException
- */
- public function testGetEmpty()
- {
- AlibabaCloud::get('');
- }
-
- /**
- * @expectedExceptionMessage Client Name must be a string
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- *
- * @throws ClientException
- */
- public function testGetFormat()
- {
- AlibabaCloud::get(null);
- }
-
- /**
- * @expectedExceptionMessage Client 'notFound' not found
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- *
- * @throws ClientException
- */
- public function testGetNotFound()
- {
- AlibabaCloud::get('notFound');
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Traits/EndpointTraitTest.php b/tests/LowerthanVersion7_2/Unit/Traits/EndpointTraitTest.php
deleted file mode 100644
index fc3eb519..00000000
--- a/tests/LowerthanVersion7_2/Unit/Traits/EndpointTraitTest.php
+++ /dev/null
@@ -1,218 +0,0 @@
- 'Please check the parameters',
- ]
- );
- AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)
- ->regionId('cn-hangzhou')
- ->asDefaultClient();
-
- // Test
- $request = new RpcRequest();
- $request->connectTimeout(25)->timeout(30);
- $request->product = 'Dysmsapi';
- $request->serviceCode = 'dysmsapi';
-
- // Assert
- LocationService::resolveHost($request);
- }
-
- /**
- * @throws ClientException
- */
- public function testAddGlobalHost()
- {
- // Setup
- $product = 'a';
- $host = 'a.com';
-
- // Test
- AlibabaCloud::addHost($product, $host);
-
- // Assert
- self::assertEquals($host, AlibabaCloud::resolveHost($product));
- }
-
- /**
- * @throws ClientException
- */
- public function testGlobal()
- {
- // Assert
- self::assertEquals('', AlibabaCloud::resolveHost('dysmsapi'));
- self::assertEquals('dysmsapi.aliyuncs.com', AlibabaCloud::resolveHost('dysmsapi', 'cn-hangzhou'));
- }
-
-
- public function testIsGlobalProduct()
- {
- self::assertTrue(AlibabaCloud::isGlobalProduct('ccc'));
- self::assertFalse(AlibabaCloud::isGlobalProduct('no'));
- self::assertTrue(AlibabaCloud::isGlobalProduct('Ram'));
- self::assertTrue(AlibabaCloud::isGlobalProduct('ram'));
- self::assertFalse(AlibabaCloud::isGlobalProduct('tdsr'));
- self::assertFalse(AlibabaCloud::isGlobalProduct(''));
- self::assertFalse(AlibabaCloud::isGlobalProduct(null));
- }
-
- /**
- * Test for Null
- *
- * @throws ClientException
- */
- public function testNull()
- {
- // Setup
- $regionId = 'cn-hangzhou';
- $product = 'null';
-
- // Test
- self::assertEquals('', AlibabaCloud::resolveHost($product, $regionId));
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Traits/HttpTraitTest.php b/tests/LowerthanVersion7_2/Unit/Traits/HttpTraitTest.php
deleted file mode 100644
index 6511a91a..00000000
--- a/tests/LowerthanVersion7_2/Unit/Traits/HttpTraitTest.php
+++ /dev/null
@@ -1,123 +0,0 @@
-asDefaultClient();
-
- // Assert
- self::assertFalse($client->options['verify']);
-
- // Test
- $client->verify(true);
-
- // Assert
- self::assertTrue($client->options['verify']);
- }
-
- /**
- * @throws ClientException
- */
- public static function testTimeout()
- {
- $request = AlibabaCloud::rpc()->timeout(1);
- self::assertEquals(1, $request->options['timeout']);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Timeout cannot be empty
- * @throws ClientException
- */
- public static function testTimeoutException()
- {
- AlibabaCloud::rpc()->timeout('');
- }
-
- /**
- * @throws ClientException
- */
- public static function testConnectTimeout()
- {
- $request = AlibabaCloud::rpc()->connectTimeout(1);
- self::assertEquals(1, $request->options['connect_timeout']);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Connect Timeout cannot be empty
- * @throws ClientException
- */
- public static function testConnectTimeoutException()
- {
- AlibabaCloud::rpc()->connectTimeout('');
- }
-
- /**
- * @throws ClientException
- */
- public static function testTimeoutMilliseconds()
- {
- $request = AlibabaCloud::rpc()->timeoutMilliseconds(1);
- self::assertEquals(0.001, $request->options['timeout']);
- }
-
- /**
- * @throws ClientException
- */
- public static function testConnectTimeoutMilliseconds()
- {
- $request = AlibabaCloud::rpc()->connectTimeoutMilliseconds(1);
- self::assertEquals(0.001, $request->options['connect_timeout']);
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Milliseconds must be int
- * @throws ClientException
- */
- public static function testTimeoutMillisecondsException()
- {
- AlibabaCloud::rpc()->timeoutMilliseconds('');
- }
-
- /**
- * @expectedException \AlibabaCloud\Client\Exception\ClientException
- * @expectedExceptionMessage Milliseconds must be int
- * @throws ClientException
- */
- public static function testConnectTimeoutMillisecondsException()
- {
- AlibabaCloud::rpc()->connectTimeoutMilliseconds('');
- }
-}
diff --git a/tests/LowerthanVersion7_2/Unit/Traits/MockTraitTest.php b/tests/LowerthanVersion7_2/Unit/Traits/MockTraitTest.php
deleted file mode 100644
index 44263b00..00000000
--- a/tests/LowerthanVersion7_2/Unit/Traits/MockTraitTest.php
+++ /dev/null
@@ -1,68 +0,0 @@
- 'Bar'];
- $body = [
- 'Code' => 'code',
- 'Message' => 'message',
- ];
-
- AlibabaCloud::mockResponse(200, $header, $body);
- AlibabaCloud::mockResponse(500, $header, $body);
-
- $result = AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
-
- self::assertEquals($body, $result->toArray());
-
- try {
- AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
- } catch (ServerException $exception) {
- self::assertEquals('message', $exception->getErrorMessage());
- self::assertEquals($body, $exception->getResult()->toArray());
- }
-
- AlibabaCloud::rpc()
- ->product('ecs')
- ->regionId('cn-hangzhou')
- ->request();
- }
-
- public function testCancelMock()
- {
- AlibabaCloud::mockResponse();
- AlibabaCloud::mockResponse(500);
- self::assertTrue(AlibabaCloud::hasMock());
- AlibabaCloud::cancelMock();
- self::assertFalse(AlibabaCloud::hasMock());
- }
-}
diff --git a/tests/Unit/AlibabaCloudTest.php b/tests/Unit/AlibabaCloudTest.php
new file mode 100644
index 00000000..9e695606
--- /dev/null
+++ b/tests/Unit/AlibabaCloudTest.php
@@ -0,0 +1,41 @@
+expectException(ClientException::class);
+ $reg = '/May not yet support product/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
+ AlibabaCloud::Ecs();
+
+ }
+
+}
diff --git a/tests/LowerthanVersion7_2/Unit/Clients/AccessKeyClientTest.php b/tests/Unit/Clients/AccessKeyClientTest.php
similarity index 90%
rename from tests/LowerthanVersion7_2/Unit/Clients/AccessKeyClientTest.php
rename to tests/Unit/Clients/AccessKeyClientTest.php
index 422d4768..3d645ca9 100644
--- a/tests/LowerthanVersion7_2/Unit/Clients/AccessKeyClientTest.php
+++ b/tests/Unit/Clients/AccessKeyClientTest.php
@@ -1,6 +1,6 @@
getProperty('configManager');
$property->setAccessible(true);
$property->setValue($value);
+
}
/**
@@ -51,10 +54,11 @@ private static function setStaticProperty($value)
*/
public function testGetConfigManager()
{
- $ref = new \ReflectionClass(Config::class);
+ $ref = new \ReflectionClass(Config::class);
$method = $ref->getMethod('getConfigManager');
$method->setAccessible(true);
self::assertInstanceOf(ConfigManager::class, $method->invoke(null));
+
}
/**
@@ -67,6 +71,7 @@ public function testSetAndGet()
self::setStaticProperty(new ConfigManager(self::file()->url()));
Config::set('vfs', __METHOD__);
self::assertEquals(Config::get('vfs'), __METHOD__);
+
}
/**
@@ -84,11 +89,12 @@ private static function file()
return [];
EOT;
- $root = vfsStream::setup('AlibabaCloud');
+ $root = vfsStream::setup('AlibabaCloud');
self::$vfs = vfsStream::newFile('config')
- ->withContent($content)
- ->at($root);
+ ->withContent($content)
+ ->at($root);
return self::$vfs;
+
}
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/AccessKeyCredentialTest.php b/tests/Unit/Credentials/AccessKeyCredentialTest.php
similarity index 93%
rename from tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/AccessKeyCredentialTest.php
rename to tests/Unit/Credentials/AccessKeyCredentialTest.php
index f34fb5ef..517c96f8 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/AccessKeyCredentialTest.php
+++ b/tests/Unit/Credentials/AccessKeyCredentialTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
- $this->expectExceptionMessageMatches("/Missing required 'key' option for 'name'/");
+ $reg = "/Missing required 'key' option for 'name'/";
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
$object = new IniCredential();
$object->missingRequired('key', 'name');
}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Ini/OptionsTraitTest.php b/tests/Unit/Credentials/Ini/OptionsTraitTest.php
similarity index 90%
rename from tests/LowerthanVersion7_2/Unit/Credentials/Ini/OptionsTraitTest.php
rename to tests/Unit/Credentials/Ini/OptionsTraitTest.php
index 429b35a8..28bb28ad 100644
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Ini/OptionsTraitTest.php
+++ b/tests/Unit/Credentials/Ini/OptionsTraitTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
$this->expectExceptionMessage("Environment variable 'ALIBABA_CLOUD_ACCESS_KEY_ID' cannot be empty");
putenv('ALIBABA_CLOUD_ACCESS_KEY_ID=');
@@ -27,6 +37,7 @@ public function testEnvironmentVariableIdEmpty()
public function testEnvironmentVariableSecretEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Environment variable 'ALIBABA_CLOUD_ACCESS_KEY_SECRET' cannot be empty");
putenv('ALIBABA_CLOUD_ACCESS_KEY_ID=id');
@@ -40,8 +51,9 @@ public function testEnvironmentVariableSecretEmpty()
*/
public function testEnvProvider()
{
+
self::assertEquals([], AlibabaCloud::all());
- $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
+ $id = \AlibabaCloud\Client\env('ACCESS_KEY_ID');
$secret = \AlibabaCloud\Client\env('ACCESS_KEY_SECRET');
putenv("ALIBABA_CLOUD_ACCESS_KEY_ID=$id");
putenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET=$secret");
@@ -52,6 +64,7 @@ public function testEnvProvider()
public function testIniWithLoadHomeFile()
{
+
self::assertEquals([], AlibabaCloud::all());
$provider = CredentialsProvider::ini();
$provider();
@@ -62,6 +75,7 @@ public function testIniWithLoadHomeFile()
*/
public function testIniEnvironmentVariableEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Environment variable 'ALIBABA_CLOUD_CREDENTIALS_FILE' cannot be empty");
putenv('ALIBABA_CLOUD_CREDENTIALS_FILE=');
@@ -75,6 +89,7 @@ public function testIniEnvironmentVariableEmpty()
*/
public function testIniWithFile()
{
+
self::assertEquals([], AlibabaCloud::all());
$file = VirtualAccessKeyCredential::ok();
putenv("ALIBABA_CLOUD_CREDENTIALS_FILE=$file");
@@ -88,6 +103,7 @@ public function testIniWithFile()
*/
public function testInstance()
{
+
self::assertEquals([], AlibabaCloud::all());
putenv('ALIBABA_CLOUD_ECS_METADATA=role_name');
$provider = CredentialsProvider::instance();
@@ -100,6 +116,7 @@ public function testInstance()
*/
public function testDefaultProvider()
{
+
self::assertEquals([], AlibabaCloud::all());
$file = VirtualAccessKeyCredential::ok();
putenv("ALIBABA_CLOUD_CREDENTIALS_FILE=$file");
@@ -112,6 +129,7 @@ public function testDefaultProvider()
*/
public function testDefaultProviderWithEnv()
{
+
putenv('ALIBABA_CLOUD_ACCESS_KEY_ID=id');
putenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET=secret');
@@ -121,6 +139,7 @@ public function testDefaultProviderWithEnv()
public function testHasCustomChain()
{
+
self::assertFalse(CredentialsProvider::hasCustomChain());
}
@@ -129,6 +148,7 @@ public function testHasCustomChain()
*/
public function testFlush()
{
+
self::assertFalse(CredentialsProvider::hasCustomChain());
CredentialsProvider::chain(
CredentialsProvider::ini(),
@@ -148,6 +168,7 @@ public function testFlush()
*/
public function testChain()
{
+
self::assertEquals([], AlibabaCloud::all());
$file = VirtualAccessKeyCredential::ok();
putenv("ALIBABA_CLOUD_CREDENTIALS_FILE=$file");
@@ -161,6 +182,7 @@ public function testChain()
public function testChainWithNoChainException()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("No providers in chain");
CredentialsProvider::chain();
@@ -168,6 +190,7 @@ public function testChainWithNoChainException()
public function testChaiMustBeChain()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Providers must all be Closures");
CredentialsProvider::chain(
@@ -181,11 +204,13 @@ public function testChaiMustBeChain()
*/
public function testDefault()
{
+
self::assertEquals('default', CredentialsProvider::getDefaultName());
}
public function testEnvironmentVariableEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Environment variable 'ALIBABA_CLOUD_PROFILE' cannot be empty");
putenv('ALIBABA_CLOUD_PROFILE=');
@@ -197,13 +222,9 @@ public function testEnvironmentVariableEmpty()
*/
public function testEnvironmentVariable()
{
+
putenv('ALIBABA_CLOUD_PROFILE=test');
self::assertEquals('test', CredentialsProvider::getDefaultName());
putenv('ALIBABA_CLOUD_PROFILE=default');
}
-
- protected function setUp(): void
- {
- AlibabaCloud::flush();
- }
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/EcsRamRoleProviderTest.php b/tests/Unit/Credentials/Providers/EcsRamRoleProviderTest.php
similarity index 87%
rename from tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/EcsRamRoleProviderTest.php
rename to tests/Unit/Credentials/Providers/EcsRamRoleProviderTest.php
index 3cb0f58c..5299cec4 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/EcsRamRoleProviderTest.php
+++ b/tests/Unit/Credentials/Providers/EcsRamRoleProviderTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
$this->expectExceptionMessage("Timeout or instance does not belong to Alibaba Cloud");
// Setup
- $client = new EcsRamRoleClient('foo');
+ $client = new EcsRamRoleClient('foo');
$provider = new EcsRamRoleProvider($client);
AlibabaCloud::mockRequestException('timed', new Request('GET', 'url'));
// Test
$provider->get();
+
}
/**
@@ -49,7 +58,7 @@ public function testGet()
public function testGetInCache()
{
// Setup
- $client = new EcsRamRoleClient(
+ $client = new EcsRamRoleClient(
'foo'
);
$provider = new EcsRamRoleProvider($client);
@@ -61,16 +70,17 @@ public function testGetInCache()
);
$cacheMethod->setAccessible(true);
$result = [
- 'Expiration' => '2049-10-01 11:11:11',
- 'AccessKeyId' => 'foo',
+ 'Expiration' => '2049-10-01 11:11:11',
+ 'AccessKeyId' => 'foo',
'AccessKeySecret' => 'bar',
- 'SecurityToken' => 'token',
+ 'SecurityToken' => 'token',
];
$cacheMethod->invokeArgs($provider, [$result]);
$actual = $provider->get();
// Assert
self::assertInstanceOf(StsCredential::class, $actual);
+
}
/**
@@ -81,7 +91,7 @@ public function testServerUnreachable()
{
// Setup
$roleName = 'EcsRamRoleTest';
- $client = new EcsRamRoleClient($roleName);
+ $client = new EcsRamRoleClient($roleName);
// Test
$credential = new EcsRamRoleProvider($client);
@@ -92,6 +102,7 @@ public function testServerUnreachable()
} catch (ClientException $e) {
$this->assertEquals($e->getErrorCode(), SDK::SERVER_UNREACHABLE);
}
+
}
/**
@@ -101,7 +112,7 @@ public function estInvalidCredential()
{
// Setup
$roleName = 'EcsRamRoleTest';
- $client = new EcsRamRoleClient($roleName);
+ $client = new EcsRamRoleClient($roleName);
// Test
$provider = new EcsRamRoleProvider($client);
@@ -115,6 +126,7 @@ public function estInvalidCredential()
SDK::INVALID_CREDENTIAL
);
}
+
}
/**
@@ -135,9 +147,10 @@ public function testOk()
"Code" : "Success"
}'
);
- $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
+ $provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
$credential = $provider->get();
self::assertInstanceOf(StsCredential::class, $credential);
+
}
/**
@@ -151,6 +164,7 @@ public function testNoCredentials()
AlibabaCloud::mockResponse();
$provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
$provider->get();
+
}
/**
@@ -164,6 +178,7 @@ public function test404()
AlibabaCloud::mockResponse(404);
$provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
$provider->get();
+
}
/**
@@ -177,6 +192,7 @@ public function testErrorRetrieving()
AlibabaCloud::mockResponse(500);
$provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
$provider->get();
+
}
/**
@@ -190,10 +206,7 @@ public function testRequestException()
AlibabaCloud::mockRequestException('Error', new Request('GET', 'test'));
$provider = new EcsRamRoleProvider(AlibabaCloud::ecsRamRoleClient('role'));
$provider->get();
+
}
- protected function tearDown(): void
- {
- AlibabaCloud::cancelMock();
- }
}
diff --git a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/ProviderTest.php b/tests/Unit/Credentials/Providers/ProviderTest.php
similarity index 95%
rename from tests/LowerthanVersion7_2/Unit/Credentials/Providers/ProviderTest.php
rename to tests/Unit/Credentials/Providers/ProviderTest.php
index 38504a7a..4ef3529b 100644
--- a/tests/LowerthanVersion7_2/Unit/Credentials/Providers/ProviderTest.php
+++ b/tests/Unit/Credentials/Providers/ProviderTest.php
@@ -1,6 +1,6 @@
getErrorCode());
}
+
}
/**
@@ -54,7 +65,7 @@ public function testGet()
public function testGetInCache()
{
// Setup
- $client = new RamRoleArnClient(
+ $client = new RamRoleArnClient(
'foo',
'bar',
'arn',
@@ -69,10 +80,10 @@ public function testGetInCache()
);
$cacheMethod->setAccessible(true);
$result = [
- 'Expiration' => '2049-10-01 11:11:11',
- 'AccessKeyId' => 'foo',
+ 'Expiration' => '2049-10-01 11:11:11',
+ 'AccessKeyId' => 'foo',
'AccessKeySecret' => 'bar',
- 'SecurityToken' => 'token',
+ 'SecurityToken' => 'token',
];
$cacheMethod->invokeArgs($provider, [$result]);
@@ -80,6 +91,7 @@ public function testGetInCache()
// Assert
self::assertInstanceOf(StsCredential::class, $actual);
+
}
/**
@@ -96,6 +108,7 @@ public function testNoCredentials()
$provider = new RamRoleArnProvider($client);
$provider->get();
+
}
/**
@@ -124,13 +137,10 @@ public function testOk()
$client = AlibabaCloud::ramRoleArnClient('id', 'secret', 'arn', 'session');
- $provider = new RamRoleArnProvider($client);
+ $provider = new RamRoleArnProvider($client);
$credential = $provider->get();
self::assertInstanceOf(StsCredential::class, $credential);
+
}
- protected function tearDown(): void
- {
- AlibabaCloud::cancelMock();
- }
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/RsaKeyPairProviderTest.php b/tests/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
similarity index 76%
rename from tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
rename to tests/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
index b7eaabba..073ebe96 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
+++ b/tests/Unit/Credentials/Providers/RsaKeyPairProviderTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
- $this->expectExceptionMessageMatches("/openssl_sign/");
+ $reg = '/openssl_sign/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
// Setup
- $client = new RsaKeyPairClient(
+ $client = new RsaKeyPairClient(
'foo',
VirtualRsaKeyPairCredential::ok()
);
@@ -43,6 +67,7 @@ public function testGet()
// Assert
self::assertInstanceOf(AccessKeyCredential::class, $actual);
+
}
/**
@@ -52,8 +77,9 @@ public function testGet()
*/
public function testGetInCache()
{
+
// Setup
- $client = new RsaKeyPairClient(
+ $client = new RsaKeyPairClient(
'foo',
VirtualRsaKeyPairCredential::ok()
);
@@ -66,8 +92,8 @@ public function testGetInCache()
);
$cacheMethod->setAccessible(true);
$result = [
- 'Expiration' => '2049-10-01 11:11:11',
- 'SessionAccessKeyId' => 'foo',
+ 'Expiration' => '2049-10-01 11:11:11',
+ 'SessionAccessKeyId' => 'foo',
'SessionAccessKeySecret' => 'bar',
];
$cacheMethod->invokeArgs($provider, [$result]);
@@ -76,6 +102,7 @@ public function testGetInCache()
// Assert
self::assertInstanceOf(StsCredential::class, $actual);
+
}
/**
@@ -84,6 +111,7 @@ public function testGetInCache()
*/
public function testNoCredentials()
{
+
$this->expectException(ServerException::class);
$this->expectExceptionMessage("SDK.InvalidCredential: Result contains no credentials RequestId:");
AlibabaCloud::mockResponse();
@@ -95,6 +123,7 @@ public function testNoCredentials()
$provider = new RsaKeyPairProvider($client);
$provider->get();
+
}
/**
@@ -103,6 +132,7 @@ public function testNoCredentials()
*/
public function testSuccess()
{
+
AlibabaCloud::mockResponse(
200,
[],
@@ -121,19 +151,11 @@ public function testSuccess()
VirtualRsaKeyPairCredential::privateKeyFileUrl()
);
- $provider = new RsaKeyPairProvider($client);
+ $provider = new RsaKeyPairProvider($client);
$credential = $provider->get();
self::assertInstanceOf(StsCredential::class, $credential);
+
}
- protected function setUp(): void
- {
- AlibabaCloud::cancelMock();
- }
-
- protected function tearDown(): void
- {
- AlibabaCloud::cancelMock();
- }
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/RamRoleArnCredentialTest.php b/tests/Unit/Credentials/RamRoleArnCredentialTest.php
similarity index 95%
rename from tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/RamRoleArnCredentialTest.php
rename to tests/Unit/Credentials/RamRoleArnCredentialTest.php
index 7858cdbf..bbbabb5a 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Credentials/RamRoleArnCredentialTest.php
+++ b/tests/Unit/Credentials/RamRoleArnCredentialTest.php
@@ -1,6 +1,6 @@
asDefaultClient();
+ }
+
+ /**
+ * @after
+ */
+ protected function finalize()
+ {
+ parent::tearDown();
+ AlibabaCloud::cancelMock();
+ }
+
/**
* @throws ClientException
* @throws ServerException
*/
public function testAddHost()
{
+
// Setup
- $product = 'b';
- $host = 'c';
+ $product = 'b';
+ $host = 'c';
$regionId = 'a';
// Test
@@ -34,6 +54,7 @@ public function testAddHost()
// Assert
self::assertEquals(LocationService::resolveHost($request), $host);
+
}
/**
@@ -42,14 +63,21 @@ public function testAddHost()
*/
public function testResolveHostWithServiceUnknownError()
{
+
$this->expectException(ClientException::class);
- $this->expectExceptionMessageMatches("/Not found Region ID in location.aliyuncs.com/");
+ $reg = '/Not found Region ID in location.aliyuncs.com/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
AlibabaCloud::mockResponse();
$request = AlibabaCloud::rpc()->product(__METHOD__)
- ->regionId('regionId');
+ ->regionId('regionId');
$host = LocationService::resolveHost($request);
self::assertEquals('', $host);
+
}
/**
@@ -58,6 +86,7 @@ public function testResolveHostWithServiceUnknownError()
*/
public function testResolveHostNotFound()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Not found Region ID in location.aliyuncs.com");
AlibabaCloud::mockResponse();
@@ -65,6 +94,7 @@ public function testResolveHostNotFound()
$request = AlibabaCloud::rpc()->product(__METHOD__)->regionId('regionId');
LocationService::resolveHost($request);
+
}
/**
@@ -73,6 +103,7 @@ public function testResolveHostNotFound()
*/
public function testResolveHostSuccess()
{
+
$body = [
'Endpoints' => [
'Endpoint' => [
@@ -90,6 +121,7 @@ public function testResolveHostSuccess()
$host = LocationService::resolveHost($request);
self::assertEquals('cdn.aliyun.com', $host);
+
}
/**
@@ -97,9 +129,11 @@ public function testResolveHostSuccess()
*/
public function testAddHostWithProductEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Product cannot be empty");
LocationService::addHost('', 'host', 'regionId');
+
}
/**
@@ -107,9 +141,11 @@ public function testAddHostWithProductEmpty()
*/
public function testAddHostWithProductFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Product must be a string");
LocationService::addHost(null, 'host', 'regionId');
+
}
/**
@@ -117,9 +153,11 @@ public function testAddHostWithProductFormat()
*/
public function testAddHostWithHostEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Host cannot be empty");
LocationService::addHost('product', '', 'regionId');
+
}
/**
@@ -127,9 +165,11 @@ public function testAddHostWithHostEmpty()
*/
public function testAddHostWithHostFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Host must be a string");
LocationService::addHost('product', null, 'regionId');
+
}
/**
@@ -137,9 +177,11 @@ public function testAddHostWithHostFormat()
*/
public function testAddHostWithRegionIdEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Region ID cannot be empty");
LocationService::addHost('product', 'host', '');
+
}
/**
@@ -147,9 +189,11 @@ public function testAddHostWithRegionIdEmpty()
*/
public function testAddHostWithRegionIdFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Region ID must be a string");
LocationService::addHost('product', 'host', null);
+
}
/**
@@ -158,8 +202,14 @@ public function testAddHostWithRegionIdFormat()
*/
public function testLocationServiceException()
{
+
$this->expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/Specified access key is not found/");
+ $reg = '/Specified access key is not found/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
// Setup
AlibabaCloud::accessKeyClient('key', 'secret')->asDefaultClient();
@@ -178,6 +228,7 @@ public function testLocationServiceException()
// Test
LocationService::resolveHost($request);
+
}
/**
@@ -186,23 +237,18 @@ public function testLocationServiceException()
*/
public function testLocationServiceWithBadServiceDomain()
{
+
$this->expectException(ClientException::class);
- $this->expectExceptionMessageMatches("/cURL error 6: Could not resolve/");
+ $reg = '/cURL error 6: Could not resolve/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
AlibabaCloud::accessKeyClient('key', 'secret')->asDefaultClient();
$request = (new DeleteDatabaseRequest())->regionId('cn-hangzhou');
LocationService::resolveHost($request, 'not.alibaba.com');
+
}
- /**
- * @throws ClientException
- */
- protected function setUp(): void
- {
- AlibabaCloud::accessKeyClient('foo', 'bar')->asDefaultClient();
- }
-
- protected function tearDown(): void
- {
- AlibabaCloud::cancelMock();
- }
}
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Request/AcsTraitTest.php b/tests/Unit/Request/AcsTraitTest.php
similarity index 91%
rename from tests/HigherthanorEqualtoVersion7_2/Unit/Request/AcsTraitTest.php
rename to tests/Unit/Request/AcsTraitTest.php
index ddfaff52..702c7bc8 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Request/AcsTraitTest.php
+++ b/tests/Unit/Request/AcsTraitTest.php
@@ -1,6 +1,6 @@
action);
+
}
/**
@@ -46,6 +57,7 @@ public function testActionWithEmpty()
// Test
$request->action('');
+
}
/**
@@ -60,6 +72,7 @@ public function testActionWithFormat()
// Test
$request->action(null);
+
}
/**
@@ -76,6 +89,7 @@ public function testVersion()
// Assert
self::assertEquals($version, $request->version);
+
}
/**
@@ -90,6 +104,7 @@ public function testVersionWithEmpty()
// Test
$request->version('');
+
}
/**
@@ -104,6 +119,7 @@ public function testVersionWithFormat()
// Test
$request->version(null);
+
}
/**
@@ -120,6 +136,7 @@ public function testProduct()
// Assert
self::assertEquals($product, $request->product);
+
}
public function testNetwork()
@@ -133,6 +150,7 @@ public function testNetwork()
// Assert
self::assertEquals($network, $request->network);
+
}
/**
@@ -147,6 +165,7 @@ public function testProductWithEmpty()
// Test
$request->product('');
+
}
/**
@@ -161,6 +180,7 @@ public function testProductWithFormat()
// Test
$request->product(null);
+
}
/**
@@ -170,7 +190,7 @@ public function testLocationEndpointType()
{
// Setup
$endpointType = 'endpointType';
- $request = new RpcRequest();
+ $request = new RpcRequest();
// Test
$request->endpointType($endpointType);
@@ -180,6 +200,7 @@ public function testLocationEndpointType()
$endpointType,
$request->endpointType
);
+
}
/**
@@ -194,6 +215,7 @@ public function testLocationEndpointTypeEmpty()
// Test
$request->endpointType('');
+
}
/**
@@ -208,6 +230,7 @@ public function testLocationEndpointTypeFormat()
// Test
$request->endpointType(null);
+
}
/**
@@ -217,7 +240,7 @@ public function testLocationServiceCode()
{
// Setup
$serviceCode = 'serviceCode';
- $request = new RpcRequest();
+ $request = new RpcRequest();
// Test
$request->serviceCode($serviceCode);
@@ -227,6 +250,7 @@ public function testLocationServiceCode()
$serviceCode,
$request->serviceCode
);
+
}
/**
@@ -241,6 +265,7 @@ public function testServiceCodeEmpty()
// Test
$request->serviceCode('');
+
}
/**
@@ -255,6 +280,7 @@ public function testServiceCodeFormat()
// Test
$request->serviceCode(null);
+
}
/**
@@ -264,7 +290,7 @@ public function testRealRegionIdOnRequest()
{
// Setup
$regionId = 'regionId';
- $request = new RpcRequest();
+ $request = new RpcRequest();
// Test
$request->regionId($regionId);
@@ -274,6 +300,7 @@ public function testRealRegionIdOnRequest()
strtolower($regionId),
$request->realRegionId()
);
+
}
/**
@@ -285,10 +312,11 @@ public function testRegionIdEmpty()
$this->expectExceptionMessage("Region ID cannot be empty");
// Setup
$regionId = '';
- $request = new RpcRequest();
+ $request = new RpcRequest();
// Test
$request->regionId($regionId);
+
}
/**
@@ -300,10 +328,11 @@ public function testRegionIdFormat()
$this->expectExceptionMessage("Region ID must be a string");
// Setup
$regionId = null;
- $request = new RpcRequest();
+ $request = new RpcRequest();
// Test
$request->regionId($regionId);
+
}
/**
@@ -318,6 +347,7 @@ public function testTimeoutEmpty()
// Test
$request->timeout('');
+
}
/**
@@ -332,6 +362,7 @@ public function testConnectTimeout()
// Test
$request->connectTimeout('');
+
}
/**
@@ -342,8 +373,8 @@ public function testRealRegionIdOnClient()
// Setup
$regionId = 'regionId';
AlibabaCloud::accessKeyClient('foo', 'bar')
- ->regionId($regionId)
- ->name('regionId');
+ ->regionId($regionId)
+ ->name('regionId');
$request = new RpcRequest();
// Test
@@ -354,6 +385,7 @@ public function testRealRegionIdOnClient()
strtolower($regionId),
$request->realRegionId()
);
+
}
/**
@@ -364,7 +396,7 @@ public function testRealRegionIdOnDefault()
// Setup
$regionId = 'regionId';
AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
+ ->name('regionId');
AlibabaCloud::setDefaultRegionId($regionId);
// Test
@@ -376,6 +408,7 @@ public function testRealRegionIdOnDefault()
strtolower($regionId),
$request->realRegionId()
);
+
}
/**
@@ -386,23 +419,24 @@ public function testEndpointMap()
{
// Setup
$request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
+ $region = 'cn-hangzhou';
$request->regionId($region);
$request->endpointMap[$region] = 'b.com';
// Test
$request->resolveHost();
- self::assertEquals('http://b.com', (string)$request->uri);
+ self::assertEquals('http://b.com', (string) $request->uri);
// Setup
$request = AlibabaCloud::rpc();
- $region = 'cn-shanghai';
+ $region = 'cn-shanghai';
$request->regionId($region);
$request->product('ecs');
// Test
$request->resolveHost();
- self::assertEquals('http://ecs-cn-hangzhou.aliyuncs.com', (string)$request->uri);
+ self::assertEquals('http://ecs-cn-hangzhou.aliyuncs.com', (string) $request->uri);
+
}
/**
@@ -413,14 +447,15 @@ public function testEndpointRegional()
{
// Setup
$request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
+ $region = 'cn-hangzhou';
$request->regionId($region);
$request->product('ecs');
$request->endpointRegional = 'regional';
// Test
$request->resolveHost();
- self::assertEquals('http://ecs.cn-hangzhou.aliyuncs.com', (string)$request->uri);
+ self::assertEquals('http://ecs.cn-hangzhou.aliyuncs.com', (string) $request->uri);
+
}
/**
@@ -431,14 +466,15 @@ public function testEndpointCentral()
{
// Setup
$request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
+ $region = 'cn-hangzhou';
$request->regionId($region);
$request->product('ecs');
$request->endpointRegional = 'central';
// Test
$request->resolveHost();
- self::assertEquals('http://ecs.aliyuncs.com', (string)$request->uri);
+ self::assertEquals('http://ecs.aliyuncs.com', (string) $request->uri);
+
}
/**
@@ -451,13 +487,14 @@ public function testEndpointRegionalRnvalid()
$this->expectExceptionMessage("endpointRegional is invalid.");
// Setup
$request = AlibabaCloud::rpc();
- $region = 'cn-hangzhou';
+ $region = 'cn-hangzhou';
$request->regionId($region);
$request->product('ecs');
$request->endpointRegional = 'invalid';
// Test
$request->resolveHost();
+
}
/**
@@ -470,12 +507,13 @@ public function testRealRegionIdException()
// Setup
AlibabaCloud::flush();
AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
+ ->name('regionId');
// Test
$request = new RpcRequest();
$request->client('regionId');
$request->realRegionId();
+
}
/**
@@ -487,8 +525,9 @@ public function testSetDefaultRegionIdNull()
$this->expectExceptionMessage("Region ID must be a string");
// Test
AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
+ ->name('regionId');
AlibabaCloud::setDefaultRegionId(null);
+
}
/**
@@ -500,8 +539,9 @@ public function testSetDefaultRegionIdEmpty()
$this->expectExceptionMessage("Region ID cannot be empty");
// Test
AlibabaCloud::accessKeyClient('foo', 'bar')
- ->name('regionId');
+ ->name('regionId');
AlibabaCloud::setDefaultRegionId('');
+
}
/**
@@ -523,6 +563,7 @@ public function testFindDomainInConfig()
'ecs.eu-central-1.aliyuncs.com',
$request->uri->getHost()
);
+
}
/**
@@ -553,6 +594,7 @@ public function testFindDomainOnLocationService()
// Assert
$request->resolveHost();
self::assertEquals('ecs-cn-hangzhou.aliyuncs.com', $request->uri->getHost());
+
}
/**
@@ -586,10 +628,8 @@ public function testFindDomainOnLocationServiceWithEmpty()
// Assert
$request->resolveHost();
self::assertEquals('ecs-cn-hangzhou.aliyuncs.com', $request->uri->getHost());
+
}
- protected function tearDown(): void
- {
- AlibabaCloud::cancelMock();
- }
+
}
diff --git a/tests/LowerthanVersion7_2/Unit/Request/ArrayAccessTraitTest.php b/tests/Unit/Request/ArrayAccessTraitTest.php
similarity index 86%
rename from tests/LowerthanVersion7_2/Unit/Request/ArrayAccessTraitTest.php
rename to tests/Unit/Request/ArrayAccessTraitTest.php
index d0b8b796..d16354d3 100644
--- a/tests/LowerthanVersion7_2/Unit/Request/ArrayAccessTraitTest.php
+++ b/tests/Unit/Request/ArrayAccessTraitTest.php
@@ -1,6 +1,6 @@
'1.0.0',
- 'Append2' => '2.0.0',
- 'PHP' => '2.0.0',
- ]);
+ 'Append' => '1.0.0',
+ 'Append2' => '2.0.0',
+ 'PHP' => '2.0.0',
+ ]);
self::assertStringStartsWith('AlibabaCloud', $userAgent);
self::assertStringEndsWith('Append/1.0.0 Append2/2.0.0', $userAgent);
@@ -41,9 +51,9 @@ public static function testUserAgentAppend()
public static function testUserAgentWith()
{
UserAgent::with([
- 'Append' => '1.0.0',
- 'Append2' => '2.0.0',
- ]);
+ 'Append' => '1.0.0',
+ 'Append2' => '2.0.0',
+ ]);
$userAgent = UserAgent::toString();
self::assertStringEndsWith('Append/1.0.0 Append2/2.0.0', $userAgent);
}
@@ -67,6 +77,7 @@ public function testGuardWithNameEmpty()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Name cannot be empty");
UserAgent::append('', '7.3');
+
}
/**
@@ -77,6 +88,7 @@ public function testGuardWithNameFormat()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Name must be a string");
UserAgent::append(null, '7.3');
+
}
/**
@@ -87,6 +99,7 @@ public function testGuardWithValueEmpty()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Value cannot be empty");
UserAgent::append('PHP', '');
+
}
/**
@@ -97,6 +110,7 @@ public function testGuardWithValueFormat()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Value must be a string");
UserAgent::append('PHP', null);
+
}
/**
@@ -107,6 +121,7 @@ public static function testAppendGlobalUserAgent()
AlibabaCloud::appendUserAgent('cli', '1.0.0');
AlibabaCloud::appendUserAgent('cmp', 'fit2cloud');
self::assertStringEndsWith('cli/1.0.0 cmp/fit2cloud', UserAgent::toString());
+
}
/**
@@ -117,6 +132,7 @@ public function testAppendUserAgentWithNameEmpty()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Name cannot be empty");
AlibabaCloud::appendUserAgent('', '1.0.0');
+
}
/**
@@ -127,6 +143,7 @@ public function testAppendUserAgentWithNameFormat()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Name must be a string");
AlibabaCloud::appendUserAgent(null, '1.0.0');
+
}
/**
@@ -137,6 +154,7 @@ public function testAppendUserAgentWithValueEmpty()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Value cannot be empty");
AlibabaCloud::appendUserAgent('cli', '');
+
}
/**
@@ -147,14 +165,15 @@ public function testAppendUserAgentWithValueFormat()
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Value must be a string");
AlibabaCloud::appendUserAgent('cli', null);
+
}
public static function testWithGlobalUserAgent()
{
AlibabaCloud::withUserAgent([
- 'Append' => '1.0.0',
- 'Append2' => '2.0.0',
- ]);
+ 'Append' => '1.0.0',
+ 'Append2' => '2.0.0',
+ ]);
self::assertStringEndsWith('Append/1.0.0 Append2/2.0.0', UserAgent::toString());
@@ -191,9 +210,9 @@ public static function testWithForRequest()
AlibabaCloud::appendUserAgent('cli', '1.0.0');
$request = new RpcRequest();
$request->withUserAgent([
- 'Append' => '1.0.0',
- 'Append2' => '2.0.0',
- ]);
+ 'Append' => '1.0.0',
+ 'Append2' => '2.0.0',
+ ]);
// Execution request to get UA information, expected exception.
try {
@@ -216,9 +235,9 @@ public static function testRequestFirst()
AlibabaCloud::appendUserAgent('cli', '1.0.0');
$request = new RpcRequest();
$request->withUserAgent([
- 'Append' => '1.0.0',
- 'cli' => '2.0.0',
- ]);
+ 'Append' => '1.0.0',
+ 'cli' => '2.0.0',
+ ]);
// Execution request to get UA information, expected exception.
try {
@@ -236,14 +255,10 @@ public static function testRequestFirst()
public static function testNull()
{
AlibabaCloud::withUserAgent([
- 'Append' => null,
- ]);
+ 'Append' => null,
+ ]);
self::assertStringEndsWith('Append', UserAgent::toString());
}
- protected function tearDown(): void
- {
- UserAgent::clear();
- }
}
diff --git a/tests/LowerthanVersion7_2/Unit/Result/ResultTest.php b/tests/Unit/Result/ResultTest.php
similarity index 96%
rename from tests/LowerthanVersion7_2/Unit/Result/ResultTest.php
rename to tests/Unit/Result/ResultTest.php
index 7cbe19c9..e0af1f8c 100644
--- a/tests/LowerthanVersion7_2/Unit/Result/ResultTest.php
+++ b/tests/Unit/Result/ResultTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
$this->expectExceptionCode(0);
- $this->expectExceptionMessageMatches("/openssl_sign()/");
+ $reg = '/openssl_sign()/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
// Setup
$string = 'string';
$privateKeyFile = VirtualRsaKeyPairCredential::badPrivateKey();
diff --git a/tests/LowerthanVersion7_2/Unit/Support/ArraysTest.php b/tests/Unit/Support/ArraysTest.php
similarity index 88%
rename from tests/LowerthanVersion7_2/Unit/Support/ArraysTest.php
rename to tests/Unit/Support/ArraysTest.php
index 0d294934..6b010b00 100644
--- a/tests/LowerthanVersion7_2/Unit/Support/ArraysTest.php
+++ b/tests/Unit/Support/ArraysTest.php
@@ -1,6 +1,6 @@
expectException(ClientException::class);
$this->expectExceptionMessage("Client 'default' not found");
AlibabaCloud::flush();
AlibabaCloud::getDefaultClient();
}
- public function setUp(): void
- {
- self::$regionId = 'cn-hangzhou';
- self::$accessKeyId = \getenv('ACCESS_KEY_ID');
- self::$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
- self::$roleName = 'EcsRamRoleTest';
- self::$roleArn = 'acs:ram::1483445870618637:role/test';
- self::$roleSessionName = 'role_session_name';
- self::$bearerToken = 'BEARER_TOKEN';
- }
-
/**
* @throws ClientException
*/
public function testClient()
{
+
AlibabaCloud::client(
new AccessKeyCredential('foo', 'bar'),
new ShaHmac256WithRsaSignature()
@@ -95,6 +102,7 @@ public function testClient()
*/
public function testAccessKeyClient()
{
+
AlibabaCloud::accessKeyClient(self::$accessKeyId, self::$accessKeyId)->asDefaultClient();
$credential = AlibabaCloud::getDefaultClient()->getCredential();
self::assertInstanceOf(AccessKeyCredential::class, $credential);
@@ -106,6 +114,7 @@ public function testAccessKeyClient()
*/
public function testAccessKeyClientWithAccessKeyIdEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey ID cannot be empty");
AlibabaCloud::accessKeyClient(
@@ -119,6 +128,7 @@ public function testAccessKeyClientWithAccessKeyIdEmpty()
*/
public function testAccessKeyClientWithAccessKeyIdFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey ID format is invalid");
AlibabaCloud::accessKeyClient(
@@ -132,6 +142,7 @@ public function testAccessKeyClientWithAccessKeyIdFormat()
*/
public function testAccessKeyClientWithAccessKeySecretEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey Secret cannot be empty");
AlibabaCloud::accessKeyClient(
@@ -145,6 +156,7 @@ public function testAccessKeyClientWithAccessKeySecretEmpty()
*/
public function testAccessKeyClientWithAccessKeySecretFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey Secret format is invalid");
AlibabaCloud::accessKeyClient(
@@ -158,6 +170,7 @@ public function testAccessKeyClientWithAccessKeySecretFormat()
*/
public function testRamRoleArnClient()
{
+
AlibabaCloud::ramRoleArnClient(
self::$accessKeyId,
self::$accessKeySecret,
@@ -178,6 +191,7 @@ public function testRamRoleArnClient()
*/
public function testRamRoleArnClientWithAccessKeyIdEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey ID cannot be empty");
AlibabaCloud::ramRoleArnClient(
@@ -193,6 +207,7 @@ public function testRamRoleArnClientWithAccessKeyIdEmpty()
*/
public function testRamRoleArnClientWithAccessKeyIdFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey ID must be a string");
AlibabaCloud::ramRoleArnClient(
@@ -208,6 +223,7 @@ public function testRamRoleArnClientWithAccessKeyIdFormat()
*/
public function testRamRoleArnClientWithAccessKeySecretEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey Secret cannot be empty");
AlibabaCloud::ramRoleArnClient(
@@ -223,6 +239,7 @@ public function testRamRoleArnClientWithAccessKeySecretEmpty()
*/
public function testRamRoleArnClientWithAccessKeySecretFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey Secret must be a string");
AlibabaCloud::ramRoleArnClient(
@@ -238,6 +255,7 @@ public function testRamRoleArnClientWithAccessKeySecretFormat()
*/
public function testEcsRamRoleClient()
{
+
AlibabaCloud::ecsRamRoleClient(self::$roleName)->asDefaultClient();
$credential = AlibabaCloud::getDefaultClient()->getCredential();
self::assertInstanceOf(EcsRamRoleCredential::class, $credential);
@@ -249,6 +267,7 @@ public function testEcsRamRoleClient()
*/
public function testEcsRamRoleClientEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Role Name cannot be empty");
AlibabaCloud::ecsRamRoleClient('')->asDefaultClient();
@@ -259,6 +278,7 @@ public function testEcsRamRoleClientEmpty()
*/
public function testEcsRamRoleClientFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Role Name must be a string");
AlibabaCloud::ecsRamRoleClient(null)->asDefaultClient();
@@ -269,6 +289,7 @@ public function testEcsRamRoleClientFormat()
*/
public function testBearerTokenClient()
{
+
AlibabaCloud::bearerTokenClient(self::$bearerToken)->asDefaultClient();
$credential = AlibabaCloud::getDefaultClient()->getCredential();
@@ -283,6 +304,7 @@ public function testBearerTokenClient()
*/
public function testBearerTokenClientEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Bearer Token cannot be empty");
AlibabaCloud::bearerTokenClient('')->asDefaultClient();
@@ -293,6 +315,7 @@ public function testBearerTokenClientEmpty()
*/
public function testBearerTokenClientFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Bearer Token must be a string");
AlibabaCloud::bearerTokenClient(null)->asDefaultClient();
@@ -303,6 +326,7 @@ public function testBearerTokenClientFormat()
*/
public function testStsClient()
{
+
AlibabaCloud::stsClient('key', 'secret', 'token')->name('sts');
self::assertInstanceOf(StsCredential::class, AlibabaCloud::get('sts')->getCredential());
}
@@ -312,10 +336,11 @@ public function testStsClient()
*/
public function testStsClientWithPublicKeyIdEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey ID cannot be empty");
AlibabaCloud::stsClient('', 'secret')
- ->name('sts');
+ ->name('sts');
}
/**
@@ -323,10 +348,11 @@ public function testStsClientWithPublicKeyIdEmpty()
*/
public function testStsClientWithPublicKeyIdFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey ID must be a string");
AlibabaCloud::stsClient(null, 'secret')
- ->name('sts');
+ ->name('sts');
}
/**
@@ -334,10 +360,11 @@ public function testStsClientWithPublicKeyIdFormat()
*/
public function testStsClientWithPrivateKeyFileEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey Secret cannot be empty");
AlibabaCloud::stsClient('key', '')
- ->name('sts');
+ ->name('sts');
}
/**
@@ -345,10 +372,11 @@ public function testStsClientWithPrivateKeyFileEmpty()
*/
public function testStsClientWithPrivateKeyFileFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("AccessKey Secret must be a string");
AlibabaCloud::stsClient('key', null)
- ->name('sts');
+ ->name('sts');
}
/**
@@ -356,8 +384,9 @@ public function testStsClientWithPrivateKeyFileFormat()
*/
public function testRsaKeyPairClient()
{
+
AlibabaCloud::rsaKeyPairClient('key', VirtualAccessKeyCredential::ok())
- ->name('rsa');
+ ->name('rsa');
self::assertInstanceOf(
RsaKeyPairCredential::class,
@@ -370,10 +399,11 @@ public function testRsaKeyPairClient()
*/
public function testRsaKeyPairClientWithPublicKeyIdEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Public Key ID cannot be empty");
AlibabaCloud::rsaKeyPairClient('', 'privateKeyFile')
- ->name('rsa');
+ ->name('rsa');
}
/**
@@ -381,10 +411,11 @@ public function testRsaKeyPairClientWithPublicKeyIdEmpty()
*/
public function testRsaKeyPairClientWithPublicKeyIdFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Public Key ID must be a string");
AlibabaCloud::rsaKeyPairClient(null, 'privateKeyFile')
- ->name('rsa');
+ ->name('rsa');
}
/**
@@ -392,10 +423,11 @@ public function testRsaKeyPairClientWithPublicKeyIdFormat()
*/
public function testRsaKeyPairClientWithPrivateKeyFileEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Private Key File cannot be empty");
AlibabaCloud::rsaKeyPairClient('publicKeyId', '')
- ->name('rsa');
+ ->name('rsa');
}
/**
@@ -403,10 +435,11 @@ public function testRsaKeyPairClientWithPrivateKeyFileEmpty()
*/
public function testRsaKeyPairClientWithPrivateKeyFileFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Private Key File must be a string");
AlibabaCloud::rsaKeyPairClient('publicKeyId', null)
- ->name('rsa');
+ ->name('rsa');
}
/**
@@ -414,8 +447,9 @@ public function testRsaKeyPairClientWithPrivateKeyFileFormat()
*/
public function testGet()
{
+
// setup
- $accessKeyId = uniqid('', true);
+ $accessKeyId = uniqid('', true);
$accessKeySecret = uniqid('', true);
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
static::assertEquals(
@@ -435,7 +469,8 @@ public function testGet()
*/
public function testIsDebug()
{
- $accessKeyId = uniqid('', true);
+
+ $accessKeyId = uniqid('', true);
$accessKeySecret = uniqid('', true);
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
AlibabaCloud::get('client1')->debug(true);
@@ -447,7 +482,8 @@ public function testIsDebug()
*/
public function testGetSignature()
{
- $accessKeyId = uniqid('', true);
+
+ $accessKeyId = uniqid('', true);
$accessKeySecret = uniqid('', true);
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
static::assertInstanceOf(ShaHmac1Signature::class, AlibabaCloud::get('client1')->getSignature());
@@ -458,9 +494,10 @@ public function testGetSignature()
*/
public function testDel()
{
+
// Setup
- $clientName = 'test';
- $accessKeyId = uniqid('', true);
+ $clientName = 'test';
+ $accessKeyId = uniqid('', true);
$accessKeySecret = uniqid('', true);
// Test
@@ -475,7 +512,8 @@ public function testDel()
*/
public function testAll()
{
- $accessKeyId = uniqid('', true);
+
+ $accessKeyId = uniqid('', true);
$accessKeySecret = uniqid('', true);
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client1');
AlibabaCloud::accessKeyClient($accessKeyId, $accessKeySecret)->name('client2');
@@ -488,6 +526,7 @@ public function testAll()
*/
public function testLoadWithFiles()
{
+
AlibabaCloud::load(
VirtualRsaKeyPairCredential::ok(),
VirtualAccessKeyCredential::ok()
@@ -500,6 +539,7 @@ public function testLoadWithFiles()
*/
public function testLoad()
{
+
AlibabaCloud::load();
static::assertNotNull(AlibabaCloud::all());
}
@@ -510,6 +550,7 @@ public function testLoad()
*/
public function testDelEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name cannot be empty");
AlibabaCloud::del('');
@@ -521,6 +562,7 @@ public function testDelEmpty()
*/
public function testDelFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name must be a string");
AlibabaCloud::del(null);
@@ -532,6 +574,7 @@ public function testDelFormat()
*/
public function testHasEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name cannot be empty");
AlibabaCloud::has('');
@@ -543,6 +586,7 @@ public function testHasEmpty()
*/
public function testHasFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name must be a string");
AlibabaCloud::has(null);
@@ -554,6 +598,7 @@ public function testHasFormat()
*/
public function testSetEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name cannot be empty");
AlibabaCloud::set('', AlibabaCloud::bearerTokenClient('token'));
@@ -565,6 +610,7 @@ public function testSetEmpty()
*/
public function testSetFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name must be a string");
AlibabaCloud::set(null, AlibabaCloud::bearerTokenClient('token'));
@@ -575,6 +621,7 @@ public function testSetFormat()
*/
public function testSet()
{
+
$name = uniqid('', true);
AlibabaCloud::set($name, AlibabaCloud::bearerTokenClient('token'));
self::assertTrue(AlibabaCloud::has($name));
@@ -587,6 +634,7 @@ public function testSet()
*/
public function testGetEmpty()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name cannot be empty");
AlibabaCloud::get('');
@@ -598,6 +646,7 @@ public function testGetEmpty()
*/
public function testGetFormat()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client Name must be a string");
AlibabaCloud::get(null);
@@ -609,6 +658,7 @@ public function testGetFormat()
*/
public function testGetNotFound()
{
+
$this->expectException(ClientException::class);
$this->expectExceptionMessage("Client 'notFound' not found");
AlibabaCloud::get('notFound');
diff --git a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/EndpointTraitTest.php b/tests/Unit/Traits/EndpointTraitTest.php
similarity index 93%
rename from tests/HigherthanorEqualtoVersion7_2/Unit/Traits/EndpointTraitTest.php
rename to tests/Unit/Traits/EndpointTraitTest.php
index 904144c3..f6a8829b 100644
--- a/tests/HigherthanorEqualtoVersion7_2/Unit/Traits/EndpointTraitTest.php
+++ b/tests/Unit/Traits/EndpointTraitTest.php
@@ -1,6 +1,6 @@
expectException(ServerException::class);
- $this->expectExceptionMessageMatches("/Please check the parameters RequestId:/");
+ $reg = '/Please check the parameters RequestId:/';
+ if (method_exists($this, 'expectExceptionMessageMatches')) {
+ $this->expectExceptionMessageMatches($reg);
+ } elseif (method_exists($this, 'expectExceptionMessageRegExp')) {
+ $this->expectExceptionMessageRegExp($reg);
+ }
// Setup
$accessKeyId = \getenv('ACCESS_KEY_ID');
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
diff --git a/tests/LowerthanVersion7_2/Unit/Traits/HasDataTraitClass.php b/tests/Unit/Traits/HasDataTraitClass.php
similarity index 72%
rename from tests/LowerthanVersion7_2/Unit/Traits/HasDataTraitClass.php
rename to tests/Unit/Traits/HasDataTraitClass.php
index 671453fa..c6a9c1ee 100644
--- a/tests/LowerthanVersion7_2/Unit/Traits/HasDataTraitClass.php
+++ b/tests/Unit/Traits/HasDataTraitClass.php
@@ -1,13 +1,13 @@