Skip to content

Commit cbe228a

Browse files
committed
fix(deps): bump oidc-plugin, add regression test MONGOSH-2884
1 parent ee147bf commit cbe228a

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@mongosh/cli-repl": "2.5.8",
3131
"@mongosh/service-provider-core": "3.6.1",
32-
"@mongodb-js/oidc-plugin": "^2.0.4",
32+
"@mongodb-js/oidc-plugin": "^2.0.5",
3333
"strip-ansi": "^6.0.0"
3434
},
3535
"devDependencies": {

packages/e2e-tests/test/e2e-oidc.spec.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,54 @@ describe('OIDC auth e2e', function () {
181181
);
182182
}
183183

184-
for (const useNonce of [true, false]) {
185-
describe(`with nonce=${useNonce}`, function () {
184+
function* nonceTestParameters(): Generator<{
185+
expectNonce: boolean;
186+
provideNonce: boolean;
187+
}> {
188+
for (const expectNonce of [false, true]) {
189+
for (const provideNonce of [false, true]) {
190+
yield { expectNonce, provideNonce };
191+
}
192+
}
193+
}
194+
195+
for (const { expectNonce, provideNonce } of nonceTestParameters()) {
196+
describe(`with expectNonce=${expectNonce} provideNonce=${provideNonce}`, function () {
186197
it('can successfully authenticate using OIDC Auth Code Flow', async function () {
198+
const originalGetPayload = getTokenPayload;
199+
getTokenPayload = async (metadata) => {
200+
const result = await originalGetPayload(metadata);
201+
if (provideNonce === false) {
202+
result.payload.nonce = undefined;
203+
}
204+
return result;
205+
};
206+
187207
const args = [
188208
await testServer.connectionString(),
189209
'--authenticationMechanism=MONGODB-OIDC',
190210
'--oidcRedirectUri=http://localhost:0/',
191211
`--browser=${fetchBrowserFixture}`,
192212
];
193213

194-
if (!useNonce) {
214+
if (!expectNonce) {
195215
args.push('--oidcNoNonce');
196216
}
197217

198218
shell = this.startTestShell({
199219
args,
200220
});
201-
await shell.waitForPrompt();
202-
203-
await verifyUser(shell, 'testuser', 'testServer-group');
204-
shell.assertNoErrors();
221+
if (!expectNonce || provideNonce) {
222+
await shell.waitForPrompt();
223+
224+
await verifyUser(shell, 'testuser', 'testServer-group');
225+
shell.assertNoErrors();
226+
} else {
227+
expect(await shell.waitForAnyExit()).to.equal(1);
228+
shell.assertContainsOutput(
229+
'Error: invalid response encountered (caused by: JWT "nonce" (nonce) claim missing)'
230+
);
231+
}
205232
});
206233
});
207234
}

packages/service-provider-node-driver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@mongodb-js/devtools-connect": "^3.9.4",
51-
"@mongodb-js/oidc-plugin": "^2.0.4",
51+
"@mongodb-js/oidc-plugin": "^2.0.5",
5252
"@mongosh/errors": "2.4.4",
5353
"@mongosh/service-provider-core": "3.6.1",
5454
"@mongosh/types": "^3.14.0",

0 commit comments

Comments
 (0)