diff --git a/integration/base.go b/integration/base.go index e8be56df48..43dc269e54 100644 --- a/integration/base.go +++ b/integration/base.go @@ -30,6 +30,8 @@ var ( rolearn = fmt.Sprintf("acs:ram::%s:role/%s", os.Getenv("USER_ID"), rolename) ) +var ecsEndpoint = "ecs." + os.Getenv("REGION_ID") + ".aliyuncs.com" + func createRole(userid string) (name string, arn string, err error) { listRequest := ram.CreateListRolesRequest() listRequest.Scheme = "HTTPS" diff --git a/integration/core_test.go b/integration/core_test.go index 56718472e5..abda97fba4 100644 --- a/integration/core_test.go +++ b/integration/core_test.go @@ -26,7 +26,7 @@ func Test_DescribeRegionsWithCommonRequestWithRPC(t *testing.T) { request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "DescribeRegions" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET")) assert.Nil(t, err) @@ -43,7 +43,7 @@ func Test_DescribeRegionsWithCommonRequestWithSTStoken(t *testing.T) { request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "DescribeRegions" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() client, err := sdk.NewClientWithStsToken(os.Getenv("REGION_ID"), credential.AccessKeyId, credential.AccessKeySecret, credential.SecurityToken) assert.Nil(t, err) @@ -57,7 +57,7 @@ func Test_DescribeRegionsWithCommonRequestWithHTTPS(t *testing.T) { request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "DescribeRegions" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() request.SetScheme("HTTPS") client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET")) @@ -72,7 +72,7 @@ func Test_DescribeRegionsWithCommonRequestWithUnicodeSpecificParams(t *testing.T request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "DescribeRegions" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() request.SetContent([]byte("sdk&-杭&&&州-test")) client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET")) @@ -87,7 +87,7 @@ func Test_AddTagsWithCommonRequestWithError(t *testing.T) { request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "AddTags" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET")) assert.Nil(t, err) @@ -104,7 +104,7 @@ func SkipTest_DescribeRegionsWithCommonRequestWithIncompleteSignature(t *testing request.SetScheme("https") request.Method = "POST" request.ApiName = "DescribeRegions" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), strings.ToUpper(os.Getenv("ACCESS_KEY_SECRET"))) assert.Nil(t, err) @@ -226,7 +226,7 @@ func Test_CreateInstanceWithCommonRequestWithPolicy(t *testing.T) { request := requests.NewCommonRequest() request.Method = "POST" request.Product = "Ecs" - request.Domain = "ecs.aliyuncs.com" + request.Domain = "ecs." + os.Getenv("REGION_ID") + ".aliyuncs.com" request.Version = "2014-05-26" request.SetScheme("HTTPS") request.ApiName = "CreateInstance" diff --git a/integration/credential_test.go b/integration/credential_test.go index 6049ea8c9f..5293d75bbb 100644 --- a/integration/credential_test.go +++ b/integration/credential_test.go @@ -54,7 +54,7 @@ func Test_DescribeRegionsWithRPCrequestWithArn(t *testing.T) { request := ecs.CreateDescribeRegionsRequest() request.Scheme = "https" - request.Domain = "ecs.aliyuncs.com" + request.Domain = ecsEndpoint response, err := client.DescribeRegions(request) assert.Nil(t, err) assert.Equal(t, 36, len(response.RequestId)) @@ -67,7 +67,7 @@ func TestDescribeRegionsWithProviderAndAk(t *testing.T) { request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "DescribeRegions" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() client, err := sdk.NewClientWithProvider(os.Getenv("REGION_ID")) assert.Nil(t, err) diff --git a/integration/error_test.go b/integration/error_test.go index f69edf0999..27d72d50aa 100644 --- a/integration/error_test.go +++ b/integration/error_test.go @@ -18,7 +18,7 @@ func Test_AddTagsWithParameterError(t *testing.T) { request.Version = "2014-05-26" request.Product = "Ecs" request.ApiName = "AddTags" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) request.TransToAcsRequest() client, err := sdk.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET")) assert.Nil(t, err) @@ -49,12 +49,12 @@ func Test_DescribeRegionsWithTimeout(t *testing.T) { } request := ecs.CreateDescribeRegionsRequest() request.Scheme = "https" - request.SetDomain("ecs.aliyuncs.com") + request.SetDomain(ecsEndpoint) client, err := ecs.NewClientWithOptions(os.Getenv("REGION_ID"), config, credentail) assert.Nil(t, err) response, err := client.DescribeRegions(request) assert.Equal(t, 0, response.GetHttpStatus()) - assert.Contains(t, err.Error(), "https://ecs.aliyuncs.com") + assert.Contains(t, err.Error(), "https://"+ecsEndpoint) assert.Contains(t, err.Error(), "Client.Timeout exceeded while awaiting headers") }