Skip to content

Commit

Permalink
Bump org.jenkins-ci.main:jenkins-test-harness from 2135.v8f2e9795cf3f…
Browse files Browse the repository at this point in the history
… to 2137.vb_4eb_49f51c4b_ (#8779)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored Dec 14, 2023
1 parent be77274 commit 2239347
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ THE SOFTWARE.
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jenkins-test-harness</artifactId>
<version>2135.v8f2e9795cf3f</version>
<version>2137.vb_4eb_49f51c4b_</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
3 changes: 1 addition & 2 deletions test/src/test/java/hudson/model/NodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import java.util.Collection;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import jenkins.model.Jenkins;
import jenkins.security.QueueItemAuthenticatorConfiguration;
import org.htmlunit.HttpMethod;
Expand Down Expand Up @@ -222,7 +221,7 @@ public void testCanTake() throws Exception {
j.jenkins.setSecurityRealm(realm);
realm.createAccount("John", "");
notTake = false;
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Map.of(project.getFullName(), user.impersonate2())));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator().authenticate(project.getFullName(), user.impersonate2()));
assertNotNull("Node should not take project because user does not have build permission.", node.canTake(item));
message = Messages._Node_LackingBuildPermission(item.authenticate2().getName(), node.getNodeName()).toString();
assertEquals("Cause of blockage should be build permission label.", message, node.canTake(item).getShortDescription());
Expand Down
4 changes: 2 additions & 2 deletions test/src/test/java/hudson/model/QueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
*/
@Test public void accessControl() throws Exception {
FreeStyleProject p = r.createFreeStyleProject();
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Map.of(p.getFullName(), alice)));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator().authenticate(p.getFullName(), alice));
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
Expand All @@ -845,7 +845,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
DumbSlave s2 = r.createSlave();

FreeStyleProject p = r.createFreeStyleProject();
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Map.of(p.getFullName(), alice)));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator().authenticate(p.getFullName(), alice));
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
Expand Down
4 changes: 2 additions & 2 deletions test/src/test/java/hudson/tasks/BuildTriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void downstreamProjectSecurity() throws Exception {
j.jenkins.setAuthorizationStrategy(auth);
final FreeStyleProject upstream = j. createFreeStyleProject("upstream");
Authentication alice = User.getOrCreateByIdOrFullName("alice").impersonate2();
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Map.of("upstream", alice)));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator().authenticate("upstream", alice));
Map<Permission, Set<String>> perms = new HashMap<>();
perms.put(Item.READ, Set.of("alice"));
perms.put(Item.CONFIGURE, Set.of("alice"));
Expand Down Expand Up @@ -207,7 +207,7 @@ public void downstreamProjectSecurity() throws Exception {
assertNotNull(cause);
assertEquals(b, cause.getUpstreamRun());
// Now if we have configured some QIA’s but they are not active on this job, we should normally fall back to running as anonymous. Which would normally have no permissions:
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(Map.of("upstream", Jenkins.ANONYMOUS2)));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator().authenticate("upstream", Jenkins.ANONYMOUS2));
assertDoCheck(alice, Messages.BuildTrigger_you_have_no_permission_to_build_(downstreamName), upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
b = j.buildAndAssertSuccess(upstream);
Expand Down
57 changes: 30 additions & 27 deletions test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
import hudson.tasks.BuildTrigger;
import hudson.tasks.BuildTriggerTest;
import hudson.triggers.Trigger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jenkins.model.Jenkins;
import jenkins.security.QueueItemAuthenticatorConfiguration;
Expand All @@ -57,7 +55,6 @@
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockAuthorizationStrategy;
import org.jvnet.hudson.test.MockQueueItemAuthenticator;
import org.springframework.security.core.Authentication;

public class ReverseBuildTriggerTest {

Expand Down Expand Up @@ -116,40 +113,44 @@ public void runMoreQuickly() throws Exception {
assertNotNull(JenkinsRule.getLog(b), downstream.getLastBuild());
assertEquals(1, downstream.getLastBuild().number);
// A QIA is configured but does not specify any authentication for downstream, so upstream should not trigger it:
Map<String, Authentication> qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("admin").impersonate2());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS2);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(qiaConfig));
QueueItemAuthenticatorConfiguration.get()
.getAuthenticators()
.add(new MockQueueItemAuthenticator()
.authenticate(upstreamName, User.get("admin").impersonate2())
.authenticate(downstreamName, Jenkins.ANONYMOUS2));
b = r.buildAndAssertSuccess(upstream);
r.assertLogContains(downstreamName, b);
r.assertLogContains(Messages.ReverseBuildTrigger_running_as_cannot_even_see_for_trigger_f("anonymous", upstreamName, downstreamName), b);
r.waitUntilNoActivity();
assertEquals(1, downstream.getLastBuild().number);
// Auth for upstream is defined but cannot see downstream, so no message is printed about it:
qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS2);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
QueueItemAuthenticatorConfiguration.get()
.getAuthenticators()
.replace(new MockQueueItemAuthenticator()
.authenticate(upstreamName, User.get("bob").impersonate2())
.authenticate(downstreamName, Jenkins.ANONYMOUS2));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
r.waitUntilNoActivity();
assertEquals(1, downstream.getLastBuild().number);
// Alice can see upstream, so downstream gets built, but the upstream build cannot see downstream:
auth.grant(Item.READ).onItems(upstream).to("alice", "bob");
qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, User.get("alice").impersonate2());
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
QueueItemAuthenticatorConfiguration.get()
.getAuthenticators()
.replace(new MockQueueItemAuthenticator()
.authenticate(upstreamName, User.get("bob").impersonate2())
.authenticate(downstreamName, User.get("alice").impersonate2()));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
r.waitUntilNoActivity();
assertEquals(2, downstream.getLastBuild().number);
assertEquals(new Cause.UpstreamCause((Run) b), downstream.getLastBuild().getCause(Cause.UpstreamCause.class));
// Now if upstream build is permitted to report on downstream:
qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("admin").impersonate2());
qiaConfig.put(downstreamName, User.get("alice").impersonate2());
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
QueueItemAuthenticatorConfiguration.get()
.getAuthenticators()
.replace(new MockQueueItemAuthenticator()
.authenticate(upstreamName, User.get("admin").impersonate2())
.authenticate(downstreamName, User.get("alice").impersonate2()));
b = r.buildAndAssertSuccess(upstream);
r.assertLogContains(downstreamName, b);
r.waitUntilNoActivity();
Expand All @@ -165,10 +166,11 @@ public void runMoreQuickly() throws Exception {
.grant(Item.DISCOVER).onItems(upstream).to("alice");
r.jenkins.setAuthorizationStrategy(auth);
auth.grant(Item.READ).onItems(downstream).to("alice");
qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, User.get("alice").impersonate2());
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
QueueItemAuthenticatorConfiguration.get()
.getAuthenticators()
.replace(new MockQueueItemAuthenticator()
.authenticate(upstreamName, User.get("bob").impersonate2())
.authenticate(downstreamName, User.get("alice").impersonate2()));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
r.waitUntilNoActivity();
Expand All @@ -178,10 +180,11 @@ public void runMoreQuickly() throws Exception {
// so no message is printed about it, and no Exception neither (JENKINS-42707)
auth.grant(Item.READ).onItems(upstream).to("bob");
auth.grant(Item.DISCOVER).onItems(upstream).to("anonymous");
qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS2);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
QueueItemAuthenticatorConfiguration.get()
.getAuthenticators()
.replace(new MockQueueItemAuthenticator()
.authenticate(upstreamName, User.get("bob").impersonate2())
.authenticate(downstreamName, Jenkins.ANONYMOUS2));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
r.assertLogNotContains("Please login to access job " + upstreamName, b);
Expand Down

0 comments on commit 2239347

Please sign in to comment.