Skip to content

Commit

Permalink
🧹 test ssh errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Jan 27, 2024
1 parent c360d7e commit 721e3ef
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions providers/os/connection/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/stretchr/testify/assert"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v10/providers/os/connection/shared"
)

func TestSSHDefaultSettings(t *testing.T) {
Expand All @@ -22,3 +23,17 @@ func TestSSHDefaultSettings(t *testing.T) {
assert.Equal(t, int32(22), conn.conf.Port)
assert.Equal(t, "sudo", conn.conf.Sudo.Executable)
}

func TestSSHProviderError(t *testing.T) {
_, err := NewSshConnection(0, &inventory.Config{Type: shared.Type_Local.String(), Host: "example.local"}, nil)

Check failure on line 28 in providers/os/connection/ssh_test.go

View workflow job for this annotation

GitHub Actions / go-test

shared.Type_Local.String undefined (type shared.ConnectionType has no field or method String)

Check failure on line 28 in providers/os/connection/ssh_test.go

View workflow job for this annotation

GitHub Actions / go-test

shared.Type_Local.String undefined (type shared.ConnectionType has no field or method String)
assert.Equal(t, "provider type does not match", err.Error())
}

func TestSSHAuthError(t *testing.T) {
_, err := NewSshConnection(0, &inventory.Config{Type: shared.Type_SSH.String(), Host: "example.local"}, nil)

Check failure on line 33 in providers/os/connection/ssh_test.go

View workflow job for this annotation

GitHub Actions / go-test

shared.Type_SSH.String undefined (type shared.ConnectionType has no field or method String)

Check failure on line 33 in providers/os/connection/ssh_test.go

View workflow job for this annotation

GitHub Actions / go-test

shared.Type_SSH.String undefined (type shared.ConnectionType has no field or method String)
assert.True(t,
// local testing if ssh agent is available
err.Error() == "dial tcp: lookup example.local: no such host" ||
// local testing without ssh agent
err.Error() == "no authentication method defined")
}

0 comments on commit 721e3ef

Please sign in to comment.