Skip to content

Commit ca25868

Browse files
run tests
1 parent a135e79 commit ca25868

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

.github/workflows/encryption-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
node-version: latest
3535
- name: Install Dependencies
3636
run: npm install
37+
- name: Install mongodb-client-encryption
38+
run: npm install mongodb-client-encryption
3739
- name: Set up cluster
3840
id: setup-cluster
3941
uses: mongodb-labs/drivers-evergreen-tools@master
@@ -44,5 +46,5 @@ jobs:
4446
- name: Run Tests
4547
run: npx mocha --exit ./test/encryption/*.test.js
4648
env:
47-
MONGODB_URI: ${{ steps.setup-cluster.outputs.cluster-uri }}
49+
MONGOOSE_TEST_URI: ${{ steps.setup-cluster.outputs.cluster-uri }}
4850
CRYPT_SHARED_LIB_PATH: ${{ steps.setup-cluster.outputs.crypt-shared-lib-path }}

mongocryptd.pid

Whitespace-only changes.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"bson": "^6.7.0",
2323
"kareem": "2.6.3",
2424
"mongodb": "~6.10.0",
25+
"mongodb-client-encryption": "^6.1.0",
2526
"mpath": "0.9.0",
2627
"mquery": "5.0.0",
2728
"ms": "2.1.3",

test/encryption/encryption.test.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22

33
const assert = require('assert');
4-
const EJSON = require('bson').EJSON;
4+
const mdb = require('mongodb');
55

66
describe('environmental variables', () => {
7-
it('MONGODB_URI is set', async function() {
8-
const uri = process.env.MONGODB_URI;
7+
it('MONGODB_TEST_URI is set', async function() {
8+
const uri = process.env.MONGOOSE_TEST_URI;
99
assert.ok(uri);
1010
});
1111

@@ -14,3 +14,32 @@ describe('environmental variables', () => {
1414
assert.ok(shared_library_path);
1515
});
1616
});
17+
18+
describe('basic integration', () => {
19+
it('supports mongodb csfle auto-encryption integration', async() => {
20+
// 1. Create a MongoClient configured with auto encryption (referred to as `client_encrypted`)
21+
const client = new mdb.MongoClient(
22+
process.env.MONGOOSE_TEST_URI,
23+
{
24+
autoEncryption: {
25+
keyVaultNamespace: 'keyvault.datakeys',
26+
kmsProviders: { local: { key: Buffer.from(
27+
'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk',
28+
'base64'
29+
)
30+
} },
31+
extraOptions: {
32+
cryptdSharedLibRequired: true,
33+
cryptSharedLibPath: process.env.CRYPT_SHARED_LIB_PATH
34+
}
35+
}
36+
}
37+
);
38+
await client.connect();
39+
const insertResult = await client
40+
.db('db')
41+
.collection('coll')
42+
.insertOne({ unencrypted: 'test' });
43+
assert.ok(insertResult.insertedId);
44+
});
45+
});

0 commit comments

Comments
 (0)