"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/src/test/java/hudson/cli/UpdateNodeCommandTest.java" between
jenkins-jenkins-2.280.tar.gz and jenkins-jenkins-2.281.tar.gz

About: Jenkins is a automation server (written in Java) which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software (for e.g. as Continuous Integration and Continuous Delivery server). Weekly release.

UpdateNodeCommandTest.java  (jenkins-jenkins-2.280):UpdateNodeCommandTest.java  (jenkins-jenkins-2.281)
skipping to change at line 34 skipping to change at line 34
package hudson.cli; package hudson.cli;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
import static hudson.cli.CLICommandInvoker.Matcher.failedWith; import static hudson.cli.CLICommandInvoker.Matcher.failedWith;
import static hudson.cli.CLICommandInvoker.Matcher.hasNoStandardOutput; import static hudson.cli.CLICommandInvoker.Matcher.hasNoStandardOutput;
import static hudson.cli.CLICommandInvoker.Matcher.succeededSilently; import static hudson.cli.CLICommandInvoker.Matcher.succeededSilently;
import static org.junit.Assert.assertEquals;
import hudson.model.Computer; import hudson.model.Computer;
import hudson.model.Messages;
import hudson.model.Node; import hudson.model.Node;
import hudson.model.Slave;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.JenkinsRule;
public class UpdateNodeCommandTest { public class UpdateNodeCommandTest {
skipping to change at line 114 skipping to change at line 118
CLICommandInvoker.Result result = command.authorizedTo(Computer.CONFIGUR E, Jenkins.READ).withStdin(Computer.class.getResourceAsStream("node.xml")).invok eWithArgs(""); CLICommandInvoker.Result result = command.authorizedTo(Computer.CONFIGUR E, Jenkins.READ).withStdin(Computer.class.getResourceAsStream("node.xml")).invok eWithArgs("");
assertThat(result.stderr(), containsString("No such node ''")); assertThat(result.stderr(), containsString("No such node ''"));
assertThat(result, failedWith(3)); assertThat(result, failedWith(3));
assertThat(result, hasNoStandardOutput()); assertThat(result, hasNoStandardOutput());
result = command.authorizedTo(Computer.EXTENDED_READ, Jenkins.READ).with Stdin(Computer.class.getResourceAsStream("node.xml")).invokeWithArgs("(master)") ; result = command.authorizedTo(Computer.EXTENDED_READ, Jenkins.READ).with Stdin(Computer.class.getResourceAsStream("node.xml")).invokeWithArgs("(master)") ;
assertThat(result.stderr(), containsString("No such node '(master)'")); assertThat(result.stderr(), containsString("No such node '(master)'"));
assertThat(result, failedWith(3)); assertThat(result, failedWith(3));
assertThat(result, hasNoStandardOutput()); assertThat(result, hasNoStandardOutput());
} }
@Test
@Issue("SECURITY-2021")
public void updateNodeShouldFailForDotDot() throws Exception {
String okName = "MyNode";
Slave node = j.createSlave(okName, null, null);
// currently <dummy>, but doing so will be a bit more future-proof
String defaultDescription = node.getNodeDescription();
final CLICommandInvoker.Result result = command
.authorizedTo(Computer.CONFIGURE, Jenkins.READ)
.withStdin(UpdateNodeCommandTest.class.getResourceAsStream("node
_sec2021.xml"))
.invokeWithArgs(okName)
;
assertThat(result.stderr(), containsString(Messages.Hudson_UnsafeChar('/
')));
assertThat(result, hasNoStandardOutput());
assertThat(result, failedWith(1));
assertEquals(okName, node.getNodeName());
// ensure the other data were not saved
assertEquals(defaultDescription, node.getNodeDescription());
}
} }
 End of changes. 4 change blocks. 
0 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)