diff --git a/encrypted_fields/tests.py b/encrypted_fields/tests.py index 9eb8c5e..dd92376 100644 --- a/encrypted_fields/tests.py +++ b/encrypted_fields/tests.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import re @@ -122,6 +123,21 @@ def test_char_field_encrypted(self): fresh_model = TestModel.objects.get(id=model.id) self.assertEqual(fresh_model.char, plaintext) + def test_unicode_encrypted(self): + plaintext = 'Oh hi, test reader! 🐱' + + model = TestModel() + model.char = plaintext + model.save() + + ciphertext = self.get_db_value('char', model.id) + + self.assertNotEqual(plaintext, ciphertext) + self.assertTrue('test' not in ciphertext) + + fresh_model = TestModel.objects.get(id=model.id) + self.assertEqual(fresh_model.char, plaintext) + def test_short_char_field_encrypted(self): """ Test the max_length validation of an encrypted char field """ plaintext = 'Oh hi, test reader!'