Skip to content

Commit c5ecb99

Browse files
authored
fix(logging): forward debug logs (#2528)
Without this, we lose debug logging information from the oidc-plugin internals, such as HTTP request tracking.
1 parent 6e615e3 commit c5ecb99

File tree

9 files changed

+55
-24
lines changed

9 files changed

+55
-24
lines changed

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/arg-parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"mongodb-connection-string-url": "^3.0.1"
4141
},
4242
"devDependencies": {
43-
"@mongodb-js/devtools-connect": "^3.9.3",
43+
"@mongodb-js/devtools-connect": "^3.9.4",
4444
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
4545
"@mongodb-js/prettier-config-devtools": "^1.0.1",
4646
"@mongodb-js/tsconfig-mongosh": "^1.0.0",

packages/cli-repl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
}
6363
},
6464
"dependencies": {
65-
"@mongodb-js/devtools-proxy-support": "^0.5.2",
65+
"@mongodb-js/devtools-proxy-support": "^0.5.3",
6666
"@mongosh/arg-parser": "^3.16.0",
6767
"@mongosh/autocomplete": "^3.20.0",
6868
"@mongosh/editor": "^3.20.0",

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { TestShell } from './test-shell';
1010
import path from 'path';
1111
import { expect } from 'chai';
1212
import { createServer as createHTTPSServer } from 'https';
13-
import { getCertPath, useTmpdir } from './repl-helpers';
13+
import { getCertPath, readReplLogFile, useTmpdir } from './repl-helpers';
1414
import {
1515
baseOidcServerConfig,
1616
commonOidcServerArgs,
@@ -530,6 +530,34 @@ describe('OIDC auth e2e', function () {
530530
shell.assertContainsOutput(/"refreshToken": "(?!debugid:)/);
531531
});
532532

533+
it('logs OIDC HTTP calls', async function () {
534+
shell = this.startTestShell({
535+
args: [
536+
await testServer.connectionString(),
537+
'--authenticationMechanism=MONGODB-OIDC',
538+
'--oidcRedirectUri=http://localhost:0/',
539+
`--browser=${fetchBrowserFixture}`,
540+
'--eval=log.getPath()',
541+
'--quiet',
542+
'--json',
543+
],
544+
env: {
545+
...process.env,
546+
HOME: tmpdir.path,
547+
LOCALAPPDATA: tmpdir.path,
548+
APPDATA: tmpdir.path,
549+
},
550+
});
551+
await shell.waitForSuccessfulExit();
552+
const logs = await readReplLogFile(JSON.parse(shell.output));
553+
const inbound = logs.find((e) => e.id === 1_002_000_024);
554+
const outbound = logs.find((e) => e.id === 1_002_000_023);
555+
expect(inbound?.attr.url).to.be.a('string');
556+
expect(inbound?.s).to.equal('D1');
557+
expect(outbound?.attr.url).to.be.a('string');
558+
expect(outbound?.s).to.equal('D1');
559+
});
560+
533561
it('can successfully authenticate using workload OIDC', async function () {
534562
// Get a token from the OIDC server, store it to disk, then pass that to mongosh
535563
const tokenFile = path.join(tmpdir.path, 'token');

packages/logging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"dependencies": {
2020
"@mongodb-js/device-id": "^0.2.1",
21-
"@mongodb-js/devtools-connect": "^3.9.3",
21+
"@mongodb-js/devtools-connect": "^3.9.4",
2222
"@mongosh/errors": "2.4.4",
2323
"@mongosh/history": "2.4.8",
2424
"@mongosh/types": "^3.12.0",

packages/logging/src/logging-and-telemetry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ export class LoggingAndTelemetry implements MongoshLoggingAndTelemetry {
913913
hookLogger(
914914
this.bus,
915915
{
916+
debug: (...args: Parameters<typeof this.log.debug>) => {
917+
return this.log.debug(...args);
918+
},
916919
info: (...args: Parameters<typeof this.log.info>) => {
917920
return this.log.info(...args);
918921
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
}
4848
},
4949
"dependencies": {
50-
"@mongodb-js/devtools-connect": "^3.9.3",
50+
"@mongodb-js/devtools-connect": "^3.9.4",
5151
"@mongodb-js/oidc-plugin": "^2.0.3",
5252
"@mongosh/errors": "2.4.4",
5353
"@mongosh/service-provider-core": "3.3.7",

packages/snippet-manager/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"unitTestsOnly": true
3636
},
3737
"dependencies": {
38-
"@mongodb-js/devtools-proxy-support": "^0.5.2",
38+
"@mongodb-js/devtools-proxy-support": "^0.5.3",
3939
"@mongosh/errors": "2.4.4",
4040
"@mongosh/shell-api": "^3.20.0",
4141
"@mongosh/types": "^3.12.0",

packages/types/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"unitTestsOnly": true
3939
},
4040
"dependencies": {
41-
"@mongodb-js/devtools-connect": "^3.9.3"
41+
"@mongodb-js/devtools-connect": "^3.9.4"
4242
},
4343
"devDependencies": {
4444
"@mongodb-js/eslint-config-mongosh": "^1.0.0",

0 commit comments

Comments
 (0)