Skip to content

Commit

Permalink
Merge pull request #41 from Ostorlab/fix/invalid_tld
Browse files Browse the repository at this point in the history
Fix electrohold invalid TLD.
  • Loading branch information
amine3 authored Jul 22, 2024
2 parents e62915d + 55d6293 commit 7de7b82
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
18 changes: 18 additions & 0 deletions tests/whois_domain_agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 7de7b82

Please sign in to comment.