diff --git a/tests/conftest.py b/tests/conftest.py index 2c3ab06..710593d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -33,6 +33,16 @@ def scan_message() -> message.Message: return message.Message.from_data(selector, data=msg_data) +@pytest.fixture +def electro_scan_message() -> message.Message: + """Creates a dummy message of type v3.asset.domain_name to be used by the agent for testing purposes.""" + selector = "v3.asset.domain_name" + msg_data = { + "name": "electrohold.bg", + } + return message.Message.from_data(selector, data=msg_data) + + @pytest.fixture def test_agent() -> whois_domain_agent.AgentWhoisDomain: """Creates a dummy agent for the Whois Domain Agent.""" diff --git a/tests/whois_domain_agent_test.py b/tests/whois_domain_agent_test.py index 4097252..5e3e22b 100644 --- a/tests/whois_domain_agent_test.py +++ b/tests/whois_domain_agent_test.py @@ -412,3 +412,21 @@ def testAgentWhois_whenEmailIsNotDisclosed_shouldNotEmitEmails( ) assert agent_mock[0].data.get("emails") is None + + +def testAgentWhois_whenDomainNameAssetInvalidTLD_emitsMessages( + electro_scan_message: message.Message, + test_agent: whois_domain_agent.AgentWhoisDomain, + agent_persist_mock: Any, + mocker: plugin.MockerFixture, + agent_mock: List[message.Message], +) -> None: + """Tests running the agent and emitting vulnerabilities.""" + del agent_persist_mock + + test_agent.start() + test_agent.process(electro_scan_message) + + assert len(agent_mock) > 0 + assert agent_mock[0].selector == "v3.asset.domain_name.whois" + assert "electrohold.bg" in agent_mock[0].data["name"]