Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
laramies
GitHub Repository: laramies/theHarvester
Path: blob/master/tests/discovery/test_otx.py
609 views
1
#!/usr/bin/env python3
2
# coding=utf-8
3
import os
4
from typing import Optional
5
import httpx
6
import pytest
7
from _pytest.mark.structures import MarkDecorator
8
9
from theHarvester.discovery import otxsearch
10
from theHarvester.lib.core import *
11
12
pytestmark: MarkDecorator = pytest.mark.asyncio
13
github_ci: Optional[str] = os.getenv(
14
"GITHUB_ACTIONS"
15
) # Github set this to be the following: true instead of True
16
17
18
class TestOtx(object):
19
@staticmethod
20
def domain() -> str:
21
return "cybermon.uk"
22
23
async def test_api(self) -> None:
24
base_url = f"https://otx.alienvault.com/api/v1/indicators/domain/{TestOtx.domain()}/passive_dns"
25
headers = {"User-Agent": Core.get_user_agent()}
26
request = httpx.get(base_url, headers=headers)
27
assert request.status_code == 200
28
29
async def test_search(self) -> None:
30
search = otxsearch.SearchOtx(TestOtx.domain())
31
await search.process()
32
assert isinstance(await search.get_hostnames(), set)
33
assert isinstance(await search.get_ips(), set)
34
35
36
if __name__ == "__main__":
37
pytest.main()
38
39