initial
This commit is contained in:
45
test/test.rulebuilder-table.ts
Normal file
45
test/test.rulebuilder-table.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import {
|
||||
buildTableSetup,
|
||||
buildFilterChains,
|
||||
buildTableCleanup,
|
||||
} from '../ts/nft.rulebuilder.table.js';
|
||||
|
||||
tap.test('should build table setup commands', async () => {
|
||||
const commands = buildTableSetup('mytest');
|
||||
expect(commands.length).toEqual(3);
|
||||
expect(commands[0]).toInclude('add table ip mytest');
|
||||
expect(commands[1]).toInclude('prerouting');
|
||||
expect(commands[1]).toInclude('nat hook prerouting');
|
||||
expect(commands[2]).toInclude('postrouting');
|
||||
expect(commands[2]).toInclude('nat hook postrouting');
|
||||
});
|
||||
|
||||
tap.test('should build table setup with custom family', async () => {
|
||||
const commands = buildTableSetup('mytest', 'inet');
|
||||
for (const cmd of commands) {
|
||||
expect(cmd).toInclude('inet mytest');
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('should build filter chains', async () => {
|
||||
const commands = buildFilterChains('mytest');
|
||||
expect(commands.length).toEqual(3);
|
||||
expect(commands[0]).toInclude('input');
|
||||
expect(commands[0]).toInclude('filter hook input');
|
||||
expect(commands[1]).toInclude('forward');
|
||||
expect(commands[2]).toInclude('output');
|
||||
});
|
||||
|
||||
tap.test('should build table cleanup command', async () => {
|
||||
const commands = buildTableCleanup('mytest');
|
||||
expect(commands.length).toEqual(1);
|
||||
expect(commands[0]).toInclude('delete table ip mytest');
|
||||
});
|
||||
|
||||
tap.test('should build table cleanup with custom family', async () => {
|
||||
const commands = buildTableCleanup('mytest', 'ip6');
|
||||
expect(commands[0]).toInclude('delete table ip6 mytest');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user