Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
    def setup(self):
        self.fname = get_fixture_file("pubkey-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)
Exemplo n.º 3
0
def import_fixture_file_in_random_directory(filename):
    fname = get_fixture_file(filename)
    original = open(fname, 'rb').read()
    # This should be a new, empty directory
    homedir = tempfile.mkdtemp()
    gpgcmd = ["gpg", "--homedir={}".format(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", fname])

    originalkey = openpgpkey_from_data(original)
    return homedir, originalkey
Exemplo n.º 4
0
def test_openpgpkey_from_wrong_data():
    r = openpgpkey_from_data("this is no key!!1")
    assert False
Exemplo n.º 5
0
def test_openpgpkey_from_empty_data():
    r = openpgpkey_from_data("")
    assert False
Exemplo n.º 6
0
def test_openpgpkey_from_no_data():
    r = openpgpkey_from_data(None)
    assert False
Exemplo n.º 7
0
 def test_no_match(self):
     data = get_public_key_data("nothing should match this",
                                homedir=self.homedir)
     newkey = openpgpkey_from_data(data)
     assert False
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 def setup(self):
     data = read_fixture_file("pubkey-1.asc")
     self.key = openpgpkey_from_data(data)