diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java
index 6ddc03391ae5e61bd878836f2e866375e6729296..27fab02f8668d7ebf0b47e947b8ef1c77c75109f 100644
--- a/core/src/main/java/hudson/model/AbstractProject.java
+++ b/core/src/main/java/hudson/model/AbstractProject.java
@@ -763,7 +763,7 @@ public abstract class AbstractProject
,R extends A
/**
* Reflect the submission of the pseudo 'upstream build trigger'.
*/
- private void convertUpstreamBuildTrigger(Set upstream) throws IOException {
+ protected void convertUpstreamBuildTrigger(Set upstream) throws IOException {
SecurityContext saveCtx = ACL.impersonate(ACL.SYSTEM);
try {
diff --git a/test/src/test/java/hudson/model/AbstractProjectTest.java b/test/src/test/java/hudson/model/AbstractProjectTest.java
index 15284b67516537258bcafa576ab3fc445db37a06..9820c03a7caafe5e7a0347a775f3bc95097cd7c4 100644
--- a/test/src/test/java/hudson/model/AbstractProjectTest.java
+++ b/test/src/test/java/hudson/model/AbstractProjectTest.java
@@ -27,7 +27,8 @@ import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import hudson.security.GlobalMatrixAuthorizationStrategy;
+import hudson.security.*;
+import hudson.tasks.BuildTrigger;
import hudson.tasks.Shell;
import hudson.scm.NullSCM;
import hudson.Launcher;
@@ -38,6 +39,10 @@ import hudson.tasks.ArtifactArchiver;
import hudson.util.StreamTaskListener;
import hudson.util.OneShotEvent;
import java.io.IOException;
+
+import jenkins.model.Jenkins;
+import org.acegisecurity.context.SecurityContext;
+import org.acegisecurity.context.SecurityContextHolder;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.MemoryAssert;
@@ -45,6 +50,10 @@ import org.jvnet.hudson.test.recipes.PresetData;
import org.jvnet.hudson.test.recipes.PresetData.DataSet;
import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.Future;
import org.apache.commons.io.FileUtils;
import java.lang.ref.WeakReference;
@@ -285,4 +294,39 @@ public class AbstractProjectTest extends HudsonTestCase {
MemoryAssert.assertGC(new WeakReference(job.getLastBuild()));
assertTrue(job.getLastBuild() != null);
}
+
+ @Bug(13502)
+ public void testHandleBuildTrigger() throws Exception {
+ Project u = createFreeStyleProject("u"),
+ d = createFreeStyleProject("d"),
+ e = createFreeStyleProject("e");
+
+ u.addPublisher(new BuildTrigger("d", Result.SUCCESS));
+
+ jenkins.setSecurityRealm(createDummySecurityRealm());
+ ProjectMatrixAuthorizationStrategy authorizations = new ProjectMatrixAuthorizationStrategy();
+ jenkins.setAuthorizationStrategy(authorizations);
+
+ authorizations.add(Jenkins.ADMINISTER, "admin");
+ authorizations.add(Jenkins.READ, "user");
+
+ // user can READ u and CONFIGURE e
+ Map> permissions = new HashMap>();
+ permissions.put(Job.READ, Collections.singleton("user"));
+ u.addProperty(new AuthorizationMatrixProperty(permissions));
+
+ permissions = new HashMap>();
+ permissions.put(Job.CONFIGURE, Collections.singleton("user"));
+ e.addProperty(new AuthorizationMatrixProperty(permissions));
+
+ User user = User.get("user");
+ SecurityContext sc = ACL.impersonate(user.impersonate());
+ try {
+ e.convertUpstreamBuildTrigger(Collections.emptySet());
+ } finally {
+ SecurityContextHolder.setContext(sc);
+ }
+
+ assertEquals(1, u.getPublishersList().size());
+ }
}