示例#1
0
 def testEncryptWithKeyring(self):
     """Test encrypting with a specific keyring."""
     # Where our keyrings are
     pubring=os.path.join(os.getcwd(), "rings", "pubtest.gpg")
     g=gpg.GPG(gpg.findGPG())
     encrypted, warnings=g.encryptString(['*****@*****.**'], 'hello',
         pubring)
     self.assertEncrypted(encrypted)
示例#2
0
 def testNegativeFindGPG(self):
     """Negative test finding gpg."""
     # This should fail to find the requested binary
     try:
         fnd=gpg.findGPG('ThisShouldNotExist')
         self.fail("Shouldn't have found ThisShouldNotExist, got:  " + fnd)
     except exceptions.Exception, e:
         self.assertEquals(str(e), "Cannot find GPG")
示例#3
0
 def testFailingEncryption(self):
     """Test an attempt to encrypt with an invalid key should fail."""
     g=gpg.GPG(gpg.findGPG())
     try:
         encrypted, warnings=g.encryptString(['ThisKeyDoesNotExist'],
             'hello')
         fail("Expected encryption to fail, returned\n" + encrypted
             + " with warnings:\n" + warnings)
     except gpg.EncryptionError, e:
         self.failUnless(str(e).find("public key not found") > 0,
             "Got the wrong error:\n" + str(e))
示例#4
0
 def testEncryptString(self):
     """Test encrypting a string."""
     g=gpg.GPG(gpg.findGPG())
     encrypted, warnings=g.encryptString(['primary'], 'hello')
     self.assertEncrypted(encrypted)
示例#5
0
 def testFindGPG(self):
     """Positive test finding gpg"""
     # Just make sure we got something
     self.failIf(len(gpg.findGPG()) == 0)