d3ecb6d7a0
* Add templating to inject JSON into an application/json script tag Plus an external script in order to pick it out and inject the values we need injecting into ember's environment meta tag. The UI still uses env style naming (CONSUL_*) but we uses the new style JSON/golang props behind the scenes. Co-authored-by: Paul Banks <banks@banksco.de>
82 lines
1.9 KiB
JavaScript
82 lines
1.9 KiB
JavaScript
/* eslint-env node */
|
|
|
|
const test = require('tape');
|
|
|
|
const getEnvironment = require('../../config/environment.js');
|
|
|
|
test(
|
|
'config has the correct environment settings',
|
|
function(t) {
|
|
[
|
|
{
|
|
environment: 'production',
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
operatorConfig: {}
|
|
},
|
|
{
|
|
environment: 'test',
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
operatorConfig: {
|
|
ACLsEnabled: true,
|
|
NamespacesEnabled: false,
|
|
SSOEnabled: false,
|
|
LocalDatacenter: 'dc1',
|
|
}
|
|
},
|
|
{
|
|
$: {
|
|
CONSUL_NSPACES_ENABLED: 1
|
|
},
|
|
environment: 'test',
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
operatorConfig: {
|
|
ACLsEnabled: true,
|
|
NamespacesEnabled: true,
|
|
SSOEnabled: false,
|
|
LocalDatacenter: 'dc1',
|
|
}
|
|
},
|
|
{
|
|
$: {
|
|
CONSUL_SSO_ENABLED: 1
|
|
},
|
|
environment: 'test',
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
operatorConfig: {
|
|
ACLsEnabled: true,
|
|
NamespacesEnabled: false,
|
|
SSOEnabled: true,
|
|
LocalDatacenter: 'dc1',
|
|
}
|
|
},
|
|
{
|
|
environment: 'staging',
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
operatorConfig: {
|
|
ACLsEnabled: true,
|
|
NamespacesEnabled: true,
|
|
SSOEnabled: true,
|
|
LocalDatacenter: 'dc1',
|
|
}
|
|
}
|
|
].forEach(
|
|
function(item) {
|
|
const env = getEnvironment(item.environment, typeof item.$ !== 'undefined' ? item.$ : undefined);
|
|
Object.keys(item).forEach(
|
|
function(key) {
|
|
if(key === '$') {
|
|
return;
|
|
}
|
|
t.deepEqual(
|
|
env[key],
|
|
item[key],
|
|
`Expect ${key} to equal ${item[key]} in the ${item.environment} environment ${typeof item.$ !== 'undefined' ? `(with ${JSON.stringify(item.$)})` : ''}`
|
|
);
|
|
}
|
|
);
|
|
}
|
|
);
|
|
t.end();
|
|
}
|
|
);
|