fix(smartproxy): improve certificate manager mocking in tests, enhance IPv6 validation, and record initial bytes for connection metrics

This commit is contained in:
2026-01-30 19:52:36 +00:00
parent 1d1e5062a6
commit 2068b7a1ad
15 changed files with 230 additions and 119 deletions

View File

@@ -44,24 +44,18 @@ tap.test('HttpProxy IP connection tracking', async () => {
tap.test('HttpProxy connection rate limiting', async () => {
const testIP = '10.0.0.2';
// Make 10 connections rapidly (at rate limit)
// Make 10 connection attempts rapidly (at rate limit)
// Note: We don't track connections here as we're testing rate limiting, not per-IP limiting
for (let i = 0; i < 10; i++) {
const result = securityManager.validateIP(testIP);
expect(result.allowed).toBeTrue();
// Track the connection to simulate real usage
securityManager.trackConnectionByIP(testIP, `rate-conn${i}`);
}
// 11th connection should be rate limited
const result = securityManager.validateIP(testIP);
expect(result.allowed).toBeFalse();
expect(result.reason).toInclude('Connection rate limit (10/min) exceeded');
// Clean up
for (let i = 0; i < 10; i++) {
securityManager.removeConnectionByIP(testIP, `rate-conn${i}`);
}
});
tap.test('HttpProxy CLIENT_IP header handling', async () => {