Exemple #1
0
def test_gen_keypair_if_needed():
    new_enc_keypair = keypairs.EncryptingKeypair()
    assert new_enc_keypair._privkey != None
    assert new_enc_keypair.pubkey != None

    new_sig_keypair = keypairs.SigningKeypair()
    assert new_sig_keypair._privkey != None
    assert new_sig_keypair.pubkey != None
Exemple #2
0
def test_gen_keypair_if_needed():
    new_enc_keypair = keypairs.EncryptingKeypair()
    assert new_enc_keypair._privkey is not None
    assert new_enc_keypair.pubkey is not None
    assert new_enc_keypair.pubkey == new_enc_keypair._privkey.get_pubkey()

    new_sig_keypair = keypairs.SigningKeypair()
    assert new_sig_keypair._privkey is not None
    assert new_sig_keypair.pubkey is not None
    assert new_sig_keypair.pubkey == new_sig_keypair._privkey.get_pubkey()
def test_policy_arrangement_sqlite_keystore(test_keystore):
    alice_keypair_sig = keypairs.SigningKeypair(generate_keys_if_needed=True)
    alice_keypair_enc = keypairs.EncryptingKeypair(generate_keys_if_needed=True)
    bob_keypair_sig = keypairs.SigningKeypair(generate_keys_if_needed=True)

    arrangement_id = b'test'

    # Test add PolicyArrangement
    new_arrangement = test_keystore.add_policy_arrangement(
            datetime.utcnow(), b'test', arrangement_id, alice_pubkey_sig=alice_keypair_sig.pubkey,
            alice_signature=b'test'
    )

    # Test get PolicyArrangement
    query_arrangement = test_keystore.get_policy_arrangement(arrangement_id)
    assert new_arrangement == query_arrangement

    # Test del PolicyArrangement
    test_keystore.del_policy_arrangement(arrangement_id)
    with pytest.raises(keystore.NotFound):
        del_key = test_keystore.get_policy_arrangement(arrangement_id)