summaryrefslogtreecommitdiff
path: root/reconfigure/tests/configs/iptables_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'reconfigure/tests/configs/iptables_tests.py')
-rw-r--r--reconfigure/tests/configs/iptables_tests.py100
1 files changed, 100 insertions, 0 deletions
diff --git a/reconfigure/tests/configs/iptables_tests.py b/reconfigure/tests/configs/iptables_tests.py
new file mode 100644
index 0000000..335e081
--- /dev/null
+++ b/reconfigure/tests/configs/iptables_tests.py
@@ -0,0 +1,100 @@
+from reconfigure.configs import IPTablesConfig
+from base_test import BaseConfigTest
+
+
+class IPTablesConfigTest (BaseConfigTest):
+ sources = {
+ None: '''*filter
+:INPUT ACCEPT [0:0]
+:FORWARD DROP [0:0]
+:OUTPUT ACCEPT [0:0]
+-A INPUT ! -s 202.54.1.2/32 -j DROP
+-A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT # test
+COMMIT
+'''
+ }
+ result = {
+ 'tables': [
+ {
+ 'chains': [
+ {
+ 'default': 'ACCEPT',
+ 'rules': [
+ {
+ 'options': [
+ {
+ 'arguments': [
+ {
+ 'value': '202.54.1.2/32'
+ }
+ ],
+ 'negative': True,
+ 'name': 's'
+ },
+ {
+ 'arguments': [
+ {
+ 'value': 'DROP'
+ }
+ ],
+ 'negative': False,
+ 'name': 'j'
+ }
+ ],
+ 'comment': None,
+ },
+ {
+ 'options': [
+ {
+ 'arguments': [
+ {
+ 'value': 'state'
+ }
+ ],
+ 'negative': False,
+ 'name': 'm'
+ },
+ {
+ 'arguments': [
+ {
+ 'value': 'NEW,ESTABLISHED'
+ }
+ ],
+ 'negative': False,
+ 'name': 'state'
+ },
+ {
+ 'arguments': [
+ {
+ 'value': 'ACCEPT'
+ }
+ ],
+ 'negative': False,
+ 'name': 'j'
+ }
+ ],
+ 'comment': 'test',
+ }
+ ],
+ 'name': 'INPUT'
+ },
+ {
+ 'default': 'DROP',
+ 'rules': [],
+ 'name': 'FORWARD'
+ },
+ {
+ 'default': 'ACCEPT',
+ 'rules': [],
+ 'name': 'OUTPUT'
+ }
+ ],
+ 'name': 'filter'
+ }
+ ]
+ }
+
+ config = IPTablesConfig
+
+
+del BaseConfigTest