go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/_motor/providers/ssh/provider_test.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package ssh_test
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  	"go.mondoo.com/cnquery/motor/providers"
    11  	"go.mondoo.com/cnquery/motor/providers/ssh"
    12  )
    13  
    14  func TestSSHProviderError(t *testing.T) {
    15  	_, err := ssh.New(&providers.Config{Backend: providers.ProviderType_LOCAL_OS, Host: "example.local"})
    16  	assert.Equal(t, "provider type does not match", err.Error())
    17  }
    18  
    19  func TestSSHAuthError(t *testing.T) {
    20  	_, err := ssh.New(&providers.Config{Backend: providers.ProviderType_SSH, Host: "example.local"})
    21  
    22  	assert.True(t,
    23  		// local testing if ssh agent is available
    24  		err.Error() == "dial tcp: lookup example.local: no such host" ||
    25  			// local testing without ssh agent
    26  			err.Error() == "no authentication method defined")
    27  }