use of org.jenkinsci.test.acceptance.junit.WithPlugins 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.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobConfigHistoryPluginTest method track_change_in_maven_project.
@Test
@Issue("JENKINS-24410")
@WithPlugins("maven-plugin")
public void track_change_in_maven_project() {
MavenModuleSet job = jenkins.jobs.create(MavenModuleSet.class);
JobConfigHistory history = job.action(JobConfigHistory.class);
List<Change> original = history.getChanges();
job.configure();
job.goals.set("clean");
job.save();
List<Change> newOnes = history.getChanges();
assertThat("New changes saved", newOnes.size(), greaterThan(original.size()));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class StageViewTest method multiBuildJobShouldContainCorrectNumberOfJobsHeadline.
/**
* This tests verfies the width of the display. Stageviews have to adapt
* to new stages with future builds.
*/
@Test
@WithPlugins("pipeline-stage-view@2.18")
public void multiBuildJobShouldContainCorrectNumberOfJobsHeadline() {
WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
String pre = "node {\n";
String post = "}";
String singleStage = "stage ('Clone sources'){\n" + " echo 'cloned'\n" + " }\n";
job.script.set("");
job.sandbox.check();
job.save();
Build build = job.startBuild().shouldSucceed();
for (int i = 0; i < 10; i++) {
String text = pre + repeatString(singleStage, i + 1) + post;
job.configure(() -> job.script.set(text));
build = job.startBuild().shouldSucceed();
}
assertThat(build, notNullValue());
job.open();
StageView stageView = new StageView(job, JOB_PATH);
assertThat(stageView.getAllStageViewJobs(), hasSize(10));
assertThat(stageView.getStageViewHeadlines(), hasSize(10));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class ForemanNodeSharingPluginTest method testMatrixJob.
/**
* Test a matrix job
*/
@Test
@WithPlugins("matrix-project")
public void testMatrixJob() {
jenkins.save();
MatrixProject job = jenkins.jobs.create(MatrixProject.class);
job.configure();
LabelExpressionAxis a = job.addAxis(LabelExpressionAxis.class);
a.values.set("label1");
job.addUserAxis("X", "1 2 3 4 5");
job.save();
MatrixBuild b = job.startBuild().as(MatrixBuild.class);
b.waitUntilFinished(EXTENDED_PROVISION_TIMEOUT);
for (MatrixRun config : b.getConfigurations()) {
config.shouldSucceed();
}
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class GradlePluginTest method run_gradle_pipeline_build_scan_link.
/**
* Runs a pipeline gradle build and verifies that the build scan links are existent
*/
@Test
@WithPlugins("workflow-aggregator")
@Ignore("JENKINS-45205")
public void run_gradle_pipeline_build_scan_link() {
final Build build = setUpAndRunPipelineBuild(JENKINS_FILE_WITH_BUILD_SCAN, GRADLE_SCRIPT);
build.openStatusPage();
final WebElement buildScanLink = build.find(By.partialLinkText("Gradle Build Scan"));
assertThat(buildScanLink.getAttribute("href"), containsString("https://gradle.com/"));
}
Aggregations