-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathSignMethodTest.java
More file actions
113 lines (100 loc) · 4.18 KB
/
SignMethodTest.java
File metadata and controls
113 lines (100 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package com.tencentcloudapi.integration.requests;
import com.tencentcloudapi.common.CommonClient;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.cvm.v20170312.CvmClient;
import com.tencentcloudapi.cvm.v20170312.models.DescribeInstancesRequest;
import org.junit.Test;
public class SignMethodTest {
@Test
public void TestCvmClient() throws TencentCloudSDKException {
Credential cred = new Credential(
System.getenv("TENCENTCLOUD_SECRET_ID"),
System.getenv("TENCENTCLOUD_SECRET_KEY")
);
String[] signMethods = new String[]{
ClientProfile.SIGN_SHA1,
ClientProfile.SIGN_SHA256,
ClientProfile.SIGN_TC3_256
};
String[] reqMethods = new String[]{
HttpProfile.REQ_POST,
HttpProfile.REQ_GET,
};
for (String signMethod : signMethods) {
for (String reqMethod : reqMethods) {
ClientProfile cpf = new ClientProfile();
cpf.setSignMethod(signMethod);
HttpProfile hpf = new HttpProfile();
hpf.setReqMethod(reqMethod);
cpf.setHttpProfile(hpf);
CvmClient client = new CvmClient(cred, "ap-guangzhou", cpf);
DescribeInstancesRequest req = new DescribeInstancesRequest();
client.DescribeInstances(req);
}
}
}
@Test
public void TestCommonClient() throws TencentCloudSDKException {
Credential cred = new Credential(
System.getenv("TENCENTCLOUD_SECRET_ID"),
System.getenv("TENCENTCLOUD_SECRET_KEY")
);
String[] signMethods = new String[]{
ClientProfile.SIGN_SHA1,
ClientProfile.SIGN_SHA256,
ClientProfile.SIGN_TC3_256
};
String[] reqMethods = new String[]{
HttpProfile.REQ_POST,
HttpProfile.REQ_GET,
};
for (String signMethod : signMethods) {
for (String reqMethod : reqMethods) {
ClientProfile cpf = new ClientProfile();
cpf.setSignMethod(signMethod);
HttpProfile hpf = new HttpProfile();
hpf.setReqMethod(reqMethod);
cpf.setHttpProfile(hpf);
CommonClient client = new CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou", cpf);
DescribeInstancesRequest req = new DescribeInstancesRequest();
client.commonRequest(req, "DescribeInstances");
}
}
}
@Test
public void TestCommonClientCall() throws TencentCloudSDKException {
Credential cred = new Credential(
System.getenv("TENCENTCLOUD_SECRET_ID"),
System.getenv("TENCENTCLOUD_SECRET_KEY")
);
String[] signMethods = new String[]{
ClientProfile.SIGN_SHA1,
ClientProfile.SIGN_SHA256,
ClientProfile.SIGN_TC3_256
};
String[] reqMethods = new String[]{
HttpProfile.REQ_POST,
HttpProfile.REQ_GET,
};
for (String signMethod : signMethods) {
for (String reqMethod : reqMethods) {
ClientProfile cpf = new ClientProfile();
cpf.setSignMethod(signMethod);
HttpProfile hpf = new HttpProfile();
hpf.setReqMethod(reqMethod);
cpf.setHttpProfile(hpf);
CommonClient client = new CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou", cpf);
client.call("DescribeInstances",
"{\"Filters\":"
+ "[{\"Name\":\"zone\","
+ "\"Values\":[\"ap-guangzhou-1\"]},"
+ "{\"Name\":\"instance-charge-type\","
+ "\"Values\":[\"PREPAID\",\"POSTPAID_BY_HOUR\"]}]"
+ "}");
}
}
}
}