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)
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)
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)
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)
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)
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 )
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 )
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)
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)
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)