Skip to content

Commit a702990

Browse files
fix tests
1 parent 5321999 commit a702990

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

src/client-side-encryption/providers/aws.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { getAwsCredentialProvider } from '../../deps';
2-
import { type KMSProviders } from '.';
31
import { AWSSDKCredentialProvider } from '../../cmap/auth/aws_temporary_credentials';
2+
import { type KMSProviders } from '.';
43

54
/**
65
* @internal

test/integration/auth/mongodb_aws.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { performance } from 'perf_hooks';
66
import * as sinon from 'sinon';
77

88
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
9-
import { KMSCredentialProvider, refreshKMSCredentials } from '../../../src/client-side-encryption/providers';
9+
import { refreshKMSCredentials } from '../../../src/client-side-encryption/providers';
1010
import {
1111
AWSTemporaryCredentialProvider,
1212
MongoAWSError,
@@ -17,7 +17,7 @@ import {
1717
setDifference
1818
} from '../../mongodb';
1919

20-
const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB_AWS');
20+
const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB-AWS');
2121

2222
describe('MONGODB-AWS', function () {
2323
let awsSdkPresent;
@@ -337,7 +337,7 @@ describe('AWS KMS Credential Fetching', function () {
337337
this.currentTest?.skipReason && this.skip();
338338
});
339339
it('fetching AWS KMS credentials throws an error', async function () {
340-
const error = await new KMSCredentialProvider({ aws: {} }).refreshCredentials().catch(e => e);
340+
const error = await refreshKMSCredentials({ aws: {} }).catch(e => e);
341341
expect(error).to.be.instanceOf(MongoAWSError);
342342
});
343343
});

test/unit/client-side-encryption/providers/credentialsProvider.test.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import {
2020
} from '../../../../src/client-side-encryption/providers/azure';
2121
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
2222
import * as utils from '../../../../src/client-side-encryption/providers/utils';
23-
import * as requirements from '../requirements.helper';
23+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
2424
import { AWSSDKCredentialProvider } from '../../../../src/cmap/auth/aws_temporary_credentials';
25-
import { MongoAWSError } from '../../../../src/error';
25+
import * as requirements from '../requirements.helper';
2626

2727
const originalAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
2828
const originalSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
@@ -156,29 +156,6 @@ describe('#refreshKMSCredentials', function () {
156156
});
157157
});
158158

159-
context('when the sdk is not installed', function () {
160-
const kmsProviders = {
161-
local: {
162-
key: Buffer.alloc(96)
163-
},
164-
aws: {}
165-
};
166-
167-
before(function () {
168-
if (requirements.credentialProvidersInstalled.aws && this.currentTest) {
169-
this.currentTest.skipReason = 'Credentials will be loaded when sdk present';
170-
this.currentTest.skip();
171-
return;
172-
}
173-
});
174-
175-
it('throws a MongoAWSError', async function () {
176-
const error = await refreshKMSCredentials(kmsProviders).catch(e => e);
177-
const expectedErrorMessage = 'Optional module `@aws-sdk/credential-providers` not found';
178-
expect(error).to.be.instanceOf(MongoAWSError).to.match(new RegExp(expectedErrorMessage, 'i'));
179-
});
180-
});
181-
182159
context('when the AWS SDK returns unknown fields', function () {
183160
beforeEach(() => {
184161
sinon.stub(AWSSDKCredentialProvider.prototype, 'getCredentials').resolves({

0 commit comments

Comments
 (0)