Skip to content

Commit 4922988

Browse files
committed
Make bolt agent an object in intergration tests
1 parent 367efdf commit 4922988

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

packages/bolt-connection/src/connection/connection-channel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export default class ChannelConnection extends Connection {
183183
/**
184184
* Send initialization message.
185185
* @param {string} userAgent the user agent for this driver.
186-
* @param {string} boltAgent the bolt agent for this driver.
186+
* @param {Object} boltAgent the bolt agent for this driver.
187187
* @param {Object} authToken the object containing auth information.
188188
* @param {boolean} waitReAuth whether ot not the connection will wait for re-authentication to happen
189189
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.

packages/bolt-connection/src/connection/connection.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class Connection {
9090
/**
9191
* Connect to the target address, negotiate Bolt protocol and send initialization message.
9292
* @param {string} userAgent the user agent for this driver.
93-
* @param {string} boltAgent the bolt agent for this driver.
93+
* @param {Object} boltAgent the bolt agent for this driver.
9494
* @param {Object} authToken the object containing auth information.
9595
* @param {boolean} shouldWaitReAuth whether ot not the connection will wait for re-authentication to happen
9696
* @return {Promise<Connection>} promise resolved with the current connection if connection is successful. Rejected promise otherwise.

packages/neo4j-driver/test/internal/connection-channel.test.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ const SUCCESS_MESSAGE = { signature: 0x70, fields: [{}] }
4747
const FAILURE_MESSAGE = { signature: 0x7f, fields: [newError('Hello')] }
4848
const RECORD_MESSAGE = { signature: 0x71, fields: [{ value: 'Hello' }] }
4949

50+
const BOLT_AGENT = {
51+
product: 'js-driver',
52+
platform: 'SomePlatform',
53+
language: 'js',
54+
language_details: 'Some node or deno details'
55+
}
56+
5057
describe('#integration ChannelConnection', () => {
5158
/** @type {Connection} */
5259
let connection
@@ -104,7 +111,7 @@ describe('#integration ChannelConnection', () => {
104111
}
105112

106113
connection
107-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
114+
.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
108115
.then(() => {
109116
connection
110117
.protocol()
@@ -177,7 +184,7 @@ describe('#integration ChannelConnection', () => {
177184
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
178185

179186
connection
180-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
187+
.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
181188
.then(initializedConnection => {
182189
expect(initializedConnection).toBe(connection)
183190
done()
@@ -189,7 +196,7 @@ describe('#integration ChannelConnection', () => {
189196
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`) // wrong port
190197

191198
connection
192-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicWrongAuthToken())
199+
.connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken())
193200
.then(() => done.fail('Should not initialize'))
194201
.catch(error => {
195202
expect(error).toBeDefined()
@@ -200,7 +207,7 @@ describe('#integration ChannelConnection', () => {
200207
it('should have server version after connection initialization completed', async done => {
201208
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
202209
connection
203-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
210+
.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
204211
.then(initializedConnection => {
205212
expect(initializedConnection).toBe(connection)
206213
const serverVersion = ServerVersion.fromString(connection.version)
@@ -214,7 +221,7 @@ describe('#integration ChannelConnection', () => {
214221
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
215222

216223
connection
217-
.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicWrongAuthToken())
224+
.connect('mydriver/0.0.0', BOLT_AGENT, basicWrongAuthToken())
218225
.then(() => done.fail('Should not connect'))
219226
.catch(initialError => {
220227
expect(initialError).toBeDefined()
@@ -274,7 +281,7 @@ describe('#integration ChannelConnection', () => {
274281
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
275282

276283
connection
277-
.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken())
284+
.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken())
278285
.then(() => {
279286
connection
280287
.resetAndFlush()
@@ -297,7 +304,7 @@ describe('#integration ChannelConnection', () => {
297304
it('should fail to reset and flush when FAILURE received', async done => {
298305
createConnection(`bolt://${sharedNeo4j.hostname}`)
299306
.then(connection => {
300-
connection.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken()).then(() => {
307+
connection.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken()).then(() => {
301308
connection
302309
.resetAndFlush()
303310
.then(() => done.fail('Should fail'))
@@ -325,7 +332,7 @@ describe('#integration ChannelConnection', () => {
325332
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
326333

327334
connection
328-
.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken())
335+
.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken())
329336
.then(() => {
330337
connection
331338
.resetAndFlush()
@@ -353,7 +360,7 @@ describe('#integration ChannelConnection', () => {
353360
createConnection(`bolt://${sharedNeo4j.hostname}`)
354361
.then(connection => {
355362
connection
356-
.connect('my-driver/1.2.3', 'mydriver/0.0.0 some system info', basicAuthToken())
363+
.connect('my-driver/1.2.3', BOLT_AGENT, basicAuthToken())
357364
.then(() => {
358365
connection.protocol()._responseHandler._currentFailure = newError(
359366
'Hello'
@@ -419,7 +426,7 @@ describe('#integration ChannelConnection', () => {
419426
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
420427
recordWrittenMessages(connection._protocol, messages)
421428

422-
await connection.connect('mydriver/0.0.0', 'mydriver/0.0.0 some system info', basicAuthToken())
429+
await connection.connect('mydriver/0.0.0', BOLT_AGENT, basicAuthToken())
423430

424431
expect(connection.isOpen()).toBeTruthy()
425432
await connection.close()
@@ -436,7 +443,7 @@ describe('#integration ChannelConnection', () => {
436443
it('should not prepare broken connection to close', async () => {
437444
connection = await createConnection(`bolt://${sharedNeo4j.hostname}`)
438445

439-
await connection.connect('my-connection/9.9.9', 'mydriver/0.0.0 some system info', basicAuthToken())
446+
await connection.connect('my-connection/9.9.9', BOLT_AGENT, basicAuthToken())
440447
expect(connection._protocol).toBeDefined()
441448
expect(connection._protocol).not.toBeNull()
442449

0 commit comments

Comments
 (0)