From 6dda2d08c07a9a7eeb395bd8600cd57257b86109 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Wed, 14 Apr 2021 19:57:33 +0200 Subject: [PATCH] fix: [tests] Fixed hibp test which requires an API key --- tests/test_expansions.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_expansions.py b/tests/test_expansions.py index f3bc53a..62ca7f1 100644 --- a/tests/test_expansions.py +++ b/tests/test_expansions.py @@ -228,12 +228,16 @@ class TestExpansions(unittest.TestCase): self.assertEqual(self.get_errors(response), 'Farsight DNSDB apikey is missing') def test_haveibeenpwned(self): + module_name = 'hibp' query = {"module": "hibp", "email-src": "info@circl.lu"} response = self.misp_modules_post(query) - to_check = self.get_values(response) - if to_check == "haveibeenpwned.com API not accessible (HTTP 401)": - self.skipTest(f"haveibeenpwned blocks travis IPs: {response}") - self.assertEqual(to_check, 'OK (Not Found)', response) + if module_name in self.configs: + to_check = self.get_values(response) + if to_check == "haveibeenpwned.com API not accessible (HTTP 401)": + self.skipTest(f"haveibeenpwned blocks travis IPs: {response}") + self.assertEqual(to_check, 'OK (Not Found)', response) + else: + self.assertEqual(self.get_errors(response), 'Have I Been Pwned authentication is incomplete (no API key)') def test_greynoise(self): module_name = 'greynoise'