def test_encrypt_then_decrypt_multi(mocked_os_urandom, key): d = {'username': '******', 'role': u'admin', 'expiration': 1404737752.972032} for cnt in xrange(200): d[str(cnt)] = cnt enc = encrypt_cookie(key, d) dec = decrypt_cookie(key, enc) assert d == dec
def setup_session_cookie(username, role): """Set a valid session cookie in the browser""" d = dict( username=username, role=role, expiration=time.time() + SESSION_DURATION, ) ciphertext = encrypt_cookie(session_random_key, d) bottle.response.set_cookie('fireletd', ciphertext, httponly=True)
def test_encrypt_then_decrypt(mocked_os_urandom, key): d = dict(longvalue="longstring" * 33, a=1, b=2, c=3) enc = encrypt_cookie(key, d) dec = decrypt_cookie(key, enc) assert d == dec
def test_encrypt_cookie(mocked_os_urandom, key, encrypted_cookie): enc = encrypt_cookie(key, dict(a=1, b='two', c='\0')) assert enc == encrypted_cookie