39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
|
import * as smartproxy from '../ts/index.js';
|
|
|
|
tap.test('route security should be correctly configured', async () => {
|
|
// Test that we can create a proxy with route-specific security
|
|
const routes = [{
|
|
name: 'secure-route',
|
|
match: {
|
|
ports: 8990
|
|
},
|
|
action: {
|
|
type: 'forward' as const,
|
|
targets: [{
|
|
host: '127.0.0.1',
|
|
port: 8991
|
|
}]
|
|
},
|
|
security: {
|
|
ipAllowList: ['192.168.1.1'],
|
|
ipBlockList: ['10.0.0.1']
|
|
}
|
|
}];
|
|
|
|
// This should not throw an error
|
|
const proxy = new smartproxy.SmartProxy({
|
|
enableDetailedLogging: false,
|
|
routes: routes
|
|
});
|
|
|
|
// The proxy should be created successfully
|
|
expect(proxy).toBeInstanceOf(smartproxy.SmartProxy);
|
|
|
|
// Verify route configuration was preserved
|
|
expect(proxy.settings.routes[0].security?.ipAllowList).toContain('192.168.1.1');
|
|
expect(proxy.settings.routes[0].security?.ipBlockList).toContain('10.0.0.1');
|
|
});
|
|
|
|
export default tap.start();
|