From 682a7357e9931422e8ee4fb325d5e45a17c7305e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 19:14:23 +0000 Subject: [PATCH 1/2] Bump org.jenkins-ci.main:jenkins-test-harness Bumps [org.jenkins-ci.main:jenkins-test-harness](https://github.com/jenkinsci/jenkins-test-harness) from 2129.v09f309d2339c to 2135.v8f2e9795cf3f. - [Release notes](https://github.com/jenkinsci/jenkins-test-harness/releases) - [Changelog](https://github.com/jenkinsci/jenkins-test-harness/blob/master/docs/CHANGELOG-OLD.md) - [Commits](https://github.com/jenkinsci/jenkins-test-harness/commits) --- updated-dependencies: - dependency-name: org.jenkins-ci.main:jenkins-test-harness dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pom.xml b/test/pom.xml index 0ffbfe5a1469..71d4556b7162 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -131,7 +131,7 @@ THE SOFTWARE. ${project.groupId} jenkins-test-harness - 2129.v09f309d2339c + 2135.v8f2e9795cf3f test From e5ba7bd6eeb1ab49ece98a0faa60b9bbdec2b965 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 13 Dec 2023 11:56:47 -0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/src/test/java/hudson/model/NodeTest.java | 2 +- .../src/test/java/hudson/model/QueueTest.java | 9 +++---- .../java/hudson/tasks/BuildTriggerTest.java | 9 ++++--- .../triggers/ReverseBuildTriggerTest.java | 27 ++++++++++--------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/test/src/test/java/hudson/model/NodeTest.java b/test/src/test/java/hudson/model/NodeTest.java index 037e53bc4d0f..7523f52c51a9 100644 --- a/test/src/test/java/hudson/model/NodeTest.java +++ b/test/src/test/java/hudson/model/NodeTest.java @@ -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()); diff --git a/test/src/test/java/hudson/model/QueueTest.java b/test/src/test/java/hudson/model/QueueTest.java index bdacb2f72a63..bd46fc333e30 100644 --- a/test/src/test/java/hudson/model/QueueTest.java +++ b/test/src/test/java/hudson/model/QueueTest.java @@ -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()); /** @@ -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; } }); @@ -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; } diff --git a/test/src/test/java/hudson/tasks/BuildTriggerTest.java b/test/src/test/java/hudson/tasks/BuildTriggerTest.java index 0731854d894e..b8038afceebe 100644 --- a/test/src/test/java/hudson/tasks/BuildTriggerTest.java +++ b/test/src/test/java/hudson/tasks/BuildTriggerTest.java @@ -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 { @@ -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> perms = new HashMap<>(); perms.put(Item.READ, Set.of("alice")); @@ -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); @@ -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) { diff --git a/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java b/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java index d510ce069660..22dc81086364 100644 --- a/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java +++ b/test/src/test/java/jenkins/triggers/ReverseBuildTriggerTest.java @@ -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 { @@ -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 qiaConfig = new HashMap<>(); - qiaConfig.put(upstreamName, User.get("admin").impersonate()); - qiaConfig.put(downstreamName, Jenkins.ANONYMOUS); + Map 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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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);