Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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
Esempio n. 6
0
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
Esempio n. 7
0
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
Esempio n. 8
0
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