Skip to content

Revert changes in the userAgent #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default class BoltProtocol {
// passing notification filter on this protocol version throws an error
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)

this.write(RequestMessage.init(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken), observer, true)
this.write(RequestMessage.init(userAgent, authToken), observer, true)

return observer
}
Expand Down
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
// passing notification filter on this protocol version throws an error
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)

this.write(RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken), observer, true)
this.write(RequestMessage.hello(userAgent, authToken), observer, true)

return observer
}
Expand Down
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v4x1.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class BoltProtocol extends BoltProtocolV4 {
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)

this.write(
RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken, this._serversideRouting),
RequestMessage.hello(userAgent, authToken, this._serversideRouting),
observer,
true
)
Expand Down
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v4x3.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class BoltProtocol extends BoltProtocolV42 {
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)

this.write(
RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken, this._serversideRouting, ['utc']),
RequestMessage.hello(userAgent, authToken, this._serversideRouting, ['utc']),
observer,
true
)
Expand Down
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v5x0.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class BoltProtocol extends BoltProtocolV44 {
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)

this.write(
RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken, this._serversideRouting),
RequestMessage.hello(userAgent, authToken, this._serversideRouting),
observer,
true
)
Expand Down
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v5x1.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class BoltProtocol extends BoltProtocolV5x0 {
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)

this.write(
RequestMessage.hello5x1(userAgent === '' || userAgent == null ? boltAgent : userAgent, this._serversideRouting),
RequestMessage.hello5x1(userAgent, this._serversideRouting),
observer,
false
)
Expand Down
2 changes: 1 addition & 1 deletion packages/bolt-connection/src/bolt/bolt-protocol-v5x2.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class BoltProtocol extends BoltProtocolV5x1 {

this.write(
// if useragent is null then for all versions before 5.3 it should be bolt agent by default
RequestMessage.hello5x2(userAgent === '' || userAgent == null ? boltAgent : userAgent, notificationFilter, this._serversideRouting),
RequestMessage.hello5x2(userAgent, notificationFilter, this._serversideRouting),
observer,
false
)
Expand Down
23 changes: 23 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ describe('#unit BoltProtocolV1', () => {
expect(protocol.flushes).toEqual([true])
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV1(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.init(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should run a query', () => {
const recorder = new utils.MessageRecordingConnection()
const protocol = utils.spyProtocolWrite(
Expand Down
24 changes: 24 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import BoltProtocolV2 from '../../src/bolt/bolt-protocol-v2'
import RequestMessage from '../../src/bolt/request-message'
import utils from '../test-utils'

import {
Expand All @@ -44,6 +45,29 @@ describe('#unit BoltProtocolV2', () => {
expect.extend(utils.matchers)
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV2(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.init(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should return correct bolt version number', () => {
const protocol = new BoltProtocolV2(null, null, false)

Expand Down
23 changes: 23 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ describe('#unit BoltProtocolV3', () => {
expect(protocol.flushes).toEqual([true])
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV3(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should run a query', () => {
const bookmarks = new Bookmarks([
'neo4j:bookmark:v1:tx1',
Expand Down
23 changes: 23 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ describe('#unit BoltProtocolV4x0', () => {
expect.extend(utils.matchers)
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV4x0(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should run a query', () => {
const database = 'testdb'
const bookmarks = new Bookmarks([
Expand Down
28 changes: 28 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v4x1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import BoltProtocolV4x1 from '../../src/bolt/bolt-protocol-v4x1'
import RequestMessage from '../../src/bolt/request-message'
import utils from '../test-utils'
import {
Date,
Expand Down Expand Up @@ -45,6 +46,33 @@ const {
} = internal

describe('#unit BoltProtocolV4x1', () => {
beforeEach(() => {
expect.extend(utils.matchers)
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV4x1(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

describe('Bolt v4.4', () => {
/**
* @param {string} impersonatedUser The impersonated user.
Expand Down
28 changes: 28 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v4x2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import BoltProtocolV4x2 from '../../src/bolt/bolt-protocol-v4x2'
import RequestMessage from '../../src/bolt/request-message'
import utils from '../test-utils'
import {
Date,
Expand Down Expand Up @@ -45,6 +46,33 @@ const {
} = internal

describe('#unit BoltProtocolV4x2', () => {
beforeEach(() => {
expect.extend(utils.matchers)
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV4x2(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

describe('Bolt v4.4', () => {
/**
* @param {string} impersonatedUser The impersonated user.
Expand Down
23 changes: 23 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,29 @@ describe('#unit BoltProtocolV4x3', () => {
expect(protocol.flushes).toEqual([true])
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV4x3(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken, null, ['utc'])
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should begin a transaction', () => {
const bookmarks = new Bookmarks([
'neo4j:bookmark:v1:tx1',
Expand Down
23 changes: 23 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,29 @@ describe('#unit BoltProtocolV4x4', () => {
expect(protocol.flushes).toEqual([true])
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV4x4(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken, null, ['utc'])
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should begin a transaction', () => {
const bookmarks = new Bookmarks([
'neo4j:bookmark:v1:tx1',
Expand Down
23 changes: 23 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,29 @@ describe('#unit BoltProtocolV5x0', () => {
expect(protocol.flushes).toEqual([true])
})

it.each([
'javascript-driver/5.5.0',
'',
undefined,
null
])('should always use the user agent set by the user', (userAgent) => {
const recorder = new utils.MessageRecordingConnection()
const protocol = new BoltProtocolV5x0(recorder, null, false)
utils.spyProtocolWrite(protocol)

const clientName = 'js-driver/1.2.3'
const authToken = { username: 'neo4j', password: 'secret' }

const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })

protocol.verifyMessageCount(1)
expect(protocol.messages[0]).toBeMessage(
RequestMessage.hello(userAgent, authToken)
)
expect(protocol.observers).toEqual([observer])
expect(protocol.flushes).toEqual([true])
})

it('should begin a transaction', () => {
const bookmarks = new Bookmarks([
'neo4j:bookmark:v1:tx1',
Expand Down
Loading