22
33Drivers MUST test the following scenarios:
44
5- 1 . ` Regular Credentials ` : Auth via an ` ACCESS_KEY_ID ` and ` SECRET_ACCESS_KEY ` pair
5+ 1 . ` Regular Credentials ` : Auth via an ` AWS_ACCESS_KEY_ID ` and ` AWS_SECRET_ACCESS_KEY ` pair
662 . ` EC2 Credentials ` : Auth from an EC2 instance via temporary credentials assigned to the machine
773 . ` ECS Credentials ` : Auth from an ECS instance via temporary credentials assigned to the task
884 . ` Assume Role ` : Auth via temporary credentials obtained from an STS AssumeRole request
@@ -21,15 +21,41 @@ SecretAccessKey=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
2121Token=AQoDYXdzEJr...<remainder of security token>
2222```
2323
24- If the driver supports user provided custom AWS credential providers, then the driver MUST also test the above scenarios
25- 2-6 with a user provided ` AWS_CREDENTIAL_PROVIDER ` auth mechanism property. This value MUST be the default credential
26- provider from the AWS SDK. If the default provider does not cover all scenarios above, those not covered MAY be skipped.
27- In these tests the driver MUST also assert that the user provided credential provider was called at least once in each
28- test.
24+ ## Testing custom credential providers
2925
30- If the driver supports a custom AWS credential provider, it MUST verify the custom provider was used when testing. This
31- may be via a custom function or object that wraps the calls to the custom provider and asserts that it was called at
32- least once.
26+ If the driver supports custom AWS credential providers, the driver MUST test the following:
27+
28+ ### 1. Custom Credential Provider Authenticates
29+
30+ Scenarios 1-6 from the previous section with a user provided ` AWS_CREDENTIAL_PROVIDER ` auth mechanism property. This
31+ credentials MAY be obtained from the default credential provider from the AWS SDK. If the default provider does not
32+ cover all scenarios above, those not covered MAY be skipped. In these tests the driver MUST also assert that the user
33+ provided credential provider was called in each test. This may be via a custom function or object that wraps the calls
34+ to the custom provider and asserts that it was called at least once. For test scenarios where the drivers tools scripts
35+ put the credentials in the MONGODB_URI, drivers MAY extract the credentials from the URI and return the AWS credentials
36+ directly from the custom provider instead of using the AWS SDK default provider.
37+
38+ ### 2. Custom Credential Provider Authentication Precedence
39+
40+ #### Case 1: Credentials in URI Take Precedence
41+
42+ Create a ` MongoClient ` configured with AWS auth and credentials in the URI. Example:
43+ ` mongodb://<AccessKeyId>:<SecretAccessKey>@localhost:27017/?authMechanism=MONGODB-AWS `
44+
45+ Configure a custom credential provider to pass valid AWS credentials. The provider must track if it was called.
46+
47+ Expect authentication to succeed and the custom credential provider was * not* called.
48+
49+ #### Case 2: Custom Provider Takes Precedence Over Environment Variables
50+
51+ Run this test in an environment with AWS credentials configured as environment variables (e.g. ` AWS_ACCESS_KEY_ID ` ,
52+ ` AWS_SECRET_ACCESS_KEY ` , and ` AWS_SESSION_TOKEN ` )
53+
54+ Create a ` MongoClient ` configured to use AWS auth. Example: ` mongodb://localhost:27017/?authMechanism=MONGODB-AWS ` .
55+
56+ Configure a custom credential provider to pass valid AWS credentials. The provider must track if it was called.
57+
58+ Expect authentication to succeed and the custom credential provider was called.
3359
3460## Regular credentials
3561
0 commit comments