Search in sources :

Example 11 with WithDocker

use of org.jenkinsci.test.acceptance.junit.WithDocker in project acceptance-test-harness by jenkinsci.

the class SAMLPluginTest method authenticationOKPostBinding.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationOKPostBinding() throws IOException, InterruptedException {
    // navigate to root
    jenkins.open();
    String rootUrl = jenkins.getCurrentUrl();
    SAMLContainer samlServer = startSimpleSAML(rootUrl);
    GlobalSecurityConfig sc = new GlobalSecurityConfig(jenkins);
    sc.open();
    // Authentication
    SamlSecurityRealm realm = configureBasicSettings(sc);
    String idpMetadata = readIdPMetadataFromURL(samlServer);
    realm.setXml(idpMetadata);
    realm.setBinding(SAML2_POST_BINDING_URI);
    configureEncrytion(realm);
    configureAuthorization(sc);
    // SAML service login page
    waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> hasContent("Enter your username and password"));
    // SAML server login
    makeLoginWithUser1();
}
Also used : SAMLContainer(org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) GlobalSecurityConfig(org.jenkinsci.test.acceptance.po.GlobalSecurityConfig) SamlSecurityRealm(org.jenkinsci.test.acceptance.plugins.saml.SamlSecurityRealm) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 12 with WithDocker

use of org.jenkinsci.test.acceptance.junit.WithDocker in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method detailsTabContentWithOneWarningTest.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void detailsTabContentWithOneWarningTest() throws ExecutionException, InterruptedException {
    WarningsAction action = createAndBuildCompileJobOnAgent(resource("/warnings_plugin/WarningMain2.java"), "javac -Xlint:all WarningMain2.java");
    SortedMap<String, String> details = action.getDetailsTabContents();
    assertThat("Assert the proper detail count.", details.entrySet(), hasSize(1));
    assertThatDetailsAre(details, "redundant cast to TextClass", "WarningMain2.java:9");
}
Also used : WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 13 with WithDocker

use of org.jenkinsci.test.acceptance.junit.WithDocker in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_scan_files_on_slave.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_files_on_slave() {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource("/warnings_plugin/out.txt"));
    job.addPublisher(WarningsPublisher.class).addWorkspaceFileScanner(JAVA_ID, "out.txt");
    job.save();
    Build build = job.startBuild().shouldSucceed();
    assertThatActionExists(job, build, "Java Warnings");
    build.open();
    assertThat(driver, hasContent("Java Warnings: " + 2));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WarningsPublisher(org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 14 with WithDocker

use of org.jenkinsci.test.acceptance.junit.WithDocker in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_have_correct_details.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_have_correct_details() throws ExecutionException, InterruptedException {
    WarningsAction action = createAndBuildCompileJobOnAgent(resource("/warnings_plugin/WarningMain.java"), "javac -Xlint:all WarningMain.java");
    SortedMap<String, String> details = action.getDetailsTabContents();
    assertThat("Assert the proper detail count.", details.entrySet(), hasSize(3));
    assertThatDetailsAre(details, "redundant cast to TextClass", "WarningMain.java:10");
    // removing tested entry from details.
    details.remove(details.firstKey());
    assertThatDetailsAre(details, "redundant cast to TextClass", "WarningMain.java:11");
    // removing tested entry from details.
    details.remove(details.firstKey());
    assertThatDetailsAre(details, "division by zero", "WarningMain.java:14");
}
Also used : WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 15 with WithDocker

use of org.jenkinsci.test.acceptance.junit.WithDocker in project acceptance-test-harness by jenkinsci.

the class AnalysisCollectorPluginTest method should_open_links_in_folder_dashboard_and_nested_views.

/**
 * Sets up a nested view that contains a dashboard view with a warnings-per-project portlet.
 * Creates a folder in this view and a multi-branch job in this folder.
 * The multi-branch job is based on a git repository with two branches (master and branch).
 * Each branch contains a Jenkinsfile and several warnings results files.
 * Builds the jobs and verifies that the portlet is correctly filled and that all links open the correct page.
 */
@Test
@Issue({ "JENKINS-39950" })
@WithPlugins({ "dashboard-view", "nested-view", "git", "workflow-job", "workflow-cps", "workflow-basic-steps", "workflow-durable-task-step", "workflow-multibranch" })
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { "warnings", "/org/jenkinsci/test/acceptance/docker/fixtures/GitContainer/unsafe" })
public void should_open_links_in_folder_dashboard_and_nested_views() {
    // avoid JENKINS-49026
    checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);
    // Given
    NestedView nested = jenkins.getViews().create(NestedView.class);
    DashboardView dashboard = nested.getViews().create(DashboardView.class);
    dashboard.configure(() -> {
        dashboard.matchAllJobs();
        dashboard.checkRecurseIntoFolders();
        addWarningsPortlet(dashboard);
    });
    Folder folder = dashboard.jobs.create(Folder.class);
    folder.save();
    folder.open();
    String repoUrl = createGitRepositoryInDockerContainer();
    WorkflowMultiBranchJob job = folder.getJobs().create(WorkflowMultiBranchJob.class);
    GitBranchSource branchSource = job.addBranchSource(GitBranchSource.class);
    branchSource.setRemote(repoUrl);
    branchSource.setCredentials("warnings");
    job.save();
    job.waitForBranchIndexingFinished(20);
    // When
    List<String> jobs = Arrays.asList("master", "branch");
    for (String name : jobs) {
        buildBranch(job, name);
    }
    // Then
    dashboard.open();
    for (String name : jobs) {
        verifyWarningsCountInPortlet(name, dashboard);
    }
    for (AnalysisPlugin plugin : ANALYSIS_PLUGINS) {
        for (String name : jobs) {
            dashboard.open();
            findPortletLink(dashboard, name, plugin.getId()).click();
            assertThat(driver, hasContent(plugin.getName()));
        }
    }
}
Also used : NestedView(org.jenkinsci.test.acceptance.plugins.nested_view.NestedView) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Folder(org.jenkinsci.test.acceptance.po.Folder) WorkflowMultiBranchJob(org.jenkinsci.test.acceptance.po.WorkflowMultiBranchJob) GitBranchSource(org.jenkinsci.test.acceptance.plugins.workflow_multibranch.GitBranchSource) AnalysisPlugin(org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisPlugin) Issue(org.jvnet.hudson.test.Issue) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Aggregations

WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)15 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)15 Test (org.junit.Test)15 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)7 Build (org.jenkinsci.test.acceptance.po.Build)5 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)5 SAMLContainer (org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer)4 SamlSecurityRealm (org.jenkinsci.test.acceptance.plugins.saml.SamlSecurityRealm)4 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)4 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)4 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)4 Issue (org.jvnet.hudson.test.Issue)4 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)3 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)3 Category (org.junit.experimental.categories.Category)3 Matchers.containsString (org.hamcrest.Matchers.containsString)2 WarningsPublisher (org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher)2 TreeMap (java.util.TreeMap)1