-
-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
good first issueGood for newcomersGood for newcomerspythonPull requests that update Python codePull requests that update Python codetestsAdd or improve test casesAdd or improve test cases
Description
In our tests for the API, we depend on the API returning IoCs in the right order. For example:
def test_200_all_feeds(self):
response = self.client.get("/api/feeds/advanced/")
self.assertEqual(response.status_code, 200)
if settings.FEEDS_LICENSE:
self.assertEqual(response.json()["license"], settings.FEEDS_LICENSE)
else:
self.assertNotIn("license", response.json())
iocs = response.json()["iocs"]
target_ioc = next((i for i in iocs if i["value"] == self.ioc.name), None)
self.assertIsNotNone(target_ioc)
self.assertEqual(target_ioc["feed_type"], ["log4j", "cowrie", "heralding", "ciscoasa"])
self.assertEqual(target_ioc["attack_count"], 1)
self.assertEqual(target_ioc["scanner"], True)
self.assertEqual(target_ioc["payload_request"], True)
self.assertEqual(target_ioc["recurrence_probability"], self.ioc.recurrence_probability)
self.assertEqual(target_ioc["expected_interactions"], self.ioc.expected_interactions)Here the API returns all 4 IoCs we defined in ./tests/__init__.py. The success of the test now depends on which IoC is returned first, as this will be assigned to target_ioc. This is usually not a problem, as the order should not change, but I think we can find a way to do this more reliably.
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomerspythonPull requests that update Python codePull requests that update Python codetestsAdd or improve test casesAdd or improve test cases