mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
feat: tests
This commit is contained in:
@@ -20,8 +20,7 @@ import mustache from 'mustache';
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import {
|
||||
asyncReadFile,
|
||||
ConfigFile,
|
||||
configFile,
|
||||
isFileType,
|
||||
protocolHardeningParameters,
|
||||
SSLFilePaths,
|
||||
@@ -29,10 +28,9 @@ import {
|
||||
SupportedLogFormats,
|
||||
TemplateView,
|
||||
} from './common.js';
|
||||
// @ts-expect-error missing type defs
|
||||
import nodePortScanner from 'node-port-scanner';
|
||||
import {readFile} from 'fs/promises';
|
||||
import PortScanner from './port-scanner.js';
|
||||
|
||||
/* eslint-disable unicorn/prefer-module */
|
||||
/* eslint-disable unicorn/no-await-expression-member */
|
||||
|
||||
/**
|
||||
@@ -90,9 +88,7 @@ Please expose a port if the container should be accessible by NGINX.`);
|
||||
|
||||
// Get a routable network connection
|
||||
for (const network in container.NetworkSettings.Networks) {
|
||||
const scan = await nodePortScanner(container.NetworkSettings.Networks[network].IPAddress, [port]);
|
||||
|
||||
if ((scan.ports.open as Array<number>).includes(port)) {
|
||||
if (await PortScanner.isPortFree(port, container.NetworkSettings.Networks[network].IPAddress)) {
|
||||
Logger.info(
|
||||
`${container.Names[0]} reachable via ${container.NetworkSettings.Networks[network].IPAddress}:${port}`,
|
||||
);
|
||||
@@ -260,7 +256,7 @@ export async function generateMetricsServer(logFormat: string, enableMetrics?: b
|
||||
* @param view Data to render template with
|
||||
*/
|
||||
async function renderTemplate(path: string, view: unknown): Promise<string> {
|
||||
const content = await asyncReadFile(path, 'utf8');
|
||||
const content = await readFile(path, 'utf8');
|
||||
|
||||
return mustache.render(content, view);
|
||||
}
|
||||
@@ -283,12 +279,7 @@ function generateRateLimitAllowList(entries: string[]): string {
|
||||
* @param containers List of container info
|
||||
*/
|
||||
export async function getTemplateView(containers: Dockerode.ContainerInfo[]): Promise<TemplateView> {
|
||||
delete require.cache[require.resolve('config')];
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const config = require('config');
|
||||
const configFile = config as ConfigFile;
|
||||
|
||||
const cors = await asyncReadFile('./fixtures/cors.template', 'utf8');
|
||||
const cors = await readFile('./fixtures/cors.template', 'utf8');
|
||||
|
||||
const visibleRoutesPromises = ['/'].map(async route => {
|
||||
return renderTemplate(path.join('fixtures', 'visibleRoute.template'), {
|
||||
|
||||
Reference in New Issue
Block a user