Skip to content

Commit b1d2838

Browse files
fix CI
1 parent 0224235 commit b1d2838

File tree

6 files changed

+42
-57
lines changed

6 files changed

+42
-57
lines changed

src/cmap/handshake/client_metadata.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ export class LimitedSizeDocument {
9999
}
100100
}
101101

102-
type MakeClientMetadataOptions = Pick<
103-
MongoOptions,
104-
'appName' | 'driverInfo' | 'additionalDriverInfo'
105-
>;
102+
type MakeClientMetadataOptions = Pick<MongoOptions, 'appName' | 'additionalDriverInfo'>;
106103
/**
107104
* From the specs:
108105
* Implementors SHOULD cumulatively update fields in the following order until the document is under the size limit:

src/connection_string.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { URLSearchParams } from 'url';
55
import type { Document } from './bson';
66
import { MongoCredentials } from './cmap/auth/mongo_credentials';
77
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './cmap/auth/providers';
8-
import { addContainerMetadata, makeClientMetadata } from './cmap/handshake/client_metadata';
98
import { Compressor, type CompressorName } from './cmap/wire_protocol/compression';
109
import { Encrypter } from './encrypter';
1110
import {

test/integration/mongodb-handshake/mongodb-handshake.prose.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,10 @@ describe('Client Metadata Update Prose Tests', function () {
412412
// 4. Save intercepted `client` document as `updatedClientMetadata`.
413413
// 5. Wait 5ms for the connection to become idle.
414414
beforeEach(async function () {
415-
client = new RawMongoClient(this.configuration.url(), { maxIdleTimeMS: 1 });
415+
client = new RawMongoClient(this.configuration.url(), {
416+
maxIdleTimeMS: 1,
417+
serverApi: this.configuration.serverApi
418+
});
416419
client.appendMetadata(originalDriverInfo);
417420

418421
sinon
@@ -515,6 +518,7 @@ describe('Client Metadata Update Prose Tests', function () {
515518
// | platform | Library Platform |
516519
client = new RawMongoClient(this.configuration.url(), {
517520
maxIdleTimeMS: 1,
521+
serverApi: this.configuration.serverApi,
518522
driverInfo: { name: 'library', version: '1.2', platform: 'Library Platform' }
519523
});
520524

test/tools/runner/filters/api_version_filter.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type MongoClient } from '../../../mongodb';
12
import { Filter } from './filter';
23

34
/**
@@ -20,6 +21,13 @@ export class ApiVersionFilter extends Filter {
2021
this.apiVersion = process.env.MONGODB_API_VERSION;
2122
}
2223

24+
override async initializeFilter(
25+
_client: MongoClient,
26+
context: Record<string, any>
27+
): Promise<void> {
28+
context.serverApi = this.apiVersion;
29+
}
30+
2331
filter(test: { metadata?: MongoDBMetadataUI }) {
2432
if (!test.metadata) return true;
2533
if (!test.metadata.requires) return true;

test/tools/runner/hooks/configuration.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ process.env.MONGODB_URI =
4040
// determine the connection string based on the value of process.env.AUTH
4141
const MONGODB_URI = process.env.MONGODB_URI;
4242

43-
const MONGODB_API_VERSION = process.env.MONGODB_API_VERSION;
4443
// Load balancer fronting 1 mongos.
4544
const SINGLE_MONGOS_LB_URI = process.env.SINGLE_MONGOS_LB_URI;
4645
// Load balancer fronting 2 mongoses.
@@ -126,10 +125,6 @@ const testConfigBeforeHook = async function () {
126125

127126
const context = await initializeFilters(client);
128127

129-
if (MONGODB_API_VERSION) {
130-
context.serverApi = MONGODB_API_VERSION;
131-
}
132-
133128
if (SINGLE_MONGOS_LB_URI && MULTI_MONGOS_LB_URI) {
134129
context.singleMongosLoadBalancerUri = SINGLE_MONGOS_LB_URI;
135130
context.multiMongosLoadBalancerUri = MULTI_MONGOS_LB_URI;
@@ -167,7 +162,7 @@ const testConfigBeforeHook = async function () {
167162
},
168163
cryptSharedVersion: context.cryptSharedVersion,
169164
cryptSharedLibPath: process.env.CRYPT_SHARED_LIB_PATH,
170-
serverApi: MONGODB_API_VERSION,
165+
serverApi: process.env.MONGODB_API_VERSION,
171166
atlas: process.env.ATLAS_CONNECTIVITY != null,
172167
aws: MONGODB_URI.includes('authMechanism=MONGODB-AWS'),
173168
awsSdk: process.env.MONGODB_AWS_SDK,

test/unit/cmap/handshake/client_metadata.test.ts

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('client metadata module', () => {
142142
describe('makeClientMetadata()', () => {
143143
context('when no FAAS environment is detected', () => {
144144
it('does not append FAAS metadata', () => {
145-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
145+
const metadata = makeClientMetadata({ additionalDriverInfo: [{}] });
146146
expect(metadata).not.to.have.property(
147147
'env',
148148
'faas metadata applied in a non-faas environment'
@@ -167,16 +167,14 @@ describe('client metadata module', () => {
167167
it('throws an error if driverInfo.platform is too large', () => {
168168
expect(() =>
169169
makeClientMetadata({
170-
driverInfo: { platform: 'a'.repeat(512) },
171-
additionalDriverInfo: []
170+
additionalDriverInfo: [{ platform: 'a'.repeat(512) }]
172171
})
173172
).to.throw(MongoInvalidArgumentError, /platform/);
174173
});
175174

176175
it('appends driverInfo.platform to the platform field', () => {
177176
const options = {
178-
driverInfo: { platform: 'myPlatform' },
179-
additionalDriverInfo: []
177+
additionalDriverInfo: [{ platform: 'myPlatform' }]
180178
};
181179
const metadata = makeClientMetadata(options);
182180
expect(metadata).to.deep.equal({
@@ -198,16 +196,12 @@ describe('client metadata module', () => {
198196
context('when driverInfo.name is provided', () => {
199197
it('throws an error if driverInfo.name is too large', () => {
200198
expect(() =>
201-
makeClientMetadata({ driverInfo: { name: 'a'.repeat(512) }, additionalDriverInfo: [] })
199+
makeClientMetadata({ additionalDriverInfo: [{ name: 'a'.repeat(512) }] })
202200
).to.throw(MongoInvalidArgumentError, /name/);
203201
});
204202

205203
it('appends driverInfo.name to the driver.name field', () => {
206-
const options = {
207-
driverInfo: { name: 'myName' },
208-
additionalDriverInfo: []
209-
};
210-
const metadata = makeClientMetadata(options);
204+
const metadata = makeClientMetadata({ additionalDriverInfo: [{ name: 'myName' }] });
211205
expect(metadata).to.deep.equal({
212206
driver: {
213207
name: 'nodejs|myName',
@@ -227,16 +221,14 @@ describe('client metadata module', () => {
227221
context('when driverInfo.version is provided', () => {
228222
it('throws an error if driverInfo.version is too large', () => {
229223
expect(() =>
230-
makeClientMetadata({ driverInfo: { version: 'a'.repeat(512) }, additionalDriverInfo: [] })
224+
makeClientMetadata({ additionalDriverInfo: [{ version: 'a'.repeat(512) }] })
231225
).to.throw(MongoInvalidArgumentError, /version/);
232226
});
233227

234228
it('appends driverInfo.version to the version field', () => {
235-
const options = {
236-
driverInfo: { version: 'myVersion' },
237-
additionalDriverInfo: []
238-
};
239-
const metadata = makeClientMetadata(options);
229+
const metadata = makeClientMetadata({
230+
additionalDriverInfo: [{ version: 'myVersion' }]
231+
});
240232
expect(metadata).to.deep.equal({
241233
driver: {
242234
name: 'nodejs',
@@ -254,7 +246,7 @@ describe('client metadata module', () => {
254246
});
255247

256248
context('when no custom driverInto is provided', () => {
257-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
249+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
258250

259251
it('does not append the driver info to the metadata', () => {
260252
expect(metadata).to.deep.equal({
@@ -280,12 +272,10 @@ describe('client metadata module', () => {
280272
context('when app name is provided', () => {
281273
context('when the app name is over 128 bytes', () => {
282274
const longString = 'a'.repeat(300);
283-
const options = {
275+
const metadata = makeClientMetadata({
284276
appName: longString,
285-
driverInfo: {},
286277
additionalDriverInfo: []
287-
};
288-
const metadata = makeClientMetadata(options);
278+
});
289279

290280
it('truncates the application name to <=128 bytes', () => {
291281
expect(metadata.application?.name).to.be.a('string');
@@ -300,12 +290,10 @@ describe('client metadata module', () => {
300290
'TODO(NODE-5150): fix appName truncation when multi-byte unicode charaters straddle byte 128',
301291
() => {
302292
const longString = '€'.repeat(300);
303-
const options = {
293+
const metadata = makeClientMetadata({
304294
appName: longString,
305-
driverInfo: {},
306295
additionalDriverInfo: []
307-
};
308-
const metadata = makeClientMetadata(options);
296+
});
309297

310298
it('truncates the application name to 129 bytes', () => {
311299
expect(metadata.application?.name).to.be.a('string');
@@ -318,12 +306,10 @@ describe('client metadata module', () => {
318306
);
319307

320308
context('when the app name is under 128 bytes', () => {
321-
const options = {
309+
const metadata = makeClientMetadata({
322310
appName: 'myApplication',
323-
driverInfo: {},
324311
additionalDriverInfo: []
325-
};
326-
const metadata = makeClientMetadata(options);
312+
});
327313

328314
it('sets the application name to the value', () => {
329315
expect(metadata.application?.name).to.equal('myApplication');
@@ -339,40 +325,39 @@ describe('client metadata module', () => {
339325

340326
it('sets platform to Deno', () => {
341327
globalThis.Deno = { version: { deno: '1.2.3' } };
342-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
328+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
343329
expect(metadata.platform).to.equal('Deno v1.2.3, LE');
344330
});
345331

346332
it('sets platform to Deno with driverInfo.platform', () => {
347333
globalThis.Deno = { version: { deno: '1.2.3' } };
348334
const metadata = makeClientMetadata({
349-
driverInfo: { platform: 'myPlatform' },
350-
additionalDriverInfo: []
335+
additionalDriverInfo: [{ platform: 'myPlatform' }]
351336
});
352337
expect(metadata.platform).to.equal('Deno v1.2.3, LE|myPlatform');
353338
});
354339

355340
it('ignores version if Deno.version.deno is not a string', () => {
356341
globalThis.Deno = { version: { deno: 1 } };
357-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
342+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
358343
expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE');
359344
});
360345

361346
it('ignores version if Deno.version does not have a deno property', () => {
362347
globalThis.Deno = { version: { somethingElse: '1.2.3' } };
363-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
348+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
364349
expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE');
365350
});
366351

367352
it('ignores version if Deno.version is null', () => {
368353
globalThis.Deno = { version: null };
369-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
354+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
370355
expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE');
371356
});
372357

373358
it('ignores version if Deno is nullish', () => {
374359
globalThis.Deno = null;
375-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
360+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
376361
expect(metadata.platform).to.equal('Deno v0.0.0-unknown, LE');
377362
});
378363
});
@@ -386,7 +371,7 @@ describe('client metadata module', () => {
386371
globalThis.Bun = class {
387372
static version = '1.2.3';
388373
};
389-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
374+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
390375
expect(metadata.platform).to.equal('Bun v1.2.3, LE');
391376
});
392377

@@ -395,8 +380,7 @@ describe('client metadata module', () => {
395380
static version = '1.2.3';
396381
};
397382
const metadata = makeClientMetadata({
398-
driverInfo: { platform: 'myPlatform' },
399-
additionalDriverInfo: []
383+
additionalDriverInfo: [{ platform: 'myPlatform' }]
400384
});
401385
expect(metadata.platform).to.equal('Bun v1.2.3, LE|myPlatform');
402386
});
@@ -405,7 +389,7 @@ describe('client metadata module', () => {
405389
globalThis.Bun = class {
406390
static version = 1;
407391
};
408-
const metadata = makeClientMetadata({ driverInfo: {}, additionalDriverInfo: [] });
392+
const metadata = makeClientMetadata({ additionalDriverInfo: [] });
409393
expect(metadata.platform).to.equal('Bun v0.0.0-unknown, LE');
410394
});
411395

@@ -414,17 +398,15 @@ describe('client metadata module', () => {
414398
static version = 1;
415399
};
416400
const metadata = makeClientMetadata({
417-
driverInfo: { platform: 'myPlatform' },
418-
additionalDriverInfo: []
401+
additionalDriverInfo: [{ platform: 'myPlatform' }]
419402
});
420403
expect(metadata.platform).to.equal('Bun v0.0.0-unknown, LE|myPlatform');
421404
});
422405

423406
it('ignores version if Bun is nullish', () => {
424407
globalThis.Bun = null;
425408
const metadata = makeClientMetadata({
426-
driverInfo: { platform: 'myPlatform' },
427-
additionalDriverInfo: []
409+
additionalDriverInfo: [{ platform: 'myPlatform' }]
428410
});
429411
expect(metadata.platform).to.equal('Bun v0.0.0-unknown, LE|myPlatform');
430412
});

0 commit comments

Comments
 (0)