Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
laramies
GitHub Repository: laramies/theHarvester
Path: blob/master/tests/discovery/test_certspotter.py
916 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
9
from theHarvester.discovery import certspottersearch
10
from theHarvester.lib.core import *
11
12
github_ci: Optional[str] = os.getenv(
13
"GITHUB_ACTIONS"
14
) # Github set this to be the following: true instead of True
15
16
17
class TestCertspotter(object):
18
@staticmethod
19
def domain() -> str:
20
return "metasploit.com"
21
22
23
@pytest.mark.skipif(github_ci == 'true', reason="Skipping this test for now")
24
class TestCertspotterSearch(object):
25
@pytest.mark.asyncio
26
async def test_api(self) -> None:
27
base_url = f"https://api.certspotter.com/v1/issuances?domain={TestCertspotter.domain()}&expand=dns_names"
28
headers = {"User-Agent": Core.get_user_agent()}
29
request = httpx.get(base_url, headers=headers)
30
assert request.status_code == 200
31
32
@pytest.mark.asyncio
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