Skip to content

Commit 4be3e9d

Browse files
committed
fix: properly close, remove debug
1 parent 6663a27 commit 4be3e9d

File tree

4 files changed

+1
-21
lines changed

4 files changed

+1
-21
lines changed

src/cmap/auth/mongodb_oidc/callback_workflow.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,18 @@ export class CallbackWorkflow implements Workflow {
6161
'Auth mechanism property REQUEST_TOKEN_CALLBACK is required.'
6262
);
6363
}
64-
console.log('RESPONSE', response);
6564
// Look for an existing entry in the cache.
6665
const entry = this.cache.getEntry(
6766
connection.address,
6867
credentials.username,
6968
requestCallback,
7069
refreshCallback || null
7170
);
72-
console.log('ENTRY', entry, entry?.isValid());
7371
let result;
7472
// Reauthentication must go through all the steps again regards of a cache entry
7573
// being present.
7674
if (entry && !reauthenticating) {
7775
if (entry.isValid()) {
78-
console.log('FINISHING');
7976
// Presence of a valid cache entry means we can skip to the finishing step.
8077
result = await this.finishAuthentication(
8178
connection,
@@ -84,7 +81,6 @@ export class CallbackWorkflow implements Workflow {
8481
response?.speculativeAuthenticate?.conversationId
8582
);
8683
} else {
87-
console.log('FETCH AND FINISH');
8884
// Presence of an expired cache entry means we must fetch a new one and
8985
// then execute the final step.
9086
const tokenResult = await this.fetchAccessToken(
@@ -103,7 +99,6 @@ export class CallbackWorkflow implements Workflow {
10399
);
104100
}
105101
} else {
106-
console.log('NO ENTRY IN CACHE');
107102
// No entry in the cache requires us to do all authentication steps
108103
// from start to finish, including getting a fresh token for the cache.
109104
const startDocument = await this.startAuthentication(
@@ -112,12 +107,10 @@ export class CallbackWorkflow implements Workflow {
112107
reauthenticating,
113108
response
114109
);
115-
console.log('START DOCUMENT', startDocument);
116110
const conversationId = startDocument.conversationId;
117111
const serverResult = BSON.deserialize(
118112
startDocument.payload.buffer
119113
) as OIDCMechanismServerStep1;
120-
console.log('SERVER_RESULT', serverResult);
121114
const tokenResult = await this.fetchAccessToken(
122115
connection,
123116
credentials,
@@ -189,38 +182,32 @@ export class CallbackWorkflow implements Workflow {
189182
requestCallback: OIDCRequestFunction,
190183
refreshCallback?: OIDCRefreshFunction
191184
): Promise<OIDCRequestTokenResult> {
192-
console.log('FETCH ACCESS TOKEN');
193185
// Get the token from the cache.
194186
const entry = this.cache.getEntry(
195187
connection.address,
196188
credentials.username,
197189
requestCallback,
198190
refreshCallback || null
199191
);
200-
console.log('ENTRY', entry);
201192
let result;
202193
const clientInfo = { principalName: credentials.username, timeoutSeconds: TIMEOUT_S };
203194
// Check if there's a token in the cache.
204195
if (entry) {
205196
// If the cache entry is valid, return the token result.
206197
if (entry.isValid() && !reauthenticating) {
207-
console.log('ENTRY IS VALID AND NOT REAUTHENTICATING');
208198
return entry.tokenResult;
209199
}
210200
// If the cache entry is not valid, remove it from the cache and first attempt
211201
// to use the refresh callback to get a new token. If no refresh callback
212202
// exists, then fallback to the request callback.
213203
if (refreshCallback) {
214204
result = await refreshCallback(clientInfo, startResult, entry.tokenResult);
215-
console.log('USING REFRESH CALLBACK', result);
216205
} else {
217206
result = await requestCallback(clientInfo, startResult);
218-
console.log('USING REQUEST CALLBACK, NO REFRESH FOUND', result);
219207
}
220208
} else {
221209
// With no token in the cache we use the request callback.
222210
result = await requestCallback(clientInfo, startResult);
223-
console.log('USING REQUEST CALLBACK, NO TOKEN IN CACHE', result);
224211
}
225212
// Validate that the result returned by the callback is acceptable.
226213
if (isCallbackResultInvalid(result)) {

src/cmap/connection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
410410
}
411411

412412
if (document.ok === 0 || document.$err || document.errmsg || document.code) {
413-
console.log('DOCUMENT', document);
414413
callback(new MongoServerError(document));
415414
return;
416415
}
@@ -489,7 +488,6 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
489488
options: CommandOptions | undefined,
490489
callback: Callback
491490
): void {
492-
console.log('CMD', cmd);
493491
const readPreference = getReadPreference(cmd, options);
494492
const shouldUseOpMsg = supportsOpMsg(this);
495493
const session = options?.session;

src/cmap/connection_pool.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
580580
callback: Callback<Connection>
581581
) {
582582
if (fnErr instanceof MongoError && fnErr.code === MONGODB_ERROR_CODES.Reauthenticate) {
583-
console.log('REAUTHENTICATING');
584583
this.reauthenticate(conn, fn, (error, res) => {
585584
if (error) {
586585
return callback(error);

test/manual/mongodb_oidc.prose.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@ describe('MONGODB-OIDC', function () {
706706
try {
707707
await collection.findOne();
708708
} catch (e) {
709-
console.log(e);
710709
expect(cache.entries.size).to.equal(0);
711710
}
712711
});
@@ -764,7 +763,7 @@ describe('MONGODB-OIDC', function () {
764763
});
765764
};
766765

767-
after(async function () {
766+
afterEach(async function () {
768767
await removeFailPoint();
769768
await client?.close();
770769
});
@@ -839,19 +838,16 @@ describe('MONGODB-OIDC', function () {
839838
const commandFailedEvents: CommandFailedEvent[] = [];
840839

841840
const commandStartedListener = event => {
842-
console.log('commandStarted', event);
843841
if (event.commandName === 'find') {
844842
commandStartedEvents.push(event);
845843
}
846844
};
847845
const commandSucceededListener = event => {
848-
console.log('commandSuceeded', event);
849846
if (event.commandName === 'find') {
850847
commandSucceededEvents.push(event);
851848
}
852849
};
853850
const commandFailedListener = event => {
854-
console.log('commandFailed', event);
855851
if (event.commandName === 'find') {
856852
commandFailedEvents.push(event);
857853
}

0 commit comments

Comments
 (0)