2026-02-19 13:24:14 +01:00
|
|
|
import { describe, it, before, after } from 'mocha';
|
2026-02-14 15:43:24 +01:00
|
|
|
import common from './common.js';
|
|
|
|
|
import domains from '../domains.js';
|
2026-02-18 22:21:54 +01:00
|
|
|
import assert from 'node:assert/strict';
|
2026-02-14 09:53:14 +01:00
|
|
|
import fs from 'node:fs';
|
|
|
|
|
import paths from '../paths.js';
|
2026-02-14 15:43:24 +01:00
|
|
|
import reverseProxy from '../reverseproxy.js';
|
2026-02-14 09:53:14 +01:00
|
|
|
|
2015-12-10 20:31:38 -08:00
|
|
|
|
2021-08-13 17:22:28 -07:00
|
|
|
describe('Reverse Proxy', function () {
|
2022-11-28 21:23:06 +01:00
|
|
|
const { setup, cleanup, domain, auditSource, app } = common;
|
2021-08-13 10:41:10 -07:00
|
|
|
const domainCopy = Object.assign({}, domain);
|
|
|
|
|
|
|
|
|
|
before(setup);
|
|
|
|
|
after(cleanup);
|
2021-06-03 12:20:44 -07:00
|
|
|
|
|
|
|
|
describe('configureApp', function () {
|
2021-08-13 17:22:28 -07:00
|
|
|
before(async function () {
|
2021-08-13 10:41:10 -07:00
|
|
|
domainCopy.tlsConfig = { provider: 'fallback' };
|
2021-06-03 16:16:04 -07:00
|
|
|
|
2021-12-03 13:46:54 -08:00
|
|
|
await domains.setConfig(domainCopy.domain, domainCopy, auditSource);
|
2021-06-03 16:16:04 -07:00
|
|
|
});
|
|
|
|
|
|
2021-08-17 14:04:29 -07:00
|
|
|
it('configure nginx correctly', async function () {
|
|
|
|
|
await reverseProxy.configureApp(app, auditSource);
|
2026-02-18 22:21:54 +01:00
|
|
|
const appConfigDir = `${paths.NGINX_APPCONFIG_DIR}/${app.id}`;
|
|
|
|
|
assert.ok(fs.existsSync(appConfigDir));
|
|
|
|
|
assert.ok(fs.readdirSync(appConfigDir).some((f) => f.endsWith('.conf')));
|
2021-06-03 12:20:44 -07:00
|
|
|
});
|
|
|
|
|
|
2021-08-17 14:04:29 -07:00
|
|
|
it('unconfigure nginx', async function () {
|
|
|
|
|
await reverseProxy.unconfigureApp(app);
|
2026-02-18 22:21:54 +01:00
|
|
|
assert.ok(!fs.existsSync(`${paths.NGINX_APPCONFIG_DIR}/${app.id}`));
|
2021-06-03 12:20:44 -07:00
|
|
|
});
|
|
|
|
|
});
|
2015-12-10 20:31:38 -08:00
|
|
|
});
|