Skip to content

Commit e22944f

Browse files
author
Sebastian Wagner
committed
TST: cymru expert: loosen 6to4 testcase
the test caused regularly troubles as the ownership chaned. we now just checks of the fields were added, not the contents.
1 parent 5ddba76 commit e22944f

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ IntelMQ no longer supports Python 3.5 (and thus Debian 9 and Ubuntu 16.04), the
157157
- `intelmq.lib.test`:
158158
- `test_static_bot_check_method` checks the bot's static `check(parameters)` method for any exceptions, and a valid formatted return value (#1505, by Sebastian Wagner).
159159
- `setUpClass`: Skip tests if cache was requests with `use_cache` member, but Redis is deactivated with the environment variable `INTELMQ_SKIP_REDIS` (by Sebastian Wagner).
160-
- `intelmq.tests.bots.experts.cymru_whois.test_expert`: Switch from `example.com` to `ns2.univie.ac.at` for hopefully more stable responses (#1730, PR#1731 by Sebastian Waldbauer).
160+
- `intelmq.tests.bots.experts.cymru_whois.test_expert`:
161+
- Switch from `example.com` to `ns2.univie.ac.at` for hopefully more stable responses (#1730, PR#1731 by Sebastian Waldbauer).
162+
- Do not test for exact expected values in the 6to4 network test, as the values are changing regularly (by Sebastian Wagner).
161163
- `intelmq.tests.bots.parsers.abusech`: Remove tests cases of discontinued feeds (PR#1741 by Thomas Bellus).
162164
- Activate GitHub's CodeQL Code Analyzing tool as GitHub Action (by Sebastian Wagner).
163165

intelmq/tests/bots/experts/cymru_whois/test_expert.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
import json
23
import unittest
34

45
import intelmq.lib.test as test
@@ -40,20 +41,6 @@
4041
"source.ip": "2002:3ee0:3972:0001::1",
4142
"time.observation": "2015-01-01T00:00:00+00:00",
4243
}
43-
EXAMPLE_6TO4_OUTPUT = {"__type": "Event",
44-
"source.ip": "2002:3ee0:3972:0001::1",
45-
"source.network": "2002::/16",
46-
"source.asn": 1103,
47-
"source.as_name": "SURFNET-NL SURFnet, The Netherlands, NL",
48-
"time.observation": "2015-01-01T00:00:00+00:00",
49-
}
50-
EXAMPLE_6TO4_OUTPUT_1 = {"__type": "Event",
51-
"source.ip": "2002:3ee0:3972:0001::1",
52-
"source.network": "2002::/16",
53-
"source.asn": 6939,
54-
"source.as_name": "HURRICANE, US",
55-
"time.observation": "2015-01-01T00:00:00+00:00",
56-
}
5744
OVERWRITE_OUT = {"__type": "Event",
5845
"source.ip": "78.104.144.2",
5946
"source.geolocation.cc": "AA",
@@ -98,20 +85,21 @@ def test_empty_result(self):
9885
def test_6to4_result(self):
9986
"""
10087
Test the whois for an IPv6 to IPv4 network range.
101-
The result can vary, so we test for two possible expected results.
88+
The result can vary, so we only tests if values exist.
10289
"""
10390
self.input_message = EXAMPLE_6TO4_INPUT
10491
self.run_bot()
105-
try:
106-
self.assertMessageEqual(0, EXAMPLE_6TO4_OUTPUT)
107-
except AssertionError:
108-
self.assertMessageEqual(0, EXAMPLE_6TO4_OUTPUT_1)
92+
actual = json.loads(self.get_output_queue()[0])
93+
self.assertDictContainsSubset(EXAMPLE_6TO4_INPUT, actual)
94+
self.assertIn("source.asn", actual)
95+
self.assertIn("source.as_name", actual)
96+
self.assertIn("source.network", actual)
10997

11098
def test_overwrite(self):
11199
self.input_message = EXAMPLE_INPUT.copy()
112100
self.input_message["source.geolocation.cc"] = "AA"
113101
self.input_message["source.registry"] = "LACNIC"
114-
self.run_bot(parameters={'overwrite' : False})
102+
self.run_bot(parameters={'overwrite': False})
115103
self.assertMessageEqual(0, OVERWRITE_OUT)
116104

117105

0 commit comments

Comments
 (0)