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 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 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 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)); }