package main import ( "strings" "testing" ) // --trust-remote-code runs Python from the model repository: only models root listed in runner.json get it, // and the agent cannot ask for it. func TestTrustRemoteCodeOnlyForListedModels(t *testing.T) { cfg, _ := fixture(t) args, err := buildRun(cfg, goodReq(), nil) if err != nil || strings.Contains(strings.Join(args, " "), "--trust-remote-code") { t.Fatalf("not listed: %v %v", args, err) } cfg.TrustRemoteCode = []string{"nvidia/Qwen3.8-27B-NVFP4"} args, err = buildRun(cfg, goodReq(), nil) if err != nil || !strings.Contains(strings.Join(args, " "), "--trust-remote-code") { t.Fatalf("listed: %v %v", args, err) } other := goodReq() other.Model = "nvidia/Other" cfg.TrustRemoteCode = []string{"nvidia/Qwen3.8-27B-NVFP4"} if a, err := buildRun(cfg, other, nil); err == nil && strings.Contains(strings.Join(a, " "), "--trust-remote-code") { t.Fatalf("another model got the flag: %v", a) } asked := goodReq() asked.Args = []string{"--trust-remote-code"} cfg.TrustRemoteCode = nil if _, err := buildRun(cfg, asked, nil); err == nil { t.Fatal("the agent must not be able to ask for --trust-remote-code") } }