|
@@ -108,18 +108,19 @@ func testSetup() {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
panic(err)
|
|
panic(err)
|
|
|
}
|
|
}
|
|
|
- //err = clientKeyPair.InitWithKeyPair("cn-hangzhou", testConfig.PublicKeyId, testConfig.PrivateKey, 3600)
|
|
|
|
|
- //if err != nil {
|
|
|
|
|
- // panic(err)
|
|
|
|
|
- //}
|
|
|
|
|
- //err = clientEcs.InitWithEcsInstance("cn-hangzhou", "conan")
|
|
|
|
|
- //if err != nil {
|
|
|
|
|
- // panic(err)
|
|
|
|
|
- //}
|
|
|
|
|
- //err = clientRoleArn.InitWithRoleArn("cn-hangzhou", testConfig.ChildAK, testConfig.ChildSecret, testConfig.RoleArn, "clientTest")
|
|
|
|
|
- //if err != nil {
|
|
|
|
|
- // panic(err)
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ clientKeyPair, err = NewClientWithKeyPair("cn-hangzhou", clientConfig, testConfig.PublicKeyId, testConfig.PrivateKey, 3600)
|
|
|
|
|
+ clientKeyPair.config = clientConfig
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ panic(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ clientEcs, err = NewClientWithEcsInstance("cn-hangzhou", clientConfig, "conan")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ panic(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ clientRoleArn, err = NewClientWithRoleArn("cn-hangzhou", clientConfig, testConfig.ChildAK, testConfig.ChildSecret, testConfig.RoleArn, "clientTest")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ panic(err)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func testTearDown() {
|
|
func testTearDown() {
|
|
@@ -418,21 +419,21 @@ func TestRpcGetForLocationCache(t *testing.T) {
|
|
|
assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//func TestRpcGetForKeyPair(t *testing.T) {
|
|
|
|
|
-// request := getFtTestRpcRequest()
|
|
|
|
|
-// request.Method = requests.GET
|
|
|
|
|
-//
|
|
|
|
|
-// response := &responses.BaseResponse{}
|
|
|
|
|
-// err := clientKeyPair.DoAction(request, response)
|
|
|
|
|
-// assert.Nil(t, err)
|
|
|
|
|
-// assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
|
|
|
|
|
-// assert.NotNil(t, response.GetHttpContentString())
|
|
|
|
|
-//
|
|
|
|
|
-// var responseBean MockResponse
|
|
|
|
|
-// json.Unmarshal([]byte(response.GetHttpContentString()), &responseBean)
|
|
|
|
|
-//
|
|
|
|
|
-// assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
|
|
-//}
|
|
|
|
|
|
|
+func TestRpcGetForKeyPair(t *testing.T) {
|
|
|
|
|
+ request := getFtTestRpcRequest()
|
|
|
|
|
+ request.Method = requests.GET
|
|
|
|
|
+
|
|
|
|
|
+ response := &responses.BaseResponse{}
|
|
|
|
|
+ err := clientKeyPair.DoAction(request, response)
|
|
|
|
|
+ assert.Nil(t, err)
|
|
|
|
|
+ assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
|
|
|
|
|
+ assert.NotNil(t, response.GetHttpContentString())
|
|
|
|
|
+
|
|
|
|
|
+ var responseBean MockResponse
|
|
|
|
|
+ json.Unmarshal([]byte(response.GetHttpContentString()), &responseBean)
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/*func TestRpcGetForEcs(t *testing.T) {
|
|
/*func TestRpcGetForEcs(t *testing.T) {
|
|
|
//测试接口,想测试的时候,要替换掉singer_ecs_instance中对应的变量,并且还要提供一个mock服务
|
|
//测试接口,想测试的时候,要替换掉singer_ecs_instance中对应的变量,并且还要提供一个mock服务
|
|
@@ -461,30 +462,30 @@ func TestRpcGetForLocationCache(t *testing.T) {
|
|
|
assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
}*/
|
|
}*/
|
|
|
|
|
|
|
|
-//func TestRpcGetForRoleArn(t *testing.T) {
|
|
|
|
|
-// request := getFtTestRpcRequest()
|
|
|
|
|
-// request.Method = requests.GET
|
|
|
|
|
-//
|
|
|
|
|
-// response := &responses.BaseResponse{}
|
|
|
|
|
-// err := clientRoleArn.DoAction(request, response)
|
|
|
|
|
-// assert.Nil(t, err)
|
|
|
|
|
-// assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
|
|
|
|
|
-// assert.NotNil(t, response.GetHttpContentString())
|
|
|
|
|
-//
|
|
|
|
|
-// var responseBean MockResponse
|
|
|
|
|
-// json.Unmarshal([]byte(response.GetHttpContentString()), &responseBean)
|
|
|
|
|
-//
|
|
|
|
|
-// assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
|
|
-//
|
|
|
|
|
-// err = clientRoleArn.DoAction(request, response)
|
|
|
|
|
-// assert.Nil(t, err)
|
|
|
|
|
-// assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
|
|
|
|
|
-// assert.NotNil(t, response.GetHttpContentString())
|
|
|
|
|
-//
|
|
|
|
|
-// json.Unmarshal([]byte(response.GetHttpContentString()), &responseBean)
|
|
|
|
|
-//
|
|
|
|
|
-// assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
|
|
-//}
|
|
|
|
|
|
|
+func TestRpcGetForRoleArn(t *testing.T) {
|
|
|
|
|
+ request := getFtTestRpcRequest()
|
|
|
|
|
+ request.Method = requests.GET
|
|
|
|
|
+
|
|
|
|
|
+ response := &responses.BaseResponse{}
|
|
|
|
|
+ err := clientRoleArn.DoAction(request, response)
|
|
|
|
|
+ assert.Nil(t, err)
|
|
|
|
|
+ assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
|
|
|
|
|
+ assert.NotNil(t, response.GetHttpContentString())
|
|
|
|
|
+
|
|
|
|
|
+ var responseBean MockResponse
|
|
|
|
|
+ json.Unmarshal([]byte(response.GetHttpContentString()), &responseBean)
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
|
|
+
|
|
|
|
|
+ err = clientRoleArn.DoAction(request, response)
|
|
|
|
|
+ assert.Nil(t, err)
|
|
|
|
|
+ assert.Equal(t, http.StatusOK, response.GetHttpStatus(), response.GetHttpContentString())
|
|
|
|
|
+ assert.NotNil(t, response.GetHttpContentString())
|
|
|
|
|
+
|
|
|
|
|
+ json.Unmarshal([]byte(response.GetHttpContentString()), &responseBean)
|
|
|
|
|
+
|
|
|
|
|
+ assert.Equal(t, "QueryParamValue", responseBean.Params["QueryParam"])
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
func TestCommonRoaRequestForAcceptXML(t *testing.T) {
|
|
func TestCommonRoaRequestForAcceptXML(t *testing.T) {
|
|
|
roaRequest := requests.NewCommonRequest()
|
|
roaRequest := requests.NewCommonRequest()
|