forked from v1v/jenkinslint-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-46177] Support GroovySandbox in Publisher/Builder/Parameters (…
…#33) * Initial approach to detect whether sandbox is enabled or current plugin versions are obsolted and unsecured Change-Id: I98ebba01b9907135e775b506a3b36659f1ca506d * [JENKINS-46177] Groovy sandbox checker for Publisher/Build/Parameters Change-Id: I23b018ca9cb05b2a909360e5c3f0411171ae88d9 * Support Groovy plugin version 2.X and 1.X too Change-Id: I8b7d0eca71777115c67b65f73204f6bc48c57646 * Removed unused plugin, since it is not possible to install a default plugin version usinig the pom and reinstall another version usign the plugin annotation Change-Id: I435f9d0be548685bcbaef50416fcc4eb53e50f4a * Added IT Change-Id: If6a5963fef2c051f3ec27f00d4de6e6141031158
- Loading branch information
Showing
8 changed files
with
421 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/org/jenkins/ci/plugins/jenkinslint/check/GroovyAbstractCheckerTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.jenkins.ci.plugins.jenkinslint.check; | ||
|
||
import hudson.model.ParametersDefinitionProperty; | ||
import org.biouno.unochoice.CascadeChoiceParameter; | ||
import org.biouno.unochoice.ChoiceParameter; | ||
import org.biouno.unochoice.DynamicReferenceParameter; | ||
import org.biouno.unochoice.model.GroovyScript; | ||
import org.jenkins.ci.plugins.jenkinslint.AbstractTestCase; | ||
import org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript; | ||
|
||
/** | ||
* Created by vicmar02 on 07/08/2017. | ||
*/ | ||
public class GroovyAbstractCheckerTestCase extends AbstractTestCase { | ||
|
||
protected ParametersDefinitionProperty createChoiceParameter(String content) { | ||
GroovyScript script = new GroovyScript(createScript(content),createScript(content)); | ||
ChoiceParameter cp = new ChoiceParameter("param", "desc", script, "", false); | ||
return new ParametersDefinitionProperty(cp); | ||
} | ||
|
||
protected ParametersDefinitionProperty createCascadeChoiceParameter(String content) { | ||
GroovyScript script = new GroovyScript(createScript(content),createScript(content)); | ||
CascadeChoiceParameter ccp = new CascadeChoiceParameter("param", "desc", script, "", "", false); | ||
return new ParametersDefinitionProperty(ccp); | ||
} | ||
|
||
protected ParametersDefinitionProperty createDynamicReferenceParameter(String content) { | ||
GroovyScript script = new GroovyScript(createScript(content),createScript(content)); | ||
DynamicReferenceParameter drp = new DynamicReferenceParameter("param", "desc", script, "", "", false); | ||
return new ParametersDefinitionProperty(drp); | ||
} | ||
|
||
private SecureGroovyScript createScript (String content) { | ||
return new SecureGroovyScript(content,false,null); | ||
} | ||
|
||
protected ParametersDefinitionProperty createChoiceParameter(String content, Boolean sandbox) { | ||
GroovyScript script = new GroovyScript(createScript(content, sandbox),createScript(content, sandbox)); | ||
ChoiceParameter cp = new ChoiceParameter("param", "desc", script, "", false); | ||
return new ParametersDefinitionProperty(cp); | ||
} | ||
|
||
protected ParametersDefinitionProperty createCascadeChoiceParameter(String content, Boolean sandbox) { | ||
GroovyScript script = new GroovyScript(createScript(content, sandbox),createScript(content, sandbox)); | ||
CascadeChoiceParameter ccp = new CascadeChoiceParameter("param", "desc", script, "", "", false); | ||
return new ParametersDefinitionProperty(ccp); | ||
} | ||
|
||
protected ParametersDefinitionProperty createDynamicReferenceParameter(String content, Boolean sandbox) { | ||
GroovyScript script = new GroovyScript(createScript(content, sandbox),createScript(content, sandbox)); | ||
DynamicReferenceParameter drp = new DynamicReferenceParameter("param", "desc", script, "", "", false); | ||
return new ParametersDefinitionProperty(drp); | ||
} | ||
|
||
private SecureGroovyScript createScript (String content, Boolean sandbox) { | ||
return new SecureGroovyScript(content,sandbox,null); | ||
} | ||
} |
Oops, something went wrong.