aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/transport/ssh/common.go4
-rw-r--r--plumbing/transport/ssh/common_test.go23
2 files changed, 26 insertions, 1 deletions
diff --git a/plumbing/transport/ssh/common.go b/plumbing/transport/ssh/common.go
index 46fda73..05dea44 100644
--- a/plumbing/transport/ssh/common.go
+++ b/plumbing/transport/ssh/common.go
@@ -49,7 +49,9 @@ type runner struct {
func (r *runner) Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
c := &command{command: cmd, endpoint: ep, config: r.config}
if auth != nil {
- c.setAuth(auth)
+ if err := c.setAuth(auth); err != nil {
+ return nil, err
+ }
}
if err := c.connect(); err != nil {
diff --git a/plumbing/transport/ssh/common_test.go b/plumbing/transport/ssh/common_test.go
index 4cc2a06..a724936 100644
--- a/plumbing/transport/ssh/common_test.go
+++ b/plumbing/transport/ssh/common_test.go
@@ -206,3 +206,26 @@ func (c *mockSSHConfig) Get(alias, key string) string {
return a[key]
}
+
+type invalidAuthMethod struct {
+}
+
+func (a *invalidAuthMethod) Name() string {
+ return "invalid"
+}
+
+func (a *invalidAuthMethod) String() string {
+ return "invalid"
+}
+
+func (s *SuiteCommon) TestCommandWithInvalidAuthMethod(c *C) {
+ uploadPack := &UploadPackSuite{}
+ uploadPack.SetUpSuite(c)
+ r := &runner{}
+ auth := &invalidAuthMethod{}
+
+ _, err := r.Command("command", uploadPack.newEndpoint(c, "endpoint"), auth)
+
+ c.Assert(err, NotNil)
+ c.Assert(err, ErrorMatches, "invalid auth method")
+}