-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_start_tls.js
67 lines (56 loc) · 1.98 KB
/
test_start_tls.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
'use strict';
const should = require('should');
const LDAPWrap = require('../libs/ldap_async_wrap.js');
const config = require('./config.json');
const StateError = require('../libs/errors/state_error');
const errorHandler = require('../libs/errors/error_dispenser').errorFunction;
const errorCodes = require('../libs/error_codes');
const errorMessages = require('../libs/messages.json');
describe('Testing the LDAP start TLS routine', () => {
const host = config.ldapAuthentication.host;
let adminLDAP = new LDAPWrap(host);
const pathFileToCert = config.ldapAuthentication.pathFileToCert;
beforeEach(() => {
adminLDAP = new LDAPWrap(host);
return adminLDAP.initialize();
});
afterEach(() => {
return adminLDAP.unbind();
});
/* The TLS test should run separated */
it('should reject if the state is not Initialized', () => {
return adminLDAP.unbind()
.then(() => {
return adminLDAP.startTLS(pathFileToCert);
})
.then(() => {
should.fail('Didn\'t expect success');
})
.catch(StateError, (error) => {
should.deepEqual(error.message, errorMessages.initErrorMessage);
})
.catch((err) => {
should.fail('did not expect generic Error');
});
});
it('should start a TLS communication using the default certificate if the path is wrong', () => {
const CustomError = errorHandler(errorCodes.connectionError);
const wrongCred = '/wrong/cred.pam';
return adminLDAP.startTLS(wrongCred)
.catch(() => {
should.fail('did not expect an error');
});
});
it('should start a TLS communication using the server certificate', () => {
return adminLDAP.startTLS()
.catch((err) => {
should.fail('did not expect an error');
});
});
it('should start a TLS communication using the full path file to the certificate', () => {
return adminLDAP.startTLS(pathFileToCert)
.catch(() => {
should.fail('did not expect an error');
});
});
});