Resolve OpenRouter native contract and promote secrets-engine PDP
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a09cbb-87c6-7900-a145-4ce53ba9f1a6
This commit is contained in:
parent
25712f2aad
commit
41f359f2dc
5 changed files with 177 additions and 2 deletions
43
internal/callerauth/openrouter_test.go
Normal file
43
internal/callerauth/openrouter_test.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package callerauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// IR-WP-0004 / WARDEN-WP-0039: a caller binding is representation,
|
||||
// not delegated authority over another system's credentials.
|
||||
func TestOpenRouterNativeCallerBoundary(t *testing.T) {
|
||||
bindings := map[string]string{
|
||||
"ops-warden": "system:serviceaccount:ops-warden:ops-warden",
|
||||
"secrets-engine": "system:serviceaccount:secrets-engine:secrets-engine",
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
name, caller string
|
||||
systems []string
|
||||
denied bool
|
||||
}{
|
||||
{"native lifecycle caller", bindings["secrets-engine"], []string{"secrets-engine"}, false},
|
||||
{"warden own system", bindings["ops-warden"], []string{"ops-warden"}, false},
|
||||
{"warden cannot represent custody owner", bindings["ops-warden"], []string{"railiance-platform"}, true},
|
||||
{"warden cannot impersonate native engine", bindings["ops-warden"], []string{"secrets-engine"}, true},
|
||||
{"radar is recipient not lifecycle caller", "system:serviceaccount:intelligence-radar:intelligence-radar", []string{"secrets-engine"}, true},
|
||||
{"native caller cannot represent custody owner", bindings["secrets-engine"], []string{"railiance-platform"}, true},
|
||||
{"batch must bind every owner", bindings["ops-warden"], []string{"ops-warden", "railiance-platform"}, true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
auth, err := New(ModeEnforce, fakeReviewer{identity: Identity{Username: tc.caller, Audiences: []string{"flex-auth"}}}, "flex-auth", bindings, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = auth.Authorize(context.Background(), "Bearer synthetic-caller", tc.systems)
|
||||
if tc.denied && !errors.Is(err, ErrForbidden) {
|
||||
t.Fatalf("want forbidden, got %v", err)
|
||||
}
|
||||
if !tc.denied && err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue