use of org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_disallow_importing_groovy_classes_when_script_security_enabled.
/**
* Verifies that if script security for Job DSL scripts is enabled and Jenkins
* security is enabled, it is not possible to import Groovy classes from the
* workspace.
*/
@Test
@WithPlugins({ "matrix-auth@2.3", "mock-security-realm" })
public void should_disallow_importing_groovy_classes_when_script_security_enabled() {
GlobalSecurityConfig sc = setUpSecurity();
jenkins.login().doLogin(ADMIN);
FreeStyleJob seedJob = createSeedJob();
seedJob.copyResource(resource("/job_dsl_plugin/MyUtilities.groovy"), "utilities/MyUtilities.groovy");
JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
jobDsl.setScript("import utilities.MyUtilities\n" + "\n" + "def newJob = job('New_Job')\n" + "MyUtilities.addDescription(newJob)");
seedJob.save();
// Build should fail because importing Groovy classes not allowed if script security is enabled
Build build = seedJob.scheduleBuild().shouldFail();
assertThat(build.getConsole(), containsString("unable to resolve class utilities.MyUtilities"));
sc.configure(() -> sc.setJobDslScriptSecurity(false));
seedJob.scheduleBuild().shouldSucceed();
}
use of org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method is_ignoreMissingFiles_shown_right.
/**
* Tests if the checkbox ignoreMissingFiles is shown when the
* radiobutton 'Look on Filesystem' is selected,
* and not shown if the radiobutton 'Use the provided DSL script'
* is selected.
*/
@Test
public void is_ignoreMissingFiles_shown_right() {
FreeStyleJob seedJob = createSeedJob();
JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
assertThat(jobDsl.isIgnoreMissingFilesShown(), is(true));
jobDsl.clickUseScriptText();
assertThat(jobDsl.isIgnoreMissingFilesShown(), is(false));
jobDsl.clickLookOnFilesystem();
assertThat(jobDsl.isIgnoreMissingFilesShown(), is(true));
}
use of org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_unstable_on_deprecated_features.
/**
* Verifies whether the build will be marked as unstable if deprecated
* features are used.
* By default, only a warning is printed to the build log.
* If the function is used, the build will be marked as unstable.
*/
@Test
@WithPlugins("config-file-provider")
public void should_unstable_on_deprecated_features() {
FreeStyleJob seedJob = createSeedJob();
JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
jobDsl.setScript("customConfigFile('New_Config_File')");
seedJob.save();
Build build = seedJob.scheduleBuild().shouldSucceed();
assertThat(build.getConsole(), containsString("Warning: (script, line 1) customConfigFile is deprecated"));
seedJob.configure(() -> jobDsl.setUnstableOnDeprecation(true));
build = seedJob.scheduleBuild().shouldBeUnstable();
assertThat(build.getConsole(), containsString("Warning: (script, line 1) customConfigFile is deprecated"));
}
Aggregations