Search in sources :

Example 6 with SshSlaveLauncher

use of org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher in project acceptance-test-harness by jenkinsci.

the class AbstractAnalysisTest method createDockerAgent.

/**
 * Creates an agent in a Docker container.
 *
 * @return the new agent ready for new builds
 */
protected DumbSlave createDockerAgent() {
    DumbSlave agent = jenkins.slaves.create(DumbSlave.class);
    agent.setExecutors(1);
    agent.remoteFS.set("/tmp/");
    SshSlaveLauncher launcher = agent.setLauncher(SshSlaveLauncher.class);
    JavaGitContainer container = getDockerContainer();
    launcher.host.set(container.ipBound(22));
    launcher.port(container.port(22));
    launcher.setSshHostKeyVerificationStrategy(SshSlaveLauncher.NonVerifyingKeyVerificationStrategy.class);
    launcher.selectCredentials(CREDENTIALS_ID);
    agent.save();
    agent.waitUntilOnline();
    assertThat(agent.isOnline(), is(true));
    return agent;
}
Also used : SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) JavaGitContainer(org.jenkinsci.test.acceptance.docker.fixtures.JavaGitContainer) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave)

Example 7 with SshSlaveLauncher

use of org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher in project acceptance-test-harness by jenkinsci.

the class SshSlavesPluginTest method jvmOptions.

@Test
public void jvmOptions() {
    String option = "-XX:-PrintGC";
    setUp();
    SshSlaveLauncher launcher = configureDefaultSSHSlaveLauncher().pwdCredentials("test", "test");
    launcher.jvmOptions.set(option);
    slave.save();
    verify();
    verifyLog(option);
}
Also used : SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) Matchers.containsString(org.hamcrest.Matchers.containsString) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Example 8 with SshSlaveLauncher

use of org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher in project acceptance-test-harness by jenkinsci.

the class SshSlavesPluginTest method newSlaveWithExistingCredential.

@Test
public void newSlaveWithExistingCredential() throws Exception {
    String username = "xyz";
    String description = "ssh_creds";
    String privateKey = "1212121122121212";
    CredentialsPage c = new CredentialsPage(jenkins, "_");
    c.open();
    SshPrivateKeyCredential sc = c.add(SshPrivateKeyCredential.class);
    sc.username.set(username);
    sc.description.set(description);
    sc.selectEnterDirectly().privateKey.set(privateKey);
    c.create();
    // now verify
    ManagedCredentials mc = new ManagedCredentials(jenkins);
    String href = mc.credentialById("ssh_creds");
    c.setConfigUrl(href);
    verifyValueForCredential(c, sc.username, username);
    // See https://jenkins.io/doc/developer/security/secrets/#secrets-and-configuration-forms, available from Jenkins 2.171
    if (jenkins.getVersion().isNewerThan(new VersionNumber("2.170"))) {
        verifyUnexpectedValueForCredential("Credentials in plain text should not be accessible from Web UI", c, sc.selectEnterDirectly().privateKey, privateKey);
    }
    // Just to make sure the dumb slave is set up properly, we should seed it
    // with a FS root and executors
    final DumbSlave s = jenkins.slaves.create(DumbSlave.class);
    SshSlaveLauncher l = s.setLauncher(SshSlaveLauncher.class);
    l.host.set("127.0.0.1");
    l.credentialsId.select(String.format("%s (%s)", username, description));
}
Also used : SshPrivateKeyCredential(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential) SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) CredentialsPage(org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage) Matchers.containsString(org.hamcrest.Matchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) ManagedCredentials(org.jenkinsci.test.acceptance.plugins.credentials.ManagedCredentials) VersionNumber(hudson.util.VersionNumber) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Example 9 with SshSlaveLauncher

use of org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher in project acceptance-test-harness by jenkinsci.

the class SshSlavesPluginTest method newSlave.

@Test
@Since("1.560")
public void newSlave() {
    // Just to make sure the dumb slave is set up properly, we should seed it
    // with a FS root and executors
    final DumbSlave s = jenkins.slaves.create(DumbSlave.class);
    {
        SshSlaveLauncher l = s.setLauncher(SshSlaveLauncher.class);
        String username = "user1";
        String privateKey = "1212122112";
        String description = "Ssh key";
        l.host.set("127.0.0.1");
        // make sure this exists
        l.credentialsId.resolve();
        try {
            l.credentialsId.select(String.format("%s (%s)", username, description));
            fail();
        } catch (NoSuchElementException e) {
        // ignore
        }
        SshCredentialDialog f = l.addCredential();
        {
            SshPrivateKeyCredential sc = f.select(SshPrivateKeyCredential.class);
            sc.description.set(description);
            sc.username.set(username);
            sc.selectEnterDirectly().privateKey.set(privateKey);
        }
        f.add();
        l.credentialsId.select(String.format("%s (%s)", username, description));
    }
    s.save();
}
Also used : SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) SshPrivateKeyCredential(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential) SshCredentialDialog(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog) Matchers.containsString(org.hamcrest.Matchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) NoSuchElementException(org.openqa.selenium.NoSuchElementException) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) Since(org.jenkinsci.test.acceptance.junit.Since)

Example 10 with SshSlaveLauncher

use of org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher in project acceptance-test-harness by jenkinsci.

the class SshSlavesPluginTest method customStartup.

@Test
public void customStartup() {
    setUp();
    SshSlaveLauncher launcher = configureDefaultSSHSlaveLauncher().pwdCredentials("test", "test");
    launcher.prefixCmd.set("sh -c \"");
    launcher.suffixCmd.set("\"");
    slave.save();
    verify();
    verifyLog("sh -c \"");
}
Also used : SshSlaveLauncher(org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Aggregations

SshSlaveLauncher (org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher)11 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)8 Test (org.junit.Test)8 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)7 Matchers.containsString (org.hamcrest.Matchers.containsString)6 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)6 SshPrivateKeyCredential (org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential)4 Since (org.jenkinsci.test.acceptance.junit.Since)2 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)2 CredentialsPage (org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage)2 ManagedCredentials (org.jenkinsci.test.acceptance.plugins.credentials.ManagedCredentials)2 SshCredentialDialog (org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog)2 NoSuchElementException (org.openqa.selenium.NoSuchElementException)2 VersionNumber (hudson.util.VersionNumber)1 DockerAgentContainer (org.jenkinsci.test.acceptance.docker.fixtures.DockerAgentContainer)1 GitContainer (org.jenkinsci.test.acceptance.docker.fixtures.GitContainer)1 JavaGitContainer (org.jenkinsci.test.acceptance.docker.fixtures.JavaGitContainer)1 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)1 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)1 GitRepo (org.jenkinsci.test.acceptance.plugins.git.GitRepo)1