Search in sources :

Example 1 with WithDocker

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

the class AnalysisCollectorPluginTest method should_checkout_pipeline_from_git.

/**
 * Creates and builds a pipeline that is version controlled in Git. Basically the same test case as
 * {@link AbstractAnalysisTest#should_navigate_to_result_action_from_pipeline()}. Rather than using the script
 * text box a Git repository is connected.
 */
@Test
@WithPlugins({ "git", "workflow-basic-steps", "workflow-multibranch", "workflow-job", "workflow-durable-task-step" })
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, KEY_FILENAME })
public void should_checkout_pipeline_from_git() {
    String gitRepositoryUrl = createGitRepositoryInDockerContainer();
    WorkflowJob job = jenkins.getJobs().create(WorkflowJob.class);
    job.setJenkinsFileRepository(gitRepositoryUrl, CREDENTIALS_ID);
    job.save();
    Build build = buildSuccessfulJob(job);
    verifyJobResults(job, build);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WorkflowJob(org.jenkinsci.test.acceptance.po.WorkflowJob) 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 2 with WithDocker

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

the class CheckStylePluginTest method should_show_warnings_per_user.

/**
 * Verifies that blaming of warnings works on agents: creates a new project in a Git repository in a docker
 * container. Registers the same docker container as slave agent to build the project. Uses the recorded build
 * results in checkstyle-result.xml (no actual maven goal is invoked). Verifies that the blame information is
 * correctly assigned for each of the warnings. Also checks, that the age is increased for yet another build.
 */
@Test
@WithPlugins({ "git", "dashboard-view", "analysis-core@1.88-SNAPSHOT", "ssh-slaves" })
@WithDocker
@Issue("JENKINS-6748")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
public void should_show_warnings_per_user() {
    // avoid JENKINS-49026
    jenkins.restart();
    DumbSlave agent = createDockerAgent();
    String gitRepositoryUrl = createGitRepositoryInDockerContainer();
    FreeStyleJob job = createFreeStyleJob(jenkins, null, settings -> settings.pattern.set("**/checkstyle-result.xml"));
    job.configure(() -> {
        job.useScm(GitScm.class).url(gitRepositoryUrl).credentials(CREDENTIALS_ID);
        job.setLabelExpression(agent.getName());
    });
    buildSuccessfulJob(job);
    CheckStyleAction action = new CheckStyleAction(job);
    action.open();
    SortedMap<String, Integer> expectedPeople = new TreeMap<>();
    expectedPeople.put("Unknown authors", 1);
    expectedPeople.put("Jenkins-ATH <jenkins-ath@example.org>", 11);
    assertThat(action.getPeopleTabContents(), is(expectedPeople));
    action.find(By.partialLinkText("Jenkins-ATH")).click();
    assertThat(driver, hasContent("Checkstyle Warnings - Jenkins-ATH"));
    action.open();
    SortedMap<String, String> expectedOrigin = new TreeMap<>();
    expectedOrigin.put("Main.java:0", "-");
    expectedOrigin.put("Main.java:2", "Jenkins-ATH");
    expectedOrigin.put("Main.java:4", "Jenkins-ATH");
    expectedOrigin.put("Main.java:6", "Jenkins-ATH");
    expectedOrigin.put("Main.java:9", "Jenkins-ATH");
    expectedOrigin.put("Main.java:13", "Jenkins-ATH");
    expectedOrigin.put("Main.java:18", "Jenkins-ATH");
    expectedOrigin.put("Main.java:23", "Jenkins-ATH");
    expectedOrigin.put("Main.java:24", "Jenkins-ATH");
    expectedOrigin.put("Main.java:27", "Jenkins-ATH");
    assertThat(action.getOriginTabContentsAsStrings(AUTHOR), is(expectedOrigin));
    assertThatAgeIsAt(action, expectedOrigin, 1);
    buildSuccessfulJob(job);
    assertThatAgeIsAt(action, expectedOrigin, 2);
    GraphConfigurationView view = action.configureTrendGraphForUser();
    view.open();
    view.setUserGraph();
    view.save();
    WebElement graph = find(getUsersTrendGraphXpath());
    assertThat(graph.isDisplayed(), is(true));
    verifyNoAuthors(action, true);
    WebElement nothing = getElement(getUsersTrendGraphXpath());
    assertThat(nothing, nullValue());
    verifyNoAuthors(action, false);
}
Also used : CheckStyleAction(org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction) GraphConfigurationView(org.jenkinsci.test.acceptance.plugins.analysis_core.GraphConfigurationView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) TreeMap(java.util.TreeMap) WebElement(org.openqa.selenium.WebElement) 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)

Example 3 with WithDocker

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

the class SAMLPluginTest method authenticationOKFromURL.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationOKFromURL() 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);
    realm.setUrl(createIdPMetadataURL(samlServer));
    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 4 with WithDocker

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

the class SAMLPluginTest method authenticationFail.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationFail() 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);
    configureEncrytion(realm);
    configureAuthorization(sc);
    // SAML service login page
    waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> hasContent("Enter your username and password"));
    // SAML server login
    find(by.id("username")).sendKeys("user1");
    find(by.id("password")).sendKeys("WrOnGpAsSwOrD");
    find(by.button("Login")).click();
    // wait for the login to propagate
    waitFor().withTimeout(5, TimeUnit.SECONDS).until(() -> hasContent("Either no user with the given username could be found, or the password you gave was wrong").matchesSafely(driver));
    assertThat(jenkins.getCurrentUrl(), containsString("simplesaml/module.php/core/loginuserpass.php"));
}
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 5 with WithDocker

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

the class SAMLPluginTest method authenticationOK.

@Test
@WithDocker
@WithPlugins({ "saml", "matrix-auth" })
public void authenticationOK() 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_REDIRECT_BINDING_URI);
    configureEncrytion(realm);
    configureAuthorization(sc);
    // SAML service login page
    waitFor().withTimeout(10, TimeUnit.SECONDS).until(() -> hasContent("Enter your username and password"));
    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)

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