public void testAuthorizeRSAPublicKeyUNIXCurrentUser() { assertEquals( new AuthorizeRSAPublicKeys(ImmutableSet.of("ssh-dss AAAAB")).render(OsFamily.UNIX), "mkdir -p ~/.ssh\n"+ "cat >> ~/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n"+ "\tssh-dss AAAAB\n"+ "END_OF_JCLOUDS_FILE\n"+ "chmod 600 ~/.ssh/authorized_keys\n"); }
String sshDir = homeDir + "{fs}.ssh"; if (authorizeRSAPublicKeys.size() > 0) statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
String sshDir = homeDir + "{fs}.ssh"; if (authorizeRSAPublicKeys.size() > 0) statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testAuthorizeRSAPublicKeyUNIXCurrentUserWith2Keys() { assertEquals( new AuthorizeRSAPublicKeys(ImmutableSet.of("ssh-dss AAAAB", "ssh-dss CCCCD")).render(OsFamily.UNIX), "mkdir -p ~/.ssh\n"+ "cat >> ~/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n"+ "\tssh-dss AAAAB\n"+ "\t\n"+ "\tssh-dss CCCCD\n"+ "END_OF_JCLOUDS_FILE\n"+ "chmod 600 ~/.ssh/authorized_keys\n"); }
String sshDir = homeDir + "{fs}.ssh"; if (authorizeRSAPublicKeys.size() > 0) statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testAuthorizeRSAPublicKeyUNIXSpecifiedDirWith2Keys() { assertEquals( new AuthorizeRSAPublicKeys("/home/me/.ssh", ImmutableSet.of("ssh-dss AAAAB", "ssh-dss CCCCD")) .render(OsFamily.UNIX), "mkdir -p /home/me/.ssh\n"+ "cat >> /home/me/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n"+ "\tssh-dss AAAAB\n"+ "\t\n"+ "\tssh-dss CCCCD\n"+ "END_OF_JCLOUDS_FILE\n"+ "chmod 600 /home/me/.ssh/authorized_keys\n"); }
String sshDir = homeDir + "{fs}.ssh"; if (!authorizeRSAPublicKeys.isEmpty()) statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys, login)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testAuthorizeRSAPublicKeyUNIXSpecifiedDir() { assertEquals( new AuthorizeRSAPublicKeys("/home/me/.ssh", ImmutableSet.of("ssh-dss AAAAB")).render(OsFamily.UNIX), "mkdir -p /home/me/.ssh\n"+ "cat >> /home/me/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n"+ "\tssh-dss AAAAB\n"+ "END_OF_JCLOUDS_FILE\n"+ "chmod 600 /home/me/.ssh/authorized_keys\n"); }
String sshDir = homeDir + "{fs}.ssh"; if (!authorizeRSAPublicKeys.isEmpty()) statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys, login)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
@Test(expectedExceptions = UnsupportedOperationException.class) public void testAuthorizeRSAPublicKeyWINDOWS() { new AuthorizeRSAPublicKeys(ImmutableSet.of("ssh-dss AAAAB")).render(OsFamily.WINDOWS); } }
String sshDir = homeDir + "{fs}.ssh"; if (!authorizeRSAPublicKeys.isEmpty()) statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys, login)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testAuthorizeRSAPublicKeyUNIXSpecifiedDir() { assertEquals( new AuthorizeRSAPublicKeys("/home/me/.ssh", ImmutableSet.of("ssh-dss AAAAB"), "jclouds").render(OsFamily.UNIX), "mkdir -p /home/me/.ssh\n" + "cat >> /home/me/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n" + "\tssh-dss AAAAB\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 /home/me/.ssh/authorized_keys\n" + "chown -R jclouds /home/me/.ssh\n"); }
@Override public Statement apply(TemplateOptions options) { List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()))); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
public void testAuthorizeRSAPublicKeyUNIXNoOwner() { assertEquals( new AuthorizeRSAPublicKeys(ImmutableSet.of("ssh-dss AAAAB")).render(OsFamily.UNIX), "mkdir -p ~/.ssh\n" + "cat >> ~/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n" + "\tssh-dss AAAAB\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 ~/.ssh/authorized_keys\n"); }
@Override public Statement apply(TemplateOptions options) { List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()))); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
public void testAuthorizeRSAPublicKeyUNIXCurrentUserWith2Keys() { assertEquals( new AuthorizeRSAPublicKeys(ImmutableSet.of("ssh-dss AAAAB", "ssh-dss CCCCD"), "jclouds").render(OsFamily.UNIX), "mkdir -p ~/.ssh\n" + "cat >> ~/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n" + "\tssh-dss AAAAB\n" + "\t\n" + "\tssh-dss CCCCD\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 ~/.ssh/authorized_keys\n" + "chown -R jclouds ~/.ssh\n"); }
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { String user = options.getLoginUser(); if (user == null && node.getCredentials() != null) { user = node.getCredentials().getUser(); } List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()), user)); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
public void testAuthorizeRSAPublicKeyUNIXSpecifiedDirWith2Keys() { assertEquals( new AuthorizeRSAPublicKeys("/home/me/.ssh", ImmutableSet.of("ssh-dss AAAAB", "ssh-dss CCCCD"), "jclouds") .render(OsFamily.UNIX), "mkdir -p /home/me/.ssh\n" + "cat >> /home/me/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n" + "\tssh-dss AAAAB\n" + "\t\n" + "\tssh-dss CCCCD\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 /home/me/.ssh/authorized_keys\n" + "chown -R jclouds /home/me/.ssh\n"); }
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { String user = options.getLoginUser(); if (user == null && node.getCredentials() != null) { user = node.getCredentials().getUser(); } List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()), user)); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
public void testAuthorizeRSAPublicKeyUNIXCurrentUser() { assertEquals( new AuthorizeRSAPublicKeys(ImmutableSet.of("ssh-dss AAAAB"), "jclouds").render(OsFamily.UNIX), "mkdir -p ~/.ssh\n" + "cat >> ~/.ssh/authorized_keys <<-'END_OF_JCLOUDS_FILE'\n" + "\tssh-dss AAAAB\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 ~/.ssh/authorized_keys\n" + "chown -R jclouds ~/.ssh\n"); }