This commit is contained in:
2025-05-09 21:21:28 +00:00
parent d57d343050
commit b214e58a26
41 changed files with 502 additions and 2224 deletions

View File

@ -1,12 +1,12 @@
import { tap, expect } from '@push.rocks/tapbundle';
import * as plugins from '../ts/plugins.js';
import type { IForwardConfig } from '../ts/smartproxy/types/forwarding.types.js';
import type { ForwardConfig } from '../ts/forwarding/config/forwarding-types.js';
// First, import the components directly to avoid issues with compiled modules
import { ForwardingHandlerFactory } from '../ts/smartproxy/forwarding/forwarding.factory.js';
import { createDomainConfig } from '../ts/smartproxy/forwarding/domain-config.js';
import { DomainManager } from '../ts/smartproxy/forwarding/domain-manager.js';
import { httpOnly, tlsTerminateToHttp, tlsTerminateToHttps, httpsPassthrough } from '../ts/smartproxy/types/forwarding.types.js';
import { ForwardingHandlerFactory } from '../ts/forwarding/factory/forwarding-factory.js';
import { createDomainConfig } from '../ts/forwarding/config/domain-config.js';
import { DomainManager } from '../ts/forwarding/config/domain-manager.js';
import { httpOnly, tlsTerminateToHttp, tlsTerminateToHttps, httpsPassthrough } from '../ts/forwarding/config/forwarding-types.js';
const helpers = {
httpOnly,
@ -17,7 +17,7 @@ const helpers = {
tap.test('ForwardingHandlerFactory - apply defaults based on type', async () => {
// HTTP-only defaults
const httpConfig: IForwardConfig = {
const httpConfig: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 3000 }
};
@ -26,7 +26,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
expect(expandedHttpConfig.http?.enabled).toEqual(true);
// HTTPS-passthrough defaults
const passthroughConfig: IForwardConfig = {
const passthroughConfig: ForwardConfig = {
type: 'https-passthrough',
target: { host: 'localhost', port: 443 }
};
@ -36,7 +36,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
expect(expandedPassthroughConfig.http?.enabled).toEqual(false);
// HTTPS-terminate-to-http defaults
const terminateToHttpConfig: IForwardConfig = {
const terminateToHttpConfig: ForwardConfig = {
type: 'https-terminate-to-http',
target: { host: 'localhost', port: 3000 }
};
@ -48,7 +48,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
expect(expandedTerminateToHttpConfig.acme?.maintenance).toEqual(true);
// HTTPS-terminate-to-https defaults
const terminateToHttpsConfig: IForwardConfig = {
const terminateToHttpsConfig: ForwardConfig = {
type: 'https-terminate-to-https',
target: { host: 'localhost', port: 8443 }
};
@ -62,7 +62,7 @@ tap.test('ForwardingHandlerFactory - apply defaults based on type', async () =>
tap.test('ForwardingHandlerFactory - validate configuration', async () => {
// Valid configuration
const validConfig: IForwardConfig = {
const validConfig: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 3000 }
};
@ -77,7 +77,7 @@ tap.test('ForwardingHandlerFactory - validate configuration', async () => {
expect(() => ForwardingHandlerFactory.validateConfig(invalidConfig1)).toThrow();
// Invalid configuration - invalid port
const invalidConfig2: IForwardConfig = {
const invalidConfig2: ForwardConfig = {
type: 'http-only',
target: { host: 'localhost', port: 0 }
};

View File

@ -1,6 +1,6 @@
import { expect, tap } from '@push.rocks/tapbundle';
import * as net from 'net';
import { SmartProxy } from '../ts/smartproxy/classes.smartproxy.js';
import { SmartProxy } from '../ts/proxies/smart-proxy/index.js';
let testServer: net.Server;
let smartProxy: SmartProxy;