|
1 | 1 | import { DevtoolsConnectOptions } from '@mongosh/service-provider-server/lib/cli-service-provider';
|
2 | 2 | import { expect } from 'chai';
|
3 |
| -import { UUID } from 'bson'; |
| 3 | +import { UUID, Long } from 'bson'; |
4 | 4 | import {
|
5 | 5 | serializeError,
|
6 | 6 | deserializeError,
|
@@ -141,7 +141,7 @@ describe('serializer', () => {
|
141 | 141 | });
|
142 | 142 |
|
143 | 143 | describe('connection options', () => {
|
144 |
| - it('should serialize and deserialize connection options', () => { |
| 144 | + it('should serialize and deserialize FLE1 connection options', () => { |
145 | 145 | const options: DevtoolsConnectOptions = {
|
146 | 146 | autoEncryption: {
|
147 | 147 | schemaMap: {
|
@@ -184,5 +184,41 @@ describe('serializer', () => {
|
184 | 184 |
|
185 | 185 | expect(deserializeConnectOptions(serialized)).to.deep.equal(options);
|
186 | 186 | });
|
| 187 | + |
| 188 | + it('should serialize and deserialize FLE2 connection options', () => { |
| 189 | + const options: DevtoolsConnectOptions = { |
| 190 | + autoEncryption: { |
| 191 | + encryptedFieldsMap: { |
| 192 | + 'hr.employees': { |
| 193 | + fields: [{ |
| 194 | + path: 'phoneNumber', |
| 195 | + keyId: new UUID('fd6275d7-9260-4e6c-a86b-68ec5240814a').toBinary(), |
| 196 | + bsonType: 'string', |
| 197 | + queries: { queryType: 'equality', contention: new Long(0) } |
| 198 | + }] |
| 199 | + } |
| 200 | + } |
| 201 | + } |
| 202 | + }; |
| 203 | + |
| 204 | + const serialized = serializeConnectOptions(options); |
| 205 | + |
| 206 | + expect(serialized).to.deep.equal({ |
| 207 | + autoEncryption: { |
| 208 | + encryptedFieldsMap: { |
| 209 | + 'hr.employees': { |
| 210 | + fields: [{ |
| 211 | + path: 'phoneNumber', |
| 212 | + keyId: { $binary: { base64: '/WJ115JgTmyoa2jsUkCBSg==', subType: '04' } }, |
| 213 | + bsonType: 'string', |
| 214 | + queries: { queryType: 'equality', contention: { $numberLong: '0' } } |
| 215 | + }] |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | + }); |
| 220 | + |
| 221 | + expect(deserializeConnectOptions(serialized)).to.deep.equal(options); |
| 222 | + }); |
187 | 223 | });
|
188 | 224 | });
|
0 commit comments