Skip to content

Commit

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

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 13, 2023
1 parent 0a7ab5f commit be77274
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 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>2129.v09f309d2339c</version>
<version>2135.v8f2e9795cf3f</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/model/NodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,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.impersonate())));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Map.of(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
9 changes: 4 additions & 5 deletions test/src/test/java/hudson/model/QueueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -823,15 +823,14 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
assertEquals(alice2, Jenkins.getAuthentication2());
assertEquals(alice, Jenkins.getAuthentication2());
return true;
}
});
r.buildAndAssertSuccess(p);
}

private static Authentication alice2 = new UsernamePasswordAuthenticationToken("alice", "alice", Collections.emptySet());
private static org.acegisecurity.Authentication alice = org.acegisecurity.Authentication.fromSpring(alice2);
private static Authentication alice = new UsernamePasswordAuthenticationToken("alice", "alice", Collections.emptySet());


/**
Expand All @@ -850,7 +849,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
assertEquals(alice2, Jenkins.getAuthentication2());
assertEquals(alice, Jenkins.getAuthentication2());
return true;
}
});
Expand Down Expand Up @@ -883,7 +882,7 @@ public ACL getACL(Node node) {
if (node.getNodeName().equals(blocked)) {
// ACL that allow anyone to do anything except Alice can't build.
SparseACL acl = new SparseACL(null);
acl.add(new PrincipalSid(alice2), Computer.BUILD, false);
acl.add(new PrincipalSid(alice), Computer.BUILD, false);
acl.add(new PrincipalSid("anonymous"), Jenkins.ADMINISTER, true);
return acl;
}
Expand Down
9 changes: 5 additions & 4 deletions test/src/test/java/hudson/tasks/BuildTriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.jvnet.hudson.test.MockBuilder;
import org.jvnet.hudson.test.MockQueueItemAuthenticator;
import org.jvnet.hudson.test.TestBuilder;
import org.springframework.security.core.Authentication;
import org.xml.sax.SAXException;

public class BuildTriggerTest {
Expand Down Expand Up @@ -150,7 +151,7 @@ public void downstreamProjectSecurity() throws Exception {
auth.add(Computer.BUILD, "anonymous");
j.jenkins.setAuthorizationStrategy(auth);
final FreeStyleProject upstream = j. createFreeStyleProject("upstream");
org.acegisecurity.Authentication alice = User.getOrCreateByIdOrFullName("alice").impersonate();
Authentication alice = User.getOrCreateByIdOrFullName("alice").impersonate2();
QueueItemAuthenticatorConfiguration.get().getAuthenticators().add(new MockQueueItemAuthenticator(Map.of("upstream", alice)));
Map<Permission, Set<String>> perms = new HashMap<>();
perms.put(Item.READ, Set.of("alice"));
Expand Down Expand Up @@ -206,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.ANONYMOUS)));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(Map.of("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 Expand Up @@ -242,9 +243,9 @@ public void downstreamProjectSecurity() throws Exception {
j.buildAndAssertSuccess(simple);
}

private void assertDoCheck(org.acegisecurity.Authentication auth, @CheckForNull String expectedError, AbstractProject<?, ?> project, String value) {
private void assertDoCheck(Authentication auth, @CheckForNull String expectedError, AbstractProject<?, ?> project, String value) {
FormValidation result;
try (ACLContext c = ACL.as(auth)) {
try (ACLContext c = ACL.as2(auth)) {
result = j.jenkins.getDescriptorByType(BuildTrigger.DescriptorImpl.class).doCheck(project, value);
}
if (expectedError == null) {
Expand Down
27 changes: 14 additions & 13 deletions test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
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 @@ -115,9 +116,9 @@ 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, org.acegisecurity.Authentication> qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("admin").impersonate());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS);
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));
b = r.buildAndAssertSuccess(upstream);
r.assertLogContains(downstreamName, b);
Expand All @@ -126,8 +127,8 @@ public void runMoreQuickly() throws Exception {
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").impersonate());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS);
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS2);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
Expand All @@ -136,8 +137,8 @@ public void runMoreQuickly() throws Exception {
// 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").impersonate());
qiaConfig.put(downstreamName, User.get("alice").impersonate());
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, User.get("alice").impersonate2());
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
Expand All @@ -146,8 +147,8 @@ public void runMoreQuickly() throws Exception {
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").impersonate());
qiaConfig.put(downstreamName, User.get("alice").impersonate());
qiaConfig.put(upstreamName, User.get("admin").impersonate2());
qiaConfig.put(downstreamName, User.get("alice").impersonate2());
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
b = r.buildAndAssertSuccess(upstream);
r.assertLogContains(downstreamName, b);
Expand All @@ -165,8 +166,8 @@ public void runMoreQuickly() throws Exception {
r.jenkins.setAuthorizationStrategy(auth);
auth.grant(Item.READ).onItems(downstream).to("alice");
qiaConfig = new HashMap<>();
qiaConfig.put(upstreamName, User.get("bob").impersonate());
qiaConfig.put(downstreamName, User.get("alice").impersonate());
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, User.get("alice").impersonate2());
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
Expand All @@ -178,8 +179,8 @@ public void runMoreQuickly() throws Exception {
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").impersonate());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS);
qiaConfig.put(upstreamName, User.get("bob").impersonate2());
qiaConfig.put(downstreamName, Jenkins.ANONYMOUS2);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(qiaConfig));
b = r.buildAndAssertSuccess(upstream);
r.assertLogNotContains(downstreamName, b);
Expand Down

0 comments on commit be77274

Please sign in to comment.