Skip to content

Commit 5be618f

Browse files
jorgebaydaprahamian
authored andcommitted
feat(package): export the package version
As kerberos can be used as an optional dependency, we expose the version at api level to allow third party libraries to consume the version number easily. It includes a test that verifies what's being exported.
1 parent cd1db13 commit 5be618f

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module.exports = kerberos;
88
// Support legacy versions of the mongodb driver which expect this export
99
module.exports.Kerberos = kerberos;
1010

11+
module.exports.version = require('./package.json').version;
12+
1113
// Set up the auth processes
1214
module.exports.processes = {
1315
MongoAuthProcess: require('./lib/auth_processes/mongodb').MongoAuthProcess

test/exports_tests.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
const chai = require('chai');
4+
const expect = chai.expect;
5+
const api = require('../index');
6+
7+
describe('module', function () {
8+
it('should export version', function () {
9+
expect(api.version).to.be.a('string');
10+
expect(api.version).to.match(/\d+\.\d+/);
11+
});
12+
13+
it('should export flags and ids', function () {
14+
[
15+
api.GSS_C_DELEG_FLAG,
16+
api.GSS_C_MUTUAL_FLAG,
17+
api.GSS_C_REPLAY_FLAG,
18+
api.GSS_C_SEQUENCE_FLAG,
19+
api.GSS_C_CONF_FLAG,
20+
api.GSS_C_INTEG_FLAG,
21+
api.GSS_C_ANON_FLAG,
22+
api.GSS_C_PROT_READY_FLAG,
23+
api.GSS_C_TRANS_FLAG,
24+
api.GSS_C_NO_OID,
25+
api.GSS_MECH_OID_KRB5,
26+
api.GSS_MECH_OID_SPNEGO
27+
].forEach(flag => expect(flag).to.be.a('number'));
28+
});
29+
30+
it('should export functions', function () {
31+
expect(api.initializeClient).to.be.a('function');
32+
expect(api.initializeServer).to.be.a('function');
33+
expect(api.principalDetails).to.be.a('function');
34+
expect(api.checkPassword).to.be.a('function');
35+
});
36+
37+
it('should export Kerberos', () => {
38+
expect(api.Kerberos).to.be.an('object');
39+
});
40+
});

0 commit comments

Comments
 (0)