7
7
from .routers import TestEncryptedRouter
8
8
9
9
EXPECTED_ENCRYPTED_FIELDS_MAP = {
10
- "encryption__billing" : {
11
- "fields" : [
12
- {
13
- "bsonType" : "string" ,
14
- "path" : "cc_type" ,
15
- "queries" : {"queryType" : "equality" },
16
- },
17
- {
18
- "bsonType" : "long" ,
19
- "path" : "cc_number" ,
20
- "queries" : {"queryType" : "equality" },
21
- },
22
- {
23
- "bsonType" : "decimal" ,
24
- "path" : "account_balance" ,
25
- "queries" : {"queryType" : "range" },
26
- },
27
- ]
28
- },
29
10
"encryption__patientrecord" : {
30
11
"fields" : [
31
12
{
55
36
},
56
37
]
57
38
},
58
- "encryption__patient" : {
59
- "fields" : [
60
- {
61
- "bsonType" : "int" ,
62
- "path" : "patient_id" ,
63
- "queries" : {"queryType" : "equality" },
64
- },
65
- {
66
- "bsonType" : "string" ,
67
- "path" : "patient_name" ,
68
- },
69
- {
70
- "bsonType" : "string" ,
71
- "path" : "patient_notes" ,
72
- "queries" : {"queryType" : "equality" },
73
- },
74
- {
75
- "bsonType" : "date" ,
76
- "path" : "registration_date" ,
77
- "queries" : {"queryType" : "equality" },
78
- },
79
- {
80
- "bsonType" : "bool" ,
81
- "path" : "is_active" ,
82
- "queries" : {"queryType" : "equality" },
83
- },
84
- {"bsonType" : "string" , "path" : "email" , "queries" : {"queryType" : "equality" }},
85
- ]
86
- },
87
- "encryption__patientportaluser" : {
88
- "fields" : [
89
- {"bsonType" : "string" , "path" : "ip_address" , "queries" : {"queryType" : "equality" }},
90
- {"bsonType" : "string" , "path" : "url" , "queries" : {"queryType" : "equality" }},
91
- ]
92
- },
93
- "encryption__encryptednumbers" : {
94
- "fields" : [
95
- {"bsonType" : "int" , "path" : "pos_bigint" , "queries" : {"queryType" : "equality" }},
96
- {"bsonType" : "int" , "path" : "pos_smallint" , "queries" : {"queryType" : "equality" }},
97
- {"bsonType" : "int" , "path" : "smallint" , "queries" : {"queryType" : "equality" }},
98
- ]
99
- },
100
- "encryption__appointment" : {
101
- "fields" : [{"bsonType" : "date" , "path" : "time" , "queries" : {"queryType" : "equality" }}]
102
- },
103
39
}
104
40
105
41
@@ -113,11 +49,8 @@ class EncryptedFieldsManagementCommandTests(TransactionTestCase):
113
49
114
50
def _compare_json (self , json1 , json2 ):
115
51
# Remove keyIds since they are different for each run.
116
- for table in json2 :
117
- for field in json2 [table ]["fields" ]:
118
- del field ["keyId" ]
119
- # TODO: probably we don't need to test the entire mapping, otherwise it
120
- # requires updates every time a new model or field is added!
52
+ for field in json2 ["fields" ]:
53
+ del field ["keyId" ]
121
54
self .assertEqual (json1 , json2 )
122
55
123
56
def test_show_encrypted_fields_map (self ):
@@ -131,7 +64,10 @@ def test_show_encrypted_fields_map(self):
131
64
stdout = out ,
132
65
)
133
66
output_json = json_util .loads (out .getvalue ())
134
- self ._compare_json (EXPECTED_ENCRYPTED_FIELDS_MAP , output_json )
67
+ self ._compare_json (
68
+ EXPECTED_ENCRYPTED_FIELDS_MAP ["encryption__patientrecord" ],
69
+ output_json ["encryption__patientrecord" ],
70
+ )
135
71
136
72
def test_create_encrypted_fields_map (self ):
137
73
self .maxDiff = None
@@ -145,4 +81,7 @@ def test_create_encrypted_fields_map(self):
145
81
stdout = out ,
146
82
)
147
83
output_json = json_util .loads (out .getvalue ())
148
- self ._compare_json (EXPECTED_ENCRYPTED_FIELDS_MAP , output_json )
84
+ self ._compare_json (
85
+ EXPECTED_ENCRYPTED_FIELDS_MAP ["encryption__patientrecord" ],
86
+ output_json ["encryption__patientrecord" ],
87
+ )
0 commit comments