40 lines
1014 B
Go
40 lines
1014 B
Go
package ssh
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func TestIntegrationSSHBackendStatRoot(t *testing.T) {
|
|
host := os.Getenv("DISTRIBUTOR_TEST_SSH_HOST")
|
|
if host == "" {
|
|
t.Skip("DISTRIBUTOR_TEST_SSH_HOST is not set")
|
|
}
|
|
port := 22
|
|
if raw := os.Getenv("DISTRIBUTOR_TEST_SSH_PORT"); raw != "" {
|
|
parsed, err := strconv.Atoi(raw)
|
|
if err != nil {
|
|
t.Fatalf("parse DISTRIBUTOR_TEST_SSH_PORT: %v", err)
|
|
}
|
|
port = parsed
|
|
}
|
|
backend, err := New(context.Background(), Options{
|
|
Host: host,
|
|
User: os.Getenv("DISTRIBUTOR_TEST_SSH_USER"),
|
|
Port: port,
|
|
Root: os.Getenv("DISTRIBUTOR_TEST_SSH_PATH"),
|
|
KeyFile: os.Getenv("DISTRIBUTOR_TEST_SSH_KEY_FILE"),
|
|
KnownHosts: os.Getenv("DISTRIBUTOR_TEST_SSH_KNOWN_HOSTS"),
|
|
HostKeyPolicy: HostKeyPolicyStrict,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("New() error = %v", err)
|
|
}
|
|
defer backend.Close()
|
|
if _, err := backend.Stat(context.Background(), ""); err != nil {
|
|
t.Fatalf("Stat(root) error = %v", err)
|
|
}
|
|
}
|