Skip to content

Commit 7b2560b

Browse files
add rest of prose test comments
1 parent a864fba commit 7b2560b

File tree

1 file changed

+54
-11
lines changed

1 file changed

+54
-11
lines changed

test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('27. Text Explicit Encryption', function () {
3535
beforeEach(async function () {
3636
utilClient = this.configuration.newClient();
3737

38-
// Using QE CreateCollection() and Collection.Drop(), drop and create the following collections:
38+
// Using QE CreateCollection() and Collection.Drop(), drop and create the following collections with majority write concern:
3939
// - db.prefix-suffix using the encryptedFields option set to the contents of encryptedFields-prefix-suffix.json
4040
// - db.substring using the encryptedFields option set to the contents of encryptedFields-substring.json
4141
async function dropAndCreateCollection(ns: string, encryptedFields?: Document) {
@@ -64,10 +64,10 @@ describe('27. Text Explicit Encryption', function () {
6464
// Read the "_id" field of key1Document as key1ID.
6565
keyId1 = keyDocument1._id;
6666

67-
// Drop and create the collection keyvault.datakeys.
67+
// Drop and create the collection keyvault.datakeys with majority write concern.
6868
await dropAndCreateCollection('keyvault.datakeys');
6969

70-
// Insert `key1Document` in `keyvault.datakeys` with majority write concern.
70+
// Insert `key1Document` in `keyvault.datakeys` with majority write concern with majority write concern.
7171
await utilClient
7272
.db('keyvault')
7373
.collection('datakeys')
@@ -109,6 +109,24 @@ describe('27. Text Explicit Encryption', function () {
109109
);
110110

111111
{
112+
// Use `clientEncryption` to encrypt the string `"foobarbaz"` with the following `EncryptOpts`:
113+
// class EncryptOpts {
114+
// keyId : <key1ID>,
115+
// algorithm: "TextPreview",
116+
// contentionFactor: 0,
117+
// textOpts: TextOpts {
118+
// caseSensitive: true,
119+
// diacriticSensitive: true,
120+
// prefix: PrefixOpts {
121+
// strMaxQueryLength: 10,
122+
// strMinQueryLength: 2,
123+
// },
124+
// suffix: SuffixOpts {
125+
// strMaxQueryLength: 10,
126+
// strMinQueryLength: 2,
127+
// },
128+
// },
129+
// }
112130
const encryptedText = await clientEncryption.encrypt('foobarbaz', {
113131
keyId: keyId1,
114132
algorithm: 'TextPreview',
@@ -127,16 +145,36 @@ describe('27. Text Explicit Encryption', function () {
127145
}
128146
});
129147

148+
// Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern:
149+
// { "_id": 0, "encryptedText": <encrypted 'foobarbaz'> }
130150
await encryptedClient
131151
.db('db')
132152
.collection<{ _id: number; encryptedText: Binary }>('prefix-suffix')
133-
.insertOne({
134-
_id: 0,
135-
encryptedText
136-
});
153+
.insertOne(
154+
{
155+
_id: 0,
156+
encryptedText
157+
},
158+
{ writeConcern: { w: 'majority' } }
159+
);
137160
}
138161

139162
{
163+
// Use `clientEncryption` to encrypt the string `"foobarbaz"` with the following `EncryptOpts`:
164+
// class EncryptOpts {
165+
// keyId : <key1ID>,
166+
// algorithm: "TextPreview",
167+
// contentionFactor: 0,
168+
// textOpts: TextOpts {
169+
// caseSensitive: true,
170+
// diacriticSensitive: true,
171+
// substring: SubstringOpts {
172+
// strMaxLength: 10,
173+
// strMaxQueryLength: 10,
174+
// strMinQueryLength: 2,
175+
// }
176+
// },
177+
// }
140178
const encryptedText = await clientEncryption.encrypt('foobarbaz', {
141179
keyId: keyId1,
142180
algorithm: 'TextPreview',
@@ -152,13 +190,18 @@ describe('27. Text Explicit Encryption', function () {
152190
}
153191
});
154192

193+
// Use `encryptedClient` to insert the following document into `db.substring` with majority write concern:
194+
// { "_id": 0, "encryptedText": <encrypted 'foobarbaz'> }
155195
await encryptedClient
156196
.db('db')
157197
.collection<{ _id: number; encryptedText: Binary }>('substring')
158-
.insertOne({
159-
_id: 0,
160-
encryptedText
161-
});
198+
.insertOne(
199+
{
200+
_id: 0,
201+
encryptedText
202+
},
203+
{ writeConcern: { w: 'majority' } }
204+
);
162205
}
163206
});
164207

0 commit comments

Comments
 (0)