mirror of
https://github.com/usestrix/strix.git
synced 2026-08-22 02:58:39 +02:00
Wire vulnerability amendment callbacks
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -107,6 +107,35 @@ async def test_update_requires_nonempty_reason() -> None:
|
||||
assert result == {"success": False, "error": "update_reason cannot be empty"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("field", "value", "expected_error"),
|
||||
[
|
||||
("impact", "", "Impact cannot be empty"),
|
||||
("impact", " ", "Impact cannot be empty"),
|
||||
("endpoint", "", "Endpoint cannot be empty"),
|
||||
("endpoint", " ", "Endpoint cannot be empty"),
|
||||
],
|
||||
)
|
||||
async def test_update_rejects_blank_text_fields(
|
||||
report_state: ReportState,
|
||||
field: str,
|
||||
value: str,
|
||||
expected_error: str,
|
||||
) -> None:
|
||||
original_value = report_state.vulnerability_reports[0][field]
|
||||
update = cast("dict[str, Any]", {field: value})
|
||||
|
||||
result = await _do_update(
|
||||
report_id="vuln-0001",
|
||||
update_reason="The source review supplied no content for this field.",
|
||||
**update,
|
||||
)
|
||||
|
||||
assert result["success"] is False
|
||||
assert expected_error in result["errors"]
|
||||
assert report_state.vulnerability_reports[0][field] == original_value
|
||||
|
||||
|
||||
async def test_update_changes_impact_only(report_state: ReportState) -> None:
|
||||
result = await _do_update(
|
||||
report_id="vuln-0001",
|
||||
|
||||
Reference in New Issue
Block a user