返回 DeepSeek-Reasonix
authentication_request_scope_test.go
根目录 / internal / control / authentication_request_scope_test.go
1 package control
2
3 import (
4 "context"
5 "reasonix/internal/event"
6 "reasonix/internal/provider"
7 "reasonix/internal/skill"
8 "testing"
9 )
10
11 func TestMissingCredentialBlocksSiblingModel(t *testing.T) {
12 prov := &sessionTitleProviderStub{out: "title"}
13 c := newOwnedTestController(t, Options{
14 ModelRef: "relay/chat", Sink: event.Discard,
15 Authentication: AuthenticationState{Status: AuthenticationMissingCredential, ProviderName: "relay", ModelRef: "relay/chat"},
16 ProviderResolver: &provider.StaticResolver{Descriptors: []provider.Descriptor{{Ref: "relay/title"}}, Providers: map[string]provider.Provider{"relay/title": prov}},
17 })
18 _, _ = c.GenerateSessionTitleForModel(context.Background(), "relay/title", "draft")
19 if len(prov.requests) != 0 {
20 t.Fatalf("same connection is missing a credential but title issued %d request(s)", len(prov.requests))
21 }
22 }
23
24 func TestSubagentRejectionMustNotBlockPrimary(t *testing.T) {
25 c := newOwnedTestController(t, Options{
26 ModelRef: "main/chat",
27 Skills: []skill.Skill{{Name: "helper", Body: "help", RunAs: skill.RunSubagent, Scope: skill.ScopeGlobal}},
28 SkillRunner: func(context.Context, skill.Skill, string, skill.SubagentRunOptions) (string, error) {
29 return "", &provider.AuthError{Provider: "other", Status: 403, KeyEnv: "OTHER_KEY", HasKey: true}
30 },
31 })
32 _, err := c.RunSubagentProfile(context.Background(), "helper", "task", false)
33 if err == nil {
34 t.Fatal("expected subagent rejection")
35 }
36 if !c.AuthenticationState().Ready() {
37 t.Fatalf("other model's rejection blocked main/chat: %+v", c.AuthenticationState())
38 }
39 }
40
40 lines GO