File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,3 +126,7 @@ def role(self):
126126 @property
127127 def account_id (self ) -> str :
128128 return self .request_ctx .user .account_id
129+
130+ @property
131+ def namespace_policy (self ) -> AccountNamespacePolicy :
132+ return self .request_ctx .namespace_policy
Original file line number Diff line number Diff line change 33
44"""Tests for identity types (openviking/server/identity.py)."""
55
6- from openviking .server .identity import RequestContext , ResolvedIdentity , Role
6+ from openviking .server .identity import (
7+ AccountNamespacePolicy ,
8+ RequestContext ,
9+ ResolvedIdentity ,
10+ Role ,
11+ ToolContext ,
12+ )
713from openviking_cli .session .user_id import UserIdentifier
814
915
@@ -51,3 +57,23 @@ def test_request_context_account_id_property():
5157 assert ctx .account_id == "acme"
5258 assert ctx .role == Role .USER
5359 assert ctx .user .account_id == "acme"
60+
61+
62+ def test_tool_context_proxies_namespace_policy_from_request_context ():
63+ policy = AccountNamespacePolicy (
64+ isolate_user_scope_by_agent = True ,
65+ isolate_agent_scope_by_user = True ,
66+ )
67+ request_ctx = RequestContext (
68+ user = UserIdentifier (
69+ account_id = "test-account" ,
70+ user_id = "test-user" ,
71+ agent_id = "test-agent" ,
72+ ),
73+ role = Role .USER ,
74+ namespace_policy = policy ,
75+ )
76+
77+ tool_ctx = ToolContext (viking_fs = object (), request_ctx = request_ctx )
78+
79+ assert tool_ctx .namespace_policy is policy
You can’t perform that action at this time.
0 commit comments