New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-42556] Make PlaceholderTask.getFullDisplayName ignore thread authentication #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,13 @@ | |
|
||
package org.jenkinsci.plugins.workflow.support.pickles; | ||
|
||
import hudson.model.Item; | ||
import hudson.model.Label; | ||
import hudson.model.Queue; | ||
import hudson.model.User; | ||
import hudson.slaves.DumbSlave; | ||
import hudson.slaves.OfflineCause; | ||
import jenkins.model.Jenkins; | ||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
|
@@ -38,12 +42,15 @@ | |
import org.junit.Rule; | ||
import org.junit.runners.model.Statement; | ||
import org.jvnet.hudson.test.BuildWatcher; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.MockAuthorizationStrategy; | ||
import org.jvnet.hudson.test.RestartableJenkinsRule; | ||
|
||
public class ExecutorPickleTest { | ||
|
||
@ClassRule public static BuildWatcher buildWatcher = new BuildWatcher(); | ||
@Rule public RestartableJenkinsRule r = new RestartableJenkinsRule(); | ||
//@Rule public LoggerRule logging = new LoggerRule().record(Queue.class, Level.FINE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useful with jenkinsci/jenkins#2791, and triggers further exceptions fixed in jenkinsci/jenkins#2792. |
||
|
||
@Test public void canceledQueueItem() throws Exception { | ||
r.addStep(new Statement() { | ||
|
@@ -71,4 +78,33 @@ public class ExecutorPickleTest { | |
}); | ||
} | ||
|
||
@Issue("JENKINS-42556") | ||
@Test public void anonDiscover() { | ||
r.addStep(new Statement() { | ||
@Override public void evaluate() throws Throwable { | ||
r.j.jenkins.setSecurityRealm(r.j.createDummySecurityRealm()); | ||
r.j.jenkins.setAuthorizationStrategy(new MockAuthorizationStrategy(). | ||
grant(Jenkins.ADMINISTER).everywhere().to("admin"). | ||
grant(Jenkins.READ, Item.DISCOVER).everywhere().toEveryone()); | ||
r.j.jenkins.save(); // TODO pending https://github.com/jenkinsci/jenkins/pull/2790 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
DumbSlave remote = r.j.createSlave("remote", null, null); | ||
WorkflowJob p = r.j.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition("node('remote') {semaphore 'wait'}", true)); | ||
SemaphoreStep.waitForStart("wait/1", p.scheduleBuild2(0).waitForStart()); | ||
remote.toComputer().setTemporarilyOffline(true, new OfflineCause.UserCause(User.get("admin"), "hold")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise |
||
} | ||
}); | ||
r.addStep(new Statement() { | ||
@Override public void evaluate() throws Throwable { | ||
SemaphoreStep.success("wait/1", null); | ||
WorkflowJob p = r.j.jenkins.getItemByFullName("p", WorkflowJob.class); | ||
assertFalse(p.getACL().hasPermission(Jenkins.ANONYMOUS, Item.READ)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. verifying that |
||
WorkflowRun b = p.getBuildByNumber(1); | ||
r.j.waitForMessage(Messages.ExecutorPickle_waiting_to_resume(Messages.ExecutorStepExecution_PlaceholderTask_displayName(b.getFullDisplayName())), b); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
r.j.jenkins.getNode("remote").toComputer().setTemporarilyOffline(false, null); | ||
r.j.assertBuildStatusSuccess(r.j.waitForCompletion(b)); | ||
} | ||
}); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to worry about showing the task to other users in the executor widget; this display code already handled that, since
run()
will normally return something without an access check (while thenode
block is up and running)—this code path is only used duringExecutorPickle
rehydration when resuming a build.