Skip to content

Commit bd0829e

Browse files
author
Fabien Coelho
committed
blind attempt to encrypt on redis
1 parent d750f0f commit bd0829e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Diff for: test.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
log = logging.getLogger("ctu-test")
1111
# log.setLevel(logging.DEBUG)
1212

13+
SECRET = b"incredible secret key for testing encrypted cache..."
1314

1415
def has_service(host="localhost", port=22):
1516
"""check whether a network TCP/IP service is available."""
@@ -233,14 +234,15 @@ def test_redis():
233234

234235
c0 = redis.Redis(host="localhost")
235236
c1 = ctu.RedisCache(c0)
236-
c2 = ctu.LockedCache(c1, threading.RLock())
237-
run_cached(c2)
238-
assert len(c2) >= 50
239-
assert c2[(1, "a", True)] == 111
240-
assert c2[(3, None, False)] == -17
241-
setgetdel(c2)
237+
c2 = ctu.EncryptedCache(c1, SECRET)
238+
c3 = ctu.LockedCache(c2, threading.RLock())
239+
run_cached(c3)
240+
assert len(c3) >= 50
241+
assert c3[(1, "a", True)] == 111
242+
assert c3[(3, None, False)] == -17
243+
setgetdel(c3)
242244
try:
243-
c2.__iter__()
245+
c3.__iter__()
244246
pytest.fail("not supported")
245247
except Exception as e:
246248
assert "not implemented yet" in str(e)
@@ -546,7 +548,6 @@ def test_cache_key():
546548

547549

548550
def test_encrypted_cache():
549-
SECRET = b"incredible secret key for testing encrypted cache..."
550551
# bytes
551552
cache = ctu.EncryptedCache(ctu.DictCache(), SECRET)
552553
cache[b"Hello"] = b"World!"

0 commit comments

Comments
 (0)