From b848f853c8d377210eb58d9e05ec4c45ceeca40f Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Wed, 22 Jan 2020 13:36:33 -0700 Subject: [PATCH] Use the stapler incremental now that's republished. --- core/pom.xml | 2 +- .../security/StackTraceSuppressionTest.java | 63 ++++++++++--------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 4594bbbfd5..05ed45ef8b 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -39,7 +39,7 @@ THE SOFTWARE. true - 1.258 + 1.259-rc1393.7b6d39453a92 2.5.6.SEC03 2.4.12 diff --git a/test/src/test/java/jenkins/security/StackTraceSuppressionTest.java b/test/src/test/java/jenkins/security/StackTraceSuppressionTest.java index 5c1537da0b..22ede97258 100644 --- a/test/src/test/java/jenkins/security/StackTraceSuppressionTest.java +++ b/test/src/test/java/jenkins/security/StackTraceSuppressionTest.java @@ -23,6 +23,7 @@ */ package jenkins.security; +import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.model.FreeStyleProject; import hudson.model.ItemGroup; @@ -34,6 +35,7 @@ import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.MockAuthorizationStrategy; +import org.kohsuke.stapler.HttpResponses; import java.io.IOException; @@ -49,6 +51,7 @@ public class StackTraceSuppressionTest { @Before public void setup() { Jenkins.SHOW_STACK_TRACE = false; + HttpResponses.SHOW_STACK_TRACE = false; } @Test @@ -83,36 +86,36 @@ public class StackTraceSuppressionTest { assertThat(content, not(containsString("Caused by"))); } -// @Test -// public void nonexistentAdjunct() throws Exception { -// /* This test belongs in Stapler but it's easy to put it together here. -// This test is based upon Stapler throwing an exception for this broken request. -// If Stapler is improved to better handle this error, this test may erroneously fail. */ -// JenkinsRule.WebClient wc = j.createWebClient(); -// -// wc.setThrowExceptionOnFailingStatusCode(false); -// HtmlPage page = wc.goTo("adjuncts/40331c1bldu3i%3b//'%3b//\"%3b//%25>%3f>uezm3foo/org/kohsuke/stapler/jquery/jquery.full.js"); -// -// String content = page.getWebResponse().getContentAsString(); -// assertThat(content, containsString("No such adjunct found")); -// assertThat(content, not(containsString("AdjunctManager.doDynamic"))); -// } -// -// @Test -// public void nonexistentAdjunctShowsTrace() throws Exception { -// /* This test belongs in Stapler but it's easy to put it together here. -// This test is based upon Stapler throwing an exception for this broken request. -// If Stapler is improved to better handle this error, this test may erroneously fail. */ -// JenkinsRule.WebClient wc = j.createWebClient(); -// HttpResponses.SHOW_STACK_TRACE = true; -// -// wc.setThrowExceptionOnFailingStatusCode(false); -// Page page = wc.goTo("adjuncts/40331c1bldu3i%3b//'%3b//\"%3b//%25>%3f>uezm3foo/org/kohsuke/stapler/jquery/jquery.full.js", "text/plain"); -// -// String content = page.getWebResponse().getContentAsString(); -// assertThat(content, containsString("No such adjunct found")); -// assertThat(content, containsString("AdjunctManager.doDynamic")); -// } + @Test + public void nonexistentAdjunct() throws Exception { + /* This test belongs in Stapler but it's easy to put it together here. + This test is based upon Stapler throwing an exception for this broken request. + If Stapler is improved to better handle this error, this test may erroneously fail. */ + JenkinsRule.WebClient wc = j.createWebClient(); + + wc.setThrowExceptionOnFailingStatusCode(false); + HtmlPage page = wc.goTo("adjuncts/40331c1bldu3i%3b//'%3b//\"%3b//%25>%3f>uezm3foo/org/kohsuke/stapler/jquery/jquery.full.js"); + + String content = page.getWebResponse().getContentAsString(); + assertThat(content, containsString("No such adjunct found")); + assertThat(content, not(containsString("AdjunctManager.doDynamic"))); + } + + @Test + public void nonexistentAdjunctShowsTrace() throws Exception { + /* This test belongs in Stapler but it's easy to put it together here. + This test is based upon Stapler throwing an exception for this broken request. + If Stapler is improved to better handle this error, this test may erroneously fail. */ + JenkinsRule.WebClient wc = j.createWebClient(); + HttpResponses.SHOW_STACK_TRACE = true; + + wc.setThrowExceptionOnFailingStatusCode(false); + Page page = wc.goTo("adjuncts/40331c1bldu3i%3b//'%3b//\"%3b//%25>%3f>uezm3foo/org/kohsuke/stapler/jquery/jquery.full.js", "text/plain"); + + String content = page.getWebResponse().getContentAsString(); + assertThat(content, containsString("No such adjunct found")); + assertThat(content, containsString("AdjunctManager.doDynamic")); + } @Test public void exception() throws Exception { -- GitLab