Skip to content

Commit 2c2dbd4

Browse files
committed
test(NODE-3777): move csfle back to integration
1 parent 2f1c62a commit 2c2dbd4

7 files changed

+36
-57
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"check:tls": "mocha --config test/manual/mocharc.json test/manual/tls_support.test.js",
117117
"check:ldap": "mocha --config test/manual/mocharc.json test/manual/ldap.test.js",
118118
"check:socks5": "mocha --config test/manual/mocharc.json test/manual/socks5.test.ts",
119-
"check:csfle": "mocha --config test/mocha_mongodb.json test/manual/client-side-encryption",
119+
"check:csfle": "mocha --config test/mocha_mongodb.json test/integration/client-side-encryption",
120120
"check:snappy": "mocha test/unit/assorted/snappy.test.js",
121121
"prepare": "node etc/prepare.js",
122122
"release": "standard-version -i HISTORY.md",

test/manual/client-side-encryption/client_side_encryption.prose.test.js renamed to test/integration/client-side-encryption/client_side_encryption.prose.test.js

+35-56
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,6 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
162162
);
163163
});
164164

165-
beforeEach(async function () {
166-
await clientNoTls.connect();
167-
await clientWithTls.connect();
168-
await clientWithTlsExpired.connect();
169-
await clientWithInvalidHostname.connect();
170-
await dropCollection(clientNoTls.db(keyVaultDbName), keyVaultCollName);
171-
await dropCollection(clientNoTls.db(keyVaultDbName), keyVaultCollName);
172-
});
173-
174-
afterEach(async function () {
175-
await clientNoTls.close();
176-
await clientWithTls.close();
177-
await clientWithTlsExpired.close();
178-
await clientWithInvalidHostname.close();
179-
});
180-
181165
// Case 1.
182166
context('Case 1: AWS', metadata, function () {
183167
const masterKey = {
@@ -188,40 +172,39 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
188172
const masterKeyExpired = { ...masterKey, endpoint: '127.0.0.1:8000' };
189173
const masterKeyInvalidHostname = { ...masterKey, endpoint: '127.0.0.1:8001' };
190174

191-
it('fails with no tls', metadata, async function () {
175+
it('fails with various invalid tls options', metadata, async function () {
192176
try {
177+
await clientNoTls.connect();
193178
await clientEncryptionNoTls.createDataKey('aws', { masterKey });
194179
expect.fail('it must fail with no tls');
195180
} catch (e) {
196181
expect(e.originalError.message).to.include('certificate required');
182+
await clientNoTls.close();
197183
}
198-
});
199-
200-
it('passes with tls but fails to parse', metadata, async function () {
201184
try {
185+
await clientWithTls.connect();
202186
await clientEncryptionWithTls.createDataKey('aws', { masterKey });
203187
expect.fail('it must fail to parse response');
204188
} catch (e) {
189+
await clientWithTls.close();
205190
expect(e.message).to.include('parse error');
206191
}
207-
});
208-
209-
it('fails with expired certificates', metadata, async function () {
210192
try {
193+
await clientWithTlsExpired.connect();
211194
await clientEncryptionWithTlsExpired.createDataKey('aws', { masterKeyExpired });
212195
expect.fail('it must fail with invalid certificate');
213196
} catch (e) {
197+
await clientWithTlsExpired.close();
214198
expect(e.message).to.include('expected UTF-8 key');
215199
}
216-
});
217-
218-
it('fails with invalid hostnames', metadata, async function () {
219200
try {
201+
await clientWithInvalidHostname.connect();
220202
await clientEncryptionWithInvalidHostname.createDataKey('aws', {
221203
masterKeyInvalidHostname
222204
});
223205
expect.fail('it must fail with invalid hostnames');
224206
} catch (e) {
207+
await clientWithInvalidHostname.close();
225208
expect(e.message).to.include('expected UTF-8 key');
226209
}
227210
});
@@ -234,38 +217,37 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
234217
keyName: 'foo'
235218
};
236219

237-
it('fails with no tls', metadata, async function () {
220+
it('fails with various invalid tls options', metadata, async function () {
238221
try {
222+
await clientNoTls.connect();
239223
await clientEncryptionNoTls.createDataKey('azure', { masterKey });
240224
expect.fail('it must fail with no tls');
241225
} catch (e) {
226+
await clientNoTls.close();
242227
expect(e.originalError.message).to.include('certificate required');
243228
}
244-
});
245-
246-
it('fails with invalid host', metadata, async function () {
247229
try {
230+
await clientWithTls.connect();
248231
await clientEncryptionWithTls.createDataKey('azure', { masterKey });
249232
expect.fail('it must fail with invalid host');
250233
} catch (e) {
234+
await clientWithTls.close();
251235
expect(e.message).to.include('HTTP status=404');
252236
}
253-
});
254-
255-
it('fails with expired certificates', metadata, async function () {
256237
try {
238+
await clientWithTlsExpired.connect();
257239
await clientEncryptionWithTlsExpired.createDataKey('azure', { masterKey });
258240
expect.fail('it must fail with expired certificates');
259241
} catch (e) {
242+
await clientWithTlsExpired.close();
260243
expect(e.originalError.message).to.include('certificate has expired');
261244
}
262-
});
263-
264-
it('fails with invalid hostnames', metadata, async function () {
265245
try {
246+
await clientWithInvalidHostname.connect();
266247
await clientEncryptionWithInvalidHostname.createDataKey('azure', { masterKey });
267248
expect.fail('it must fail with invalid hostnames');
268249
} catch (e) {
250+
await clientWithInvalidHostname.close();
269251
expect(e.originalError.message).to.include('does not match certificate');
270252
}
271253
});
@@ -280,70 +262,67 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
280262
keyName: 'foo'
281263
};
282264

283-
it('fails with no tls', metadata, async function () {
265+
it('fails with various invalid tls options', metadata, async function () {
284266
try {
267+
await clientNoTls.connect();
285268
await clientEncryptionNoTls.createDataKey('gcp', { masterKey });
286269
expect.fail('it must fail with no tls');
287270
} catch (e) {
271+
await clientNoTls.close();
288272
expect(e.originalError.message).to.include('certificate required');
289273
}
290-
});
291-
292-
it('fails with invalid host', metadata, async function () {
293274
try {
275+
await clientWithTls.connect();
294276
await clientEncryptionWithTls.createDataKey('gcp', { masterKey });
295277
expect.fail('it must fail with invalid host');
296278
} catch (e) {
279+
await clientWithTls.close();
297280
expect(e.message).to.include('HTTP status=404');
298281
}
299-
});
300-
301-
it('fails with expired certificates', metadata, async function () {
302282
try {
283+
await clientWithTlsExpired.connect();
303284
await clientEncryptionWithTlsExpired.createDataKey('gcp', { masterKey });
304285
expect.fail('it must fail with expired certificates');
305286
} catch (e) {
287+
await clientWithTlsExpired.close();
306288
expect(e.originalError.message).to.include('certificate has expired');
307289
}
308-
});
309-
310-
it('fails with invalid hostnames', metadata, async function () {
311290
try {
291+
await clientWithInvalidHostname.connect();
312292
await clientEncryptionWithInvalidHostname.createDataKey('gcp', { masterKey });
313293
expect.fail('it must fail with invalid hostnames');
314294
} catch (e) {
295+
await clientWithInvalidHostname.close();
315296
expect(e.originalError.message).to.include('does not match certificate');
316297
}
317298
});
318299
});
319300

320-
// Case 4. The success test is skipped as the client was closing from the after
321-
// block before the it block actually finished. But we have another test in the
322-
// KMIP section that tests the same thing and works.
301+
// Case 4.
323302
context('Case 4: KMIP', metadata, function () {
324-
it('fails with no tls', metadata, async function () {
303+
it('fails with various invalid tls options', metadata, async function () {
325304
try {
305+
await clientNoTls.connect();
326306
await clientEncryptionNoTls.createDataKey('kmip');
327307
expect.fail('it must fail with no tls');
328308
} catch (e) {
309+
await clientNoTls.close();
329310
expect(e.originalError.message).to.include('before secure TLS connection');
330311
}
331-
});
332-
333-
it('fails with expired certificates', metadata, async function () {
334312
try {
313+
await clientWithTlsExpired.connect();
335314
await clientEncryptionWithTlsExpired.createDataKey('kmip');
336315
expect.fail('it must fail with expired certificates');
337316
} catch (e) {
317+
await clientWithTlsExpired.close();
338318
expect(e.originalError.message).to.include('certificate has expired');
339319
}
340-
});
341-
342-
it('fails with invalid hostnames', metadata, async function () {
343320
try {
321+
await clientWithInvalidHostname.connect();
344322
await clientEncryptionWithInvalidHostname.createDataKey('kmip');
345323
expect.fail('it must fail with invalid hostnames');
346324
} catch (e) {
325+
await clientWithInvalidHostname.close();
347326
expect(e.originalError.message).to.include('does not match certificate');
348327
}
349328
});

0 commit comments

Comments
 (0)