From 23b427f97b552d274f16d3506c739cb474353021 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Wed, 12 Aug 2026 08:30:09 +0200 Subject: [PATCH] toolsrv: fix integration test to provide sandbox.yaml --- cmd/toolsrv/integration_test.go | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/cmd/toolsrv/integration_test.go b/cmd/toolsrv/integration_test.go index 2a65e9d..b40f5d8 100644 --- a/cmd/toolsrv/integration_test.go +++ b/cmd/toolsrv/integration_test.go @@ -53,14 +53,43 @@ func startTestServer(t *testing.T) (socketPath string, cleanup func()) { t.Fatalf("failed to create temp dir: %v", err) } + // Create sandbox config in temp dir + cfgDir := filepath.Join(tmpDir, "ollie") + if err := os.MkdirAll(cfgDir, 0755); err != nil { + os.RemoveAll(tmpDir) + t.Fatalf("failed to create config dir: %v", err) + } + sandboxCfg := `filesystem: + rox: + - /usr + - /lib + - /lib64 + - /bin + - /sbin + - /etc + rwx: + - "{CWD}" + - "{TMPDIR}" + - "{HOME}" +network: + unrestricted: true +` + if err := os.WriteFile(filepath.Join(cfgDir, "sandbox.yaml"), []byte(sandboxCfg), 0644); err != nil { + os.RemoveAll(tmpDir) + t.Fatalf("failed to write sandbox.yaml: %v", err) + } + socketPath = filepath.Join(tmpDir, "toolsrv.sock") cwd, _ := os.Getwd() ctx, cancel := context.WithCancel(context.Background()) cmd := exec.CommandContext(ctx, testToolsrvBinary, "serve", "--cwd", cwd, "--listen", socketPath) cmd.Stderr = os.Stderr - // Set session ID so tool registry is configured - cmd.Env = append(os.Environ(), "OLLIE_SESSION_ID=test-session") + // Set session ID so tool registry is configured, and XDG_CONFIG_HOME so sandbox.yaml is found + cmd.Env = append(os.Environ(), + "OLLIE_SESSION_ID=test-session", + "XDG_CONFIG_HOME="+tmpDir, + ) if err := cmd.Start(); err != nil { cancel()