예제 #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)
예제 #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)
예제 #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
예제 #4
0
def test_openpgpkey_from_wrong_data():
    r = openpgpkey_from_data("this is no key!!1")
    assert False
예제 #5
0
def test_openpgpkey_from_empty_data():
    r = openpgpkey_from_data("")
    assert False
예제 #6
0
def test_openpgpkey_from_no_data():
    r = openpgpkey_from_data(None)
    assert False
예제 #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
예제 #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)
예제 #9
0
 def setup(self):
     data = read_fixture_file("pubkey-1.asc")
     self.key = openpgpkey_from_data(data)