-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsh-token.spec.js
55 lines (51 loc) · 1.48 KB
/
bsh-token.spec.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
49
50
51
52
53
54
55
var should = require('should');
var bshPool = require('bsh-mongo-pool');
var bshMongoToken = require('./node_modules/bsh-mongo-token/bsh-mongo-token.js');
var bshToken = require('./index');
bshToken.implementation(bshMongoToken);
beforeEach(function() {
return bshPool.init('mongodb://localhost/tokenTest');
});
describe('BSH Token Tests', function () {
it('should create a token', function (done) {
bshToken.createToken('testContext','someUser',['all'])
.then(function (token){
if (token) {
done();
}
})
});
it ('should touch a created token', function (done) {
bshToken.createToken('testContext','someUser',['all'])
.then(function (token){
if (token) {
bshToken.touchToken(token)
.then(function (backToken) {
done();
});
}
})
});
it ('should check a created token', function () {
return bshToken.createToken('testContext','someUser',['all'])
.then(function (token){
if (token) {
return bshToken.checkToken(token, undefined, true)
.then(function (found) {
should.exist(found);
found.should.equal(true);
return true;
});
}
})
});
it ('should fail check a dummy token', function () {
return bshToken.checkToken('dummy')
.then(function (found) {
should.exist(found);
found.should.equal(false);
return true;
;
});
});
});