fix(auth): harden multi-account profile compatibility
Preserve manual-token defaults across explicit profile refreshes and selective logout while keeping legacy marker behavior compatible. Make profile login, refresh, switch, and logout writes rollback-safe; reject unsupported future profile versions before remote side effects; and prevent cross-profile token fallback. Forward token overrides through usage recording, use the newly authenticated identity for post-login authorization, distinguish unavailable profile state, and propagate Windows registry deletion failures.
This commit is contained in:
1 parent
e9360fe11b
commit
5224d9c527
19 files changed
+1656
-132
No files matched your search
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
type crossPlatformCoverageCaller struct {
|
||||
args map[string]any
|
||||
token string
|
||||
dryRun bool
|
||||
}
|
||||
|
||||
@@ -33,6 +34,16 @@ func (c *crossPlatformCoverageCaller) CallTool(_ context.Context, _, _ string, a
|
||||
return &edition.ToolResult{}, nil
|
||||
}
|
||||
|
||||
func (c *crossPlatformCoverageCaller) CallToolWithToken(
|
||||
_ context.Context,
|
||||
token, _, _ string,
|
||||
args map[string]any,
|
||||
) (*edition.ToolResult, error) {
|
||||
c.token = token
|
||||
c.args = args
|
||||
return &edition.ToolResult{}, nil
|
||||
}
|
||||
|
||||
func (*crossPlatformCoverageCaller) Format() string { return "json" }
|
||||
func (c *crossPlatformCoverageCaller) DryRun() bool { return c.dryRun }
|
||||
func (*crossPlatformCoverageCaller) Fields() string { return "id,name" }
|
||||
@@ -88,6 +99,23 @@ func TestCrossPlatformCoverageRecordingToolCaller(t *testing.T) {
|
||||
t.Fatal("sensitive text must not be recorded")
|
||||
}
|
||||
|
||||
tokenCaller, ok := caller.(tokenOverrideToolCaller)
|
||||
if !ok {
|
||||
t.Fatal("recording caller dropped token override support")
|
||||
}
|
||||
if _, err := tokenCaller.CallToolWithToken(
|
||||
context.Background(),
|
||||
"temporary-token",
|
||||
"contact",
|
||||
"get_current_user_profile",
|
||||
nil,
|
||||
); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if inner.token != "temporary-token" || len(inner.args) != 0 {
|
||||
t.Fatalf("token override forwarding = token %q args %#v", inner.token, inner.args)
|
||||
}
|
||||
|
||||
inner.dryRun = true
|
||||
if _, err := caller.CallTool(context.Background(), "chat", "send_message", args); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -96,7 +124,7 @@ func TestCrossPlatformCoverageRecordingToolCaller(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(records) != 1 {
|
||||
if len(records) != 2 {
|
||||
t.Fatalf("dry-run call must not be recorded: %#v", records)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user