-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathauth.js
81 lines (62 loc) · 2.34 KB
/
auth.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict';
var should = require('chai').should(),
path = require('path'),
grasshopper,
start = require('./_start');
describe('Grasshopper core - testing authentications', function(){
before(function(done) {
this.timeout(10000);
start(grasshopper).then(function(gh) { grasshopper = gh; done(); });
});
after(function(){
this.timeout(10000);
});
describe('Basic Authentication', function() {
it('not authenticate because user doesn\'t exist', function(done) {
grasshopper.auth('Basic', {username:'travis', password:'12345'})
.then(function(obj){
should.not.exist(obj);
})
.fail(function(err){
err.message.should.equal('Your username was invalid.');
})
.done(function(){
done();
});
});
it('should authenticate with a valid user.', function(done) {
grasshopper.auth('Basic', {username:'admin', password:'TestPassword'})
.then(function(obj){
should.exist(obj);
})
.fail(function(err){
should.not.exist(err);
})
.done(function(){
done();
});
});
});
describe('Google Authentication', function() {
describe('given the google token of a non-existing user', function() {
it('should add the user to the system', function() {
// send the auth
// check that the user is in DB
});
it('should add email address to user.email', function() {
// send the auth
// check that the user has a good email address
});
it('should add the google id to the user.identities.google.userid', function() {
});
it('should save the access token to the user.identities.google.accesstoken', function() {
});
it('should save the refresh token to the user.identities.google.refreshtoken', function() {
});
});
describe('given the token of a existing user', function() {
it('should return a valid token', function() {
});
});
});
});