diff options
author | Joshua Sjoding <joshua.sjoding@scjalliance.com> | 2016-02-15 19:44:25 -0800 |
---|---|---|
committer | Joshua Sjoding <joshua.sjoding@scjalliance.com> | 2016-02-15 19:44:25 -0800 |
commit | 45478768e1fa49030b574aec13390fb2d9479836 (patch) | |
tree | ae7a36bc8ab034d660191d3321b63865fa2f0560 /clients/ssh | |
parent | df3481d67f83782c7f29071f5b5e0e83f3435885 (diff) | |
parent | b682f0fbf014cf912fa94f3120fb3626ea7c4325 (diff) | |
download | go-git-45478768e1fa49030b574aec13390fb2d9479836.tar.gz |
Merge remote-tracking branch 'upstream/master' into generic-object-storage
Diffstat (limited to 'clients/ssh')
-rw-r--r-- | clients/ssh/auth_method_test.go | 20 | ||||
-rw-r--r-- | clients/ssh/git_upload_pack.go | 3 | ||||
-rw-r--r-- | clients/ssh/git_upload_pack_test.go | 38 |
3 files changed, 33 insertions, 28 deletions
diff --git a/clients/ssh/auth_method_test.go b/clients/ssh/auth_method_test.go index ca4558d..a87c950 100644 --- a/clients/ssh/auth_method_test.go +++ b/clients/ssh/auth_method_test.go @@ -13,7 +13,7 @@ type SuiteCommon struct{} var _ = Suite(&SuiteCommon{}) -func (s *SuiteRemote) TestKeyboardInteractiveName(c *C) { +func (s *SuiteCommon) TestKeyboardInteractiveName(c *C) { a := &KeyboardInteractive{ User: "test", Challenge: nil, @@ -21,7 +21,7 @@ func (s *SuiteRemote) TestKeyboardInteractiveName(c *C) { c.Assert(a.Name(), Equals, KeyboardInteractiveName) } -func (s *SuiteRemote) TestKeyboardInteractiveString(c *C) { +func (s *SuiteCommon) TestKeyboardInteractiveString(c *C) { a := &KeyboardInteractive{ User: "test", Challenge: nil, @@ -29,7 +29,7 @@ func (s *SuiteRemote) TestKeyboardInteractiveString(c *C) { c.Assert(a.String(), Equals, fmt.Sprintf("user: test, name: %s", KeyboardInteractiveName)) } -func (s *SuiteRemote) TestPasswordName(c *C) { +func (s *SuiteCommon) TestPasswordName(c *C) { a := &Password{ User: "test", Pass: "", @@ -37,7 +37,7 @@ func (s *SuiteRemote) TestPasswordName(c *C) { c.Assert(a.Name(), Equals, PasswordName) } -func (s *SuiteRemote) TestPasswordString(c *C) { +func (s *SuiteCommon) TestPasswordString(c *C) { a := &Password{ User: "test", Pass: "", @@ -45,7 +45,7 @@ func (s *SuiteRemote) TestPasswordString(c *C) { c.Assert(a.String(), Equals, fmt.Sprintf("user: test, name: %s", PasswordName)) } -func (s *SuiteRemote) TestPasswordCallbackName(c *C) { +func (s *SuiteCommon) TestPasswordCallbackName(c *C) { a := &PasswordCallback{ User: "test", Callback: nil, @@ -53,7 +53,7 @@ func (s *SuiteRemote) TestPasswordCallbackName(c *C) { c.Assert(a.Name(), Equals, PasswordCallbackName) } -func (s *SuiteRemote) TestPasswordCallbackString(c *C) { +func (s *SuiteCommon) TestPasswordCallbackString(c *C) { a := &PasswordCallback{ User: "test", Callback: nil, @@ -61,7 +61,7 @@ func (s *SuiteRemote) TestPasswordCallbackString(c *C) { c.Assert(a.String(), Equals, fmt.Sprintf("user: test, name: %s", PasswordCallbackName)) } -func (s *SuiteRemote) TestPublicKeysName(c *C) { +func (s *SuiteCommon) TestPublicKeysName(c *C) { a := &PublicKeys{ User: "test", Signer: nil, @@ -69,7 +69,7 @@ func (s *SuiteRemote) TestPublicKeysName(c *C) { c.Assert(a.Name(), Equals, PublicKeysName) } -func (s *SuiteRemote) TestPublicKeysString(c *C) { +func (s *SuiteCommon) TestPublicKeysString(c *C) { a := &PublicKeys{ User: "test", Signer: nil, @@ -77,7 +77,7 @@ func (s *SuiteRemote) TestPublicKeysString(c *C) { c.Assert(a.String(), Equals, fmt.Sprintf("user: test, name: %s", PublicKeysName)) } -func (s *SuiteRemote) TestPublicKeysCallbackName(c *C) { +func (s *SuiteCommon) TestPublicKeysCallbackName(c *C) { a := &PublicKeysCallback{ User: "test", Callback: nil, @@ -85,7 +85,7 @@ func (s *SuiteRemote) TestPublicKeysCallbackName(c *C) { c.Assert(a.Name(), Equals, PublicKeysCallbackName) } -func (s *SuiteRemote) TestPublicKeysCallbackString(c *C) { +func (s *SuiteCommon) TestPublicKeysCallbackString(c *C) { a := &PublicKeysCallback{ User: "test", Callback: nil, diff --git a/clients/ssh/git_upload_pack.go b/clients/ssh/git_upload_pack.go index 4a4021d..09cb5ab 100644 --- a/clients/ssh/git_upload_pack.go +++ b/clients/ssh/git_upload_pack.go @@ -42,8 +42,7 @@ type GitUploadPackService struct { // NewGitUploadPackService initialises a GitUploadPackService. // TODO: remove this, as the struct is zero-value safe. -func NewGitUploadPackService(url string) *GitUploadPackService { - // url ignored +func NewGitUploadPackService() *GitUploadPackService { return &GitUploadPackService{} } diff --git a/clients/ssh/git_upload_pack_test.go b/clients/ssh/git_upload_pack_test.go index 8626b50..673e0fc 100644 --- a/clients/ssh/git_upload_pack_test.go +++ b/clients/ssh/git_upload_pack_test.go @@ -25,7 +25,7 @@ const ( ) func (s *SuiteRemote) TestConnect(c *C) { - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.Connect(fixRepo), Equals, ErrAuthRequired) } @@ -57,12 +57,18 @@ func (c *sshAgentConn) close() error { return c.pipe.Close() } +func (s *SuiteRemote) SetUpSuite(c *C) { + if os.Getenv("SSH_AUTH_SOCK") == "" { + c.Skip("SSH_AUTH_SOCK is not set") + } +} + func (s *SuiteRemote) TestConnectWithPublicKeysCallback(c *C) { agent, err := newSSHAgentConn() c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) defer func() { c.Assert(r.Disconnect(), IsNil) }() c.Assert(r.connected, Equals, true) @@ -70,17 +76,17 @@ func (s *SuiteRemote) TestConnectWithPublicKeysCallback(c *C) { } func (s *SuiteRemote) TestConnectBadVcs(c *C) { - r := NewGitUploadPackService(fixRepoBadVcs) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepoBadVcs, nil), ErrorMatches, fmt.Sprintf(".*%s.*", fixRepoBadVcs)) } func (s *SuiteRemote) TestConnectNonGit(c *C) { - r := NewGitUploadPackService(fixRepoNonGit) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepoNonGit, nil), Equals, ErrUnsupportedVCS) } func (s *SuiteRemote) TestConnectNonGithub(c *C) { - r := NewGitUploadPackService(fixGitRepoNonGithub) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixGitRepoNonGithub, nil), Equals, ErrUnsupportedRepo) } @@ -92,7 +98,7 @@ func (*mockAuth) Name() string { return "" } func (*mockAuth) String() string { return "" } func (s *SuiteRemote) TestConnectWithAuthWrongType(c *C) { - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, &mockAuth{}), Equals, ErrInvalidAuthMethod) c.Assert(r.connected, Equals, false) } @@ -102,7 +108,7 @@ func (s *SuiteRemote) TestAlreadyConnected(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) defer func() { c.Assert(r.Disconnect(), IsNil) }() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), Equals, ErrAlreadyConnected) @@ -114,14 +120,14 @@ func (s *SuiteRemote) TestDisconnect(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) c.Assert(r.Disconnect(), IsNil) c.Assert(r.connected, Equals, false) } func (s *SuiteRemote) TestDisconnectedWhenNonConnected(c *C) { - r := NewGitUploadPackService("Dear Twinkle") + r := NewGitUploadPackService() c.Assert(r.Disconnect(), Equals, ErrNotConnected) } @@ -130,7 +136,7 @@ func (s *SuiteRemote) TestAlreadyDisconnected(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) c.Assert(r.Disconnect(), IsNil) c.Assert(r.Disconnect(), Equals, ErrNotConnected) @@ -142,7 +148,7 @@ func (s *SuiteRemote) TestServeralConnections(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) c.Assert(r.Disconnect(), IsNil) @@ -158,7 +164,7 @@ func (s *SuiteRemote) TestServeralConnections(c *C) { } func (s *SuiteRemote) TestInfoNotConnected(c *C) { - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() _, err := r.Info() c.Assert(err, Equals, ErrNotConnected) } @@ -168,7 +174,7 @@ func (s *SuiteRemote) TestDefaultBranch(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) defer func() { c.Assert(r.Disconnect(), IsNil) }() @@ -182,7 +188,7 @@ func (s *SuiteRemote) TestCapabilities(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) defer func() { c.Assert(r.Disconnect(), IsNil) }() @@ -192,7 +198,7 @@ func (s *SuiteRemote) TestCapabilities(c *C) { } func (s *SuiteRemote) TestFetchNotConnected(c *C) { - r := NewGitUploadPackService("foo bar") + r := NewGitUploadPackService() pr := &common.GitUploadPackRequest{} pr.Want(core.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) _, err := r.Fetch(pr) @@ -204,7 +210,7 @@ func (s *SuiteRemote) TestFetch(c *C) { c.Assert(err, IsNil) defer func() { c.Assert(agent.close(), IsNil) }() - r := NewGitUploadPackService(fixRepo) + r := NewGitUploadPackService() c.Assert(r.ConnectWithAuth(fixRepo, agent.auth), IsNil) defer func() { c.Assert(r.Disconnect(), IsNil) }() |