Search in sources :

Example 61 with WithPlugins

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();
}
Also used : JobDslBuildStep(org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 62 with WithPlugins

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()));
}
Also used : JobConfigHistory(org.jenkinsci.test.acceptance.plugins.job_config_history.JobConfigHistory) Change(org.jenkinsci.test.acceptance.plugins.job_config_history.JobConfigHistory.Change) MavenModuleSet(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 63 with WithPlugins

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));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) StageView(org.jenkinsci.test.acceptance.plugins.stageview.StageView) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 64 with WithPlugins

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();
    }
}
Also used : MatrixRun(org.jenkinsci.test.acceptance.po.MatrixRun) LabelExpressionAxis(org.jenkinsci.test.acceptance.po.LabelExpressionAxis) MatrixProject(org.jenkinsci.test.acceptance.po.MatrixProject) MatrixBuild(org.jenkinsci.test.acceptance.po.MatrixBuild) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 65 with WithPlugins

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/"));
}
Also used : WebElement(org.openqa.selenium.WebElement) Ignore(org.junit.Ignore) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)89 Test (org.junit.Test)89 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)71 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)53 Build (org.jenkinsci.test.acceptance.po.Build)39 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 Issue (org.jvnet.hudson.test.Issue)25 Job (org.jenkinsci.test.acceptance.po.Job)19 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)15 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)15 ListView (org.jenkinsci.test.acceptance.po.ListView)13 View (org.jenkinsci.test.acceptance.po.View)13 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)12 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)11 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)9 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)8 Ignore (org.junit.Ignore)8 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)5