d0a66f1701
sorry i ever left you dear mocha node:test has two major issues: * --bail does not work and requires strange modules and incantations. I was able to work around this with a custom module. * the test reporter reports _after_ the suite is run. this makes debugging really hard. the debugs that we print all happen before the test suite summary. poor design overall.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import { describe, it, before, after } from 'mocha';
|
|
import common from './common.js';
|
|
import domains from '../domains.js';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import paths from '../paths.js';
|
|
import reverseProxy from '../reverseproxy.js';
|
|
|
|
|
|
describe('Reverse Proxy', function () {
|
|
const { setup, cleanup, domain, auditSource, app } = common;
|
|
const domainCopy = Object.assign({}, domain);
|
|
|
|
before(setup);
|
|
after(cleanup);
|
|
|
|
describe('configureApp', function () {
|
|
before(async function () {
|
|
domainCopy.tlsConfig = { provider: 'fallback' };
|
|
|
|
await domains.setConfig(domainCopy.domain, domainCopy, auditSource);
|
|
});
|
|
|
|
it('configure nginx correctly', async function () {
|
|
await reverseProxy.configureApp(app, auditSource);
|
|
const appConfigDir = `${paths.NGINX_APPCONFIG_DIR}/${app.id}`;
|
|
assert.ok(fs.existsSync(appConfigDir));
|
|
assert.ok(fs.readdirSync(appConfigDir).some((f) => f.endsWith('.conf')));
|
|
});
|
|
|
|
it('unconfigure nginx', async function () {
|
|
await reverseProxy.unconfigureApp(app);
|
|
assert.ok(!fs.existsSync(`${paths.NGINX_APPCONFIG_DIR}/${app.id}`));
|
|
});
|
|
});
|
|
});
|