Skip to content

Send INIT eagerly #125

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 1 commit into from
Aug 26, 2016
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
1 change: 1 addition & 0 deletions src/v1/internal/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
15 changes: 15 additions & 0 deletions test/v1/driver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
12 changes: 5 additions & 7 deletions test/v1/tck/steps/authsteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "'");
Expand Down
1 change: 0 additions & 1 deletion test/v1/tck/steps/tlssteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand Down