samlTests.js
1.6 KB
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
'use strict';
var SAML = require('../lib/passport-saml/saml.js').SAML;
var should = require('should');
var url = require('url');
describe('SAML.js', function() {
describe('getAuthorizeUrl', function() {
var saml, req;
beforeEach(function() {
saml = new SAML({
entryPoint: 'https://exampleidp.com/path?key=value'
});
req = {
protocol: 'https',
headers: {
host: 'examplesp.com'
}
}
});
it('calls callback with right host', function(done) {
saml.getAuthorizeUrl(req, function(err, target) {
url.parse(target).host.should.equal('exampleidp.com');
done();
});
});
it('calls callback with right protocol', function(done) {
saml.getAuthorizeUrl(req, function(err, target) {
url.parse(target).protocol.should.equal('https:');
done();
});
})
it('calls callback with right path', function(done) {
saml.getAuthorizeUrl(req, function(err, target) {
url.parse(target).pathname.should.equal('/path');
done();
});
})
it('calls callback with original query string', function(done) {
saml.getAuthorizeUrl(req, function(err, target) {
url.parse(target, true).query['key'].should.equal('value');
done();
});
})
// NOTE: This test only tests existence of the assertion, not the correctness
it('calls callback with saml request object', function(done) {
saml.getAuthorizeUrl(req, function(err, target) {
should(url.parse(target, true).query).have.property('SAMLRequest');
done();
});
});
});
});