test: support ipv6

This commit is contained in:
appleboy 2024-03-16 11:00:25 +08:00
parent 7d0a886109
commit 6d352880f5
No known key found for this signature in database
2 changed files with 30 additions and 31 deletions

View File

@ -27,7 +27,9 @@ jobs:
testing: testing:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: golang:1.21-alpine container:
image: golang:1.21-alpine
options: --sysctl net.ipv6.conf.all.disable_ipv6=0
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

@ -432,7 +432,6 @@ func getHostPublicKeyFile(keypath string) (ssh.PublicKey, error) {
} }
pubkey, _, _, _, err = ssh.ParseAuthorizedKey(buf) pubkey, _, _, _, err = ssh.ParseAuthorizedKey(buf)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -965,33 +964,31 @@ func TestSudoCommand(t *testing.T) {
assert.Equal(t, unindent(expected), unindent(buffer.String())) assert.Equal(t, unindent(expected), unindent(buffer.String()))
} }
// TODO: TestCommandWithIPv6 is not working on github actions. func TestCommandWithIPv6(t *testing.T) {
// func TestCommandWithIPv6(t *testing.T) { var (
// var ( buffer bytes.Buffer
// buffer bytes.Buffer expected = `
// expected = ` ======CMD======
// ======CMD====== whoami
// whoami ======END======
// ======END====== out: ubuntu
// out: drone-scp `
// ` )
// )
// plugin := Plugin{ plugin := Plugin{
// Config: Config{ Config: Config{
// Host: []string{"::1"}, Host: []string{"2402:1f00:8000:800::2628"},
// Username: "drone-scp", Username: "ubuntu",
// Port: 22, Port: 22,
// KeyPath: "./tests/.ssh/id_rsa", Password: "1234567890",
// Script: []string{ Script: []string{
// "whoami", "whoami",
// }, },
// Protocol: easyssh.PROTOCOL_TCP6, Protocol: easyssh.PROTOCOL_TCP6,
// CommandTimeout: 10 * time.Second, CommandTimeout: 10 * time.Second,
// }, },
// Writer: &buffer, Writer: &buffer,
// } }
assert.Nil(t, plugin.Exec())
// assert.Nil(t, plugin.Exec()) assert.Equal(t, unindent(expected), unindent(buffer.String()))
// assert.Equal(t, unindent(expected), unindent(buffer.String())) }
// }