Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pentestgpt/agents/opsec_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def validate_operation(
logger.info(f"Validating operation: {operation}")

# Log the validation attempt
audit_entry = {
audit_entry: dict[str, Any] = {
"timestamp": datetime.now().isoformat(),
"operation": operation,
"context": context,
Expand All @@ -222,7 +222,7 @@ def validate_operation(
is_compliant = all(check[0] for check in compliance_checks)
reason = "; ".join(check[1] for check in compliance_checks if not check[0])

audit_entry["result"] = str(is_compliant)
audit_entry["result"] = is_compliant
audit_entry["reason"] = reason
self.audit_log.append(audit_entry)

Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts = -v --tb=short --strict-markers
addopts = -v --tb=short --strict-markers -m "not llm"
markers =
unit: Unit tests (auto-applied to component tests)
integration: Integration tests (tests/integration/)
Expand All @@ -17,6 +17,7 @@ markers =
db: Database tests
config: Configuration tests
core: Core component tests
llm: Live LLM tests (require API key, run with: pytest -m llm)
asyncio_mode = auto
filterwarnings =
ignore::DeprecationWarning
Expand Down
13 changes: 13 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
"""Test suite for PentestGPT."""

from typing import Any
from unittest.mock import MagicMock


def make_mock_router(
route_task_return: Any = ("Mocked LLM response", "openai", 0.01),
) -> MagicMock:
"""Create a mock model router. Usable from helper functions (not just fixtures)."""
router = MagicMock()
router.route_task = MagicMock(return_value=route_task_return)
router.get_model_for_task = MagicMock(return_value="gpt-4-test")
return router
Loading
Loading