forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.test.js
71 lines (56 loc) · 2.31 KB
/
env.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
'use strict';
require('should');
describe('env', function ( ) {
it( 'show the right plugins', function () {
process.env.SHOW_PLUGINS = 'iob';
process.env.ENABLE = 'iob cob';
var env = require( '../env' )();
var showPlugins = env.settings.showPlugins;
showPlugins.should.containEql( 'iob' );
showPlugins.should.containEql( 'delta' );
showPlugins.should.containEql( 'direction' );
showPlugins.should.containEql( 'upbat' );
delete process.env.SHOW_PLUGINS;
delete process.env.ENABLE;
} );
it( 'get extended settings', function () {
process.env.ENABLE = 'scaryplugin';
process.env.SCARYPLUGIN_DO_THING = 'yes';
var env = require( '../env' )();
env.settings.isEnabled( 'scaryplugin' ).should.equal( true );
//Note the camelCase
env.extendedSettings.scaryplugin.doThing.should.equal( 'yes' );
delete process.env.ENABLE;
delete process.env.SCARYPLUGIN_DO_THING;
} );
it( 'add pushover to enable if one of the env vars is set', function () {
process.env.PUSHOVER_API_TOKEN = 'abc12345';
var env = require( '../env' )();
env.settings.enable.should.containEql( 'pushover' );
env.extendedSettings.pushover.apiToken.should.equal( 'abc12345' );
delete process.env.PUSHOVER_API_TOKEN;
} );
it( 'add pushover to enable if one of the weird azure env vars is set', function () {
process.env.CUSTOMCONNSTR_PUSHOVER_API_TOKEN = 'abc12345';
var env = require( '../env' )();
env.settings.enable.should.containEql( 'pushover' );
env.extendedSettings.pushover.apiToken.should.equal( 'abc12345' );
delete process.env.PUSHOVER_API_TOKEN;
} );
it( 'readENVTruthy ', function () {
process.env.INSECURE_USE_HTTP = 'true';
var env = require( '../env' )();
env.insecureUseHttp.should.be.true();
process.env.INSECURE_USE_HTTP = 'false';
env = require( '../env' )();
env.insecureUseHttp.should.be.false();
process.env.INSECURE_USE_HTTP = 'not set ok, so use default value false';
env = require( '../env' )();
env.insecureUseHttp.should.be.false();
delete process.env.INSECURE_USE_HTTP; // unset INSECURE_USE_HTTP
process.env.SECURE_HSTS_HEADER = 'true';
env = require( '../env' )();
env.insecureUseHttp.should.be.false(); // not defined should be false
env.secureHstsHeader.should.be.true();
});
})