Пример #1
0
 def test_encrypt_binary_directly(self):
     self.content_encoding = None
     unenc, content = em.normalize_before_encryption(
         self.unencrypted, self.content_type, self.content_encoding,
         self.enforce_text_only)
     self.assertEqual(self.content_type, content)
     self.assertEqual(self.unencrypted, unenc)
Пример #2
0
 def test_encrypt_binary_from_base64(self):
     unenc, content = em.normalize_before_encryption(self.unencrypted,
                                                     self.content_type,
                                                     self.content_encoding,
                                                     self.enforce_text_only)
     self.assertEqual(self.content_type, content)
     self.assertEqual(base64.b64decode(self.unencrypted), unenc)
Пример #3
0
 def test_encrypt_text_ignore_encoding(self):
     unenc, content = em.normalize_before_encryption(self.unencrypted,
                                                     self.content_type,
                                                     self.content_encoding,
                                                     self.enforce_text_only)
     self.assertEqual(self.content_type, content)
     self.assertEqual(self.unencrypted, unenc)
Пример #4
0
 def test_encrypt_text_not_normalized_ignore_encoding(self):
     self.content_type = 'text/plain;charset=utf-8'
     unenc, content = em.normalize_before_encryption(
         self.unencrypted, self.content_type, self.content_encoding,
         self.enforce_text_only)
     self.assertEqual(mt.normalize_content_type(self.content_type), content)
     self.assertEqual(self.unencrypted.encode('utf-8'), unenc)
Пример #5
0
 def test_encrypt_binary_from_base64(self):
     unenc, content = em.normalize_before_encryption(self.unencrypted,
                                                     self.content_type,
                                                     self.content_encoding,
                                                     self.enforce_text_only)
     self.assertEqual(self.content_type, content)
     self.assertEqual(base64.b64decode(self.unencrypted), unenc)
Пример #6
0
 def test_encrypt_text_ignore_encoding(self):
     unenc, content = em.normalize_before_encryption(self.unencrypted,
                                                     self.content_type,
                                                     self.content_encoding,
                                                     self.enforce_text_only)
     self.assertEqual(self.content_type, content)
     self.assertEqual(self.unencrypted, unenc)
Пример #7
0
 def test_encrypt_binary_directly(self):
     self.content_encoding = None
     unenc, content = em.normalize_before_encryption(self.unencrypted,
                                                     self.content_type,
                                                     self.content_encoding,
                                                     self.enforce_text_only)
     self.assertEqual(self.content_type, content)
     self.assertEqual(self.unencrypted, unenc)
Пример #8
0
 def test_raises_on_no_payload(self):
     content_type = 'text/plain; charset=ISO-8859-1'
     with self.assertRaises(em.CryptoNoPayloadProvidedException):
         unenc, content = em.normalize_before_encryption(
             None,
             content_type,
             self.content_encoding,
             self.enforce_text_only
         )
Пример #9
0
 def test_raises_on_bogus_content_type(self):
     content_type = 'text/plain; charset=ISO-8859-1'
     with self.assertRaises(em.CryptoContentTypeNotSupportedException):
         unenc, content = em.normalize_before_encryption(
             self.unencrypted,
             content_type,
             self.content_encoding,
             self.enforce_text_only
         )
Пример #10
0
 def test_encrypt_text_not_normalized_ignore_encoding(self):
     self.content_type = 'text/plain;charset=utf-8'
     unenc, content = em.normalize_before_encryption(self.unencrypted,
                                                     self.content_type,
                                                     self.content_encoding,
                                                     self.enforce_text_only)
     self.assertEqual(mt.normalize_content_type(self.content_type),
                      content)
     self.assertEqual(self.unencrypted.encode('utf-8'), unenc)
Пример #11
0
 def test_raises_on_no_payload(self):
     content_type = 'text/plain; charset=ISO-8859-1'
     with self.assertRaises(em.CryptoNoPayloadProvidedException):
         unenc, content = em.normalize_before_encryption(
             None, content_type, self.content_encoding,
             self.enforce_text_only)
Пример #12
0
 def test_raises_on_bogus_content_type(self):
     content_type = 'text/plain; charset=ISO-8859-1'
     with self.assertRaises(em.CryptoContentTypeNotSupportedException):
         unenc, content = em.normalize_before_encryption(
             self.unencrypted, content_type, self.content_encoding,
             self.enforce_text_only)