forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrypt_shared_lib.test.ts
More file actions
81 lines (70 loc) · 2.65 KB
/
crypt_shared_lib.test.ts
File metadata and controls
81 lines (70 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { expect } from 'chai';
import { spawnSync } from 'child_process';
import { dirname } from 'path';
import * as process from 'process';
import { EJSON } from '../../../src/bson';
import { getEncryptExtraOptions } from '../../tools/utils';
describe('crypt shared library', () => {
it('should fail if no library can be found in the search path and cryptSharedLibRequired is set', async function () {
const env = {
MONGODB_URI: this.configuration.url(),
EXTRA_OPTIONS: JSON.stringify({
cryptSharedLibSearchPaths: ['/nonexistent'],
cryptSharedLibRequired: true
})
};
const file = `${__dirname}/../../tools/fixtures/shared_library_test.js`;
const { stderr } = spawnSync(process.execPath, [file], {
env,
encoding: 'utf-8'
});
expect(stderr).to.include('`cryptSharedLibRequired` set but no crypt_shared library loaded');
});
it(
'should load a shared library by specifying its path',
{
requires: {
crypt_shared: 'enabled'
}
},
async function () {
const env = {
MONGODB_URI: this.configuration.url(),
EXTRA_OPTIONS: JSON.stringify({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
cryptSharedLibPath: getEncryptExtraOptions().cryptSharedLibPath!
})
};
const file = `${__dirname}/../../tools/fixtures/shared_library_test.js`;
const { stdout } = spawnSync(process.execPath, [file], { env, encoding: 'utf-8' });
const response = EJSON.parse(stdout, { useBigInt64: true });
expect(response).not.to.be.null;
expect(response).to.have.property('version').that.is.a('bigint');
expect(response).to.have.property('versionStr').that.is.a('string');
}
);
it(
'should load a shared library by specifying a search path',
{
requires: {
crypt_shared: 'enabled'
}
},
async function () {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const cryptDir = dirname(getEncryptExtraOptions().cryptSharedLibPath!);
const env = {
MONGODB_URI: this.configuration.url(),
EXTRA_OPTIONS: JSON.stringify({
cryptSharedLibSearchPaths: [cryptDir]
})
};
const file = `${__dirname}/../../tools/fixtures/shared_library_test.js`;
const { stdout } = spawnSync(process.execPath, [file], { env, encoding: 'utf-8' });
const response = EJSON.parse(stdout, { useBigInt64: true });
expect(response).not.to.be.null;
expect(response).to.have.property('version').that.is.a('bigint');
expect(response).to.have.property('versionStr').that.is.a('string');
}
);
});