public void testListKeys() throws InterruptedException { server.enqueue(jsonResponse("/keys-first.json")); server.enqueue(jsonResponse("/keys-last.json")); Iterable<Key> keys = api.keyApi().list().concat(); assertEquals(size(keys), 7); // Force the PagedIterable to advance assertEquals(server.getRequestCount(), 2); assertSent(server, "GET", "/account/keys"); assertSent(server, "GET", "/account/keys?page=2&per_page=5"); }
public void testListKeysWithOptions() throws InterruptedException { server.enqueue(jsonResponse("/keys-first.json")); Iterable<Key> keys = api.keyApi().list(page(1).perPage(5)); assertEquals(size(keys), 5); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys?page=1&per_page=5"); }
public void testUpdateKey() throws InterruptedException { server.enqueue(jsonResponse("/key.json")); Key key = api.keyApi().update(1, "foo"); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "PUT", "/account/keys/1", "{\"name\":\"foo\"}"); }
public void testGetKeyUsingFingerprint() throws InterruptedException { server.enqueue(jsonResponse("/key.json")); Key key = api.keyApi().get("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); }
public void testGetKey() throws InterruptedException { server.enqueue(jsonResponse("/key.json")); Key key = api.keyApi().get(1); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "GET", "/account/keys/1"); }
public void testUpdateKeyUsingFingerprint() throws InterruptedException { server.enqueue(jsonResponse("/key.json")); Key key = api.keyApi().update("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90", "foo"); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "PUT", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90", "{\"name\":\"foo\"}"); }
public void testCreateKey() throws InterruptedException { server.enqueue(jsonResponse("/key.json").setStatus("HTTP/1.1 201 Created")); String dsa = stringFromResource("/ssh-dsa.pub"); Key key = api.keyApi().create("foo", dsa); assertEquals(key, keyFromResource("/key.json")); assertEquals(server.getRequestCount(), 1); assertSent(server, "POST", "/account/keys", String.format("{\"name\":\"foo\", \"public_key\":\"%s\"}", dsa)); }