2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2020-12-14 15:28:35 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
|
2020-01-28 17:33:20 +00:00
|
|
|
const test = require('tape');
|
|
|
|
|
|
|
|
const getEnvironment = require('../../config/environment.js');
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
test('config has the correct environment settings', function (t) {
|
|
|
|
[
|
|
|
|
{
|
|
|
|
environment: 'production',
|
|
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
|
|
operatorConfig: {
|
|
|
|
APIPrefix: '',
|
2020-01-28 17:33:20 +00:00
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
environment: 'test',
|
|
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
|
|
operatorConfig: {
|
|
|
|
ACLsEnabled: true,
|
|
|
|
NamespacesEnabled: false,
|
|
|
|
SSOEnabled: false,
|
|
|
|
PartitionsEnabled: false,
|
|
|
|
PeeringEnabled: true,
|
|
|
|
HCPEnabled: false,
|
|
|
|
LocalDatacenter: 'dc1',
|
|
|
|
PrimaryDatacenter: 'dc1',
|
|
|
|
APIPrefix: '',
|
2024-01-26 21:38:51 +00:00
|
|
|
V2CatalogEnabled: false,
|
2020-01-28 17:33:20 +00:00
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
$: {
|
|
|
|
CONSUL_NSPACES_ENABLED: 1,
|
2020-05-11 15:37:11 +00:00
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
environment: 'test',
|
|
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
|
|
operatorConfig: {
|
|
|
|
ACLsEnabled: true,
|
|
|
|
NamespacesEnabled: true,
|
|
|
|
SSOEnabled: false,
|
|
|
|
PartitionsEnabled: false,
|
|
|
|
PeeringEnabled: true,
|
|
|
|
HCPEnabled: false,
|
|
|
|
LocalDatacenter: 'dc1',
|
|
|
|
PrimaryDatacenter: 'dc1',
|
|
|
|
APIPrefix: '',
|
2024-01-26 21:38:51 +00:00
|
|
|
V2CatalogEnabled: false,
|
2020-02-07 11:02:53 +00:00
|
|
|
},
|
2022-09-15 08:43:17 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
$: {
|
|
|
|
CONSUL_SSO_ENABLED: 1,
|
|
|
|
},
|
|
|
|
environment: 'test',
|
|
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
|
|
operatorConfig: {
|
|
|
|
ACLsEnabled: true,
|
|
|
|
NamespacesEnabled: false,
|
|
|
|
SSOEnabled: true,
|
|
|
|
PartitionsEnabled: false,
|
|
|
|
PeeringEnabled: true,
|
|
|
|
HCPEnabled: false,
|
|
|
|
LocalDatacenter: 'dc1',
|
|
|
|
PrimaryDatacenter: 'dc1',
|
|
|
|
APIPrefix: '',
|
2024-01-26 21:38:51 +00:00
|
|
|
V2CatalogEnabled: false,
|
2022-09-15 08:43:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
environment: 'staging',
|
|
|
|
CONSUL_BINARY_TYPE: 'oss',
|
|
|
|
operatorConfig: {
|
|
|
|
ACLsEnabled: true,
|
|
|
|
NamespacesEnabled: true,
|
|
|
|
SSOEnabled: true,
|
|
|
|
PartitionsEnabled: true,
|
|
|
|
PeeringEnabled: true,
|
|
|
|
HCPEnabled: false,
|
|
|
|
LocalDatacenter: 'dc1',
|
|
|
|
PrimaryDatacenter: 'dc1',
|
|
|
|
APIPrefix: '',
|
2024-01-26 21:38:51 +00:00
|
|
|
V2CatalogEnabled: false,
|
2022-09-15 08:43:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
].forEach(function (item) {
|
|
|
|
const env = getEnvironment(
|
|
|
|
item.environment,
|
|
|
|
typeof item.$ !== 'undefined' ? item.$ : undefined
|
2020-01-28 17:33:20 +00:00
|
|
|
);
|
2022-09-15 08:43:17 +00:00
|
|
|
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();
|
|
|
|
});
|