Test to accompany accepting IP followed by host IP address.

This commit is contained in:
Steven Black 2018-03-14 00:10:07 -04:00
parent 2526b76bea
commit 03c247bfab

View File

@ -698,7 +698,7 @@ class TestNormalizeRule(BaseStdout):
kwargs = dict(target_ip="0.0.0.0", keep_domain_comments=False)
for rule in ["foo", "128.0.0.1", "bar.com/usa", "0.0.0 google",
"0.0.0.0 1.2.34.34", "0.1.2.3.4 foo/bar", "twitter.com"]:
"0.1.2.3.4 foo/bar", "twitter.com"]:
self.assertEqual(normalize_rule(rule, **kwargs), (None, None))
output = sys.stdout.getvalue()
@ -740,6 +740,21 @@ class TestNormalizeRule(BaseStdout):
sys.stdout = StringIO()
def test_two_ips(self):
for target_ip in ("0.0.0.0", "127.0.0.1", "8.8.8.8"):
rule = "127.0.0.1 11.22.33.44 foo"
expected = ("11.22.33.44", str(target_ip) + " 11.22.33.44\n")
actual = normalize_rule(rule, target_ip=target_ip,
keep_domain_comments=False)
self.assertEqual(actual, expected)
# Nothing gets printed if there's a match.
output = sys.stdout.getvalue()
self.assertEqual(output, "")
sys.stdout = StringIO()
class TestStripRule(Base):