Skip to content

Commit d00a4a1

Browse files
authored
Merge pull request #2 from bigmontz/bolt-agent
Revert changes in the `userAgent`
2 parents 1e4065f + 5b02022 commit d00a4a1

30 files changed

+331
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export default class BoltProtocol {
184184
// passing notification filter on this protocol version throws an error
185185
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)
186186

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

189189
return observer
190190
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
7878
// passing notification filter on this protocol version throws an error
7979
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)
8080

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

8383
return observer
8484
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default class BoltProtocol extends BoltProtocolV4 {
8383
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)
8484

8585
this.write(
86-
RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken, this._serversideRouting),
86+
RequestMessage.hello(userAgent, authToken, this._serversideRouting),
8787
observer,
8888
true
8989
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default class BoltProtocol extends BoltProtocolV42 {
104104
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)
105105

106106
this.write(
107-
RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken, this._serversideRouting, ['utc']),
107+
RequestMessage.hello(userAgent, authToken, this._serversideRouting, ['utc']),
108108
observer,
109109
true
110110
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class BoltProtocol extends BoltProtocolV44 {
6363
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)
6464

6565
this.write(
66-
RequestMessage.hello(userAgent === '' || userAgent == null ? boltAgent : userAgent, authToken, this._serversideRouting),
66+
RequestMessage.hello(userAgent, authToken, this._serversideRouting),
6767
observer,
6868
true
6969
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default class BoltProtocol extends BoltProtocolV5x0 {
7171
assertNotificationFilterIsEmpty(notificationFilter, this._onProtocolError, observer)
7272

7373
this.write(
74-
RequestMessage.hello5x1(userAgent === '' || userAgent == null ? boltAgent : userAgent, this._serversideRouting),
74+
RequestMessage.hello5x1(userAgent, this._serversideRouting),
7575
observer,
7676
false
7777
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default class BoltProtocol extends BoltProtocolV5x1 {
6969

7070
this.write(
7171
// if useragent is null then for all versions before 5.3 it should be bolt agent by default
72-
RequestMessage.hello5x2(userAgent === '' || userAgent == null ? boltAgent : userAgent, notificationFilter, this._serversideRouting),
72+
RequestMessage.hello5x2(userAgent, notificationFilter, this._serversideRouting),
7373
observer,
7474
false
7575
)

packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,29 @@ describe('#unit BoltProtocolV1', () => {
104104
expect(protocol.flushes).toEqual([true])
105105
})
106106

107+
it.each([
108+
'javascript-driver/5.5.0',
109+
'',
110+
undefined,
111+
null
112+
])('should always use the user agent set by the user', (userAgent) => {
113+
const recorder = new utils.MessageRecordingConnection()
114+
const protocol = new BoltProtocolV1(recorder, null, false)
115+
utils.spyProtocolWrite(protocol)
116+
117+
const clientName = 'js-driver/1.2.3'
118+
const authToken = { username: 'neo4j', password: 'secret' }
119+
120+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
121+
122+
protocol.verifyMessageCount(1)
123+
expect(protocol.messages[0]).toBeMessage(
124+
RequestMessage.init(userAgent, authToken)
125+
)
126+
expect(protocol.observers).toEqual([observer])
127+
expect(protocol.flushes).toEqual([true])
128+
})
129+
107130
it('should run a query', () => {
108131
const recorder = new utils.MessageRecordingConnection()
109132
const protocol = utils.spyProtocolWrite(

packages/bolt-connection/test/bolt/bolt-protocol-v2.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import BoltProtocolV2 from '../../src/bolt/bolt-protocol-v2'
21+
import RequestMessage from '../../src/bolt/request-message'
2122
import utils from '../test-utils'
2223

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

48+
it.each([
49+
'javascript-driver/5.5.0',
50+
'',
51+
undefined,
52+
null
53+
])('should always use the user agent set by the user', (userAgent) => {
54+
const recorder = new utils.MessageRecordingConnection()
55+
const protocol = new BoltProtocolV2(recorder, null, false)
56+
utils.spyProtocolWrite(protocol)
57+
58+
const clientName = 'js-driver/1.2.3'
59+
const authToken = { username: 'neo4j', password: 'secret' }
60+
61+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
62+
63+
protocol.verifyMessageCount(1)
64+
expect(protocol.messages[0]).toBeMessage(
65+
RequestMessage.init(userAgent, authToken)
66+
)
67+
expect(protocol.observers).toEqual([observer])
68+
expect(protocol.flushes).toEqual([true])
69+
})
70+
4771
it('should return correct bolt version number', () => {
4872
const protocol = new BoltProtocolV2(null, null, false)
4973

packages/bolt-connection/test/bolt/bolt-protocol-v3.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,29 @@ describe('#unit BoltProtocolV3', () => {
8989
expect(protocol.flushes).toEqual([true])
9090
})
9191

92+
it.each([
93+
'javascript-driver/5.5.0',
94+
'',
95+
undefined,
96+
null
97+
])('should always use the user agent set by the user', (userAgent) => {
98+
const recorder = new utils.MessageRecordingConnection()
99+
const protocol = new BoltProtocolV3(recorder, null, false)
100+
utils.spyProtocolWrite(protocol)
101+
102+
const clientName = 'js-driver/1.2.3'
103+
const authToken = { username: 'neo4j', password: 'secret' }
104+
105+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
106+
107+
protocol.verifyMessageCount(1)
108+
expect(protocol.messages[0]).toBeMessage(
109+
RequestMessage.hello(userAgent, authToken)
110+
)
111+
expect(protocol.observers).toEqual([observer])
112+
expect(protocol.flushes).toEqual([true])
113+
})
114+
92115
it('should run a query', () => {
93116
const bookmarks = new Bookmarks([
94117
'neo4j:bookmark:v1:tx1',

packages/bolt-connection/test/bolt/bolt-protocol-v4x0.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,29 @@ describe('#unit BoltProtocolV4x0', () => {
5757
expect.extend(utils.matchers)
5858
})
5959

60+
it.each([
61+
'javascript-driver/5.5.0',
62+
'',
63+
undefined,
64+
null
65+
])('should always use the user agent set by the user', (userAgent) => {
66+
const recorder = new utils.MessageRecordingConnection()
67+
const protocol = new BoltProtocolV4x0(recorder, null, false)
68+
utils.spyProtocolWrite(protocol)
69+
70+
const clientName = 'js-driver/1.2.3'
71+
const authToken = { username: 'neo4j', password: 'secret' }
72+
73+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
74+
75+
protocol.verifyMessageCount(1)
76+
expect(protocol.messages[0]).toBeMessage(
77+
RequestMessage.hello(userAgent, authToken)
78+
)
79+
expect(protocol.observers).toEqual([observer])
80+
expect(protocol.flushes).toEqual([true])
81+
})
82+
6083
it('should run a query', () => {
6184
const database = 'testdb'
6285
const bookmarks = new Bookmarks([

packages/bolt-connection/test/bolt/bolt-protocol-v4x1.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import BoltProtocolV4x1 from '../../src/bolt/bolt-protocol-v4x1'
21+
import RequestMessage from '../../src/bolt/request-message'
2122
import utils from '../test-utils'
2223
import {
2324
Date,
@@ -45,6 +46,33 @@ const {
4546
} = internal
4647

4748
describe('#unit BoltProtocolV4x1', () => {
49+
beforeEach(() => {
50+
expect.extend(utils.matchers)
51+
})
52+
53+
it.each([
54+
'javascript-driver/5.5.0',
55+
'',
56+
undefined,
57+
null
58+
])('should always use the user agent set by the user', (userAgent) => {
59+
const recorder = new utils.MessageRecordingConnection()
60+
const protocol = new BoltProtocolV4x1(recorder, null, false)
61+
utils.spyProtocolWrite(protocol)
62+
63+
const clientName = 'js-driver/1.2.3'
64+
const authToken = { username: 'neo4j', password: 'secret' }
65+
66+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
67+
68+
protocol.verifyMessageCount(1)
69+
expect(protocol.messages[0]).toBeMessage(
70+
RequestMessage.hello(userAgent, authToken)
71+
)
72+
expect(protocol.observers).toEqual([observer])
73+
expect(protocol.flushes).toEqual([true])
74+
})
75+
4876
describe('Bolt v4.4', () => {
4977
/**
5078
* @param {string} impersonatedUser The impersonated user.

packages/bolt-connection/test/bolt/bolt-protocol-v4x2.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import BoltProtocolV4x2 from '../../src/bolt/bolt-protocol-v4x2'
21+
import RequestMessage from '../../src/bolt/request-message'
2122
import utils from '../test-utils'
2223
import {
2324
Date,
@@ -45,6 +46,33 @@ const {
4546
} = internal
4647

4748
describe('#unit BoltProtocolV4x2', () => {
49+
beforeEach(() => {
50+
expect.extend(utils.matchers)
51+
})
52+
53+
it.each([
54+
'javascript-driver/5.5.0',
55+
'',
56+
undefined,
57+
null
58+
])('should always use the user agent set by the user', (userAgent) => {
59+
const recorder = new utils.MessageRecordingConnection()
60+
const protocol = new BoltProtocolV4x2(recorder, null, false)
61+
utils.spyProtocolWrite(protocol)
62+
63+
const clientName = 'js-driver/1.2.3'
64+
const authToken = { username: 'neo4j', password: 'secret' }
65+
66+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
67+
68+
protocol.verifyMessageCount(1)
69+
expect(protocol.messages[0]).toBeMessage(
70+
RequestMessage.hello(userAgent, authToken)
71+
)
72+
expect(protocol.observers).toEqual([observer])
73+
expect(protocol.flushes).toEqual([true])
74+
})
75+
4876
describe('Bolt v4.4', () => {
4977
/**
5078
* @param {string} impersonatedUser The impersonated user.

packages/bolt-connection/test/bolt/bolt-protocol-v4x3.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,29 @@ describe('#unit BoltProtocolV4x3', () => {
206206
expect(protocol.flushes).toEqual([true])
207207
})
208208

209+
it.each([
210+
'javascript-driver/5.5.0',
211+
'',
212+
undefined,
213+
null
214+
])('should always use the user agent set by the user', (userAgent) => {
215+
const recorder = new utils.MessageRecordingConnection()
216+
const protocol = new BoltProtocolV4x3(recorder, null, false)
217+
utils.spyProtocolWrite(protocol)
218+
219+
const clientName = 'js-driver/1.2.3'
220+
const authToken = { username: 'neo4j', password: 'secret' }
221+
222+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
223+
224+
protocol.verifyMessageCount(1)
225+
expect(protocol.messages[0]).toBeMessage(
226+
RequestMessage.hello(userAgent, authToken, null, ['utc'])
227+
)
228+
expect(protocol.observers).toEqual([observer])
229+
expect(protocol.flushes).toEqual([true])
230+
})
231+
209232
it('should begin a transaction', () => {
210233
const bookmarks = new Bookmarks([
211234
'neo4j:bookmark:v1:tx1',

packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,29 @@ describe('#unit BoltProtocolV4x4', () => {
280280
expect(protocol.flushes).toEqual([true])
281281
})
282282

283+
it.each([
284+
'javascript-driver/5.5.0',
285+
'',
286+
undefined,
287+
null
288+
])('should always use the user agent set by the user', (userAgent) => {
289+
const recorder = new utils.MessageRecordingConnection()
290+
const protocol = new BoltProtocolV4x4(recorder, null, false)
291+
utils.spyProtocolWrite(protocol)
292+
293+
const clientName = 'js-driver/1.2.3'
294+
const authToken = { username: 'neo4j', password: 'secret' }
295+
296+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
297+
298+
protocol.verifyMessageCount(1)
299+
expect(protocol.messages[0]).toBeMessage(
300+
RequestMessage.hello(userAgent, authToken, null, ['utc'])
301+
)
302+
expect(protocol.observers).toEqual([observer])
303+
expect(protocol.flushes).toEqual([true])
304+
})
305+
283306
it('should begin a transaction', () => {
284307
const bookmarks = new Bookmarks([
285308
'neo4j:bookmark:v1:tx1',

packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,29 @@ describe('#unit BoltProtocolV5x0', () => {
280280
expect(protocol.flushes).toEqual([true])
281281
})
282282

283+
it.each([
284+
'javascript-driver/5.5.0',
285+
'',
286+
undefined,
287+
null
288+
])('should always use the user agent set by the user', (userAgent) => {
289+
const recorder = new utils.MessageRecordingConnection()
290+
const protocol = new BoltProtocolV5x0(recorder, null, false)
291+
utils.spyProtocolWrite(protocol)
292+
293+
const clientName = 'js-driver/1.2.3'
294+
const authToken = { username: 'neo4j', password: 'secret' }
295+
296+
const observer = protocol.initialize({ userAgent, boltAgent: clientName, authToken })
297+
298+
protocol.verifyMessageCount(1)
299+
expect(protocol.messages[0]).toBeMessage(
300+
RequestMessage.hello(userAgent, authToken)
301+
)
302+
expect(protocol.observers).toEqual([observer])
303+
expect(protocol.flushes).toEqual([true])
304+
})
305+
283306
it('should begin a transaction', () => {
284307
const bookmarks = new Bookmarks([
285308
'neo4j:bookmark:v1:tx1',

0 commit comments

Comments
 (0)