From 3248ae8e32798be91af9b0724e5b5dc7162e1d38 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Sat, 21 Sep 2024 11:32:26 -0600 Subject: [PATCH] Replace dependee plugin binary with script security call (#83) The dependee plugin binary causes lots of noise when the JenkinsRule test is starting. The noise includes many reports of plugins that cannot be loaded because they require newer dependencies, even though the newest dependencies are already included as test scoped dependencies in the pom file. I assume that is due to the ancient Jenkins version that is referenced in the dependee plugin binary. The dependee plugin was built in 2013 and is not part of the Jenkins update center. Use the script security plugin instead because it is already a dependency and does not require separate script approval. Detected the test noise while evaluating pull request: * https://github.com/jenkinsci/groovy-postbuild-plugin/pull/81 The test was passing but was generating many failure messages because badge plugin 1.13 could not be loaded. Those messages no longer happen with this test change. Adds more assertions on the BadgeAction object for good measure. --- .../GroovyPostbuildRecorderAnnotatedTest.java | 25 ++++++++++-------- src/test/resources/plugins/dependee.hpi | Bin 4672 -> 0 bytes 2 files changed, 14 insertions(+), 11 deletions(-) delete mode 100644 src/test/resources/plugins/dependee.hpi diff --git a/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderAnnotatedTest.java b/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderAnnotatedTest.java index 8a02dca..1b66f2d 100644 --- a/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderAnnotatedTest.java +++ b/src/test/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildRecorderAnnotatedTest.java @@ -25,6 +25,8 @@ package org.jvnet.hudson.plugins.groovypostbuild; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import com.jenkinsci.plugins.badge.action.BadgeAction; import hudson.model.FreeStyleBuild; @@ -32,12 +34,9 @@ import java.util.Collections; import org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript; import org.jenkinsci.plugins.scriptsecurity.scripts.ClasspathEntry; -import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval; -import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage; import org.junit.Rule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; -import org.jvnet.hudson.test.recipes.WithPlugin; /** * Tests requires Jenkins launched for each test methods. @@ -47,14 +46,10 @@ public class GroovyPostbuildRecorderAnnotatedTest { public JenkinsRule j = new JenkinsRule(); @Test - @WithPlugin( - "dependee.hpi") // provides org.jenkinsci.plugins.dependencytest.dependee.Dependee.getValue() which returns - // "dependee". public void testDependencyToAnotherPlugin() throws Exception { - final String SCRIPT = "import org.jenkinsci.plugins.dependencytest.dependee.Dependee;" - + "manager.addShortText(Dependee.getValue());"; - // as Dependee.getValue isn't whitelisted, we need to approve that. - ScriptApproval.get().preapprove(SCRIPT, GroovyLanguage.get()); + // Test with script security plugin because it is already a dependency + final String SCRIPT = "import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApprovalLink;" + + "manager.addShortText((new ScriptApprovalLink()).getDisplayName());"; FreeStyleProject p = j.createFreeStyleProject(); p.getPublishersList() @@ -63,6 +58,14 @@ public void testDependencyToAnotherPlugin() throws Exception { FreeStyleBuild b = p.scheduleBuild2(0).get(); j.assertBuildStatusSuccess(b); - assertEquals("dependee", b.getAction(BadgeAction.class).getText()); + BadgeAction action = b.getAction(BadgeAction.class); + assertEquals("", action.getIconClass()); + assertEquals("", action.getUrlName()); + assertEquals("In-process Script Approval", action.getText()); + assertNull(action.getBorder()); + assertNull(action.getColor()); + assertNull(action.getIconFileName()); + assertNull(action.getLink()); + assertTrue(action.isTextOnly()); } } diff --git a/src/test/resources/plugins/dependee.hpi b/src/test/resources/plugins/dependee.hpi deleted file mode 100644 index 0459ae63727d9427b4fe44137ef88d90413c3338..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4672 zcmb_g3pmqzAKzTUoEI^n)i}aI8B$V8?ha~a=Gw)5|5IZ&Y;Hxfq>Ch%dZ|cqiIO*p z>J1s4P$8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