Skip to content

Commit 5caa5f5

Browse files
committed
test: aws test
1 parent c5a53b1 commit 5caa5f5

1 file changed

Lines changed: 0 additions & 125 deletions

File tree

test/integration/auth/mongodb_aws.test.ts

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -163,131 +163,6 @@ describe('MONGODB-AWS', function () {
163163
});
164164

165165
context('when using a custom credential provider', function () {
166-
// NOTE: Logic for scenarios 1-6 is handled via the evergreen variant configs.
167-
// Scenarios 1-6 from the previous section with a user provided AWS_CREDENTIAL_PROVIDER auth mechanism
168-
// property. This credentials MAY be obtained from the default credential provider from the AWS SDK.
169-
// If the default provider does not cover all scenarios above, those not covered MAY be skipped.
170-
// In these tests the driver MUST also assert that the user provided credential provider was called
171-
// in each test. This may be via a custom function or object that wraps the calls to the custom provider
172-
// and asserts that it was called at least once. For test scenarios where the drivers tools scripts put
173-
// the credentials in the MONGODB_URI, drivers MAY extract the credentials from the URI and return the AWS
174-
// credentials directly from the custom provider instead of using the AWS SDK default provider.
175-
context('1. Custom Credential Provider Authenticates', function () {
176-
let providerCount = 0;
177-
178-
beforeEach(function () {
179-
// If we have a username the credentials have been set from the URI, options, or environment
180-
// variables per the auth spec stated order.
181-
if (client.options.credentials.username) {
182-
this.skipReason = 'Credentials in the URI will not use custom provider.';
183-
return this.skip();
184-
}
185-
});
186-
187-
it('authenticates with a user provided credentials provider', async function () {
188-
const credentialProvider = AWSSDKCredentialProvider.awsSDK;
189-
const provider = async () => {
190-
providerCount++;
191-
return await credentialProvider.fromNodeProviderChain().apply();
192-
};
193-
client = this.configuration.newClient(process.env.MONGODB_URI, {
194-
authMechanismProperties: {
195-
AWS_CREDENTIAL_PROVIDER: provider
196-
}
197-
});
198-
199-
const result = await client
200-
.db('aws')
201-
.collection('aws_test')
202-
.estimatedDocumentCount()
203-
.catch(error => error);
204-
205-
expect(result).to.not.be.instanceOf(MongoServerError);
206-
expect(result).to.be.a('number');
207-
expect(providerCount).to.be.greaterThan(0);
208-
});
209-
});
210-
211-
context('2. Custom Credential Provider Authentication Precedence', function () {
212-
// Create a MongoClient configured with AWS auth and credentials in the URI.
213-
// Example: mongodb://<AccessKeyId>:<SecretAccessKey>@localhost:27017/?authMechanism=MONGODB-AWS
214-
// Configure a custom credential provider to pass valid AWS credentials. The provider must
215-
// track if it was called.
216-
// Expect authentication to succeed and the custom credential provider was not called.
217-
context('Case 1: Credentials in URI Take Precedence', function () {
218-
let providerCount = 0;
219-
let provider;
220-
221-
beforeEach(function () {
222-
if (!client?.options.credentials.username) {
223-
this.skipReason = 'Test only runs when credentials are present in the URI';
224-
return this.skip();
225-
}
226-
const credentialProvider = AWSSDKCredentialProvider.awsSDK;
227-
provider = async () => {
228-
providerCount++;
229-
return await credentialProvider.fromNodeProviderChain().apply();
230-
};
231-
});
232-
233-
it('authenticates with a user provided credentials provider', async function () {
234-
client = this.configuration.newClient(process.env.MONGODB_URI, {
235-
authMechanismProperties: {
236-
AWS_CREDENTIAL_PROVIDER: provider
237-
}
238-
});
239-
240-
const result = await client
241-
.db('aws')
242-
.collection('aws_test')
243-
.estimatedDocumentCount()
244-
.catch(error => error);
245-
246-
expect(result).to.not.be.instanceOf(MongoServerError);
247-
expect(result).to.be.a('number');
248-
expect(providerCount).to.equal(0);
249-
});
250-
});
251-
252-
// Run this test in an environment with AWS credentials configured as environment variables
253-
// (e.g. AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN)
254-
// Create a MongoClient configured to use AWS auth. Example: mongodb://localhost:27017/?authMechanism=MONGODB-AWS.
255-
// Configure a custom credential provider to pass valid AWS credentials. The provider must track if it was called.
256-
// Expect authentication to succeed and the custom credential provider was called.
257-
context('Case 2: Custom Provider Takes Precedence Over Environment Variables', function () {
258-
let providerCount = 0;
259-
let provider;
260-
261-
beforeEach(function () {
262-
if (client?.options.credentials.username || !process.env.AWS_ACCESS_KEY_ID) {
263-
this.skipReason = 'Test only runs when credentials are present in the environment';
264-
return this.skip();
265-
}
266-
const credentialProvider = AWSSDKCredentialProvider.awsSDK;
267-
provider = async () => {
268-
providerCount++;
269-
return await credentialProvider.fromNodeProviderChain().apply();
270-
};
271-
});
272-
273-
it('authenticates with a user provided credentials provider', async function () {
274-
client = this.configuration.newClient(process.env.MONGODB_URI, {
275-
authMechanismProperties: {
276-
AWS_CREDENTIAL_PROVIDER: provider
277-
}
278-
});
279-
280-
const result = await client
281-
.db('aws')
282-
.collection('aws_test')
283-
.estimatedDocumentCount()
284-
.catch(error => error);
285-
286-
expect(result).to.not.be.instanceOf(MongoServerError);
287-
expect(result).to.be.a('number');
288-
expect(providerCount).to.be.greaterThan(0);
289-
});
290-
});
291166
});
292167
});
293168

0 commit comments

Comments
 (0)