toolsrv: fix integration test to provide sandbox.yaml
This commit is contained in:
parent
3ee4f16653
commit
23b427f97b
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue