Skip to content

Commit

Permalink
[FIXED JENKINS-20866]
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Dec 4, 2013
1 parent 5b40b8d commit b89baa5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -61,6 +61,9 @@
<li class=bug>
Hudson shows 0GB free space when space available drops below 1GB.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-7776">issue 7776</a>)
<li class=bug>
Error page should be visible even if the anonymous user does not have overall/read access.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20866">issue 20866</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -3668,6 +3668,7 @@ public Object getTarget() {
|| rest.startsWith("/logout")
|| rest.startsWith("/accessDenied")
|| rest.startsWith("/adjuncts/")
|| rest.startsWith("/error")
|| rest.startsWith("/oops")
|| rest.startsWith("/signup")
|| rest.startsWith("/tcpSlaveAgentListener")
Expand Down
32 changes: 31 additions & 1 deletion test/src/test/java/jenkins/model/JenkinsTest.java
Expand Up @@ -27,11 +27,15 @@
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.maven.MavenModuleSet;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.Failure;
import hudson.model.RootAction;
import hudson.model.UnprotectedRootAction;
import hudson.model.User;
import hudson.security.FullControlOnceLoggedInAuthorizationStrategy;
import hudson.security.HudsonPrivateSecurityRealm;
import hudson.util.HttpResponses;
import hudson.model.FreeStyleProject;
import hudson.security.GlobalMatrixAuthorizationStrategy;
Expand All @@ -44,6 +48,7 @@
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.JenkinsRule.DummySecurityRealm;
import org.jvnet.hudson.test.TestExtension;
import org.kohsuke.stapler.HttpResponse;
import java.net.HttpURLConnection;
Expand All @@ -53,7 +58,7 @@
* @author kingfai
*
*/
public class JenkinsTest extends HudsonTestCase {
public class JenkinsTest extends HudsonTestCase implements UnprotectedRootAction {

@Test
public void testIsDisplayNameUniqueTrue() throws Exception {
Expand Down Expand Up @@ -354,4 +359,29 @@ public HttpResponse doDynamic() {
throw new AssertionError();
}
}

@Bug(20866)
public void testErrorPageShouldBeAnonymousAccessible() throws Exception {
HudsonPrivateSecurityRealm s = new HudsonPrivateSecurityRealm(false, false, null);
User alice = s.createAccount("alice", "alice");
jenkins.setSecurityRealm(s);

GlobalMatrixAuthorizationStrategy auth = new GlobalMatrixAuthorizationStrategy();
jenkins.setAuthorizationStrategy(auth);

// no anonymous read access
assertTrue(!Jenkins.getInstance().getACL().hasPermission(Jenkins.ANONYMOUS,Jenkins.READ));

WebClient wc = createWebClient();
wc.setThrowExceptionOnFailingStatusCode(false);
HtmlPage p = wc.goTo("/self/reportError");

assertEquals(400, p.getWebResponse().getStatusCode()); // not 403 forbidden
assertTrue(p.getWebResponse().getContentAsString().contains("My car is black"));
}

public HttpResponse doReportError() {
return new Failure("My car is black");
}

}

0 comments on commit b89baa5

Please sign in to comment.