Skip to content

Commit 46f6590

Browse files
Copilotsgerlach
andcommitted
Fix failing tests by updating them to use new API instead of restoring deprecated functions
Co-authored-by: sgerlach <[email protected]>
1 parent b144b74 commit 46f6590

File tree

4 files changed

+156
-214
lines changed

4 files changed

+156
-214
lines changed

stackhawk.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tags:
2+
- name: environment
3+
value: prod
4+
- name: application
5+
value: secure-app

test_output.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
============================= test session starts ==============================
2+
platform linux -- Python 3.12.3, pytest-8.4.2, pluggy-1.6.0 -- /usr/bin/python3
3+
cachedir: .pytest_cache
4+
rootdir: /home/runner/work/stackhawk-mcp/stackhawk-mcp
5+
configfile: pytest.ini
6+
plugins: anyio-4.11.0, asyncio-1.2.0
7+
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
8+
collecting ... collected 24 items
9+
10+
tests/quick_test.py::test_pagination PASSED [ 4%]
11+
tests/test_all_time_fix.py::test_all_time_reports PASSED [ 8%]
12+
tests/test_anti_hallucination.py::test_anti_hallucination PASSED [ 12%]
13+
tests/test_api_calls.py::test_api_calls PASSED [ 16%]
14+
tests/test_application_vulnerabilities.py::test_vulnerability_scoping PASSED [ 20%]
15+
tests/test_connection.py::test_authentication PASSED [ 25%]
16+
tests/test_connection.py::test_basic_functionality PASSED [ 29%]
17+
tests/test_connection.py::test_mcp_resources PASSED [ 33%]
18+
tests/test_executive_summary_fix.py::test_executive_summary_fix PASSED [ 37%]
19+
tests/test_mcp_imports.py::test_imports PASSED [ 41%]
20+
tests/test_mcp_imports.py::test_environment PASSED [ 45%]
21+
tests/test_mcp_imports.py::test_server_creation PASSED [ 50%]
22+
tests/test_mcp_imports.py::test_mcp_imports PASSED [ 54%]
23+
tests/test_pagination_simple.py::test_pagination PASSED [ 58%]
24+
tests/test_repository_analysis.py::test_repository_analysis PASSED [ 62%]
25+
tests/test_repository_analysis.py::test_repository_api_endpoints PASSED [ 66%]
26+
tests/test_sensitive_data.py::test_sensitive_data_functionality PASSED [ 70%]
27+
tests/test_sensitive_data.py::test_sensitive_data_api_endpoints PASSED [ 75%]
28+
tests/test_server_fix.py::test_server_import PASSED [ 79%]
29+
tests/test_server_fix.py::test_server_class PASSED [ 83%]
30+
tests/test_server_fix.py::test_tech_flag_filtering PASSED [ 87%]
31+
tests/test_tool_schema.py::test_tool_schema_output_schema_and_annotations PASSED [ 91%]
32+
tests/test_vulnerability_reporting.py::test_vulnerability_reporting PASSED [ 95%]
33+
tests/test_yaml_tools.py::test_yaml_tools PASSED [100%]
34+
35+
=============================== warnings summary ===============================
36+
tests/test_mcp_imports.py::test_imports
37+
/home/runner/.local/lib/python3.12/site-packages/_pytest/python.py:161: PytestReturnNotNoneWarning: Test functions should return None, but tests/test_mcp_imports.py::test_imports returned <class 'bool'>.
38+
Did you mean to use `assert` instead of `return`?
39+
See https://docs.pytest.org/en/stable/how-to/assert.html#return-not-none for more information.
40+
warnings.warn(
41+
42+
tests/test_mcp_imports.py::test_environment
43+
/home/runner/.local/lib/python3.12/site-packages/_pytest/python.py:161: PytestReturnNotNoneWarning: Test functions should return None, but tests/test_mcp_imports.py::test_environment returned <class 'bool'>.
44+
Did you mean to use `assert` instead of `return`?
45+
See https://docs.pytest.org/en/stable/how-to/assert.html#return-not-none for more information.
46+
warnings.warn(
47+
48+
tests/test_mcp_imports.py::test_server_creation
49+
/home/runner/.local/lib/python3.12/site-packages/_pytest/python.py:161: PytestReturnNotNoneWarning: Test functions should return None, but tests/test_mcp_imports.py::test_server_creation returned <class 'bool'>.
50+
Did you mean to use `assert` instead of `return`?
51+
See https://docs.pytest.org/en/stable/how-to/assert.html#return-not-none for more information.
52+
warnings.warn(
53+
54+
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
55+
======================== 24 passed, 3 warnings in 4.84s ========================

tests/test_all_time_fix.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,48 +107,31 @@ async def test_all_time_reports():
107107
print(f" Applications analyzed: {total_trends}")
108108
print(f" Processing time: {(end_time - start_time).total_seconds():.2f} seconds")
109109

110-
# Test 5: Sensitive Data Report - All Time
111-
print("\n5. Testing all-time sensitive data report...")
110+
# Test 5: Comprehensive Sensitive Data Summary - All Time
111+
print("\n5. Testing all-time comprehensive sensitive data summary...")
112112
start_time = datetime.now()
113-
sensitive_report = await server._get_sensitive_data_report(
114-
org_id=org_id,
115-
data_type_filter="All",
116-
time_range="all",
117-
include_details=True,
118-
group_by="data_type"
119-
)
120-
end_time = datetime.now()
121-
122-
total_sensitive = sensitive_report.get("totalFindings", 0)
123-
124-
print(f"✅ All-time sensitive data report generated!")
125-
print(f" Total sensitive data findings: {total_sensitive}")
126-
print(f" Processing time: {(end_time - start_time).total_seconds():.2f} seconds")
127-
128-
# Test 6: Sensitive Data Summary - All Time
129-
print("\n6. Testing all-time sensitive data summary...")
130-
start_time = datetime.now()
131-
sensitive_summary = await server._generate_sensitive_data_summary(
113+
sensitive_summary = await server._get_comprehensive_sensitive_data_summary(
132114
org_id=org_id,
133115
time_period="all",
116+
include_trends=True,
117+
include_critical_only=False,
134118
include_recommendations=True,
135-
include_risk_assessment=True
119+
group_by="data_type"
136120
)
137121
end_time = datetime.now()
138122

139-
total_sensitive_summary = sensitive_summary["summary"]["totalFindings"]
123+
total_sensitive = sensitive_summary.get("total_findings", 0)
140124

141-
print(f"✅ All-time sensitive data summary generated!")
142-
print(f" Total sensitive data findings: {total_sensitive_summary}")
125+
print(f"✅ All-time comprehensive sensitive data summary generated!")
126+
print(f" Total sensitive data findings: {total_sensitive}")
143127
print(f" Processing time: {(end_time - start_time).total_seconds():.2f} seconds")
144128

145129
# Summary
146130
print(f"\n📈 SUMMARY:")
147131
print(f" Executive Summary Findings: {total_findings}")
148132
print(f" Vulnerability Report Findings: {total_findings_vuln}")
149133
print(f" Critical Findings: {total_critical}")
150-
print(f" Sensitive Data Findings: {total_sensitive}")
151-
print(f" Sensitive Data Summary: {total_sensitive_summary}")
134+
print(f" Sensitive Data Summary: {total_sensitive}")
152135

153136
# Verify consistency
154137
if total_findings == total_findings_vuln:

0 commit comments

Comments
 (0)