Search in sources :

Example 1 with SshCredentialDialog

use of org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog in project acceptance-test-harness by jenkinsci.

the class TSRCreateSlaveTest method newSlave.

@Test
@Since("1.560")
public void newSlave() {
    // this test requires a newer version of credentials plugin that has inline "Add" button
    // I'm not sure exactly which version it is, but 1.532 LTS doesn't have it, and 1.555 has it,
    // so it's somewhere in between
    // TODO: this should be converted to "@WithPlugin("ssh-credentials") with specific version tag,
    // not the core version
    // 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) Since(org.jenkinsci.test.acceptance.junit.Since)

Example 2 with SshCredentialDialog

use of org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog in project acceptance-test-harness by jenkinsci.

the class SshSlaveLauncher method pwdCredentials.

/**
 * Add username/password based credentials to the configuration
 *
 * @param username to use
 * @param password for the username
 * @return the SshSlaveLauncher to be configured
 */
public SshSlaveLauncher pwdCredentials(String username, String password) {
    final SshCredentialDialog dia = this.addCredential();
    final UserPwdCredential cred = dia.select(UserPwdCredential.class);
    cred.username.set(username);
    cred.password.set(password);
    // credentials are identified by their id. Set username as id so it can be found by it
    cred.setId(username);
    cred.add();
    waitForCredentialVisible(username);
    return this;
}
Also used : SshCredentialDialog(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog) UserPwdCredential(org.jenkinsci.test.acceptance.plugins.credentials.UserPwdCredential)

Example 3 with SshCredentialDialog

use of org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog in project acceptance-test-harness by jenkinsci.

the class SshSlaveLauncher method keyCredentials.

/**
 * Add username/key based credentials to the configuration
 *
 * @param username to use
 * @param key for the private key to use
 * @return the SshSlaveLauncher to be configured
 */
public SshSlaveLauncher keyCredentials(String username, String key, @CheckForNull String passphrase) {
    final SshCredentialDialog dia = this.addCredential();
    final SshPrivateKeyCredential cred = dia.select(SshPrivateKeyCredential.class);
    cred.username.set(username);
    if (passphrase != null) {
        cred.passphrase.set(passphrase);
    }
    cred.enterDirectly(key);
    cred.add();
    waitForCredentialVisible(username);
    return this;
}
Also used : SshPrivateKeyCredential(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential) SshCredentialDialog(org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog)

Example 4 with SshCredentialDialog

use of org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog 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)

Aggregations

SshCredentialDialog (org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog)4 SshPrivateKeyCredential (org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshPrivateKeyCredential)3 Matchers.containsString (org.hamcrest.Matchers.containsString)2 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)2 Since (org.jenkinsci.test.acceptance.junit.Since)2 SshSlaveLauncher (org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher)2 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)2 Test (org.junit.Test)2 NoSuchElementException (org.openqa.selenium.NoSuchElementException)2 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)1 UserPwdCredential (org.jenkinsci.test.acceptance.plugins.credentials.UserPwdCredential)1