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(); } }