use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.
the class JnlpAccessWithSecuredHudsonTest method anonymousCanAlwaysLoadJARs.
@PresetData(DataSet.NO_ANONYMOUS_READACCESS)
@Email("http://markmail.org/message/on4wkjdaldwi2atx")
@Test
public void anonymousCanAlwaysLoadJARs() throws Exception {
ApiTokenTestHelper.enableLegacyBehavior();
r.jenkins.setNodes(Collections.singletonList(createNewJnlpSlave("test")));
JenkinsRule.WebClient wc = r.createWebClient();
HtmlPage p = wc.withBasicApiToken(User.getById("alice", true)).goTo("computer/test/");
// this fresh WebClient doesn't have a login cookie and represent JNLP launcher
JenkinsRule.WebClient jnlpAgent = r.createWebClient();
// parse the JNLP page into DOM to list up the jars.
XmlPage jnlp = (XmlPage) wc.goTo("computer/test/jenkins-agent.jnlp", "application/x-java-jnlp-file");
URL baseUrl = jnlp.getUrl();
Document dom = new DOMReader().read(jnlp.getXmlDocument());
for (Object jar : dom.selectNodes("//jar")) {
URL url = new URL(baseUrl, ((Element) jar).attributeValue("href"));
System.out.println(url);
// now make sure that these URLs are unprotected
Page jarResource = jnlpAgent.getPage(url);
assertTrue(jarResource.getWebResponse().getContentType().toLowerCase(Locale.ENGLISH).startsWith("application/"));
}
}
use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.
the class DirectoryBrowserSupportTest method doubleDots2.
/**
* <del>Also makes sure '\\' in the file name for Unix is handled correctly</del>.
*
* To prevent directory traversal attack, we now treat '\\' just like '/'.
*/
@Email("http://www.nabble.com/Status-Code-400-viewing-or-downloading-artifact-whose-filename-contains-two-consecutive-periods-tt21407604.html")
@Test
public void doubleDots2() throws Exception {
Assume.assumeFalse("can't test this on Windows", Functions.isWindows());
// create a problematic file name in the workspace
FreeStyleProject p = j.createFreeStyleProject();
p.getBuildersList().add(new Shell("mkdir abc; touch abc/def.bin"));
j.buildAndAssertSuccess(p);
// can we see it?
j.createWebClient().goTo("job/" + p.getName() + "/ws/abc%5Cdef.bin", "application/octet-stream");
}
use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.
the class ArgumentListBuilder2Test method slaveMask.
/**
* Makes sure {@link RemoteLauncher} properly masks arguments.
*/
@Test
@Email("http://n4.nabble.com/Password-masking-when-running-commands-on-a-slave-tp1753033p1753033.html")
public void slaveMask() throws Exception {
ArgumentListBuilder args = new ArgumentListBuilder();
args.add("java");
args.addMasked("-version");
Slave s = j.createOnlineSlave();
j.showAgentLogs(s, logging);
StringWriter out = new StringWriter();
assertEquals(0, s.createLauncher(new StreamTaskListener(out)).launch().cmds(args).join());
assertThat(out.toString(), containsString("$ java ********"));
}
use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.
the class ViewTest method conflictingName.
/**
* Creating two views with the same name.
*/
@Email("http://d.hatena.ne.jp/ssogabe/20090101/1230744150")
@Test
public void conflictingName() throws Exception {
assertNull(j.jenkins.getView("foo"));
WebClient wc = j.createWebClient();
HtmlForm form = wc.goTo("newView").getFormByName("createItem");
form.getInputByName("name").setValueAttribute("foo");
form.getRadioButtonsByName("mode").get(0).setChecked(true);
j.submit(form);
assertNotNull(j.jenkins.getView("foo"));
wc.setThrowExceptionOnFailingStatusCode(false);
// do it again and verify an error
Page page = j.submit(form);
assertEquals("shouldn't be allowed to create two views of the same name.", HttpURLConnection.HTTP_BAD_REQUEST, page.getWebResponse().getStatusCode());
}
use of org.jvnet.hudson.test.Email in project junit-plugin by jenkinsci.
the class CaseResultTest method testRemoteApiDefaultVisibility.
@Email("http://jenkins.361315.n4.nabble.com/Change-remote-API-visibility-for-CaseResult-getStdout-getStderr-td395102.html")
@Test
public void testRemoteApiDefaultVisibility() throws Exception {
FreeStyleBuild b = configureTestBuild("test-remoteapi");
XmlPage page = (XmlPage) rule.createWebClient().goTo("job/test-remoteapi/1/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/api/xml", "application/xml");
int found = 0;
found = page.getByXPath(composeXPath(MAX_VISIBILITY_FIELDS)).size();
assertTrue("Should have found an element, but found " + found, found > 0);
found = page.getByXPath(composeXPath(REDUCED_VISIBILITY_FIELDS)).size();
assertTrue("Should have found an element, but found " + found, found > 0);
found = page.getByXPath(composeXPath(OTHER_FIELDS)).size();
assertTrue("Should have found an element, but found " + found, found > 0);
}
Aggregations