sync: migrate ai-operator to Gitea (2026-08-10)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package handoff
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPolicy(t *testing.T) {
|
||||
d := Authorize(PolicyContext{State: "READY_TO_HELP", Route: "test", HandoffEnabled: false, HandoffMode: HandoffModeARIRedirect, AllowInTestRouteOnly: true, HasTarget: true})
|
||||
if !d.Allowed || !d.StubOnly {
|
||||
t.Fatalf("disabled must be stub only: %+v", d)
|
||||
}
|
||||
d = Authorize(PolicyContext{State: "READY_TO_HELP", Route: "test", HandoffEnabled: true, HandoffMode: HandoffModeARIRedirect, AllowInTestRouteOnly: true})
|
||||
if !d.StubOnly || d.ReasonCode != "not_configured" {
|
||||
t.Fatalf("missing target should stub: %+v", d)
|
||||
}
|
||||
d = Authorize(PolicyContext{State: "READY_TO_HELP", Route: "production", HandoffEnabled: true, HandoffMode: HandoffModeARIRedirect, AllowInTestRouteOnly: true, HasTarget: true})
|
||||
if !d.StubOnly {
|
||||
t.Fatalf("production should stub: %+v", d)
|
||||
}
|
||||
d = Authorize(PolicyContext{State: "ENDED", Route: "test", HandoffEnabled: true, HandoffMode: HandoffModeDisabledStub})
|
||||
if d.Allowed {
|
||||
t.Fatalf("ended should deny: %+v", d)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user