summaryrefslogtreecommitdiff
path: root/reconfigure/tests/parsers/iptables_tests.py
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
committerAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
commitff1408420159488a106492ccd11dd234967029b6 (patch)
tree473420cee1c5229a427ec4cafead1aa6c0a26800 /reconfigure/tests/parsers/iptables_tests.py
Imported Upstream version 0.1.29
Diffstat (limited to 'reconfigure/tests/parsers/iptables_tests.py')
-rw-r--r--reconfigure/tests/parsers/iptables_tests.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/reconfigure/tests/parsers/iptables_tests.py b/reconfigure/tests/parsers/iptables_tests.py
new file mode 100644
index 0000000..21e09fa
--- /dev/null
+++ b/reconfigure/tests/parsers/iptables_tests.py
@@ -0,0 +1,61 @@
+from reconfigure.tests.parsers.base_test import BaseParserTest
+from reconfigure.parsers import IPTablesParser
+from reconfigure.nodes import *
+
+
+class IPTablesParserTest (BaseParserTest):
+ parser = IPTablesParser()
+ source = """*filter
+:INPUT ACCEPT [0:0]
+:FORWARD DROP [0:0]
+:OUTPUT ACCEPT [0:0]
+-A INPUT ! -s 202.54.1.2/32 -j DROP # test
+-A INPUT -m state --state NEW,ESTABLISHED -j ACCEPT
+COMMIT
+"""
+ parsed = RootNode(None,
+ Node('filter',
+ Node('INPUT',
+ PropertyNode('default', 'ACCEPT'),
+ Node('append',
+ Node('option',
+ Node('argument', PropertyNode('value', '202.54.1.2/32')),
+ PropertyNode('negative', True),
+ PropertyNode('name', 's')
+ ),
+ Node('option',
+ Node('argument', PropertyNode('value', 'DROP')),
+ PropertyNode('negative', False),
+ PropertyNode('name', 'j')
+ ),
+ comment='test'
+ ),
+ Node('append',
+ Node('option',
+ Node('argument', PropertyNode('value', 'state')),
+ PropertyNode('negative', False),
+ PropertyNode('name', 'm')
+ ),
+ Node('option',
+ Node('argument', PropertyNode('value', 'NEW,ESTABLISHED')),
+ PropertyNode('negative', False),
+ PropertyNode('name', 'state')
+ ),
+ Node('option',
+ Node('argument', PropertyNode('value', 'ACCEPT')),
+ PropertyNode('negative', False),
+ PropertyNode('name', 'j')
+ ),
+ ),
+ ),
+ Node('FORWARD',
+ PropertyNode('default', 'DROP'),
+ ),
+ Node('OUTPUT',
+ PropertyNode('default', 'ACCEPT'),
+ ),
+ )
+ )
+
+
+del BaseParserTest