예제 #1
0
파일: storage_test.go 프로젝트: jiasir/juju
func (s *storageSuite) sshCommand(c *gc.C, host string, command ...string) *ssh.Cmd {
	script := []byte("#!/bin/bash\n" + strings.Join(command, " "))
	err := ioutil.WriteFile(filepath.Join(s.bin, "ssh"), script, 0755)
	c.Assert(err, gc.IsNil)
	client, err := ssh.NewOpenSSHClient()
	c.Assert(err, gc.IsNil)
	return client.Command(host, command, nil)
}
예제 #2
0
파일: ssh_test.go 프로젝트: kapilt/juju
func (s *SSHCommandSuite) SetUpTest(c *gc.C) {
	s.IsolationSuite.SetUpTest(c)
	s.testbin = c.MkDir()
	s.fakessh = filepath.Join(s.testbin, "ssh")
	s.fakescp = filepath.Join(s.testbin, "scp")
	err := ioutil.WriteFile(s.fakessh, []byte(echoScript), 0755)
	c.Assert(err, gc.IsNil)
	err = ioutil.WriteFile(s.fakescp, []byte(echoScript), 0755)
	c.Assert(err, gc.IsNil)
	s.PatchEnvPathPrepend(s.testbin)
	s.client, err = ssh.NewOpenSSHClient()
	c.Assert(err, gc.IsNil)
	s.PatchValue(ssh.DefaultIdentities, nil)
}
예제 #3
0
파일: ssh_test.go 프로젝트: Pankov404/juju
func (s *SSHCommonSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.PatchValue(&getJujuExecutable, func() (string, error) { return "juju", nil })

	s.bin = c.MkDir()
	s.PatchEnvPathPrepend(s.bin)
	for _, name := range patchedCommands {
		f, err := os.OpenFile(filepath.Join(s.bin, name), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0777)
		c.Assert(err, jc.ErrorIsNil)
		_, err = f.Write([]byte(fakecommand))
		c.Assert(err, jc.ErrorIsNil)
		err = f.Close()
		c.Assert(err, jc.ErrorIsNil)
	}
	client, _ := ssh.NewOpenSSHClient()
	s.PatchValue(&ssh.DefaultClient, client)
}
예제 #4
0
파일: run_test.go 프로젝트: Pankov404/juju
func (s *runSuite) mockSSH(c *gc.C, cmd string) {
	gitjujutesting.PatchExecutable(c, s, "ssh", cmd)
	gitjujutesting.PatchExecutable(c, s, "scp", cmd)
	client, _ := ssh.NewOpenSSHClient()
	s.PatchValue(&ssh.DefaultClient, client)
}