-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTokenTest.java
More file actions
74 lines (60 loc) · 1.67 KB
/
TokenTest.java
File metadata and controls
74 lines (60 loc) · 1.67 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
package io.bytom.integration;
import static org.junit.Assert.assertEquals;
import org.junit.Assert;
import org.junit.Test;
import io.bytom.api.Token;
import io.bytom.exception.BytomException;
import io.bytom.http.Client;
public class TokenTest {
private static Client client;
@Test
public void run() {
try {
String id = "token1";
String secret = "8fa01fed23de821a5bfc377dc5eb2371ef0c070931478021201d9e0023f0184a";
// Token t = testCreateToken(id);
// String token = t.getToken();
// secret = token.split(":")[1];
testCheckToken(id, secret);
// testListToken();
testDeleteToken(id);
} catch (Exception e) {
e.printStackTrace();
}
}
public void testListToken() throws Exception {
client = TestUtils.generateClient();
Token.Items items = Token.list(client);
assertEquals(1, items.data.size());
System.out.println(items.data.get(0));
}
public Token testCreateToken(String id) throws Exception {
client = TestUtils.generateClient();
try {
Token t = new Token.Builder().setId(id).create(client);
Assert.assertEquals(id, t.id);
return t;
} catch (BytomException e) {
e.printStackTrace();
}
return null;
}
public void testCheckToken(String id, String secret) throws BytomException {
client = TestUtils.generateClient();
try {
boolean flag = Token.check(client, id, secret);
Assert.assertEquals(true, flag);
} catch (BytomException e) {
e.printStackTrace();
}
}
public void testDeleteToken(String id) throws Exception {
client = TestUtils.generateClient();
try {
boolean flag = Token.delete(client, id);
Assert.assertEquals(true, flag);
} catch (BytomException e) {
e.printStackTrace();
}
}
}