From bcc9a468811fd05d0ff9b490cf70cbbe1c5d51e5 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Thu, 26 Dec 2024 10:58:05 +0100 Subject: [PATCH] Update code as scriptler and Jenkins now use oac.fileupload2 --- pom.xml | 4 ++-- .../org/biouno/unochoice/TestPersistingParameters.java | 7 +++---- .../unochoice/issue63983/TestSandboxAndApproval.java | 10 +++++----- .../TestJobDslWithScriptlerScriptWithParameters.java | 6 ++---- .../jenkinsci/plugins/scriptler/ScriptlerHelper.java | 3 ++- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index f09b8152..b3907afb 100644 --- a/pom.xml +++ b/pom.xml @@ -37,8 +37,8 @@ 2.8.7 -SNAPSHOT - 2.479 - + 2.479 + 2.482 diff --git a/src/test/java/org/biouno/unochoice/TestPersistingParameters.java b/src/test/java/org/biouno/unochoice/TestPersistingParameters.java index 5b23229a..c79f2ac1 100644 --- a/src/test/java/org/biouno/unochoice/TestPersistingParameters.java +++ b/src/test/java/org/biouno/unochoice/TestPersistingParameters.java @@ -33,11 +33,10 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map.Entry; -import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload2.core.FileItem; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.biouno.unochoice.model.GroovyScript; @@ -66,7 +65,7 @@ import hudson.model.ParameterDefinition; import hudson.model.ParametersDefinitionProperty; import hudson.model.Result; -import hudson.model.FileParameterValue.FileItemImpl; +import hudson.model.FileParameterValue.FileItemImpl2; import hudson.model.queue.QueueTaskFuture; /** @@ -110,7 +109,7 @@ public void setUp() throws Exception { ScriptlerHelper scriptlerHelper = new ScriptlerHelper(scriptler); scriptFile = Files.createTempFile("uno-choice", "dummy.groovy").toFile(); FileUtils.writeStringToFile(scriptFile, SCRIPT_PARAM001, Charset.defaultCharset(), false); - FileItem fi = new FileItemImpl(scriptFile); + FileItem fi = new FileItemImpl2(scriptFile); scriptlerHelper.saveScript(fi, true, "dummy.groovy"); scriptler.getConfiguration().getScriptById("dummy.groovy") diff --git a/src/test/java/org/biouno/unochoice/issue63983/TestSandboxAndApproval.java b/src/test/java/org/biouno/unochoice/issue63983/TestSandboxAndApproval.java index ab8c3716..ffebfee5 100644 --- a/src/test/java/org/biouno/unochoice/issue63983/TestSandboxAndApproval.java +++ b/src/test/java/org/biouno/unochoice/issue63983/TestSandboxAndApproval.java @@ -24,7 +24,7 @@ package org.biouno.unochoice.issue63983; import hudson.model.FileParameterValue; -import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload2.core.FileItem; import org.apache.commons.io.FileUtils; import org.biouno.unochoice.model.ScriptlerScript; import org.jenkinsci.plugins.scriptler.ScriptlerHelper; @@ -64,7 +64,7 @@ public void testGroovyScriptApprovedNoSandboxOK() throws Exception { "return \"Got instance!\";"; final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile(); FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false); - final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile); + final FileItem fi = new FileParameterValue.FileItemImpl2(scriptFile); scriptlerHelper.saveScript(fi, true, "63983"); Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false); ScriptlerConfiguration.getConfiguration().addOrReplace(script); @@ -88,7 +88,7 @@ public void testGroovyScriptPendingSandboxRejected() throws Exception { "return \"Got instance!\";"; final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile(); FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false); - final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile); + final FileItem fi = new FileParameterValue.FileItemImpl2(scriptFile); scriptlerHelper.saveScript(fi, true, "63983"); Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false); ScriptlerConfiguration.getConfiguration().addOrReplace(script); @@ -114,7 +114,7 @@ public void testGroovyScriptPendingNoSandboxRejected() throws Exception { "return \"Got instance!\";"; final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile(); FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false); - final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile); + final FileItem fi = new FileParameterValue.FileItemImpl2(scriptFile); scriptlerHelper.saveScript(fi, true, "63983"); Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false); ScriptlerConfiguration.getConfiguration().addOrReplace(script); @@ -140,7 +140,7 @@ public void testGroovyScriptApprovedSandboxRejected() throws Exception { "return \"Got instance!\";"; final File scriptFile = Files.createTempFile("uno-choice", "63983").toFile(); FileUtils.writeStringToFile(scriptFile, scriptText, Charset.defaultCharset(), false); - final FileItem fi = new FileParameterValue.FileItemImpl(scriptFile); + final FileItem fi = new FileParameterValue.FileItemImpl2(scriptFile); scriptlerHelper.saveScript(fi, true, "63983"); Script script = new Script("63983.groovy", "63983.groovy", "A comment.", false, Collections.emptyList(), false); ScriptlerConfiguration.getConfiguration().addOrReplace(script); diff --git a/src/test/java/org/biouno/unochoice/issue72105/TestJobDslWithScriptlerScriptWithParameters.java b/src/test/java/org/biouno/unochoice/issue72105/TestJobDslWithScriptlerScriptWithParameters.java index cdf75bc1..28fb9649 100644 --- a/src/test/java/org/biouno/unochoice/issue72105/TestJobDslWithScriptlerScriptWithParameters.java +++ b/src/test/java/org/biouno/unochoice/issue72105/TestJobDslWithScriptlerScriptWithParameters.java @@ -30,9 +30,8 @@ import hudson.model.ParameterDefinition; import hudson.model.ParametersDefinitionProperty; import hudson.model.Result; -import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload2.core.FileItem; import org.apache.commons.io.FileUtils; -import org.biouno.unochoice.AbstractScriptableParameter; import org.biouno.unochoice.CascadeChoiceParameter; import org.biouno.unochoice.model.ScriptlerScript; import org.jenkinsci.plugins.scriptler.ScriptlerHelper; @@ -40,7 +39,6 @@ import org.jenkinsci.plugins.scriptler.config.Parameter; import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval; import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage; -import org.jenkinsci.plugins.workflow.flow.FlowDefinition; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.junit.Before; import org.junit.Rule; @@ -91,7 +89,7 @@ public void setUp() throws Exception { ScriptlerHelper scriptlerHelper = new ScriptlerHelper(scriptler); scriptFile = Files.createTempFile("uno-choice", "Cascade.groovy").toFile(); FileUtils.writeStringToFile(scriptFile, GROOVY_SCRIPT, Charset.defaultCharset(), false); - FileItem fi = new FileParameterValue.FileItemImpl(scriptFile); + FileItem fi = new FileParameterValue.FileItemImpl2(scriptFile); scriptlerHelper.saveScript(fi, true, "Cascade.groovy"); scriptler.getConfiguration() diff --git a/src/test/java/org/jenkinsci/plugins/scriptler/ScriptlerHelper.java b/src/test/java/org/jenkinsci/plugins/scriptler/ScriptlerHelper.java index 9038b2e7..be747914 100644 --- a/src/test/java/org/jenkinsci/plugins/scriptler/ScriptlerHelper.java +++ b/src/test/java/org/jenkinsci/plugins/scriptler/ScriptlerHelper.java @@ -23,7 +23,8 @@ */ package org.jenkinsci.plugins.scriptler; -import org.apache.commons.fileupload.FileItem; + +import org.apache.commons.fileupload2.core.FileItem; /** * @see