fix(tests): test

This commit is contained in:
Philipp Kunz 2025-05-19 17:59:12 +00:00
parent 70448af5b4
commit 1b4d215cd4
4 changed files with 42 additions and 17 deletions

View File

@ -1,5 +1,17 @@
# Changelog
## 2025-05-19 - 19.3.6 - fix(tests)
Fix route configuration property names in tests: replace 'acceptedRoutes' with 'routes' in nftables tests and update 'match: { port: ... }' to 'match: { ports: ... }' in port forwarding tests.
- Renamed 'acceptedRoutes' to 'routes' in test/nftables-forwarding.ts for alignment with the current SmartProxy API.
- Changed port matching in test/port-forwarding-fix.ts from 'match: { port: ... }' to 'match: { ports: ... }' for consistency.
## 2025-05-19 - 19.3.6 - fix(tests)
Update test route config properties: replace 'acceptedRoutes' with 'routes' in nftables tests and change 'match: { port: ... }' to 'match: { ports: ... }' in port forwarding tests
- In test/nftables-forwarding.ts, renamed property 'acceptedRoutes' to 'routes' to align with current SmartProxy API.
- In test/port-forwarding-fix.ts, updated 'match: { port: 9999 }' to 'match: { ports: 9999 }' for consistency.
## 2025-05-19 - 19.3.5 - fix(smartproxy)
Correct NFTables forwarding handling to avoid premature connection termination and add comprehensive tests

View File

@ -24,7 +24,7 @@ tap.test('NFTables forwarding should not terminate connections', async () => {
// Create SmartProxy with NFTables route
const smartProxy = new SmartProxy({
enableDetailedLogging: true,
acceptedRoutes: [
routes: [
{
id: 'nftables-test',
name: 'NFTables Test Route',

View File

@ -1,24 +1,30 @@
import { expect, tap } from '@git.zone/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as net from 'net';
import { SmartProxy } from '../ts/proxies/smart-proxy/smart-proxy.js';
tap.test('Port forwarding should not immediately close connections', async () => {
let echoServer: net.Server;
let proxy: SmartProxy;
tap.test('port forwarding should not immediately close connections', async () => {
// Create an echo server
const echoServer = net.createServer((socket) => {
socket.on('data', (data) => {
socket.write(`ECHO: ${data}`);
echoServer = await new Promise<net.Server>((resolve) => {
const server = net.createServer((socket) => {
socket.on('data', (data) => {
socket.write(`ECHO: ${data}`);
});
});
server.listen(8888, () => {
console.log('Echo server listening on port 8888');
resolve(server);
});
});
await new Promise<void>((resolve) => {
echoServer.listen(8888, () => resolve());
});
// Create proxy with forwarding route
const proxy = new SmartProxy({
proxy = new SmartProxy({
routes: [{
id: 'test',
match: { port: 9999 },
match: { ports: 9999 },
action: {
type: 'forward',
target: { host: 'localhost', port: 8888 }
@ -44,16 +50,14 @@ tap.test('Port forwarding should not immediately close connections', async () =>
expect(result).toEqual('ECHO: Hello');
client.end();
await proxy.stop();
echoServer.close();
});
tap.test('TLS passthrough should work correctly', async () => {
// Create proxy with TLS passthrough
const proxy = new SmartProxy({
proxy = new SmartProxy({
routes: [{
id: 'tls-test',
match: { port: 8443, domain: 'test.example.com' },
match: { ports: 8443, domains: 'test.example.com' },
action: {
type: 'forward',
tls: { mode: 'passthrough' },
@ -70,4 +74,13 @@ tap.test('TLS passthrough should work correctly', async () => {
await proxy.stop();
});
tap.test('cleanup', async () => {
if (echoServer) {
echoServer.close();
}
if (proxy) {
await proxy.stop();
}
});
export default tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartproxy',
version: '19.3.5',
version: '19.3.6',
description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.'
}