diff --git a/src/v1/internal/connector.js b/src/v1/internal/connector.js index dba76cd96..603dbf2eb 100644 --- a/src/v1/internal/connector.js +++ b/src/v1/internal/connector.js @@ -323,6 +323,7 @@ class Connection { this._packer.packStruct( INIT, [this._packable(clientName), this._packable(token)], (err) => this._handleFatalError(err) ); this._chunker.messageBoundary(); + this.sync(); } /** Queue a RUN-message to be sent to the database */ diff --git a/test/v1/driver.test.js b/test/v1/driver.test.js index c269da942..a14b22d91 100644 --- a/test/v1/driver.test.js +++ b/test/v1/driver.test.js @@ -47,4 +47,19 @@ describe('driver', function() { // When driver.session(); }); + + it('should fail early on wrong credentials', function(done) { + // Given + var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "who would use such a password")); + + // Expect + driver.onError = function (err) { + //the error message is different whether in browser or node + expect(err.fields[0].code).toEqual('Neo.ClientError.Security.Unauthorized'); + done(); + }; + + // When + driver.session(); + }); }); diff --git a/test/v1/tck/steps/authsteps.js b/test/v1/tck/steps/authsteps.js index c879033ec..1b5e8157b 100644 --- a/test/v1/tck/steps/authsteps.js +++ b/test/v1/tck/steps/authsteps.js @@ -57,14 +57,12 @@ module.exports = function () { var message = this.err.fields[0].message var code = this.err.fields[0].code - // TODO uncomment this once we fix the init sync - //var expectedStartOfMessage = 'No operations allowed until you send an INIT message successfully.' - var expectedCode = 'Neo.ClientError'; + var expectedStartOfMessage = 'The client is unauthorized due to authentication failure.'; + var expectedCode = 'Neo.ClientError.Security.Unauthorized'; - // TODO uncomment this once we fix the init sync - //if (message.indexOf(expectedStartOfMessage) != 0) { - // throw new Error("Wrong error messsage. Expected: '" + expectedStartOfMessage + "'. Got: '" + message + "'"); - //} + if (message.indexOf(expectedStartOfMessage) != 0) { + throw new Error("Wrong error messsage. Expected: '" + expectedStartOfMessage + "'. Got: '" + message + "'"); + } if (code.indexOf(expectedCode) != 0) { throw new Error("Wrong error code. Expected: '" + expectedCode + "'. Got: '" + code + "'"); diff --git a/test/v1/tck/steps/tlssteps.js b/test/v1/tck/steps/tlssteps.js index 646aa09e8..81ea3db83 100644 --- a/test/v1/tck/steps/tlssteps.js +++ b/test/v1/tck/steps/tlssteps.js @@ -151,7 +151,6 @@ module.exports = function () { }); this.Then(/^I should get a helpful error explaining that no trusted certificate found$/, function (callback) { - console.log(this.error.message); var expected = "Server certificate is not trusted. If you trust the database you are connecting to, add the signing " + "certificate, or the server certificate, to the list of certificates trusted by this driver using " + "`neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This is a security measure to protect " +