Skip to content

Commit 2e06e53

Browse files
comment test
1 parent 732b009 commit 2e06e53

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/integration/client-side-encryption/client_side_encryption.prose.20.mongocryptd_client.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,22 @@ describe('20. Bypass creating mongocryptd client when shared library is loaded',
1919
this.skip();
2020
}
2121

22+
// Start a new thread (referred to as listenerThread)
23+
// On listenerThread, create a TcpListener on 127.0.0.1 endpoint and port 27021. Start the listener and wait for establishing connections. If any connection is established, then signal about this to the main thread.
24+
// Drivers MAY pass a different port if they expect their testing infrastructure to be using port 27021. Pass a port that should be free.
25+
// In Node, we don't need to create a separate thread for the server.
2226
server = createServer({});
2327
server.listen(27021);
2428
server.on('connection', () => (hasConnection = true));
2529

30+
// Create a MongoClient configured with auto encryption (referred to as client_encrypted)
31+
// Configure the required options. Use the local KMS provider as follows:
32+
// { "local": { "key": <base64 decoding of LOCAL_MASTERKEY> } }
33+
// Configure with the keyVaultNamespace set to keyvault.datakeys.
34+
// Configure the following extraOptions:
35+
// {
36+
// "mongocryptdURI": "mongodb://localhost:27021/?serverSelectionTimeoutMS=1000"
37+
// }
2638
client = this.configuration.newClient(
2739
{},
2840
{
@@ -51,9 +63,18 @@ describe('20. Bypass creating mongocryptd client when shared library is loaded',
5163
}
5264
},
5365
async function () {
66+
// Use client_encrypted to insert the document {"unencrypted": "test"} into db.coll.
5467
await client.db('db').collection('coll').insertOne({ unencrypted: 'test' });
68+
69+
// Expect no signal from listenerThread.
5570
expect(hasConnection).to.be.false;
5671

72+
// Note: this assertion is not in the spec test. However, unlike other drivers, Node's client
73+
// does not connect when instantiated. So, we won't receive any TCP connections to the
74+
// server unless the mongocryptd client is only instantiated. This assertion captures the
75+
// spirit of this test, causing it to fail if we do instantiate a client. I left the
76+
// TCP server in, although it isn't necessary for Node's test, just because its nice to have
77+
// in case Node's client behavior ever changes.
5778
expect(client.autoEncrypter._mongocryptdClient).to.be.undefined;
5879
}
5980
);

0 commit comments

Comments
 (0)