@@ -53,15 +53,54 @@ describe('encrypted schema declaration', function() {
53
53
assert . deepEqual ( schema . _buildSchemaMap ( ) , schemaMap ) ;
54
54
} ) ;
55
55
56
- encryptionType === 'qe ' && it ( 'then the generated encryptedFieldsMap is correct' , function ( ) {
56
+ encryptionType === 'queryableEncryption ' && it ( 'then the generated encryptedFieldsMap is correct' , function ( ) {
57
57
assert . deepEqual ( schema . _buildEncryptedFields ( ) , encryptedFields ) ;
58
58
} ) ;
59
59
} ) ;
60
60
}
61
61
} ) ;
62
62
63
63
describe ( 'Tests that fields of valid schema types can be declared as encrypted schemas' , function ( ) {
64
- it ( 'nested schema for csfle' , function ( ) {
64
+ it ( 'mongoose maps with csfle' , function ( ) {
65
+ const schema = new Schema ( {
66
+ field : {
67
+ type : Schema . Types . Map ,
68
+ of : String ,
69
+ encrypt : { keyId : [ KEY_ID ] , algorithm }
70
+ }
71
+ } , { encryptionType : 'csfle' } ) ;
72
+
73
+ assert . ok ( schemaHasEncryptedProperty ( schema , 'field' ) ) ;
74
+
75
+ assert . deepEqual ( schema . _buildSchemaMap ( ) , {
76
+ bsonType : 'object' ,
77
+ properties : {
78
+ field : { encrypt : {
79
+ bsonType : 'object' , algorithm, keyId : [ KEY_ID ]
80
+ } }
81
+ }
82
+ } ) ;
83
+ } ) ;
84
+
85
+ it ( 'mongoose maps with queryableEncryption' , function ( ) {
86
+ const schema = new Schema ( {
87
+ field : {
88
+ type : Schema . Types . Map ,
89
+ of : String ,
90
+ encrypt : { keyId : KEY_ID }
91
+ }
92
+ } , { encryptionType : 'queryableEncryption' } ) ;
93
+
94
+ assert . ok ( schemaHasEncryptedProperty ( schema , 'field' ) ) ;
95
+
96
+ assert . deepEqual ( schema . _buildEncryptedFields ( ) , {
97
+ fields : [
98
+ { path : 'field' , keyId : KEY_ID , bsonType : 'object' }
99
+ ]
100
+ } ) ;
101
+ } ) ;
102
+
103
+ it ( 'subdocument for csfle' , function ( ) {
65
104
const encryptedSchema = new Schema ( {
66
105
encrypted : {
67
106
type : String , encrypt : { keyId : KEY_ID , algorithm }
@@ -85,15 +124,15 @@ describe('encrypted schema declaration', function() {
85
124
}
86
125
} ) ;
87
126
} ) ;
88
- it ( 'nested schema for qe ' , function ( ) {
127
+ it ( 'subdocument for queryableEncryption ' , function ( ) {
89
128
const encryptedSchema = new Schema ( {
90
129
encrypted : {
91
130
type : String , encrypt : { keyId : KEY_ID }
92
131
}
93
- } , { encryptionType : 'qe ' } ) ;
132
+ } , { encryptionType : 'queryableEncryption ' } ) ;
94
133
const schema = new Schema ( {
95
134
field : encryptedSchema
96
- } , { encryptionType : 'qe ' } ) ;
135
+ } , { encryptionType : 'queryableEncryption ' } ) ;
97
136
assert . ok ( schemaHasEncryptedProperty ( schema , [ 'field' , 'encrypted' ] ) ) ;
98
137
99
138
assert . deepEqual ( schema . _buildEncryptedFields ( ) , {
@@ -123,14 +162,14 @@ describe('encrypted schema declaration', function() {
123
162
}
124
163
} ) ;
125
164
} ) ;
126
- it ( 'nested object for qe ' , function ( ) {
165
+ it ( 'nested object for queryableEncryption ' , function ( ) {
127
166
const schema = new Schema ( {
128
167
field : {
129
168
encrypted : {
130
169
type : String , encrypt : { keyId : KEY_ID }
131
170
}
132
171
}
133
- } , { encryptionType : 'qe ' } ) ;
172
+ } , { encryptionType : 'queryableEncryption ' } ) ;
134
173
assert . ok ( schemaHasEncryptedProperty ( schema , [ 'field' , 'encrypted' ] ) ) ;
135
174
assert . deepEqual ( schema . _buildEncryptedFields ( ) , {
136
175
fields : [
@@ -160,13 +199,13 @@ describe('encrypted schema declaration', function() {
160
199
}
161
200
} ) ;
162
201
} ) ;
163
- it ( 'schema with encrypted array for qe ' , function ( ) {
202
+ it ( 'schema with encrypted array for queryableEncryption ' , function ( ) {
164
203
const schema = new Schema ( {
165
204
encrypted : {
166
205
type : [ Number ] ,
167
206
encrypt : { keyId : KEY_ID }
168
207
}
169
- } , { encryptionType : 'qe ' } ) ;
208
+ } , { encryptionType : 'queryableEncryption ' } ) ;
170
209
assert . ok ( schemaHasEncryptedProperty ( schema , [ 'encrypted' ] ) ) ;
171
210
assert . deepEqual ( schema . _buildEncryptedFields ( ) , {
172
211
fields : [
@@ -633,7 +672,7 @@ function primitiveSchemaMapTests() {
633
672
{
634
673
name : 'string' ,
635
674
type : String ,
636
- encryptionType : 'qe ' ,
675
+ encryptionType : 'queryableEncryption ' ,
637
676
schemaMap : {
638
677
bsonType : 'object' ,
639
678
properties : {
@@ -684,7 +723,7 @@ function primitiveSchemaMapTests() {
684
723
} ,
685
724
{
686
725
name : 'boolean' ,
687
- encryptionType : 'qe ' ,
726
+ encryptionType : 'queryableEncryption ' ,
688
727
type : Schema . Types . Boolean ,
689
728
schemaMap : {
690
729
bsonType : 'object' ,
@@ -736,7 +775,7 @@ function primitiveSchemaMapTests() {
736
775
} ,
737
776
{
738
777
name : 'buffer' ,
739
- encryptionType : 'qe ' ,
778
+ encryptionType : 'queryableEncryption ' ,
740
779
type : Schema . Types . Buffer ,
741
780
schemaMap : {
742
781
bsonType : 'object' ,
@@ -788,7 +827,7 @@ function primitiveSchemaMapTests() {
788
827
} ,
789
828
{
790
829
name : 'date' ,
791
- encryptionType : 'qe ' ,
830
+ encryptionType : 'queryableEncryption ' ,
792
831
type : Date ,
793
832
schemaMap : {
794
833
bsonType : 'object' ,
@@ -840,7 +879,7 @@ function primitiveSchemaMapTests() {
840
879
} ,
841
880
{
842
881
name : 'objectid' ,
843
- encryptionType : 'qe ' ,
882
+ encryptionType : 'queryableEncryption ' ,
844
883
type : ObjectId ,
845
884
schemaMap : {
846
885
bsonType : 'object' ,
@@ -892,7 +931,7 @@ function primitiveSchemaMapTests() {
892
931
} ,
893
932
{
894
933
name : 'bigint' ,
895
- encryptionType : 'qe ' ,
934
+ encryptionType : 'queryableEncryption ' ,
896
935
type : BigInt ,
897
936
schemaMap : {
898
937
bsonType : 'object' ,
@@ -944,7 +983,7 @@ function primitiveSchemaMapTests() {
944
983
} ,
945
984
{
946
985
name : 'Decimal128' ,
947
- encryptionType : 'qe ' ,
986
+ encryptionType : 'queryableEncryption ' ,
948
987
type : Decimal128 ,
949
988
schemaMap : {
950
989
bsonType : 'object' ,
@@ -996,7 +1035,7 @@ function primitiveSchemaMapTests() {
996
1035
} ,
997
1036
{
998
1037
name : 'int32' ,
999
- encryptionType : 'qe ' ,
1038
+ encryptionType : 'queryableEncryption ' ,
1000
1039
type : Int32 ,
1001
1040
schemaMap : {
1002
1041
bsonType : 'object' ,
@@ -1048,7 +1087,7 @@ function primitiveSchemaMapTests() {
1048
1087
} ,
1049
1088
{
1050
1089
name : 'double' ,
1051
- encryptionType : 'qe ' ,
1090
+ encryptionType : 'queryableEncryption ' ,
1052
1091
type : Double ,
1053
1092
schemaMap : {
1054
1093
bsonType : 'object' ,
0 commit comments