fix(tests): test
This commit is contained in:
		
							
								
								
									
										12
									
								
								changelog.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								changelog.md
									
									
									
									
									
								
							| @@ -1,5 +1,17 @@ | |||||||
| # Changelog | # 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) | ## 2025-05-19 - 19.3.5 - fix(smartproxy) | ||||||
| Correct NFTables forwarding handling to avoid premature connection termination and add comprehensive tests | Correct NFTables forwarding handling to avoid premature connection termination and add comprehensive tests | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ tap.test('NFTables forwarding should not terminate connections', async () => { | |||||||
|   // Create SmartProxy with NFTables route |   // Create SmartProxy with NFTables route | ||||||
|   const smartProxy = new SmartProxy({ |   const smartProxy = new SmartProxy({ | ||||||
|     enableDetailedLogging: true, |     enableDetailedLogging: true, | ||||||
|     acceptedRoutes: [ |     routes: [ | ||||||
|       { |       { | ||||||
|         id: 'nftables-test', |         id: 'nftables-test', | ||||||
|         name: 'NFTables Test Route', |         name: 'NFTables Test Route', | ||||||
|   | |||||||
| @@ -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 * as net from 'net'; | ||||||
| import { SmartProxy } from '../ts/proxies/smart-proxy/smart-proxy.js'; | 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 |   // Create an echo server | ||||||
|   const echoServer = net.createServer((socket) => { |   echoServer = await new Promise<net.Server>((resolve) => { | ||||||
|     socket.on('data', (data) => { |     const server = net.createServer((socket) => { | ||||||
|       socket.write(`ECHO: ${data}`); |       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 |   // Create proxy with forwarding route | ||||||
|   const proxy = new SmartProxy({ |   proxy = new SmartProxy({ | ||||||
|     routes: [{ |     routes: [{ | ||||||
|       id: 'test', |       id: 'test', | ||||||
|       match: { port: 9999 }, |       match: { ports: 9999 }, | ||||||
|       action: { |       action: { | ||||||
|         type: 'forward', |         type: 'forward', | ||||||
|         target: { host: 'localhost', port: 8888 } |         target: { host: 'localhost', port: 8888 } | ||||||
| @@ -44,16 +50,14 @@ tap.test('Port forwarding should not immediately close connections', async () => | |||||||
|   expect(result).toEqual('ECHO: Hello'); |   expect(result).toEqual('ECHO: Hello'); | ||||||
|    |    | ||||||
|   client.end(); |   client.end(); | ||||||
|   await proxy.stop(); |  | ||||||
|   echoServer.close(); |  | ||||||
| }); | }); | ||||||
|  |  | ||||||
| tap.test('TLS passthrough should work correctly', async () => { | tap.test('TLS passthrough should work correctly', async () => { | ||||||
|   // Create proxy with TLS passthrough |   // Create proxy with TLS passthrough | ||||||
|   const proxy = new SmartProxy({ |   proxy = new SmartProxy({ | ||||||
|     routes: [{ |     routes: [{ | ||||||
|       id: 'tls-test',  |       id: 'tls-test',  | ||||||
|       match: { port: 8443, domain: 'test.example.com' }, |       match: { ports: 8443, domains: 'test.example.com' }, | ||||||
|       action: { |       action: { | ||||||
|         type: 'forward', |         type: 'forward', | ||||||
|         tls: { mode: 'passthrough' }, |         tls: { mode: 'passthrough' }, | ||||||
| @@ -70,4 +74,13 @@ tap.test('TLS passthrough should work correctly', async () => { | |||||||
|   await proxy.stop(); |   await proxy.stop(); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | tap.test('cleanup', async () => { | ||||||
|  |   if (echoServer) { | ||||||
|  |     echoServer.close(); | ||||||
|  |   } | ||||||
|  |   if (proxy) { | ||||||
|  |     await proxy.stop(); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  |  | ||||||
| export default tap.start(); | export default tap.start(); | ||||||
| @@ -3,6 +3,6 @@ | |||||||
|  */ |  */ | ||||||
| export const commitinfo = { | export const commitinfo = { | ||||||
|   name: '@push.rocks/smartproxy', |   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.' |   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.' | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user