Skip to content

Commit eb51f6e

Browse files
committed
wip: replacing feature falgs
1 parent ca9f3c2 commit eb51f6e

File tree

11 files changed

+37
-40
lines changed

11 files changed

+37
-40
lines changed

src/cmap/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ export class CryptoConnection extends Connection {
889889

890890
const decryptedResponse = responseType?.make(result) ?? deserialize(result, options);
891891

892-
if (autoEncrypter.__decorateDecryptionResult) {
892+
if (autoEncrypter[kDecorateResult]) {
893893
if (responseType == null) {
894894
decorateDecryptionResult(decryptedResponse, encryptedResponse.toObject(), true);
895895
} else if (decryptedResponse instanceof CursorResponse) {

src/cmap/wire_protocol/responses.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ export class MongoDBResponse extends OnDemandDocument {
221221
export class CursorResponse extends MongoDBResponse {
222222
/**
223223
* Devtools need to know which keys were encrypted before the driver automatically decrypted them.
224-
* If decorating is enabled (`__decorateDecryptionResult`), this field will be set,
224+
* If decorating is enabled (`Symbol.for('@@mdb.decorateDecryptionResult')`), this field will be set,
225225
* storing the original encrypted response from the server, so that we can build an object that has
226-
* the list of BSON keys that were encrypted stored at a well known symbol: `__decryptedKeys`.
226+
* the list of BSON keys that were encrypted stored at a well known symbol: `Symbol.for('@@mdb.decryptedKeys')`.
227227
*/
228228
encryptedResponse?: MongoDBResponse;
229229
/**

test/integration/client-side-encryption/client_side_encryption.prose.12.deadlock.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CapturingMongoClient extends MongoClient {
3434
commandStartedEvents: Array<CommandStartedEvent> = [];
3535
clientsCreated = 0;
3636
constructor(url: string, options: MongoClientOptions = {}) {
37-
options = { ...options, monitorCommands: true, [__skipPingOnConnect]: true };
37+
options = { ...options, monitorCommands: true, [Symbol.for('@@mdb.skipPingOnConnect')]: true };
3838
if (process.env.MONGODB_API_VERSION) {
3939
options.serverApi = process.env.MONGODB_API_VERSION as MongoClientOptions['serverApi'];
4040
}

test/integration/client-side-encryption/driver.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ describe('Client Side Encryption Functional', function () {
394394
}
395395
);
396396

397-
encryptedClient.autoEncrypter[__decorateDecryptionResult] = true;
397+
encryptedClient.autoEncrypter[Symbol.for('@@mdb.decorateDecryptionResult')] = true;
398398
await encryptedClient.connect();
399399
});
400400

@@ -418,13 +418,13 @@ describe('Client Side Encryption Functional', function () {
418418

419419
expect(decrypted).to.deep.equal(data);
420420
expect(decrypted)
421-
.to.have.property(__decryptedKeys)
421+
.to.have.property(Symbol.for('@@mdb.decryptedKeys'))
422422
.that.deep.equals(['a', 'b']);
423423

424424
// Nested
425425
expect(decrypted).to.have.property('c');
426426
expect(decrypted.c)
427-
.to.have.property(__decryptedKeys)
427+
.to.have.property(Symbol.for('@@mdb.decryptedKeys'))
428428
.that.deep.equals(['d']);
429429
});
430430
}

test/integration/command-logging-and-monitoring/command_logging_and_monitoring.prose.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { expect } from 'chai';
33
import { DEFAULT_MAX_DOCUMENT_LENGTH, type Document } from '../../mongodb';
44

55
describe('Command Logging and Monitoring Prose Tests', function () {
6-
const loggerFeatureFlag = __enableMongoLogger;
76
const ELLIPSES_LENGTH = 3;
87
let client;
98
let writable;
@@ -40,7 +39,7 @@ describe('Command Logging and Monitoring Prose Tests', function () {
4039
client = this.configuration.newClient(
4140
{},
4241
{
43-
[loggerFeatureFlag]: true,
42+
__enableMongoLogger: true,
4443
mongodbLogPath: writable,
4544
mongodbLogComponentSeverities: {
4645
command: 'debug'
@@ -124,7 +123,7 @@ describe('Command Logging and Monitoring Prose Tests', function () {
124123
client = this.configuration.newClient(
125124
{},
126125
{
127-
[loggerFeatureFlag]: true,
126+
__enableMongoLogger: true,
128127
mongodbLogPath: writable,
129128
mongodbLogComponentSeverities: {
130129
command: 'debug'
@@ -181,7 +180,7 @@ describe('Command Logging and Monitoring Prose Tests', function () {
181180
client = this.configuration.newClient(
182181
{},
183182
{
184-
[loggerFeatureFlag]: true,
183+
__enableMongoLogger: true,
185184
mongodbLogPath: writable,
186185
mongodbLogComponentSeverities: {
187186
command: 'debug'

test/integration/node-specific/feature_flags.test.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from 'chai';
33
import { MongoClient, SeverityLevel } from '../../mongodb';
44

55
describe('Feature Flags', () => {
6-
describe('@@mdb.skipPingOnConnect', () => {
6+
describe('__skipPingOnConnect', () => {
77
beforeEach(function () {
88
if (process.env.AUTH !== 'auth') {
99
this.currentTest.skipReason = 'ping count relies on auth to be enabled';
@@ -23,8 +23,7 @@ describe('Feature Flags', () => {
2323
];
2424
for (const { description, value, expectEvents } of tests) {
2525
it(description, async function () {
26-
const options =
27-
value === undefined ? {} : { [__skipPingOnConnect]: value };
26+
const options = value === undefined ? {} : { __skipPingOnConnect: value };
2827
const client = this.configuration.newClient({}, { ...options, monitorCommands: true });
2928
const events = [];
3029
client.on('commandStarted', event => events.push(event));
@@ -46,9 +45,8 @@ describe('Feature Flags', () => {
4645
});
4746

4847
// TODO(NODE-5672): Release Standardized Logger
49-
describe('@@mdb.enableMongoLogger', () => {
48+
describe('__enableMongoLogger', () => {
5049
let cachedEnv;
51-
const loggerFeatureFlag = __enableMongoLogger;
5250

5351
before(() => {
5452
cachedEnv = process.env;
@@ -66,7 +64,7 @@ describe('Feature Flags', () => {
6664

6765
it('enables logging for the specified component', () => {
6866
const client = new MongoClient('mongodb://localhost:27017', {
69-
[loggerFeatureFlag]: true
67+
__enableMongoLogger: true
7068
});
7169
expect(client.mongoLogger?.componentSeverities).to.have.property(
7270
'command',
@@ -82,7 +80,7 @@ describe('Feature Flags', () => {
8280

8381
it('does not create logger', () => {
8482
const client = new MongoClient('mongodb://localhost:27017', {
85-
[loggerFeatureFlag]: true
83+
__enableMongoLogger: true
8684
});
8785
expect(client.mongoLogger).to.not.exist;
8886
});
@@ -98,7 +96,7 @@ describe('Feature Flags', () => {
9896

9997
it('does not instantiate logger', () => {
10098
const client = new MongoClient('mongodb://localhost:27017', {
101-
[loggerFeatureFlag]: featureFlagValue
99+
__enableMongoLogger: featureFlagValue
102100
});
103101
expect(client.mongoLogger).to.not.exist;
104102
});
@@ -111,7 +109,7 @@ describe('Feature Flags', () => {
111109

112110
it('does not instantiate logger', () => {
113111
const client = new MongoClient('mongodb://localhost:27017', {
114-
[loggerFeatureFlag]: featureFlagValue
112+
__enableMongoLogger: featureFlagValue
115113
});
116114
expect(client.mongoLogger).to.not.exist;
117115
});
@@ -120,7 +118,7 @@ describe('Feature Flags', () => {
120118
}
121119
});
122120

123-
describe('@@mdb.internalLoggerConfig', () => {
121+
describe('__internalLoggerConfig', () => {
124122
let cachedEnv: NodeJS.ProcessEnv;
125123

126124
before(() => {
@@ -138,8 +136,8 @@ describe('Feature Flags', () => {
138136

139137
it('falls back to environment options', function () {
140138
const client = new MongoClient('mongodb://localhost:27017', {
141-
[__enableMongoLogger]: true,
142-
[__internalLoggerConfig]: undefined
139+
__enableMongoLogger: true,
140+
__internalLoggerConfig: undefined
143141
});
144142

145143
expect(client.mongoLogger?.componentSeverities).to.have.property(
@@ -152,8 +150,8 @@ describe('Feature Flags', () => {
152150
context('when defined', function () {
153151
it('overrides environment options', function () {
154152
const client = new MongoClient('mongodb://localhost:27017', {
155-
[__enableMongoLogger]: true,
156-
[__internalLoggerConfig]: {
153+
__enableMongoLogger: true,
154+
__internalLoggerConfig: {
157155
MONGODB_LOG_COMMAND: SeverityLevel.ALERT
158156
}
159157
});

test/integration/node-specific/ipv6.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('IPv6 Addresses', () => {
3131

3232
ipv6Hosts = this.configuration.options.hostAddresses.map(({ port }) => `[::1]:${port}`);
3333
client = this.configuration.newClient(`mongodb://${ipv6Hosts.join(',')}/test`, {
34-
[__skipPingOnConnect]: true,
34+
__skipPingOnConnect: true,
3535
maxPoolSize: 1
3636
});
3737
});

test/integration/node-specific/mongo_client.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ describe('class MongoClient', function () {
456456
const [findCommandStarted] = await findCommandToBeStarted;
457457

458458
expect(findCommandStarted).to.have.property('commandName', 'find');
459-
expect(client.options).to.not.have.property(__skipPingOnConnect);
460-
expect(client.s.options).to.not.have.property(__skipPingOnConnect);
459+
expect(client.options).to.not.have.property('__skipPingOnConnect');
460+
expect(client.s.options).to.not.have.property('__skipPingOnConnect');
461461

462462
// Assertion is redundant but it shows that no initial ping is run
463463
expect(findCommandStarted.commandName).to.not.equal('ping');
@@ -475,8 +475,8 @@ describe('class MongoClient', function () {
475475
const [insertCommandStarted] = await insertOneCommandToBeStarted;
476476

477477
expect(insertCommandStarted).to.have.property('commandName', 'insert');
478-
expect(client.options).to.not.have.property(__skipPingOnConnect);
479-
expect(client.s.options).to.not.have.property(__skipPingOnConnect);
478+
expect(client.options).to.not.have.property('__skipPingOnConnect');
479+
expect(client.s.options).to.not.have.property('__skipPingOnConnect');
480480

481481
// Assertion is redundant but it shows that no initial ping is run
482482
expect(insertCommandStarted.commandName).to.not.equal('ping');

test/tools/spec-runner/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ function runTestSuiteTest(configuration, spec, context) {
363363
minHeartbeatFrequencyMS: 100,
364364
monitorCommands: true,
365365
...spec.clientOptions,
366-
[__skipPingOnConnect]: true
366+
__skipPingOnConnect: true
367367
});
368368

369369
if (context.requiresCSFLE) {

test/tools/unified-spec-runner/entities.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ export class UnifiedMongoClient extends MongoClient {
222222

223223
super(uri, {
224224
monitorCommands: true,
225-
[__skipPingOnConnect]: true,
226-
[__enableMongoLogger]: true,
227-
[__internalLoggerConfig]: componentSeverities,
225+
__skipPingOnConnect: true,
226+
__enableMongoLogger: true,
227+
__internalLoggerConfig: componentSeverities,
228228
...getEnvironmentalOptions(),
229229
...(description.serverApi ? { serverApi: description.serverApi } : {}),
230230
mongodbLogPath: logCollector,

0 commit comments

Comments
 (0)