@Test public void getNodeShouldFailIfNodeDoesNotExist() throws Exception { final CLICommandInvoker.Result result = command.authorizedTo(Computer.EXTENDED_READ, Jenkins.READ).invokeWithArgs("MySlave"); assertThat(result.stderr(), containsString("No such node 'MySlave'")); assertThat(result, failedWith(-1)); assertThat(result, hasNoStandardOutput()); }
@Test public void getNodeShouldYieldConfigXml() throws Exception { j.createSlave("MySlave", null, null); final CLICommandInvoker.Result result = command.authorizedTo(Computer.EXTENDED_READ, Jenkins.READ).invokeWithArgs("MySlave"); assertThat(result.stdout(), startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")); assertThat(result.stdout(), containsString("<name>MySlave</name>")); assertThat(result, hasNoErrorOutput()); assertThat(result, succeeded()); }
@Test public void getNodeShouldFailWithoutComputerReadPermission() throws Exception { j.createSlave("MySlave", null, null); final CLICommandInvoker.Result result = command.authorizedTo(Jenkins.READ).invokeWithArgs("MySlave"); assertThat( result.stderr(), containsString("user is missing the Slave/ExtendedRead permission")); assertThat(result, failedWith(-1)); assertThat(result, hasNoStandardOutput()); }