Skip to content

Commit 144f2d2

Browse files
remove AWS provider from tests
1 parent b8246ab commit 144f2d2

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

test/integration/node-specific/client_encryption.test.ts

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,10 @@ describe('ClientEncryption integration tests', function () {
463463
let client: MongoClient;
464464
let clientEncryption: ClientEncryption;
465465
let collection: Collection<DataKey>;
466-
// Data Key Stuff
467-
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
468-
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
469-
const AWS_REGION = 'us-east-1';
470-
const AWS_CMK_ID = 'dummy-cmk-id';
471466

472467
const kmsProviders = {
473-
aws: { accessKeyId: AWS_ACCESS_KEY_ID, secretAccessKey: AWS_SECRET_ACCESS_KEY }
468+
local: { key: Buffer.alloc(96) }
474469
};
475-
const dataKeyOptions = { masterKey: { key: AWS_CMK_ID, region: AWS_REGION } };
476470

477471
beforeEach(function () {
478472
client = this.configuration.newClient();
@@ -487,41 +481,32 @@ describe('ClientEncryption integration tests', function () {
487481
await client?.close();
488482
});
489483

490-
function makeOptions(keyAltNames) {
491-
expect(dataKeyOptions.masterKey).to.be.an('object');
492-
expect(dataKeyOptions.masterKey.key).to.be.a('string');
493-
expect(dataKeyOptions.masterKey.region).to.be.a('string');
494-
495-
return {
496-
masterKey: {
497-
key: dataKeyOptions.masterKey.key,
498-
region: dataKeyOptions.masterKey.region
499-
},
500-
keyAltNames
501-
};
502-
}
503-
504484
describe('errors', function () {
505485
for (const val of [42, 'hello', { keyAltNames: 'foobar' }, /foobar/]) {
506486
it(`should fail if typeof keyAltNames = ${typeof val}`, metadata, async function () {
507-
const options = makeOptions(val);
508-
const error = await clientEncryption.createDataKey('aws', options).catch(error => error);
487+
const error = await clientEncryption.createDataKey('local', {
488+
// @ts-expect-error Invalid type tests
489+
keyAltNames: val
490+
}).catch(error => error);
509491
expect(error).to.be.instanceOf(MongoCryptInvalidArgumentError);
510492
});
511493
}
512494

513495
for (const val of [undefined, null, 42, { keyAltNames: 'foobar' }, ['foobar'], /foobar/]) {
514496
it(`should fail if typeof keyAltNames[x] = ${typeof val}`, metadata, async function () {
515-
const options = makeOptions([val]);
516-
const error = await clientEncryption.createDataKey('aws', options).catch(error => error);
497+
const error = await clientEncryption.createDataKey('local', {
498+
// @ts-expect-error Invalid type tests
499+
keyAltNames: [val]
500+
}).catch(error => error);
517501
expect(error).to.be.instanceOf(MongoCryptInvalidArgumentError);
518502
});
519503
}
520504
});
521505

522506
it('should create a key with keyAltNames', metadata, async function () {
523-
const options = makeOptions(['foobar']);
524-
const dataKey = await clientEncryption.createDataKey('aws', options);
507+
const dataKey = await clientEncryption.createDataKey('local', {
508+
keyAltNames: ['foobar']
509+
});
525510
const document = await collection.findOne({ keyAltNames: 'foobar' });
526511
expect(document).to.be.an('object');
527512
expect(document).to.have.property('keyAltNames').that.includes.members(['foobar']);
@@ -530,8 +515,10 @@ describe('ClientEncryption integration tests', function () {
530515

531516
it('should create a key with multiple keyAltNames', metadata, async function () {
532517
const dataKey = await clientEncryption.createDataKey(
533-
'aws',
534-
makeOptions(['foobar', 'fizzbuzz'])
518+
'local',
519+
{
520+
keyAltNames: ['foobar', 'fizzbuzz']
521+
}
535522
);
536523
const docs = await Promise.all([
537524
collection.findOne({ keyAltNames: 'foobar' }),
@@ -557,7 +544,9 @@ describe('ClientEncryption integration tests', function () {
557544

558545
const valueToEncrypt = 'foobar';
559546

560-
const keyId = await clientEncryption.createDataKey('aws', makeOptions([keyAltName]));
547+
const keyId = await clientEncryption.createDataKey('local', {
548+
keyAltNames: [keyAltName]
549+
});
561550
const encryptedValue = await clientEncryption.encrypt(valueToEncrypt, { keyId, algorithm });
562551
const encryptedValue2 = await clientEncryption.encrypt(valueToEncrypt, {
563552
keyAltName,

0 commit comments

Comments
 (0)