MCPcopy
hub / github.com/redis/redis-py / test_acl_log

Method test_acl_log

tests/test_commands.py:440–483  ·  view source on GitHub ↗
(self, r, request)

Source from the content-addressed store, hash-verified

438 @skip_if_redis_enterprise()
439 @pytest.mark.onlynoncluster
440 def test_acl_log(self, r, request):
441 username = "redis-py-user"
442
443 def teardown():
444 r.acl_deluser(username)
445
446 request.addfinalizer(teardown)
447 r.acl_setuser(
448 username,
449 enabled=True,
450 reset=True,
451 commands=["+get", "+set", "+select"],
452 keys=["cache:*"],
453 nopass=True,
454 )
455 r.acl_log_reset()
456
457 user_client = _get_client(
458 redis.Redis, request, flushdb=False, username=username
459 )
460
461 # Valid operation and key
462 assert user_client.set("cache:0", 1)
463 assert user_client.get("cache:0") == b"1"
464
465 # Invalid key
466 with pytest.raises(exceptions.NoPermissionError):
467 user_client.get("violated_cache:0")
468
469 # Invalid operation
470 with pytest.raises(exceptions.NoPermissionError):
471 user_client.hset("cache:0", "hkey", "hval")
472
473 assert isinstance(r.acl_log(), list)
474 assert len(r.acl_log()) == 3
475 assert len(r.acl_log(count=1)) == 1
476 assert isinstance(r.acl_log()[0], dict)
477 expected = r.acl_log(count=1)[0]
478 assert_resp_response_in(
479 r,
480 "client-info",
481 expected,
482 expected.keys(),
483 )
484
485 @skip_if_server_version_lt("6.0.0")
486 @skip_if_redis_enterprise()

Callers

nothing calls this directly

Calls 9

_get_clientFunction · 0.85
assert_resp_response_inFunction · 0.85
acl_setuserMethod · 0.80
acl_log_resetMethod · 0.80
hsetMethod · 0.80
acl_logMethod · 0.80
keysMethod · 0.80
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected