//go:build darwin || linux package server import ( "context" "os" "path/filepath" "strings" "testing" "github.com/coder/websocket" "git.a-wan.net/alan/pipelines/internal/protocol" ) // terminalHome points the operator's home at a fresh directory, the login // shell at /bin/sh (so tests never read the operator's own profile) and su // at the fake below. func terminalHome(t *testing.T) string { t.Helper() home, err := filepath.EvalSymlinks(t.TempDir()) if err != nil { t.Fatal(err) } original := operatorHomeDirectory operatorHomeDirectory = func() (string, error) { return home, nil } t.Cleanup(func() { operatorHomeDirectory = original }) t.Setenv("SHELL", "/bin/sh") t.Setenv("ENV", "") fakeTerminalSu(t) return home } // fakeSuPassword is the only password the fake su accepts. const fakeSuPassword = "test-password" // fakeSuScript stands in for su on PATH, so tests never need a real // password: `su -l -c