oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thin
2
3import (
4 "context"
5 "encoding/json"
6 "os"
7 "path/filepath"
8 "testing"
9 "time"
10
11 "amadan.net/oficina/equipo/internal/runner/provider"
12)
13
14// The log keeps a containment refusal's fixed category (2026-11-20:
15// production logged only provider_account_containment).
16func TestSanitizeKeepsContainmentReason(t *testing.T) {
17 root := t.TempDir()
18 home := filepath.Join(root, "claude-1")
19 id := provider.Identity{AccountID: "token:claude-1", HomeID: "h", ProviderVersion: provider.ClaudeVersion}
20 raw, _ := json.Marshal(id)
21 if os.Mkdir(home, 0700) != nil || os.WriteFile(filepath.Join(home, provider.IdentityFile), raw, 0600) != nil || os.WriteFile(filepath.Join(home, provider.TokenFile), []byte("sk-ant-oat01-canary"), 0600) != nil {
22 t.Fatal("home")
23 }
24 b := provider.Binding{ID: "claude-1", Home: home, AccountID: id.AccountID, Provider: "claude", Token: true, Expected: id, RuntimeRoot: filepath.Join(root, "homes")}
25 l, err := provider.OpenRuntimeCopy(context.Background(), b, func(context.Context, provider.Binding) (provider.Identity, error) { return id, nil }, time.Second)
26 if err != nil {
27 t.Fatal(err)
28 }
29 defer l.Close()
30 if err = os.WriteFile(filepath.Join(l.Binding().Home, provider.TokenFile), []byte("x"), 0600); err != nil {
31 t.Fatal(err)
32 }
33 if got := sanitize(l.CheckCopy(context.Background())); got != "provider_account_containment: runtime_token_credential" {
34 t.Fatalf("logged %q", got)
35 }
36 if got := sanitize(provider.ErrPolicy); got != "provider_policy_rejected" {
37 t.Fatalf("logged %q", got)
38 }
39}
40