Skip to content

Commit 2fd6b69

Browse files
authored
DRIVERS-2309 test create, createIndexes, and collMod in FLE (#1227)
* add test for "create" and "createIndexes" * test ban on create/collMod validator and createIndexes partialFieldExpression
1 parent 3180970 commit 2fd6b69

9 files changed

+2061
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
runOn:
2+
- minServerVersion: "4.1.10"
3+
database_name: &database_name "default"
4+
collection_name: &collection_name "default"
5+
6+
data: []
7+
tests:
8+
- description: "create is OK"
9+
clientOptions:
10+
autoEncryptOpts:
11+
kmsProviders:
12+
local: {{ local_provider() }}
13+
operations:
14+
# Drop to remove a collection that may exist from previous test runs.
15+
- name: dropCollection
16+
object: database
17+
arguments:
18+
collection: "unencryptedCollection"
19+
- name: createCollection
20+
object: database
21+
arguments:
22+
collection: "unencryptedCollection"
23+
validator:
24+
unencrypted_string: "foo"
25+
- name: assertCollectionExists
26+
object: testRunner
27+
arguments:
28+
database: *database_name
29+
collection: "unencryptedCollection"
30+
- description: "createIndexes is OK"
31+
clientOptions:
32+
autoEncryptOpts:
33+
kmsProviders:
34+
local: {{ local_provider() }}
35+
operations:
36+
# Drop to remove a collection that may exist from previous test runs.
37+
- name: dropCollection
38+
object: database
39+
arguments:
40+
collection: "unencryptedCollection"
41+
- name: createCollection
42+
object: database
43+
arguments:
44+
collection: "unencryptedCollection"
45+
- name: runCommand
46+
object: database
47+
arguments:
48+
command:
49+
createIndexes: "unencryptedCollection"
50+
indexes:
51+
- name: "name"
52+
key: { name: 1 }
53+
- name: assertIndexExists
54+
object: testRunner
55+
arguments:
56+
database: *database_name
57+
collection: "unencryptedCollection"
58+
index: name
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# This test requires libmongocrypt 1.5.0-alpha2.
2+
runOn:
3+
# Require server version 6.0.0 to get behavior added in SERVER-64911.
4+
- minServerVersion: "6.0.0"
5+
# FLE 2 Encrypted collections are not supported on standalone.
6+
topology: [ "replicaset", "sharded" ]
7+
8+
database_name: &database_name "default"
9+
collection_name: &collection_name "default"
10+
data: []
11+
tests:
12+
- description: "create with a validator on an unencrypted field is OK"
13+
clientOptions:
14+
autoEncryptOpts:
15+
kmsProviders:
16+
local: {{ local_provider() }}
17+
encryptedFieldsMap:
18+
"default.encryptedCollection": {{ yamlfile ("encryptedFields.json") }}
19+
operations:
20+
# Drop to remove a collection that may exist from previous test runs.
21+
- name: dropCollection
22+
object: database
23+
arguments:
24+
collection: "encryptedCollection"
25+
- name: createCollection
26+
object: database
27+
arguments:
28+
collection: "encryptedCollection"
29+
validator:
30+
unencrypted_string: "foo"
31+
- name: assertCollectionExists
32+
object: testRunner
33+
arguments:
34+
database: *database_name
35+
collection: "encryptedCollection"
36+
- description: "create with a validator on an encrypted field is an error"
37+
clientOptions:
38+
autoEncryptOpts:
39+
kmsProviders:
40+
local: {{ local_provider() }}
41+
encryptedFieldsMap:
42+
"default.encryptedCollection": {{ yamlfile ("encryptedFields.json") }}
43+
operations:
44+
# Drop to remove a collection that may exist from previous test runs.
45+
- name: dropCollection
46+
object: database
47+
arguments:
48+
collection: "encryptedCollection"
49+
- name: createCollection
50+
object: database
51+
arguments:
52+
collection: "encryptedCollection"
53+
validator:
54+
encryptedIndexed: "foo"
55+
result:
56+
errorContains: "Comparison to encrypted fields not supported"
57+
- description: "collMod with a validator on an unencrypted field is OK"
58+
clientOptions:
59+
autoEncryptOpts:
60+
kmsProviders:
61+
local: {{ local_provider() }}
62+
encryptedFieldsMap:
63+
"default.encryptedCollection": {{ yamlfile ("encryptedFields.json") }}
64+
operations:
65+
# Drop to remove a collection that may exist from previous test runs.
66+
- name: dropCollection
67+
object: database
68+
arguments:
69+
collection: "encryptedCollection"
70+
- name: createCollection
71+
object: database
72+
arguments:
73+
collection: "encryptedCollection"
74+
- name: runCommand
75+
object: database
76+
arguments:
77+
command:
78+
collMod: "encryptedCollection"
79+
validator:
80+
unencrypted_string: "foo"
81+
- description: "collMod with a validator on an encrypted field is an error"
82+
clientOptions:
83+
autoEncryptOpts:
84+
kmsProviders:
85+
local: {{ local_provider() }}
86+
encryptedFieldsMap:
87+
"default.encryptedCollection": {{ yamlfile ("encryptedFields.json") }}
88+
operations:
89+
# Drop to remove a collection that may exist from previous test runs.
90+
- name: dropCollection
91+
object: database
92+
arguments:
93+
collection: "encryptedCollection"
94+
- name: createCollection
95+
object: database
96+
arguments:
97+
collection: "encryptedCollection"
98+
- name: runCommand
99+
object: database
100+
arguments:
101+
command:
102+
collMod: "encryptedCollection"
103+
validator:
104+
encryptedIndexed: "foo"
105+
result:
106+
errorContains: "Comparison to encrypted fields not supported"
107+
- description: "createIndexes with a partialFilterExpression on an unencrypted field is OK"
108+
clientOptions:
109+
autoEncryptOpts:
110+
kmsProviders:
111+
local: {{ local_provider() }}
112+
encryptedFieldsMap:
113+
"default.encryptedCollection": {{ yamlfile ("encryptedFields.json") }}
114+
operations:
115+
# Drop to remove a collection that may exist from previous test runs.
116+
- name: dropCollection
117+
object: database
118+
arguments:
119+
collection: "encryptedCollection"
120+
- name: createCollection
121+
object: database
122+
arguments:
123+
collection: "encryptedCollection"
124+
- name: runCommand
125+
object: database
126+
arguments:
127+
command:
128+
createIndexes: "encryptedCollection"
129+
indexes:
130+
- name: "name"
131+
key: { name: 1 }
132+
partialFilterExpression:
133+
unencrypted_string: "foo"
134+
- name: assertIndexExists
135+
object: testRunner
136+
arguments:
137+
database: *database_name
138+
collection: "encryptedCollection"
139+
index: name
140+
- description: "createIndexes with a partialFilterExpression on an encrypted field is an error"
141+
clientOptions:
142+
autoEncryptOpts:
143+
kmsProviders:
144+
local: {{ local_provider() }}
145+
encryptedFieldsMap:
146+
"default.encryptedCollection": {{ yamlfile ("encryptedFields.json") }}
147+
operations:
148+
# Drop to remove a collection that may exist from previous test runs.
149+
- name: dropCollection
150+
object: database
151+
arguments:
152+
collection: "encryptedCollection"
153+
- name: createCollection
154+
object: database
155+
arguments:
156+
collection: "encryptedCollection"
157+
- name: runCommand
158+
object: database
159+
arguments:
160+
command:
161+
createIndexes: "encryptedCollection"
162+
indexes:
163+
- name: "name"
164+
key: { name: 1 }
165+
partialFilterExpression:
166+
encryptedIndexed: "foo"
167+
result:
168+
errorContains: "Comparison to encrypted fields not supported"
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# This test requires libmongocrypt 1.5.0-alpha2.
2+
runOn:
3+
# Require server version 6.0.0 to get behavior added in SERVER-64911.
4+
- minServerVersion: "6.0.0"
5+
6+
database_name: &database_name "default"
7+
collection_name: &collection_name "default"
8+
data: []
9+
tests:
10+
- description: "create with a validator on an unencrypted field is OK"
11+
clientOptions:
12+
autoEncryptOpts:
13+
kmsProviders:
14+
local: {{ local_provider() }}
15+
schemaMap:
16+
"default.encryptedCollection": {{schema('basic')}}
17+
operations:
18+
# Drop to remove a collection that may exist from previous test runs.
19+
- name: dropCollection
20+
object: database
21+
arguments:
22+
collection: "encryptedCollection"
23+
- name: createCollection
24+
object: database
25+
arguments:
26+
collection: "encryptedCollection"
27+
validator:
28+
unencrypted_string: "foo"
29+
- name: assertCollectionExists
30+
object: testRunner
31+
arguments:
32+
database: *database_name
33+
collection: "encryptedCollection"
34+
- description: "create with a validator on an encrypted field is an error"
35+
clientOptions:
36+
autoEncryptOpts:
37+
kmsProviders:
38+
local: {{ local_provider() }}
39+
schemaMap:
40+
"default.encryptedCollection": {{schema('basic')}}
41+
operations:
42+
# Drop to remove a collection that may exist from previous test runs.
43+
- name: dropCollection
44+
object: database
45+
arguments:
46+
collection: "encryptedCollection"
47+
- name: createCollection
48+
object: database
49+
arguments:
50+
collection: "encryptedCollection"
51+
validator:
52+
encrypted_string: "foo"
53+
result:
54+
errorContains: "Comparison to encrypted fields not supported"
55+
- description: "collMod with a validator on an unencrypted field is OK"
56+
clientOptions:
57+
autoEncryptOpts:
58+
kmsProviders:
59+
local: {{ local_provider() }}
60+
schemaMap:
61+
"default.encryptedCollection": {{schema('basic')}}
62+
operations:
63+
# Drop to remove a collection that may exist from previous test runs.
64+
- name: dropCollection
65+
object: database
66+
arguments:
67+
collection: "encryptedCollection"
68+
- name: createCollection
69+
object: database
70+
arguments:
71+
collection: "encryptedCollection"
72+
- name: runCommand
73+
object: database
74+
arguments:
75+
command:
76+
collMod: "encryptedCollection"
77+
validator:
78+
unencrypted_string: "foo"
79+
- description: "collMod with a validator on an encrypted field is an error"
80+
clientOptions:
81+
autoEncryptOpts:
82+
kmsProviders:
83+
local: {{ local_provider() }}
84+
schemaMap:
85+
"default.encryptedCollection": {{schema('basic')}}
86+
operations:
87+
# Drop to remove a collection that may exist from previous test runs.
88+
- name: dropCollection
89+
object: database
90+
arguments:
91+
collection: "encryptedCollection"
92+
- name: createCollection
93+
object: database
94+
arguments:
95+
collection: "encryptedCollection"
96+
- name: runCommand
97+
object: database
98+
arguments:
99+
command:
100+
collMod: "encryptedCollection"
101+
validator:
102+
encrypted_string: "foo"
103+
result:
104+
errorContains: "Comparison to encrypted fields not supported"
105+
- description: "createIndexes with a partialFilterExpression on an unencrypted field is OK"
106+
clientOptions:
107+
autoEncryptOpts:
108+
kmsProviders:
109+
local: {{ local_provider() }}
110+
schemaMap:
111+
"default.encryptedCollection": {{schema('basic')}}
112+
operations:
113+
# Drop to remove a collection that may exist from previous test runs.
114+
- name: dropCollection
115+
object: database
116+
arguments:
117+
collection: "encryptedCollection"
118+
- name: createCollection
119+
object: database
120+
arguments:
121+
collection: "encryptedCollection"
122+
- name: runCommand
123+
object: database
124+
arguments:
125+
command:
126+
createIndexes: "encryptedCollection"
127+
indexes:
128+
- name: "name"
129+
key: { name: 1 }
130+
partialFilterExpression:
131+
unencrypted_string: "foo"
132+
- name: assertIndexExists
133+
object: testRunner
134+
arguments:
135+
database: *database_name
136+
collection: "encryptedCollection"
137+
index: name
138+
- description: "createIndexes with a partialFilterExpression on an encrypted field is an error"
139+
clientOptions:
140+
autoEncryptOpts:
141+
kmsProviders:
142+
local: {{ local_provider() }}
143+
schemaMap:
144+
"default.encryptedCollection": {{schema('basic')}}
145+
operations:
146+
# Drop to remove a collection that may exist from previous test runs.
147+
- name: dropCollection
148+
object: database
149+
arguments:
150+
collection: "encryptedCollection"
151+
- name: createCollection
152+
object: database
153+
arguments:
154+
collection: "encryptedCollection"
155+
- name: runCommand
156+
object: database
157+
arguments:
158+
command:
159+
createIndexes: "encryptedCollection"
160+
indexes:
161+
- name: "name"
162+
key: { name: 1 }
163+
partialFilterExpression:
164+
encrypted_string: "foo"
165+
result:
166+
errorContains: "Comparison to encrypted fields not supported"

0 commit comments

Comments
 (0)