@@ -196,22 +196,20 @@ async def test_acl_categories_multi_exec_squash(df_local_factory):
196
196
async def test_acl_deluser (df_server ):
197
197
client = aioredis .Redis (port = df_server .port )
198
198
199
- try :
200
- res = await client .execute_command ("ACL DELUSER adi" )
201
- except redis .exceptions .ResponseError as e :
202
- assert e .args [0 ] == "User adi does not exist"
199
+ with pytest .raises (redis .exceptions .ResponseError ):
200
+ await client .execute_command ("ACL DELUSER random" )
203
201
204
- res = await client .execute_command ("ACL SETUSER adi ON >pass +@transaction +@string" )
202
+ res = await client .execute_command ("ACL SETUSER george ON >pass +@transaction +@string" )
205
203
assert res == b"OK"
206
204
207
- res = await client .execute_command ("AUTH adi pass" )
205
+ res = await client .execute_command ("AUTH george pass" )
208
206
assert res == b"OK"
209
207
210
208
await client .execute_command ("MULTI" )
211
209
await client .execute_command ("SET key 44" )
212
210
213
211
admin_client = aioredis .Redis (port = df_server .port )
214
- await admin_client .execute_command ("ACL DELUSER adi " )
212
+ await admin_client .execute_command ("ACL DELUSER george " )
215
213
216
214
with pytest .raises (redis .exceptions .ConnectionError ):
217
215
await client .execute_command ("EXEC" )
@@ -220,7 +218,7 @@ async def test_acl_deluser(df_server):
220
218
221
219
222
220
script = """
223
- for i = 1, 10000 do
221
+ for i = 1, 100000 do
224
222
redis.call('SET', 'key', i)
225
223
redis.call('SET', 'key1', i)
226
224
redis.call('SET', 'key2', i)
@@ -244,7 +242,7 @@ async def test_acl_del_user_while_running_lua_script(df_server):
244
242
245
243
for i in range (1 , 4 ):
246
244
res = await admin_client .get (f"key{ i } " )
247
- assert res == b"10000 "
245
+ assert res == b"100000 "
248
246
249
247
await admin_client .close ()
250
248
@@ -258,12 +256,28 @@ async def test_acl_with_long_running_script(df_server):
258
256
259
257
await asyncio .gather (
260
258
client .eval (script , 4 , "key" , "key1" , "key2" , "key3" ),
261
- admin_client .execute_command ("ACL SETUSER -@string -@scripting" ),
259
+ admin_client .execute_command ("ACL SETUSER roman -@string -@scripting" ),
262
260
)
263
261
264
262
for i in range (1 , 4 ):
265
263
res = await admin_client .get (f"key{ i } " )
266
- assert res == b"10000 "
264
+ assert res == b"100000 "
267
265
268
266
await client .close ()
269
267
await admin_client .close ()
268
+
269
+
270
+ @pytest .mark .asyncio
271
+ async def test_acl_whoami (async_client ):
272
+ await async_client .execute_command ("ACL SETUSER kostas >kk +@ALL ON" )
273
+
274
+ with pytest .raises (redis .exceptions .ResponseError ):
275
+ await async_client .execute_command ("ACL WHOAMI WHO" )
276
+
277
+ result = await async_client .execute_command ("ACL WHOAMI" )
278
+ assert result == "User is default"
279
+
280
+ result = await async_client .execute_command ("AUTH kostas kk" )
281
+
282
+ result = await async_client .execute_command ("ACL WHOAMI" )
283
+ assert result == "User is kostas"
0 commit comments