@@ -57,7 +57,7 @@ def authorized_store(backend_config):
5757 config = config_func ()
5858
5959 base_sqlstore = sqlstore_impl (config )
60- authorized_store = AuthorizedSqlStore (base_sqlstore )
60+ authorized_store = AuthorizedSqlStore (base_sqlstore , default_policy () )
6161
6262 yield authorized_store
6363
@@ -106,7 +106,7 @@ async def test_authorized_store_attributes(mock_get_authenticated_user, authoriz
106106 await authorized_store .insert (table_name , {"id" : "1" , "data" : "public_data" })
107107
108108 # Test fetching with no user - should not error on JSON comparison
109- result = await authorized_store .fetch_all (table_name , policy = default_policy () )
109+ result = await authorized_store .fetch_all (table_name )
110110 assert len (result .data ) == 1
111111 assert result .data [0 ]["id" ] == "1"
112112 assert result .data [0 ]["access_attributes" ] is None
@@ -119,15 +119,15 @@ async def test_authorized_store_attributes(mock_get_authenticated_user, authoriz
119119 await authorized_store .insert (table_name , {"id" : "2" , "data" : "admin_data" })
120120
121121 # Fetch all - admin should see both
122- result = await authorized_store .fetch_all (table_name , policy = default_policy () )
122+ result = await authorized_store .fetch_all (table_name )
123123 assert len (result .data ) == 2
124124
125125 # Test with non-admin user
126126 regular_user = User ("regular-user" , {"roles" : ["user" ]})
127127 mock_get_authenticated_user .return_value = regular_user
128128
129129 # Should only see public record
130- result = await authorized_store .fetch_all (table_name , policy = default_policy () )
130+ result = await authorized_store .fetch_all (table_name )
131131 assert len (result .data ) == 1
132132 assert result .data [0 ]["id" ] == "1"
133133
@@ -156,7 +156,7 @@ async def test_authorized_store_attributes(mock_get_authenticated_user, authoriz
156156
157157 # Now test with the multi-user who has both roles=admin and teams=dev
158158 mock_get_authenticated_user .return_value = multi_user
159- result = await authorized_store .fetch_all (table_name , policy = default_policy () )
159+ result = await authorized_store .fetch_all (table_name )
160160
161161 # Should see:
162162 # - public record (1) - no access_attributes
@@ -217,21 +217,24 @@ async def test_user_ownership_policy(mock_get_authenticated_user, authorized_sto
217217 ),
218218 ]
219219
220+ # Create a new authorized store with the owner-only policy
221+ owner_only_store = AuthorizedSqlStore (authorized_store .sql_store , owner_only_policy )
222+
220223 # Test user1 access - should only see their own record
221224 mock_get_authenticated_user .return_value = user1
222- result = await authorized_store .fetch_all (table_name , policy = owner_only_policy )
225+ result = await owner_only_store .fetch_all (table_name )
223226 assert len (result .data ) == 1 , f"Expected user1 to see 1 record, got { len (result .data )} "
224227 assert result .data [0 ]["id" ] == "1" , f"Expected user1's record, got { result .data [0 ]['id' ]} "
225228
226229 # Test user2 access - should only see their own record
227230 mock_get_authenticated_user .return_value = user2
228- result = await authorized_store .fetch_all (table_name , policy = owner_only_policy )
231+ result = await owner_only_store .fetch_all (table_name )
229232 assert len (result .data ) == 1 , f"Expected user2 to see 1 record, got { len (result .data )} "
230233 assert result .data [0 ]["id" ] == "2" , f"Expected user2's record, got { result .data [0 ]['id' ]} "
231234
232235 # Test with anonymous user - should see no records
233236 mock_get_authenticated_user .return_value = None
234- result = await authorized_store .fetch_all (table_name , policy = owner_only_policy )
237+ result = await owner_only_store .fetch_all (table_name )
235238 assert len (result .data ) == 0 , f"Expected anonymous user to see 0 records, got { len (result .data )} "
236239
237240 finally :
0 commit comments