def test_parse_rule_simple_port(self): rule = ufw._parse_rule('allow 80'.split(' ')) self.assertUfwRuleEqual(rule, { 'policy': 'allow', 'direction': 'incoming', 'port': 80, })
def test_parse_rule_complex_host_port(self): rule = ufw._parse_rule('allow from 10.0.0.0/8 port 80'.split(' ')) self.assertUfwRuleEqual(rule, { 'policy': 'allow', 'port': 80, 'source': '10.0.0.0/8', })
def test_parse_rule_complex_protocol_port(self): rule = ufw._parse_rule('allow proto tcp from 10.0.0.0/8 port 443'.split(' ')) self.assertUfwRuleEqual(rule, { 'policy': 'allow', 'source': '10.0.0.0/8', 'port': 443, 'protocol': 'tcp', })
def test_parse_rule_simple_port_protocol(self): rule = ufw._parse_rule('reject 80/tcp'.split(' ')) self.assertUfwRuleEqual(rule, { 'policy': 'reject', 'direction': 'incoming', 'port': 80, 'protocol': 'tcp', })
def test_parse_rule_complex_comment(self): rule = ufw._parse_rule('allow proto tcp from any port 80 comment \'web app\''.split(' ')) self.assertUfwRuleEqual(rule, { 'policy': 'allow', 'port': 80, 'protocol': 'tcp', 'source': 'any', 'comment': 'web app', })