feat(tests): archive round history on reopen, stop pausing from setting Jira On Hold
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled
- Reopening a test for rework (red or blue) now archives the round that's ending into a new test_round_history table before resetting the live fields — procedure/results/detection data is preserved instead of overwritten, and Phase Timeline renders every past round alongside the current one, so Blue Team keeps visibility into earlier Red attempts. - Each archived round also posts a permanent Jira comment (push_round_archived) since Jira's custom fields only ever show the latest value once the next round resubmits — the comment thread is what preserves full history there. - push_pause_event no longer transitions the Jira issue to "On Hold" — a timer pause is not a real Hold, and flipping Jira status for it was misleading. Only the explicit Hold action (push_hold_event) does that now.
This commit is contained in:
@@ -142,6 +142,21 @@ def _make_test(state: TestState = TestState.draft, **kwargs) -> MagicMock:
|
||||
t.paused_at = kwargs.get("paused_at", None)
|
||||
t.red_paused_seconds = kwargs.get("red_paused_seconds", 0)
|
||||
t.blue_paused_seconds = kwargs.get("blue_paused_seconds", 0)
|
||||
t.red_round_number = kwargs.get("red_round_number", 1)
|
||||
t.blue_round_number = kwargs.get("blue_round_number", 1)
|
||||
t.procedure_text = kwargs.get("procedure_text", None)
|
||||
t.tool_used = kwargs.get("tool_used", None)
|
||||
t.attack_success = kwargs.get("attack_success", None)
|
||||
t.red_summary = kwargs.get("red_summary", None)
|
||||
t.execution_start_time = kwargs.get("execution_start_time", None)
|
||||
t.execution_end_time = kwargs.get("execution_end_time", None)
|
||||
t.detection_result = kwargs.get("detection_result", None)
|
||||
t.containment_result = kwargs.get("containment_result", None)
|
||||
t.detection_time = kwargs.get("detection_time", None)
|
||||
t.containment_time = kwargs.get("containment_time", None)
|
||||
t.blue_summary = kwargs.get("blue_summary", None)
|
||||
t.red_tech_assignee = kwargs.get("red_tech_assignee", None)
|
||||
t.blue_tech_assignee = kwargs.get("blue_tech_assignee", None)
|
||||
return t
|
||||
|
||||
|
||||
@@ -723,6 +738,81 @@ class TestReviewDecisions:
|
||||
args, kwargs = mock_push.call_args
|
||||
assert args[3] == "blue_evaluating"
|
||||
|
||||
@patch("app.services.test_workflow_service.log_action")
|
||||
def test_reopen_red_review_archives_round_and_resets_fields(self, mock_log):
|
||||
"""Reopening must not erase what Red already submitted — it archives
|
||||
the round (visible via round_history) and only then blanks the live
|
||||
fields for a fresh attempt, bumping the round counter."""
|
||||
from app.models.test_round_history import TestRoundHistory
|
||||
|
||||
test = _make_test(
|
||||
TestState.red_review,
|
||||
procedure_text="ran mimikatz", tool_used="mimikatz",
|
||||
attack_success="successful", red_summary="Got a shell.",
|
||||
)
|
||||
reviewer = _make_user("red_lead")
|
||||
db = _make_db()
|
||||
|
||||
with patch("app.services.jira_service.push_test_event"), \
|
||||
patch("app.services.jira_service.push_round_archived"):
|
||||
from app.services.test_workflow_service import reopen_red_review
|
||||
reopen_red_review(db, test, reviewer, notes="incomplete evidence")
|
||||
|
||||
archived = [c.args[0] for c in db.add.call_args_list if isinstance(c.args[0], TestRoundHistory)]
|
||||
assert len(archived) == 1
|
||||
assert archived[0].team == "red"
|
||||
assert archived[0].round_number == 1
|
||||
assert archived[0].attack_success == "successful"
|
||||
assert archived[0].red_summary == "Got a shell."
|
||||
assert archived[0].review_notes == "incomplete evidence"
|
||||
|
||||
assert test.procedure_text is None
|
||||
assert test.tool_used is None
|
||||
assert test.attack_success is None
|
||||
assert test.red_summary is None
|
||||
assert test.red_round_number == 2
|
||||
|
||||
@patch("app.services.test_workflow_service.log_action")
|
||||
def test_reopen_blue_review_archives_round_and_resets_fields(self, mock_log):
|
||||
from app.models.test_round_history import TestRoundHistory
|
||||
|
||||
test = _make_test(
|
||||
TestState.blue_review,
|
||||
detection_result="detected", blue_summary="Caught it via EDR.",
|
||||
)
|
||||
reviewer = _make_user("blue_lead")
|
||||
db = _make_db()
|
||||
|
||||
with patch("app.services.jira_service.push_test_event"), \
|
||||
patch("app.services.jira_service.push_round_archived"):
|
||||
from app.services.test_workflow_service import reopen_blue_review
|
||||
reopen_blue_review(db, test, reviewer, notes="missing containment steps")
|
||||
|
||||
archived = [c.args[0] for c in db.add.call_args_list if isinstance(c.args[0], TestRoundHistory)]
|
||||
assert len(archived) == 1
|
||||
assert archived[0].team == "blue"
|
||||
assert archived[0].round_number == 1
|
||||
assert archived[0].detection_result == "detected"
|
||||
assert archived[0].blue_summary == "Caught it via EDR."
|
||||
assert archived[0].review_notes == "missing containment steps"
|
||||
|
||||
assert test.detection_result is None
|
||||
assert test.blue_summary is None
|
||||
assert test.blue_round_number == 2
|
||||
|
||||
@patch("app.services.test_workflow_service.log_action")
|
||||
def test_reopen_red_review_pushes_round_archived_comment_to_jira(self, mock_log):
|
||||
test = _make_test(TestState.red_review)
|
||||
reviewer = _make_user("red_lead")
|
||||
db = _make_db()
|
||||
|
||||
with patch("app.services.jira_service.push_test_event"), \
|
||||
patch("app.services.jira_service.push_round_archived") as mock_archive:
|
||||
from app.services.test_workflow_service import reopen_red_review
|
||||
reopen_red_review(db, test, reviewer, notes="redo it")
|
||||
|
||||
mock_archive.assert_called_once()
|
||||
|
||||
|
||||
class TestStartBlueWork:
|
||||
@patch("app.services.jira_service.push_bt_work_started")
|
||||
|
||||
Reference in New Issue
Block a user