Skip to content

Commit

Permalink
add unittest for triggring network exception to fix code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ybadaoui-ostorlab committed Oct 21, 2024
1 parent 8cbfd8e commit 91f6fac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/exploits/jetpack_version_detection_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Unit tests for Agent Asteroid: Jetpack Exploit"""

import pytest
import requests_mock as req_mock

from agent import definitions
Expand Down Expand Up @@ -60,3 +61,16 @@ def testCVE20249487_whenNotVulnerable_reportNothing(

assert accept is True
assert len(vulnerabilities) == 0


def testCVE20249487_whenNetworkErrorOccurs_reportNothing(
caplog: pytest.LogCaptureFixture,
) -> None:
"""Jetpack Exploit unit test: case when network error occurs."""

exploit_instance = jetpack_version_detection.JetpackExploit()
target = definitions.Target("http", "nonexesit", 80)

vulnerabilities = exploit_instance.check(target)
assert len(vulnerabilities) == 0
assert "Network error occurred" in caplog.text

0 comments on commit 91f6fac

Please sign in to comment.