Skip to content
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
16 changes: 14 additions & 2 deletions src/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,20 @@ export default {
isInt,
Neo4jError,
auth: {
basic: (username, password) => {
return {scheme: "basic", principal: username, credentials: password};
basic: (username, password, realm = undefined) => {
if (realm) {
return {scheme: "basic", principal: username, credentials: password, realm: realm};
} else {
return {scheme: "basic", principal: username, credentials: password};
}
},
custom: (principal, credentials, realm, scheme, parameters = undefined ) => {
if (parameters) {
return {scheme: scheme, principal: principal, credentials: credentials, realm: realm,
parameters: parameters}
} else {
return {scheme: scheme, principal: principal, credentials: credentials, realm: realm}
}
}
},
types: {
Expand Down
39 changes: 39 additions & 0 deletions test/v1/driver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,45 @@ describe('driver', function() {
driver.session();
});

it('should be possible to pass a realm with basic auth tokens', function(done) {
// Given
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j", "native"));

// Expect
driver.onCompleted = function (meta) {
done();
};

// When
driver.session();
});

it('should be possible to create custom auth tokens', function(done) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps also a test for basic with realm?

// Given
var driver = neo4j.driver("bolt://localhost", neo4j.auth.custom("neo4j", "neo4j", "native", "basic"));

// Expect
driver.onCompleted = function (meta) {
done();
};

// When
driver.session();
});

it('should be possible to create custom auth tokens with additional parameters', function(done) {
// Given
var driver = neo4j.driver("bolt://localhost", neo4j.auth.custom("neo4j", "neo4j", "native", "basic", {secret: 42}));

// Expect
driver.onCompleted = function (meta) {
done();
};

// When
driver.session();
});

var exposedTypes = [
'Node',
'Path',
Expand Down