def test_mixed_default_policy(self): policy = ExitPolicy('accept *:80', 'accept 127.0.0.1:1-65533', *DEFAULT_POLICY_RULES) for rule in policy: # only accept-all and reject rules are the default ones self.assertTrue(rule.is_accept != rule.is_default() or (rule.is_accept and rule.is_address_wildcard() and rule.is_port_wildcard())) self.assertEqual(get_config_policy('accept *:80, accept 127.0.0.1:1-65533'), policy.strip_default())
def test_all_default_policy(self): policy = ExitPolicy(*DEFAULT_POLICY_RULES) for rule in policy: self.assertTrue(rule.is_default()) self.assertTrue(policy.has_default()) self.assertEqual(ExitPolicy(), policy.strip_default())
def test_mixed_default_policy(self): policy = ExitPolicy('accept *:80', 'accept 127.0.0.1:1-65533', *DEFAULT_POLICY_RULES) for rule in policy: # only accept-all and reject rules are the default ones self.assertTrue(rule.is_accept != rule.is_default() or (rule.is_accept and rule.is_address_wildcard() and rule.is_port_wildcard())) self.assertEqual(ExitPolicy('accept *:80', 'accept 127.0.0.1:1-65533'), policy.strip_default())
def test_non_private_non_default_policy(self): policy = ExitPolicy('reject *:80-65535', 'accept *:1-65533', 'reject *:*') for rule in policy: self.assertFalse(rule.is_private()) self.assertFalse(rule.is_default()) self.assertFalse(policy.has_private()) self.assertFalse(policy.has_default()) self.assertEqual(policy, policy.strip_private()) self.assertEqual(policy, policy.strip_default())