1 package io.bytom.integration;
3 import io.bytom.TestUtils;
4 import io.bytom.api.Key;
5 import io.bytom.exception.BytomException;
6 import io.bytom.http.Client;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotEquals;
13 import static org.junit.Assert.assertNotNull;
15 public class KeyTest {
21 public void testClientKeyCreate() throws Exception {
22 client = TestUtils.generateClient();
24 String alias = "KeyTest.testKeyCreate.successli004";
25 String password = "123456";
27 Key.Builder builder = new Key.Builder().setAlias(alias).setPassword(password);
28 key = Key.create(client, builder);
30 assertNotNull(key.xpub);
31 assertEquals(alias.toLowerCase(), key.alias);
35 public void testClientKeyList() throws Exception {
36 //client = TestUtils.generateClient();
37 client = new Client("http://127.0.0.1:9888/");
38 List<Key> keyList = Key.list(client);
42 public void testClientKeyDelete() throws Exception {
43 client = TestUtils.generateClient();
44 List<Key> keyList = Key.list(client);
45 String xpub = keyList.get(keyList.size()-1).xpub;
46 //delete the last Key Object
47 Key.delete(client, xpub, "123456");
51 public void testClientKeyResetPassword() throws BytomException {
52 client = TestUtils.generateClient();
53 List<Key> keyList = Key.list(client);
54 String xpub = keyList.get(keyList.size()-1).xpub;
55 Key.resetPassword(client, xpub, "123456", "123456789");
56 Key.delete(client, xpub, "123456789");