Skip to content

Commit 1c6de62

Browse files
fix lint and ensure no extra values obtained
1 parent eef8162 commit 1c6de62

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

test/integration/auth/mongodb_aws.test.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ import {
1313
type MongoClient,
1414
MongoDBAWS,
1515
MongoMissingCredentialsError,
16-
MongoServerError
16+
MongoServerError,
17+
setDifference
1718
} from '../../mongodb';
1819

19-
const isMongoDBURITest = (process.env.MONGODB_URI ?? '').includes('MONGODB_AWS');
20+
const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB_AWS');
2021

2122
describe('MONGODB-AWS', function () {
2223
let awsSdkPresent;
2324
let client: MongoClient;
2425

2526
beforeEach(function () {
26-
if (!isMongoDBURITest) {
27+
if (!isMongoDBAWSAuthEnvironment) {
2728
this.currentTest.skipReason = 'requires MONGODB_URI to contain MONGODB-AWS auth mechanism';
2829
return this.skip();
2930
}
@@ -328,7 +329,7 @@ describe('MONGODB-AWS', function () {
328329
describe('AWS KMS Credential Fetching', function () {
329330
context('when the AWS SDK is not installed', function () {
330331
beforeEach(function () {
331-
this.currentTest.skipReason = !isMongoDBURITest
332+
this.currentTest.skipReason = !isMongoDBAWSAuthEnvironment
332333
? 'Test must run in an AWS auth testing environment'
333334
: AWSTemporaryCredentialProvider.isAWSSDKInstalled
334335
? 'This test must run in an environment where the AWS SDK is not installed.'
@@ -343,7 +344,7 @@ describe('AWS KMS Credential Fetching', function () {
343344

344345
context('when the AWS SDK is installed', function () {
345346
beforeEach(function () {
346-
this.currentTest.skipReason = !isMongoDBURITest
347+
this.currentTest.skipReason = !isMongoDBAWSAuthEnvironment
347348
? 'Test must run in an AWS auth testing environment'
348349
: AWSTemporaryCredentialProvider.isAWSSDKInstalled
349350
? 'This test must run in an environment where the AWS SDK is installed.'
@@ -356,5 +357,17 @@ describe('AWS KMS Credential Fetching', function () {
356357
expect(aws).to.have.property('accessKeyId');
357358
expect(aws).to.have.property('secretAccessKey');
358359
});
360+
361+
it('does not return any extra keys for the `aws` credential provider', async function () {
362+
const { aws } = await new KMSCredentialProvider({ aws: {} }).refreshCredentials();
363+
364+
const keys = new Set(Object.keys(aws ?? {}));
365+
const allowedKeys = ['accessKeyId', 'secretAccessKey', 'sessionToken'];
366+
367+
expect(
368+
setDifference(keys, allowedKeys),
369+
'received an unexpected key in the response refreshing KMS credentials'
370+
).to.deep.equal([]);
371+
});
359372
});
360373
});

0 commit comments

Comments
 (0)