-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
29 lines (26 loc) · 937 Bytes
/
test.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
var test = require('tape')
var spawn = require('child_process').spawn
var match = require('match-through')
var domain = require('./')
var port = 9999
var cmd = './node_modules/scuttlebot/bin.js'
var args = [ 'server', '--port', port ]
var child = spawn(cmd, args)
child.stdout.pipe(match(/.*info.*listening.*/i, function() {
test('that we can get a token from localhost on port ' + port, function(t) {
domain.getToken('localhost:' + port, function(err, res) {
t.ok(!err, 'no error')
t.ok(typeof res == 'object', 'result is an object')
t.ok(res.role, 'token object has a role')
t.ok(res.ts, 'token object has a timestamp')
t.ok(res.keyId, 'token object has a key id')
t.ok(res.hmac, 'token object has an hmac')
child.kill()
t.end()
})
})
}))
// TODO guess we need to auth before we can deauth
//domain.deauth('localhost', function (err, res) {
//console.log(err, res)
//})