Beispiel #1
0
class DocumentTestCase(unittest.TestCase):
    def setUp(self):
        self.gpg = GPG()
        self.gpg.import_keys(PUB_KEY)

    def testGetCertificateID(self):
        "Test result value of document ID"
        source = DocumentSourceMock((200, CORRECT_CERTIFICATE_WITH_VALID_SIGNATURE))
        document = Document(source)
        self.assertTrue(document.verify())
        self.assertEquals(document.get_id(), '64D0 F8CA 822B BDF0 FF59  42F6 A363 ED80 D8A5 CEFF')

    def testGetSignature(self):
        "Test result value of document signature"
        source = DocumentSourceMock((200, CORRECT_CERTIFICATE_WITH_VALID_SIGNATURE))
        document = Document(source)
        self.assertTrue(document.verify())
        self.assertEquals(document.get_signature(), VALID_SIGNATURE)

    def testGetBody(self):
        "Test result value of document body"
        source = DocumentSourceMock((200, CORRECT_CERTIFICATE_WITH_VALID_SIGNATURE))
        document = Document(source)
        self.assertTrue(document.verify())
        self.assertEquals(document.get_body(), VALID_BODY)

    def testGetRawData(self):
        "Test result value of document raw data"
        source = DocumentSourceMock((200, CORRECT_CERTIFICATE_WITH_VALID_SIGNATURE))
        document = Document(source)
        self.assertTrue(document.verify())
        self.assertEquals(document.get_raw_data(), CORRECT_CERTIFICATE_WITH_VALID_SIGNATURE)
Beispiel #2
0
class DocumentVerificationTestCase(unittest.TestCase):

    def setUp(self):
        self.gpg = GPG()
        self.gpg.import_keys(PUB_KEY)

    def testCorrectCertificateWithValidSignature(self):
        "Test correct certificate with valid signature"
        source = DocumentSourceMock((200, CORRECT_CERTIFICATE_WITH_VALID_SIGNATURE))
        document = Document(source)
        self.assertTrue(document.verify())

    def testCorrectCertificateWithInvalidSignature(self):
        "Test correct certificate with invalid signature"
        source = DocumentSourceMock((200, CORRECT_CERTIFICATE_WITH_INVALID_SIGNATURE))
        document = Document(source)
        self.assertFalse(document.verify())

    def testIncorrectCertificateWithValidSignature(self):
        "Test incorrect certificate with valid signature"
        source = DocumentSourceMock((200, INCORRECT_CERTIFICATE_WITH_VALID_SIGNATURE))
        document = Document(source)
        self.assertTrue(document.verify())