Beispiel #1
0
def gnupg_key_fingerprint(gnupg_instance: GPG, private_gpg_key: str):
    keys_imported = gnupg_instance.import_keys(private_gpg_key)
    key_fingerprint = keys_imported.fingerprints[0]
    yield key_fingerprint

    if key_fingerprint in gnupg_instance.list_keys(secret=True).fingerprints:
        remove_gpg_key_pair(gpg_binary=gnupg_instance.gpgbinary,
                            fingerprint=key_fingerprint)
Beispiel #2
0
def test_allowed_gpg_keys_not_existing_key(api_instance_source_git: PackitAPI,
                                           gnupg_instance: GPG,
                                           gnupg_key_fingerprint: str):
    api_instance_source_git.up.local_project.git_repo.git.commit(
        message="signed commit",
        gpg_sign=gnupg_key_fingerprint,
        allow_empty=True)
    remove_gpg_key_pair(gpg_binary=gnupg_instance.gpgbinary,
                        fingerprint=gnupg_key_fingerprint)
    api_instance_source_git.up.allowed_gpg_keys = [gnupg_key_fingerprint]
    with pytest.raises(PackitException) as ex:
        api_instance_source_git.up.check_last_commit()
    assert "Cannot receive a gpg key" in str(ex)