-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-73941 - reverting CASC compatibility
- Loading branch information
1 parent
8ffaefe
commit e0f823a
Showing
6 changed files
with
69 additions
and
1 deletion.
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
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); | ||
} | ||
} |
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 |