12
12
EncryptedIntegerField ,
13
13
EncryptedFloatField ,
14
14
EncryptedEmailField ,
15
+ EncryptedBooleanField ,
15
16
)
16
17
17
18
@@ -22,6 +23,7 @@ class TestModel(models.Model):
22
23
integer = EncryptedIntegerField (null = True )
23
24
floating = EncryptedFloatField (null = True )
24
25
email = EncryptedEmailField (null = True )
26
+ boolean = EncryptedBooleanField (default = False )
25
27
26
28
27
29
class FieldTest (TestCase ):
@@ -124,3 +126,23 @@ def test_email_field_encrypted(self):
124
126
125
127
fresh_model = TestModel .objects .get (id = model .id )
126
128
self .assertEqual (fresh_model .email , plaintext )
129
+
130
+ def test_boolean_field_encrypted (self ):
131
+ plaintext = True
132
+
133
+ model = TestModel ()
134
+ model .boolean = plaintext
135
+ model .save ()
136
+
137
+ ciphertext = self .get_db_value ('boolean' , model .id )
138
+
139
+ self .assertNotEqual (plaintext , ciphertext )
140
+ self .assertNotEqual (True , ciphertext )
141
+ self .assertNotEqual ('True' , ciphertext )
142
+ self .assertNotEqual ('true' , ciphertext )
143
+ self .assertNotEqual ('1' , ciphertext )
144
+ self .assertNotEqual (1 , ciphertext )
145
+ self .assertTrue (not isinstance (ciphertext , bool ))
146
+
147
+ fresh_model = TestModel .objects .get (id = model .id )
148
+ self .assertEqual (fresh_model .boolean , plaintext )
0 commit comments