Skip to content

Commit

Permalink
add prose test
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Aug 19, 2024
1 parent a8c8e58 commit 4498947
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions test/integration/client-side-encryption/driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,76 @@ describe('Client Side Encryption Functional', function () {
}
);
});

describe('Range Explicit Encryption with JS native types', function () {
installNodeDNSWorkaroundHooks();

const metaData: MongoDBMetadataUI = {
requires: {
clientSideEncryption: '>=6.1.0',

// The Range Explicit Encryption tests require MongoDB server 7.0+ for QE v2.
// The tests must not run against a standalone.
//
// `range` is not supported on 8.0+ servers.
mongodb: '>=8.0.0',
topology: '!single'
}
};

const getKmsProviders = (): { local: { key: string } } => {
const result = EJSON.parse(process.env.CSFLE_KMS_PROVIDERS || '{}') as unknown as {
local: { key: string };
};

return { local: result.local };
};

let clientEncryption: ClientEncryption;
let keyId;
let keyVaultClient;

beforeEach(async function () {
keyVaultClient = this.configuration.newClient();
clientEncryption = new ClientEncryption(keyVaultClient, {
keyVaultNamespace: 'keyvault.datakeys',
kmsProviders: getKmsProviders()
});

keyId = await clientEncryption.createDataKey('local');


});

afterEach(async function () {
await keyVaultClient.close();
});

it('supports a js number for trimFactor', metaData, async function () {
await clientEncryption.encrypt(new BSON.Int32(123), {
keyId,
algorithm: 'Range',
contentionFactor: 0,
rangeOptions: {
min: 0,
max: 1000,
trimFactor: 1,
sparsity: new BSON.Long(1)
}
});
});

it('supports a bigint for sparsity', metaData, async function () {
await clientEncryption.encrypt(new BSON.Int32(123), {
keyId,
algorithm: 'Range',
contentionFactor: 0,
rangeOptions: {
min: 0,
max: 1000,
trimFactor: new BSON.Int32(1),
sparsity: 1n
}
});
});
});

0 comments on commit 4498947

Please sign in to comment.