Пример #1
0
def test_encryption_invalid_version():
    pb = PushBullet("apikey", "hunter42")

    original = {"cat": "meow!"}
    encrypted = pb._encrypt_data(original)
    encrypted = "2" + encrypted[1:]

    with pytest.raises(Exception):
        pb._decrypt_data(encrypted)
Пример #2
0
def test_encryption():
    pb = PushBullet("apikey", "hunter42")

    original = {"cat": "meow!"}
    encrypted = pb._encrypt_data(original)
    decrpyted = pb._decrypt_data(encrypted)

    assert original == json.loads(decrpyted)
Пример #3
0
def test_decryption():
    pb = PushBullet(API_KEY, encryption_password="******")
    pb._encryption_key = a2b_base64(
        "1sW28zp7CWv5TtGjlQpDHHG4Cbr9v36fG5o4f74LsKg=")

    test_data = "MSfJxxY5YdjttlfUkCaKA57qU9SuCN8+ZhYg/xieI+lDnQ=="
    decrypted = pb._decrypt_data(test_data)

    assert decrypted == "meow!"