瀏覽代碼

由温仰发起的CORE SDK自动发布, BUILD_ID=120, 版本号:0.5.5

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
haowei.yao 8 年之前
父節點
當前提交
e8d38b36c7
共有 3 個文件被更改,包括 35 次插入8 次删除
  1. 3 0
      ChangeLog.txt
  2. 31 7
      sdk/client_test.go
  3. 1 1
      sdk/requests/common_request.go

+ 3 - 0
ChangeLog.txt

@@ -1,3 +1,6 @@
+2017-12-15 Version: 0.5.5
+1, fix test cases
+
 2017-12-15 Version: 0.5.4
 1, Add scdn API.
 2, Update SetReqAuthConfig.

+ 31 - 7
sdk/client_test.go

@@ -56,7 +56,7 @@ func TestMain(m *testing.M) {
 	os.Exit(result)
 }
 
-func testSetup() {
+func getConfigFromFile() *TestConfig {
 	usr, err := user.Current()
 	if err != nil {
 		panic(err)
@@ -68,6 +68,31 @@ func testSetup() {
 	}
 	var config TestConfig
 	json.Unmarshal(data, &config)
+	return &config
+}
+
+func getConfigFromEnv() *TestConfig {
+	config := &TestConfig{
+		AccessKeyId:     os.Getenv("ACCESS_KEY_ID"),
+		AccessKeySecret: os.Getenv("ACCESS_KEY_SECRET"),
+		PublicKeyId:     os.Getenv("PUBLIC_KEY_ID"),
+		PrivateKey:      os.Getenv("PRIVATE_KEY"),
+		RoleArn:         os.Getenv("ROLE_ARN"),
+		ChildAK:         os.Getenv("CHILD_AK"),
+		ChildSecret:     os.Getenv("CHILD_SECRET"),
+	}
+	if config.AccessKeyId == "" {
+		return nil
+	} else {
+		return config
+	}
+}
+
+func testSetup() {
+	config := getConfigFromEnv()
+	if config == nil {
+		config = getConfigFromFile()
+	}
 	tr := &http.Transport{
 		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
 	}
@@ -87,14 +112,14 @@ func testSetup() {
 			HttpTransport: tr,
 		},
 	}
-	err = client.InitWithAccessKey("cn-hangzhou", config.AccessKeyId, config.AccessKeySecret)
-	if err != nil {
-		panic(err)
-	}
-	err = clientKeyPair.InitWithKeyPair("cn-hangzhou", config.PublicKeyId, config.PrivateKey, 3600)
+	err := client.InitWithAccessKey("cn-hangzhou", config.AccessKeyId, config.AccessKeySecret)
 	if err != nil {
 		panic(err)
 	}
+	//err = clientKeyPair.InitWithKeyPair("cn-hangzhou", config.PublicKeyId, config.PrivateKey, 3600)
+	//if err != nil {
+	//	panic(err)
+	//}
 	err = clientEcs.InitWithEcsInstance("cn-hangzhou", "conan")
 	if err != nil {
 		panic(err)
@@ -321,7 +346,6 @@ func TestCommonRoaRequest(t *testing.T) {
 	roaRequest := requests.NewCommonRequest()
 	roaRequest.Product = "Ft"
 	roaRequest.Version = "2016-01-02"
-	roaRequest.ApiName = "TestRoaApi"
 	roaRequest.PathPattern = "/web/cloudapi"
 	roaRequest.Domain = "ft.aliyuncs.com"
 	roaRequest.Method = "POST"

+ 1 - 1
sdk/requests/common_request.go

@@ -37,7 +37,7 @@ func (request *CommonRequest) TransToAcsRequest() {
 		errors.NewClientError(errors.MissingParamCode, "At least one of [ApiName] and [PathPattern] should has a value", nil)
 	}
 	if len(request.Domain) == 0 && len(request.Product) == 0 {
-		errors.NewClientError(errors.MissingParamCode, "At least one of [Host] and [Product] should has a value", nil)
+		errors.NewClientError(errors.MissingParamCode, "At least one of [Domain] and [Product] should has a value", nil)
 	}
 
 	if len(request.PathPattern) > 0 {