Skip to content

Commit

Permalink
Add test for multiple entity types (#1106)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastien Larinier <[email protected]>
  • Loading branch information
tomchop and sebdraven authored Jul 16, 2024
1 parent d6037e4 commit 0aac06b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/apiv2/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ def test_search_entities_subfields(self):
self.assertEqual(data["entities"][0]["name"], "ta1")
self.assertEqual(data["entities"][0]["type"], "threat-actor")

def test_search_entities_multiple_types(self):
entity.AttackPattern(name="ttp1").save()
entity.Malware(name="malware1").save() # this won't show up
response = client.post(
"/api/v2/entities/search",
json={"query": {"type__in": ["threat-actor", "attack-pattern"]}},
)
data = response.json()
self.assertEqual(response.status_code, 200, data)
self.assertEqual(len(data["entities"]), 3)
all_types = {e["type"] for e in data["entities"]}
self.assertEqual(all_types, {"threat-actor", "attack-pattern"})

def test_search_entities_by_alias(self):
response = client.post(
"/api/v2/entities/search",
Expand Down

0 comments on commit 0aac06b

Please sign in to comment.