Example #1
0
 def test_incorrect_signature(self):
     """
     Tests extracting signature information when the signature itself is
     wrong.
     """
     with self.settings(PTS_KEYRING_DIRECTORY=self.TEST_KEYRING_DIRECTORY):
         self.assertIsNone(verify_signature(b"This is not a signature"))
Example #2
0
    def test_signed_message_unknown_key(self):
        """
        Tests extracting the signature from a correctly signed message when the
        signer is not found in the keyring.
        """
        with self.settings(PTS_KEYRING_DIRECTORY=self.TEST_KEYRING_DIRECTORY):
            file_path = self.get_test_file_path('signed-message')

            with open(file_path, 'rb') as f:
                self.assertSequenceEqual([], verify_signature(f.read()))
Example #3
0
    def test_signed_message(self):
        """
        Tests extracting the signature from a correctly signed message when the
        signer is found in the keyring.
        """
        with self.settings(PTS_KEYRING_DIRECTORY=self.TEST_KEYRING_DIRECTORY):
            self.import_key_from_test_file('key1.pub')
            file_path = self.get_test_file_path('signed-message')
            expected = [
                ('PTS Tests', '*****@*****.**')
            ]

            with open(file_path, 'rb') as f:
                self.assertEqual(expected, verify_signature(f.read()))
Example #4
0
    def test_utf8_content(self):
        """
        Tests extracting the signature from a message passed as unicode text
        instead of bytes.
        """
        with self.settings(PTS_KEYRING_DIRECTORY=self.TEST_KEYRING_DIRECTORY):
            self.import_key_from_test_file('key1.pub')
            file_path = self.get_test_file_path('signed-message')
            expected = [
                ('PTS Tests', '*****@*****.**')
            ]

            with open(file_path, 'rb') as f:
                content = f.read().decode('utf-8')
                self.assertEqual(expected, verify_signature(content))