func (s *S) TestGetSSHCommandsDefaultKeyFile(c *gocheck.C) { rfs := ftesting.RecordingFs{} f, err := rfs.Create(os.ExpandEnv("${HOME}/.ssh/id_rsa.pub")) c.Assert(err, gocheck.IsNil) f.Write([]byte("ssh-rsa ohwait! me@machine")) f.Close() old := fsystem fsystem = &rfs defer func() { fsystem = old }() commands, err := sshCmds() c.Assert(err, gocheck.IsNil) c.Assert(commands[0], gocheck.Equals, "/var/lib/tsuru/add-key ssh-rsa ohwait! me@machine") }
func (s *S) TestGetSSHCommandsDefaultSSHDPath(c *gocheck.C) { rfs := ftesting.RecordingFs{} f, err := rfs.Create("/opt/me/id_dsa.pub") c.Assert(err, gocheck.IsNil) f.Write([]byte("ssh-rsa ohwait! me@machine")) f.Close() old := fsystem fsystem = &rfs defer func() { fsystem = old }() config.Set("docker:ssh:public-key", "/opt/me/id_dsa.pub") defer config.Unset("docker:ssh:public-key") commands, err := sshCmds() c.Assert(err, gocheck.IsNil) c.Assert(commands[1], gocheck.Equals, "sudo /usr/sbin/sshd -D") }