@Test public void testClient() throws Exception { String json = ChefUtil.createClient(name1); assertThat("Create returns private key.", json, containsString("BEGIN")); assertThat("Create returns private key.", json, containsString("END")); json = ChefUtil.getClient(name1); assertThat("Client is created.", json, containsString("\"name\":\"" + name1)); json = ChefUtil.putClientAsAdmin(name1); assertThat("Client can be made admin.", json, containsString("\"admin\":true")); json = ChefUtil.getClient(name1); assertThat("Client is admin.", json, containsString("\"admin\":true")); }
@Test(expected = ChefUtil.InvalidChefRequest.class) public void testClientBadArgs() throws Exception { String oldClientId = chefUtil.getChefClientId(); try { chefUtil.setChefClientId("some-bad-garbage-id"); String json = ChefUtil.createClient(name2); logger.debug("Got response:" + json); json = ChefUtil.getClient(name2); logger.debug("Got response:" + json); } finally { chefUtil.setChefClientId(oldClientId); } }