From aa5760f419bc132d898a67bab51160ea60f43276 Mon Sep 17 00:00:00 2001 From: L1ghtn1ng Date: Sun, 22 Aug 2021 02:12:08 +0100 Subject: [PATCH] Adjust unitests to be able to skip if run on github --- tests/discovery/test_anubis.py | 7 +++++++ tests/discovery/test_bufferover.py | 7 +++++++ tests/discovery/test_certspotter.py | 7 +++++++ tests/discovery/test_linkedin_links.py | 6 ++++++ tests/discovery/test_omnisint.py | 8 ++++++++ tests/discovery/test_otx.py | 7 +++++++ tests/discovery/test_qwantsearch.py | 7 +++++++ tests/discovery/test_sublist3r.py | 7 +++++++ tests/discovery/test_threatminer.py | 7 +++++++ 9 files changed, 63 insertions(+) diff --git a/tests/discovery/test_anubis.py b/tests/discovery/test_anubis.py index 673d4cdd..d31e01eb 100644 --- a/tests/discovery/test_anubis.py +++ b/tests/discovery/test_anubis.py @@ -3,11 +3,18 @@ import requests from theHarvester.lib.core import * from theHarvester.discovery import anubis +import os import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestAnubis: @staticmethod def domain() -> str: diff --git a/tests/discovery/test_bufferover.py b/tests/discovery/test_bufferover.py index f251c12f..9c236e8f 100644 --- a/tests/discovery/test_bufferover.py +++ b/tests/discovery/test_bufferover.py @@ -2,12 +2,19 @@ # coding=utf-8 from theHarvester.lib.core import * from theHarvester.discovery import bufferoverun +import os import requests import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestBufferover(object): @staticmethod def domain() -> str: diff --git a/tests/discovery/test_certspotter.py b/tests/discovery/test_certspotter.py index 0a39306b..08a40bb3 100644 --- a/tests/discovery/test_certspotter.py +++ b/tests/discovery/test_certspotter.py @@ -2,12 +2,19 @@ # coding=utf-8 from theHarvester.lib.core import * from theHarvester.discovery import certspottersearch +import os import requests import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestCertspotter(object): @staticmethod def domain() -> str: diff --git a/tests/discovery/test_linkedin_links.py b/tests/discovery/test_linkedin_links.py index 6c4f5327..ed479796 100644 --- a/tests/discovery/test_linkedin_links.py +++ b/tests/discovery/test_linkedin_links.py @@ -9,6 +9,12 @@ import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestGetLinks(object): async def test_splitter(self): diff --git a/tests/discovery/test_omnisint.py b/tests/discovery/test_omnisint.py index ab6980e4..4bccc380 100644 --- a/tests/discovery/test_omnisint.py +++ b/tests/discovery/test_omnisint.py @@ -2,17 +2,25 @@ # coding=utf-8 from theHarvester.lib.core import * from theHarvester.discovery import omnisint +import os import requests import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestOmnisint(object): @staticmethod def domain() -> str: return 'uber.com' + @pytest.mark.skipif(is_github_action == 'github', reason='Skipped test as fails on CI often but not locally') async def test_api(self): base_url = f'https://sonar.omnisint.io/all/{TestOmnisint.domain()}' headers = {'User-Agent': Core.get_user_agent()} diff --git a/tests/discovery/test_otx.py b/tests/discovery/test_otx.py index e380e9a9..ac1bd1b1 100644 --- a/tests/discovery/test_otx.py +++ b/tests/discovery/test_otx.py @@ -2,12 +2,19 @@ # coding=utf-8 from theHarvester.lib.core import * from theHarvester.discovery import otxsearch +import os import requests import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestOtx(object): @staticmethod def domain() -> str: diff --git a/tests/discovery/test_qwantsearch.py b/tests/discovery/test_qwantsearch.py index 882f0024..afd8034f 100644 --- a/tests/discovery/test_qwantsearch.py +++ b/tests/discovery/test_qwantsearch.py @@ -1,11 +1,18 @@ #!/usr/bin/env python3 # coding=utf-8 from theHarvester.discovery import qwantsearch +import os import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestSearchQwant(object): @staticmethod diff --git a/tests/discovery/test_sublist3r.py b/tests/discovery/test_sublist3r.py index 52b41b72..78c481a4 100644 --- a/tests/discovery/test_sublist3r.py +++ b/tests/discovery/test_sublist3r.py @@ -3,11 +3,18 @@ import requests from theHarvester.lib.core import * from theHarvester.discovery import sublist3r +import os import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestSublist3r(object): @staticmethod def domain() -> str: diff --git a/tests/discovery/test_threatminer.py b/tests/discovery/test_threatminer.py index 545c584d..17c85942 100644 --- a/tests/discovery/test_threatminer.py +++ b/tests/discovery/test_threatminer.py @@ -3,11 +3,18 @@ import requests from theHarvester.lib.core import * from theHarvester.discovery import threatminer +import os import pytest pytestmark = pytest.mark.asyncio +@pytest.fixture() +def is_github_action(): + if os.getenv('GITHUB_ACTIONS'): + return 'github' + + class TestThreatminer(object): @staticmethod def domain() -> str: