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

Method test_acl_modules_commands

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

Source from the content-addressed store, hash-verified

535 @pytest.mark.redismod
536 @skip_if_server_version_lt("7.9.0")
537 def test_acl_modules_commands(self, r, request):
538 default_username = "default"
539 username = "redis-py-user"
540 password = "pass-for-test-user"
541
542 def teardown():
543 r.auth("", default_username)
544 r.acl_deluser(username)
545
546 request.addfinalizer(teardown)
547
548 r.ft().create_index((TextField("txt"),))
549 r.hset("doc1", mapping={"txt": "foo baz"})
550 r.hset("doc2", mapping={"txt": "foo bar"})
551
552 r.acl_setuser(
553 username,
554 enabled=True,
555 reset=True,
556 passwords=[f"+{password}"],
557 categories=["-all"],
558 commands=[
559 "+FT.SEARCH",
560 "-FT.DROPINDEX",
561 "+json.set",
562 "+json.get",
563 "-json.clear",
564 "+bf.reserve",
565 "-bf.info",
566 "+cf.reserve",
567 "+cms.initbydim",
568 "+topk.reserve",
569 "+tdigest.create",
570 "+ts.create",
571 "-ts.info",
572 ],
573 keys=["*"],
574 )
575 r.auth(password, username)
576
577 assert r.ft().search(Query("foo ~bar"))
578 with pytest.raises(exceptions.NoPermissionError):
579 r.ft().dropindex()
580
581 r.json().set("foo", Path.root_path(), "bar")
582 assert r.json().get("foo") == "bar"
583 with pytest.raises(exceptions.NoPermissionError):
584 r.json().clear("foo")
585
586 assert r.bf().create("bloom", 0.01, 1000)
587 assert r.cf().create("cuckoo", 1000)
588 assert r.cms().initbydim("cmsDim", 100, 5)
589 assert r.topk().reserve("topk", 5, 100, 5, 0.9)
590 assert r.tdigest().create("to-tDigest", 10)
591 with pytest.raises(exceptions.NoPermissionError):
592 r.bf().info("bloom")
593
594 assert r.ts().create(1, labels={"Redis": "Labs"})

Callers

nothing calls this directly

Calls 15

TextFieldClass · 0.90
QueryClass · 0.90
create_indexMethod · 0.80
hsetMethod · 0.80
acl_setuserMethod · 0.80
authMethod · 0.80
dropindexMethod · 0.80
root_pathMethod · 0.80
initbydimMethod · 0.80
reserveMethod · 0.80
ftMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected