Skip to content

Commit 617bc27

Browse files
committed
Prohibit TRUST_ON_FIRST_USE + routing
It does not make much sense with cluster where logical cluster members can be moved from one machine to another.
1 parent 8537892 commit 617bc27

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/v1/routing-driver.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import Integer from './integer'
3030
class RoutingDriver extends Driver {
3131

3232
constructor(url, userAgent, token = {}, config = {}) {
33-
super(url, userAgent, token, config);
33+
super(url, userAgent, token, RoutingDriver._validateConfig(config));
3434
this._clusterView = new ClusterView(new RoundRobinArray([url]));
3535
}
3636

@@ -148,6 +148,13 @@ class RoutingDriver extends Driver {
148148
this._pool.purge(url);
149149
this._clusterView.remove(url);
150150
}
151+
152+
static _validateConfig(config) {
153+
if(config.trust === 'TRUST_ON_FIRST_USE') {
154+
throw newError('The chosen trust mode is not compatible with a routing driver');
155+
}
156+
return config;
157+
}
151158
}
152159

153160
class ClusterView {

test/v1/driver.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ describe('driver', function() {
152152
routingDriver.close();
153153
});
154154

155+
it('should fail when TRUST_ON_FIRST_USE is used with routing', () => {
156+
const createRoutingDriverWithTOFU = () => {
157+
driver = neo4j.driver('bolt+routing://localhost', neo4j.auth.basic('neo4j', 'neo4j'), {
158+
encrypted: "ENCRYPTION_ON",
159+
trust: 'TRUST_ON_FIRST_USE'
160+
});
161+
};
162+
163+
expect(createRoutingDriverWithTOFU).toThrow();
164+
});
165+
155166
var exposedTypes = [
156167
'Node',
157168
'Path',

0 commit comments

Comments
 (0)