File tree Expand file tree Collapse file tree 3 files changed +6
-26
lines changed Expand file tree Collapse file tree 3 files changed +6
-26
lines changed Original file line number Diff line number Diff line change 7
7
class Person (EncryptedModel ):
8
8
name = models .CharField ("name" , max_length = 100 )
9
9
ssn = EncryptedCharField ("ssn" , max_length = 11 , queries = ["equality" ])
10
- ssn2 = EncryptedCharField ("ssn" , max_length = 11 , queries = ["equality" ])
11
10
12
11
class Meta :
13
12
required_db_features = {"supports_queryable_encryption" }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
from django .db import connection
2
- from django .test import TestCase , override_settings
2
+ from django .test import TestCase
3
3
4
4
from .models import Person
5
- from .routers import EncryptedRouter
6
5
7
6
8
- @override_settings (DATABASE_ROUTERS = [EncryptedRouter ()])
9
7
class EncryptedModelTests (TestCase ):
10
8
databases = {"default" , "encrypted" }
11
9
12
10
@classmethod
13
11
def setUpTestData (cls ):
14
12
cls .person = Person (ssn = "123-45-6789" )
15
13
16
- def test_encrypted_fields_map_on_instance (self ):
14
+ def test_encrypted_fields_map (self ):
15
+ """ """
17
16
expected = {
18
- "fields" : {
19
- " ssn" : "EncryptedCharField" ,
20
- }
17
+ "fields" : [
18
+ { "path" : " ssn", "bsonType" : "string" , "queries" : [{ "queryType" : "equality" }]}
19
+ ]
21
20
}
22
21
with connection .schema_editor () as editor :
23
22
self .assertEqual (editor ._get_encrypted_fields_map (self .person ), expected )
24
-
25
- def test_non_encrypted_fields_not_included (self ):
26
- with connection .schema_editor () as editor :
27
- encrypted_field_names = editor ._get_encrypted_fields_map (self .person ).get ("fields" )
28
- self .assertNotIn ("name" , encrypted_field_names )
You can’t perform that action at this time.
0 commit comments