-
Notifications
You must be signed in to change notification settings - Fork 6
/
strategy.test.js
98 lines (80 loc) · 3.12 KB
/
strategy.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var Auth0OidcStrategy = require('../lib/passport-auth0-openidconnect').Strategy;
var assert = require('assert');
describe('constructor with bad params', function () {
it('should fail if no domain is passed as option',function(){
(function(){
new Auth0OidcStrategy(
{},
function(accessToken, idToken, profile, done){}
);
}).should.throw('You must provide the domain configuration value to use passport-auth0-oidc.');
});
it('should fail if no clientID is passed as option',function(){
(function(){
new Auth0OidcStrategy(
{domain:'foo'},
function(accessToken, idToken, profile, done){}
);
}).should.throw('You must provide the clientID configuration value to use passport-auth0-oidc.');
});
it('should fail if no clientSecret is passed as option',function(){
(function(){
new Auth0OidcStrategy(
{domain:'foo',clientID:'bar'},
function(accessToken, idToken, profile, done){}
);
}).should.throw('You must provide the clientSecret configuration value to use passport-auth0-oidc.');
});
it('should fail if no callbackURL is passed as option',function(){
(function(){
new Auth0OidcStrategy(
{domain:'foo',clientID:'bar',clientSecret:'baz'},
function(accessToken, idToken, profile, done){}
);
}).should.throw('You must provide the callbackURL configuration value to use passport-auth0-oidc.');
});
});
describe('constructor with right params and pre-configured endpoints', function () {
var strategy, configuration;
before(function(done) {
strategy = new Auth0OidcStrategy({
domain: 'jj.auth0.com',
clientID: 'testid',
clientSecret: 'testsecret',
callbackURL: '/callback',
authorizationURL: 'https://jj.auth0.com/authorize',
tokenURL: 'https://jj.auth0.com/oauth/token',
userInfoURL: 'https://jj.auth0.com/userinfo'
},
function(accessToken, idToken, profile, done) {});
strategy._setup(null, function(err, params) {
if (err) { return done(err); }
configuration = params;
done();
});
});
it('should be named auth0-oidc',function(){
strategy.name.should.eql('auth0-oidc');
});
it('oidc authorizationURL should be properly set', function () {
configuration.authorizationURL.should.eql('https://jj.auth0.com/authorize');
});
it('oidc tokenURL should be properly set', function () {
configuration.tokenURL.should.eql('https://jj.auth0.com/oauth/token');
});
it('oidc userInfoURL should be properly set', function () {
configuration.userInfoURL.should.eql('https://jj.auth0.com/userinfo');
});
it('oidc clienID should be properly set',function(){
configuration.clientID.should.eql('testid');
});
it('oidc clientSecret should be properly set',function(){
configuration.clientSecret.should.eql('testsecret');
});
it('oidc callbackURL should be properly set',function(){
configuration.callbackURL.should.eql('/callback');
});
it('oidc skipUserProfile should default to false',function(){
strategy._skipUserProfile.should.be.false();
});
});