Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/integration/auth/mongodb_oidc.prose.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotations are helpful, however, the new requirement in the spec is to ensure that we not only remove the failpoint but also always set the appName for any failpoint created. In this file, there are two types of clients - the regular one and the util client (with the util clients being used to set fail points), with some clients instantiated via new MongoClient and others via the getClient method, so we want to make sure that we always configure the clients being tested and the failpoints set in the test with an appName.

await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -402,6 +403,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -457,6 +459,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -522,6 +525,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient?.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -587,6 +591,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient?.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -654,6 +659,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient?.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -733,6 +739,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1089,6 +1096,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1190,6 +1198,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1252,6 +1261,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1348,6 +1358,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1419,6 +1430,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1496,6 +1508,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down Expand Up @@ -1581,6 +1594,7 @@ describe('OIDC Auth Spec Tests', function () {
});

afterEach(async function () {
// explicitly remove the fail point to prevent interaction betweet test runs
await utilClient.db().admin().command({
configureFailPoint: 'failCommand',
mode: 'off'
Expand Down
21 changes: 14 additions & 7 deletions test/spec/auth/unified/mongodb-oidc-no-retry.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
{
"minServerVersion": "7.0",
"auth": true,
"authMechanism": "MONGODB-OIDC"
"authMechanism": "MONGODB-OIDC",
"serverless": "forbid"
}
],
"createEntities": [
Expand All @@ -24,7 +25,8 @@
"$$placeholder": 1
},
"retryReads": false,
"retryWrites": false
"retryWrites": false,
"appName": "mongodb-oidc-no-retry"
},
"observeEvents": [
"commandStartedEvent",
Expand Down Expand Up @@ -146,7 +148,8 @@
"failCommands": [
"find"
],
"errorCode": 391
"errorCode": 391,
"appName": "mongodb-oidc-no-retry"
}
}
}
Expand Down Expand Up @@ -211,7 +214,8 @@
"failCommands": [
"insert"
],
"errorCode": 391
"errorCode": 391,
"appName": "mongodb-oidc-no-retry"
}
}
}
Expand Down Expand Up @@ -288,7 +292,8 @@
"failCommands": [
"insert"
],
"closeConnection": true
"closeConnection": true,
"appName": "mongodb-oidc-no-retry"
}
}
}
Expand Down Expand Up @@ -320,7 +325,8 @@
"failCommands": [
"saslStart"
],
"errorCode": 18
"errorCode": 18,
"appName": "mongodb-oidc-no-retry"
}
}
}
Expand Down Expand Up @@ -397,7 +403,8 @@
"failCommands": [
"saslStart"
],
"errorCode": 18
"errorCode": 18,
"appName": "mongodb-oidc-no-retry"
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions test/spec/auth/unified/mongodb-oidc-no-retry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ runOnRequirements:
- minServerVersion: "7.0"
auth: true
authMechanism: "MONGODB-OIDC"
serverless: forbid
createEntities:
- client:
id: &failPointClient failPointClient
Expand All @@ -20,6 +21,7 @@ createEntities:
authMechanismProperties: { $$placeholder: 1 }
retryReads: false
retryWrites: false
appName: &appName mongodb-oidc-no-retry
observeEvents:
- commandStartedEvent
- commandSucceededEvent
Expand Down Expand Up @@ -86,6 +88,7 @@ tests:
failCommands:
- find
errorCode: 391 # ReauthenticationRequired
appName: *appName
- name: find
object: collection0
arguments:
Expand Down Expand Up @@ -120,6 +123,7 @@ tests:
failCommands:
- insert
errorCode: 391 # ReauthenticationRequired
appName: *appName
- name: insertOne
object: collection0
arguments:
Expand Down Expand Up @@ -159,6 +163,7 @@ tests:
failCommands:
- insert
closeConnection: true
appName: *appName
- name: insertOne
object: collection0
arguments:
Expand All @@ -179,6 +184,7 @@ tests:
failCommands:
- saslStart
errorCode: 18
appName: *appName
- name: insertOne
object: collection0
arguments:
Expand Down Expand Up @@ -212,17 +218,18 @@ tests:
client: failPointClient
failPoint:
configureFailPoint: failCommand
mode:
mode:
times: 1
data:
failCommands:
- saslStart
errorCode: 18
appName: *appName
- name: insertOne
object: collection0
arguments:
document:
_id: 1
x: 1
expectError:
errorCode: 18
errorCode: 18
11 changes: 11 additions & 0 deletions test/tools/unified-spec-runner/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@ export class UnifiedMongoClient extends MongoClient {
};
}

// Test descriptions use `appName` and `appname` interchangeably
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to modify the unified test runner, since there was no change to the unified test runner specification. The appName for unified tests is already passed in directly via the spec files themselves.

You may find it helpful to look at the reference implementations linked in the spec PR (mongodb/specifications#1891), for example the python one here.

description.uriOptions &&
(description.uriOptions.appName != null || description.uriOptions.appname != null)
) {
options.appName = description.uriOptions.appName ?? description.uriOptions.appname;
} else {
const appNameNonce = new Date().getTime().toString();
options.appName = `unified-spec-runner-${appNameNonce}`;
}

super(uri, options);
this.observedEventEmitter.on('error', () => null);
this.logCollector = logCollector;
Expand Down