From 373e597885919fdc4684847e0a96df2d104896a3 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Fri, 21 Apr 2017 11:20:01 +0200 Subject: transport: ssh, NewPublicKeys helper --- plumbing/transport/ssh/auth_method_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'plumbing/transport/ssh/auth_method_test.go') diff --git a/plumbing/transport/ssh/auth_method_test.go b/plumbing/transport/ssh/auth_method_test.go index 412e721..43b34df 100644 --- a/plumbing/transport/ssh/auth_method_test.go +++ b/plumbing/transport/ssh/auth_method_test.go @@ -2,8 +2,11 @@ package ssh import ( "fmt" + "io/ioutil" "os" + "golang.org/x/crypto/ssh/testdata" + . "gopkg.in/check.v1" ) @@ -104,3 +107,22 @@ func (s *SuiteCommon) TestNewSSHAgentAuth(c *C) { c.Assert(k, IsNil) c.Assert(err, Equals, ErrEmptySSHAgentAddr) } + +func (*SuiteCommon) TestNewPublicKeys(c *C) { + auth, err := NewPublicKeys("foo", testdata.PEMBytes["rsa"]) + c.Assert(err, IsNil) + c.Assert(auth, NotNil) +} + +func (*SuiteCommon) TestNewPublicKeysFromFile(c *C) { + f, err := ioutil.TempFile("", "ssh-test") + c.Assert(err, IsNil) + _, err = f.Write(testdata.PEMBytes["rsa"]) + c.Assert(err, IsNil) + c.Assert(f.Close(), IsNil) + defer os.RemoveAll(f.Name()) + + auth, err := NewPublicKeysFromFile("foo", f.Name()) + c.Assert(err, IsNil) + c.Assert(auth, NotNil) +} -- cgit