summaryrefslogtreecommitdiff
path: root/tests/e2e/config_test.go
diff options
context:
space:
mode:
authorJames O'Doherty <james@theodohertyfamily.com>2026-05-22 11:37:57 -0400
committerJames O'Doherty <james@theodohertyfamily.com>2026-05-22 11:37:57 -0400
commite5bbb969a15c569cf7d37634234a71783f628390 (patch)
tree546f8282f14be7d3db1050f1f7586ad3c3758143 /tests/e2e/config_test.go
parent079e4240534cbdc8751f1a127def20f2d1e58da6 (diff)
Fix PID lifecycle race and improve CLI routing for diagnostic commands
Diffstat (limited to 'tests/e2e/config_test.go')
-rw-r--r--tests/e2e/config_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/e2e/config_test.go b/tests/e2e/config_test.go
new file mode 100644
index 0000000..83cfc15
--- /dev/null
+++ b/tests/e2e/config_test.go
@@ -0,0 +1,58 @@
+package e2e
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "strings"
+ "testing"
+)
+
+func TestConfigPropagation(t *testing.T) {
+ binaryPath, err := GetBinaryPath()
+ if err != nil {
+ t.Skipf("Skipping test: %v", err)
+ }
+
+ tmpRuntimeDir := t.TempDir()
+ profile := "config-test-vpn"
+
+ // Test 1: Non-isolated configuration
+ cmd := exec.Command(binaryPath, "show-config", "--profile", profile)
+ cmd.Env = append(os.Environ(), fmt.Sprintf("XDG_RUNTIME_DIR=%s", tmpRuntimeDir))
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ t.Fatalf("show-config failed: %v\nOutput: %s", err, string(out))
+ }
+
+ output := string(out)
+ expectedBase := tmpRuntimeDir
+ expectedPids := fmt.Sprintf("%s/profiles/%s/pids", tmpRuntimeDir, profile)
+
+ if !strings.Contains(output, fmt.Sprintf("Runtime Base: %s", expectedBase)) {
+ t.Errorf("Expected Runtime Base %s in output: %s", expectedBase, output)
+ }
+ if !strings.Contains(output, fmt.Sprintf("PIDs Path: %s", expectedPids)) {
+ t.Errorf("Expected PIDs Path %s in output: %s", expectedPids, output)
+ }
+
+ // Test 2: Configuration after bootstrap (Isolated)
+ // We use 'test-ns' as a way to run a command that we know is isolated.
+ // Actually, we can just run 'show-config' but the current 'Route'
+ // handles 'show-config' BEFORE the bootstrap.
+ // To test isolated config, we can't use 'show-config' because it's a diagnostic
+ // command designed to run outside isolation.
+
+ // To verify what an isolated process sees, we can use a target command
+ // that prints the environment.
+ cmdIsolated := exec.Command(binaryPath, "--profile", profile, "--", "sh", "-c", "echo $XDG_RUNTIME_DIR")
+ cmdIsolated.Env = append(os.Environ(), fmt.Sprintf("XDG_RUNTIME_DIR=%s", tmpRuntimeDir))
+ outIso, err := cmdIsolated.CombinedOutput()
+ if err != nil {
+ t.Fatalf("Isolated command failed: %v\nOutput: %s", err, string(outIso))
+ }
+
+ if !strings.Contains(string(outIso), expectedBase) {
+ t.Errorf("Expected isolated process to see XDG_RUNTIME_DIR=%s, got: %s", expectedBase, string(outIso))
+ }
+}