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();
}
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;
}
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;
}
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();
}
Aggregations