-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #948 from jgarciacloudbees/JENKINS-73941
JENKINS-73941 - Option to hide "Use Groovy Sandbox" for users without Administer permission globally in the system
- Loading branch information
Showing
10 changed files
with
162 additions
and
23 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
6 changes: 0 additions & 6 deletions
6
...esources/org/jenkinsci/plugins/workflow/cps/config/CPSConfiguration/help-hideSandbox.html
This file was deleted.
Oops, something went wrong.
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
42 changes: 42 additions & 0 deletions
42
plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/JcascTest.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,42 @@ | ||
package org.jenkinsci.plugins.workflow.cps; | ||
|
||
import io.jenkins.plugins.casc.ConfigurationContext; | ||
import io.jenkins.plugins.casc.ConfiguratorRegistry; | ||
import io.jenkins.plugins.casc.misc.ConfiguredWithCode; | ||
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule; | ||
import io.jenkins.plugins.casc.model.CNode; | ||
import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static io.jenkins.plugins.casc.misc.Util.getSecurityRoot; | ||
import static io.jenkins.plugins.casc.misc.Util.toStringFromYamlFile; | ||
import static io.jenkins.plugins.casc.misc.Util.toYamlString; | ||
|
||
public class JcascTest { | ||
|
||
@ClassRule(order = 1) | ||
@ConfiguredWithCode("casc_test.yaml") | ||
public static JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule(); | ||
|
||
/** | ||
* Check that CASC for security.cps.hideSandbox is sending the value to ScriptApproval.get().isForceSandbox() | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void cascHideSandBox() throws Exception { | ||
assertTrue(ScriptApproval.get().isForceSandbox()); | ||
} | ||
|
||
@Test | ||
public void cascExport() throws Exception { | ||
ConfiguratorRegistry registry = ConfiguratorRegistry.get(); | ||
ConfigurationContext context = new ConfigurationContext(registry); | ||
CNode yourAttribute = getSecurityRoot(context).get("cps"); | ||
String exported = toYamlString(yourAttribute); | ||
String expected = toStringFromYamlFile(this, "casc_test_expected.yaml"); | ||
assertEquals(exported, expected); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...nTest/cpsLoadConfiguration/org.jenkinsci.plugins.workflow.cps.config.CPSConfiguration.xml
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,4 @@ | ||
<?xml version='1.1' encoding='UTF-8'?> | ||
<org.jenkinsci.plugins.workflow.cps.config.CPSConfiguration plugin="workflow-cps"> | ||
<hideSandbox>true</hideSandbox> | ||
</org.jenkinsci.plugins.workflow.cps.config.CPSConfiguration> |
3 changes: 3 additions & 0 deletions
3
plugin/src/test/resources/org/jenkinsci/plugins/workflow/cps/casc_test.yaml
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,3 @@ | ||
security: | ||
cps: | ||
hideSandbox: true |
1 change: 1 addition & 0 deletions
1
plugin/src/test/resources/org/jenkinsci/plugins/workflow/cps/casc_test_expected.yaml
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 @@ | ||
hideSandbox: true |