Skip to content

Commit

Permalink
Use passed-in AuthMethods in rigtest
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke committed Sep 29, 2023
1 parent 6ad339c commit e89df5c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions cmd/rigtest/rigtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ func main() {
port = p
}

var h *Host
switch *proto {
case "ssh":
h = &Host{
hosts = append(hosts, &Host{
Connection: rig.Connection{
SSH: &rig.SSH{
Address: address,
Expand All @@ -169,9 +168,27 @@ func main() {
PasswordCallback: passfunc,
},
},
})
// use a key from memory
key, err := goos.ReadFile(*kp)
if err != nil {
panic(err)
}
authMethods, err := rig.ParseSSHPrivateKey(key, rig.DefaultPasswordCallback)
hosts = append(hosts, &Host{
Connection: rig.Connection{
SSH: &rig.SSH{
Address: address,
Port: port,
User: *usr,
KeyPath: nil,
PasswordCallback: passfunc,
AuthMethods: authMethods,
},
},
})
case "winrm":
h = &Host{
hosts = append(hosts, &Host{
Connection: rig.Connection{
WinRM: &rig.WinRM{
Address: *dh,
Expand All @@ -182,19 +199,18 @@ func main() {
Password: *pwd,
},
},
}
})
case "localhost":
h = &Host{
hosts = append(hosts, &Host{
Connection: rig.Connection{
Localhost: &rig.Localhost{
Enabled: true,
},
},
}
})
default:
panic("unknown protocol " + *proto)
}
hosts = append(hosts, h)
}

t := testRunner{}
Expand Down

0 comments on commit e89df5c

Please sign in to comment.