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