def test_get_all_public_key_data(self): # Hm. The behaviour of something that matches # more than one key may change. data = get_public_key_data("", homedir=self.homedir) newkey = openpgpkey_from_data(data) # Hrm. We may be better off checking for a few things # we actually care about rather than delegating to the Key() itself. assert_equals(self.originalkey, newkey)
def import_key_from_file(fixture, homedir): fname = get_fixture_file(fixture) original = open(fname, 'rb').read() gpgcmd = ["gpg", "--homedir={}".format(homedir)] # Now we import a single key check_call(gpgcmd + ["--import", fname]) return openpgpkey_from_data(original)
def setup(self): self.fname = get_fixture_file("seckey-no-pw-1.asc") original = open(self.fname, 'rb').read() # This should be a new, empty directory self.homedir = tempfile.mkdtemp() gpgcmd = ["gpg", "--homedir={}".format(self.homedir)] # The directory should not have any keys # I don't know how to easily check for that, though # Now we import a single key check_call(gpgcmd + ["--import", self.fname]) self.originalkey = openpgpkey_from_data(original)
def setup(self): self.fname = get_fixture_file("seckey-1.asc") original = open(self.fname, 'r').read() # This should be a new, empty directory self.homedir = tempfile.mkdtemp() gpgcmd = ["gpg", "--homedir={}".format(self.homedir)] # The directory should not have any keys # I don't know how to easily check for that, though # Now we import a single key check_call(gpgcmd + ["--import", self.fname]) self.originalkey = openpgpkey_from_data(original)
def test_no_match(self): data = get_public_key_data("nothing should match this", homedir=self.homedir) newkey = openpgpkey_from_data(data) assert False
def test_get_public_key_data(self): fpr = self.originalkey.fingerprint data = get_public_key_data(fpr, homedir=self.homedir) newkey = openpgpkey_from_data(data) assert_equals(fpr, newkey.fingerprint)
def setup(self): data = read_fixture_file("pubkey-1.asc") self.key = openpgpkey_from_data(data)
def load_key(key): f = read_fixture_file(key) k = gpgmeh.openpgpkey_from_data(f) return k