File: cmds_cnxmgmt.py

package info (click to toggle)
python-redis 6.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,432 kB
  • sloc: python: 60,318; sh: 179; makefile: 128
file content (36 lines) | stat: -rw-r--r-- 752 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# EXAMPLE: cmds_cnxmgmt
# HIDE_START
import redis

r = redis.Redis(decode_responses=True)
# HIDE_END

# STEP_START auth1
# REMOVE_START
r.config_set("requirepass", "temp_pass")
# REMOVE_END
res1 = r.auth(password="temp_pass")
print(res1) # >>> True

res2 = r.auth(password="temp_pass", username="default")
print(res2) # >>> True

# REMOVE_START
assert res1 == True
assert res2 == True
r.config_set("requirepass", "")
# REMOVE_END
# STEP_END

# STEP_START auth2
# REMOVE_START
r.acl_setuser("test-user", enabled=True, passwords=["+strong_password"], commands=["+acl"])
# REMOVE_END
res = r.auth(username="test-user", password="strong_password")
print(res) # >>> True

# REMOVE_START
assert res == True
r.acl_deluser("test-user")
# REMOVE_END
# STEP_END