forked from jadonk/bonescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-rpc_secure.js
48 lines (44 loc) · 1.4 KB
/
test-rpc_secure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var server = require('bonescript');
var bonescript = require('../src/bonescript');
var myserver = null;
exports.setUp = function (callback) {
server.serverStart(8000, process.cwd(), { // create a secure server by supplying credentials
data: 'testpass',
hash: false
}, mycb);
function mycb(serverobj) {
myserver = serverobj.server;
callback();
}
};
exports.testRPC_secure1 = function (test) {
test.expect(1);
bonescript.startClient({ // this should throw an authentication error
address: '127.0.0.1',
port: 8000,
password: 'tdestpass'
}, function () {});
process.on('uncaughtException', function (err) {
console.log(err.toString());
test.equals(err.toString(), 'Error: Authentication Failed : incorrect passphrase !!');
myserver.close();
test.done();
});
}
exports.testRPC_secure2 = function (test) {
test.expect(1);
bonescript.startClient({
address: '127.0.0.1',
port: 8000,
password: 'testpass' // will not throw any error
}, function () {
var b = bonescript.require('bonescript');
b.getPlatform(function (platform) {
console.log('Name: ' + platform.name);
console.log('Version: ' + platform.bonescript);
test.ok(platform != 'undefined');
myserver.close();
test.done();
});
});
}