Skip to content

Commit b827c68

Browse files
committed
Merge remote-tracking branch 'upstream/1.0' into 1.1
2 parents 72ee068 + a3aa231 commit b827c68

File tree

13 files changed

+160
-152
lines changed

13 files changed

+160
-152
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "neokit"]
2+
path = neokit
3+
url = https://github.com/neo-technology/neokit.git

gulpfile.js

Lines changed: 39 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -165,46 +165,8 @@ gulp.task('watch-n-test', ['test-nodejs'], function () {
165165
return gulp.watch(['src/**/*.js', "test/**/*.js"], ['test-nodejs'] );
166166
});
167167

168-
var neo4jLinuxUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.1.0-NIGHTLY-unix.tar.gz';
169-
var neo4jWinUrl = 'http://alpha.neohq.net/dist/neo4j-enterprise-3.1.0-NIGHTLY-windows.zip';
170-
var neo4jHome = './build/neo4j-enterprise-3.1.0';
171-
var isWin = /^win/.test(process.platform);
172-
173-
gulp.task('download-neo4j', function() {
174-
if( !fs.existsSync(neo4jHome) ) {
175-
// Need to download
176-
if(isWin) {
177-
return download(neo4jWinUrl)
178-
.pipe(decompress({strip: 1}))
179-
.pipe(gulp.dest(neo4jHome));
180-
}
181-
else {
182-
return download(neo4jLinuxUrl)
183-
.pipe(decompress({strip: 1}))
184-
.pipe(gulp.dest(neo4jHome));
185-
}
186-
}
187-
});
188-
189-
gulp.task('set-password', ['download-neo4j'], function() {
190-
var setPassword = gulp.src('test/resources/auth')
191-
.pipe(gulp.dest(neo4jHome + "/data/dbms/"));
192-
193-
if(isWin)
194-
{
195-
var setServerName = gulp.src('test/resources/neo4j-wrapper.conf')
196-
.pipe(gulp.dest(neo4jHome + "/conf/"));
197-
198-
return merge(setPassword, setServerName);
199-
}
200-
else
201-
{
202-
return setPassword;
203-
}
204-
});
205-
206168
var featureFiles = 'https://s3-eu-west-1.amazonaws.com/remoting.neotechnology.com/driver-compliance/tck.tar.gz';
207-
var featureHome = './build/tck';
169+
var featureHome = './build/tck';
208170

209171
gulp.task('download-tck', function() {
210172
return download(featureFiles)
@@ -220,21 +182,6 @@ gulp.task('run-tck', ['download-tck', 'nodejs'], function() {
220182
}));
221183
});
222184

223-
var runPowershell = function( cmd ) {
224-
var spawn = childProcess.spawn, child;
225-
child = spawn("powershell.exe",[cmd]);
226-
child.stdout.on("data",function(data){
227-
console.log("Powershell Data: " + data);
228-
});
229-
child.stderr.on("data",function(data){
230-
console.error("Powershell Errors: " + data);
231-
});
232-
child.on("exit",function(){
233-
console.log("Powershell Script finished");
234-
});
235-
child.stdin.end(); //end input
236-
};
237-
238185
/** Set the project version, controls package.json and version.js */
239186
gulp.task('set', function() {
240187
// Get the --version arg from command line
@@ -247,28 +194,44 @@ gulp.task('set', function() {
247194

248195
});
249196

250-
gulp.task('start-neo4j', ['set-password'], function() {
251-
if(isWin) {
252-
return runPowershell(neo4jHome + '/bin/neo4j.bat install-service;' + neo4jHome + '/bin/neo4j.bat start');
253-
}
254-
else {
255-
return gulp.src('').pipe(shell([
256-
'mkdir -p ' + neo4jHome + '/logs',
257-
'mkdir -p ' + neo4jHome + '/run',
258-
'mkdir -p ' + neo4jHome + '/plugins',
259-
'mkdir -p ' + neo4jHome + '/import',
260-
'chmod +x ' + neo4jHome + '/bin/neo4j',
261-
neo4jHome + '/bin/neo4j start',
262-
]));
263-
}
197+
198+
var neo4jHome = path.resolve('./build/neo4j');
199+
var neorunPath = path.resolve('./neokit/neorun.py');
200+
var neorunStartArgsName = "--neorun.start.args"; // use this args to provide additional args for running neorun.start
201+
202+
gulp.task('start-neo4j', function() {
203+
204+
var neorunStartArgs = '-p neo4j'; // default args to neorun.start: change the default password to neo4j
205+
process.argv.slice(2).forEach(function (val) {
206+
if(val.startsWith(neorunStartArgsName))
207+
{
208+
neorunStartArgs = val.split("=")[1];
209+
}
210+
});
211+
212+
neorunStartArgs = neorunStartArgs.match(/\S+/g) || '';
213+
214+
return runScript([
215+
neorunPath, '--start=' + neo4jHome
216+
].concat( neorunStartArgs ) );
264217
});
265218

266219
gulp.task('stop-neo4j', function() {
267-
if(isWin) {
268-
return runPowershell(neo4jHome + '/bin/neo4j.bat stop;' + neo4jHome + '/bin/neo4j.bat uninstall-service');
269-
} else {
270-
return gulp.src('').pipe(shell([
271-
neo4jHome + '/bin/neo4j stop',
272-
]));
273-
}
274-
});
220+
return runScript([
221+
neorunPath, '--stop=' + neo4jHome
222+
]);
223+
});
224+
225+
var runScript = function(cmd) {
226+
var spawnSync = childProcess.spawnSync, child, code;
227+
child = spawnSync('python', cmd);
228+
console.log("Script Outputs:\n" + child.stdout.toString());
229+
var error = child.stderr.toString();
230+
if (error.trim() !== "")
231+
console.log("Script Errors:\n"+ error);
232+
code = child.status;
233+
if( code !==0 )
234+
{
235+
throw "Script finished with code " + code
236+
}
237+
};

lib/browser/neo4j-web.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27986,6 +27986,9 @@ var Connection = (function () {
2798627986
if (buf.hasRemaining()) {
2798727987
self._dechunker.write(buf.readSlice(buf.remaining()));
2798827988
}
27989+
} else if (proposed == 1213486160) {
27990+
//server responded 1213486160 == 0x48545450 == "HTTP"
27991+
self._handleFatalError((0, _error.newError)("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " + "(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)"));
2798927992
} else {
2799027993
self._handleFatalError((0, _error.newError)("Unknown Bolt protocol version: " + proposed));
2799127994
}

lib/browser/neo4j-web.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/browser/neo4j-web.test.js

Lines changed: 25 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/v1/internal/connector.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ var Connection = (function () {
241241
if (buf.hasRemaining()) {
242242
self._dechunker.write(buf.readSlice(buf.remaining()));
243243
}
244+
} else if (proposed == 1213486160) {
245+
//server responded 1213486160 == 0x48545450 == "HTTP"
246+
self._handleFatalError((0, _error.newError)("Server responded HTTP. Make sure you are not trying to connect to the http endpoint " + "(HTTP defaults to port 7474 whereas BOLT defaults to port 7687)"));
244247
} else {
245248
self._handleFatalError((0, _error.newError)("Unknown Bolt protocol version: " + proposed));
246249
}

neokit

Submodule neokit added at 46d8041

runTests.ps1

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
npm install
2-
npm run start-neo4j
3-
npm test
42

5-
if(-Not ($?)) #failed to execute npm test
6-
{
7-
$ErrorFound = $True
8-
}
3+
$ErrorFound = $False
94

10-
npm run stop-neo4j
5+
try
6+
{
7+
If ($args.Length -eq 0)
8+
{
9+
npm run start-neo4j
10+
}
11+
else
12+
{
13+
npm run start-neo4j -- --neorun.start.args="$args"
14+
}
1115

12-
if($ErrorFound -eq $True)
16+
npm test
17+
if(-Not ($?)) #failed to execute npm test
18+
{
19+
$ErrorFound = $True
20+
}
21+
}
22+
finally
1323
{
14-
exit 1
15-
}
24+
npm run stop-neo4j
25+
if($ErrorFound -eq $True)
26+
{
27+
Write-Host "Exit with code 1"
28+
exit 1
29+
}
30+
Write-Host "Exit with code 0"
31+
}

runTests.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ function finish {
66
trap finish EXIT
77

88
npm install
9-
npm run start-neo4j
9+
10+
if [ "$1" == "" ]; then
11+
npm run start-neo4j
12+
else
13+
# Example: ./runTests.sh '-v 3.0.1 -p neo4j'
14+
npm run start-neo4j -- --neorun.start.args=\'"$1"\'
15+
fi
16+
1017
sleep 2
1118
npm test

test/internal/tls.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('trust-signed-certificates', function() {
5757
driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"), {
5858
encrypted: true,
5959
trust: "TRUST_SIGNED_CERTIFICATES",
60-
trustedCertificates: ["build/neo4j-enterprise-3.1.0/certificates/neo4j.cert"]
60+
trustedCertificates: ["build/neo4j/certificates/neo4j.cert"]
6161
});
6262

6363
// When

test/resources/auth

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/v1/tck/steps/tlssteps.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
var neo4j = require("../../../../lib/v1");
22
var util = require("./util");
33

4+
var CALLBACK_TIMEOUT = 60 * 1000;
5+
46
module.exports = function () {
57

6-
this.Given(/^a running Neo(\d+)j Database$/, {timeout: 60 * 1000}, function (ignored, callback) {
8+
this.Given(/^a running Neo(\d+)j Database$/, {timeout: CALLBACK_TIMEOUT}, function (ignored, callback) {
79
if (this.driver1) this.driver1.close();
810
if (this.driver2) this.driver2.close();
911
util.changeCertificates('./test/resources/derived.key', './test/resources/derived.cert');
10-
util.restart(callback);
12+
util.restart();
13+
callback();
1114
});
1215

1316
this.When(/^I connect via a TLS\-enabled transport for the first time for the given hostname and port$/, function (callback) {
1417
this.driver1 = _connectWithHostFile(this.knownHosts1);
1518
callback();
1619
});
1720

18-
this.Then(/^sessions should simply work$/, {timeout: 60 * 1000}, function (callback) {
21+
this.Then(/^sessions should simply work$/, {timeout: CALLBACK_TIMEOUT}, function (callback) {
1922
var session = this.driver1.session();
2023
session.run("RETURN 1").then(function (result) {
2124
session.close();
@@ -26,15 +29,14 @@ module.exports = function () {
2629
});
2730

2831
this.Given(/^a running Neo(\d+)j Database that I have connected to with a TLS\-enabled transport in the past$/,
29-
{timeout: 60 * 1000}, function (arg1, callback) {
32+
{timeout: CALLBACK_TIMEOUT}, function (arg1, callback) {
3033
util.changeCertificates('./test/resources/derived.key', './test/resources/derived.cert');
3134
var self = this;
32-
util.restart(function () {
33-
var driver = _connectWithHostFile(self.knownHosts1);
34-
driver.session().run("RETURN 1").then(function (result) {
35-
driver.close();
36-
callback();
37-
});
35+
util.restart();
36+
var driver = _connectWithHostFile(self.knownHosts1);
37+
driver.session().run("RETURN 1").then(function (result) {
38+
driver.close();
39+
callback();
3840
});
3941
});
4042

@@ -43,9 +45,10 @@ module.exports = function () {
4345
callback();
4446
});
4547

46-
this.Given(/^the database has changed which certificate it uses$/, {timeout: 60 * 1000}, function (callback) {
48+
this.Given(/^the database has changed which certificate it uses$/, {timeout: CALLBACK_TIMEOUT}, function (callback) {
4749
util.changeCertificates('./test/resources/other.key', './test/resources/other.cert');
48-
util.restart(callback);
50+
util.restart();
51+
callback();
4952
});
5053

5154
this.Then(/^creating sessions should fail$/, function (callback) {
@@ -114,17 +117,18 @@ module.exports = function () {
114117
});
115118

116119
this.Given(/^a running Neo(\d+)j Database using a certificate signed by the same trusted certificate$/,
117-
{timeout: 60 * 1000}, function (arg1, callback) {
120+
{timeout: CALLBACK_TIMEOUT}, function (arg1, callback) {
118121
util.changeCertificates('./test/resources/derived.key', './test/resources/derived.cert');
119-
util.restart(callback);
122+
util.restart();
123+
callback();
120124
});
121125

122126
this.When(/^I connect via a TLS\-enabled transport$/, function (callback) {
123127
this.driver1 = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"), this.config);
124128
callback();
125129
});
126130

127-
this.Given(/^a running Neo(\d+)j Database using that exact trusted certificate$/, {timeout: 60 * 1000}, function (arg1, callback) {
131+
this.Given(/^a running Neo(\d+)j Database using that exact trusted certificate$/, {timeout: CALLBACK_TIMEOUT}, function (arg1, callback) {
128132
//will have to hack a little bit here since the root cert cannot be used by the server since its
129133
//common name is not set to localhost
130134
this.config = {
@@ -135,13 +139,15 @@ module.exports = function () {
135139
};
136140

137141
util.changeCertificates('./test/resources/other.key', './test/resources/other.cert');
138-
util.restart(callback);
142+
util.restart();
143+
callback();
139144
});
140145

141-
this.Given(/^a running Neo(\d+)j Database using a certificate not signed by the trusted certificate$/, {timeout: 60 * 1000},
146+
this.Given(/^a running Neo(\d+)j Database using a certificate not signed by the trusted certificate$/, {timeout: CALLBACK_TIMEOUT},
142147
function (arg1, callback) {
143148
util.changeCertificates('./test/resources/other.key', './test/resources/other.cert');
144-
util.restart(callback);
149+
util.restart();
150+
callback();
145151
});
146152

147153
this.Then(/^I should get a helpful error explaining that no trusted certificate found$/, function (callback) {
@@ -165,4 +171,4 @@ module.exports = function () {
165171
encrypted: true
166172
});
167173
}
168-
};
174+
};

0 commit comments

Comments
 (0)