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:
@@ -74,7 +74,10 @@ def _make_test(**overrides):
|
||||
|
||||
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
|
||||
@patch("app.services.jira_service.get_admin_jira_client")
|
||||
def test_push_pause_event_sets_on_hold(mock_get_client, mock_configured, db):
|
||||
def test_push_pause_event_does_not_change_jira_status(mock_get_client, mock_configured, db):
|
||||
"""A timer pause is not the same as a real Hold — it must never flip the
|
||||
Jira issue to 'On Hold'. Only push_hold_event (a genuine Hold action) is
|
||||
allowed to change status. Regression: pausing used to set 'On Hold'."""
|
||||
mock_jira = MagicMock()
|
||||
mock_get_client.return_value = mock_jira
|
||||
test = _make_test()
|
||||
@@ -84,13 +87,13 @@ def test_push_pause_event_sets_on_hold(mock_get_client, mock_configured, db):
|
||||
|
||||
jira_service.push_pause_event(db, test, MagicMock(username="alice"), resuming=False)
|
||||
|
||||
mock_jira.set_issue_status.assert_called_once_with(link.jira_issue_key, "On Hold")
|
||||
mock_jira.set_issue_status.assert_not_called()
|
||||
mock_jira.issue_add_comment.assert_called_once()
|
||||
|
||||
|
||||
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
|
||||
@patch("app.services.jira_service.get_admin_jira_client")
|
||||
def test_push_pause_event_resume_sets_in_progress(mock_get_client, mock_configured, db):
|
||||
def test_push_pause_event_resume_does_not_change_jira_status(mock_get_client, mock_configured, db):
|
||||
mock_jira = MagicMock()
|
||||
mock_get_client.return_value = mock_jira
|
||||
test = _make_test()
|
||||
@@ -100,7 +103,8 @@ def test_push_pause_event_resume_sets_in_progress(mock_get_client, mock_configur
|
||||
|
||||
jira_service.push_pause_event(db, test, MagicMock(username="alice"), resuming=True)
|
||||
|
||||
mock_jira.set_issue_status.assert_called_once_with(link.jira_issue_key, "In Progress")
|
||||
mock_jira.set_issue_status.assert_not_called()
|
||||
mock_jira.issue_add_comment.assert_called_once()
|
||||
|
||||
|
||||
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
|
||||
@@ -118,6 +122,39 @@ def test_push_hold_event_sets_blocked(mock_get_client, mock_configured, db):
|
||||
mock_jira.set_issue_status.assert_called_once_with(link.jira_issue_key, "Blocked")
|
||||
|
||||
|
||||
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
|
||||
@patch("app.services.jira_service.get_admin_jira_client")
|
||||
def test_push_round_archived_posts_comment_without_changing_status(mock_get_client, mock_configured, db):
|
||||
"""Archiving a round before reopen must leave a permanent Jira comment
|
||||
(custom fields get overwritten by the next round, comments don't) but
|
||||
must not touch the issue's status — that's push_test_event's job."""
|
||||
from app.domain.enums import AttackSuccessResult
|
||||
from app.models.test_round_history import TestRoundHistory
|
||||
|
||||
test = _make_test()
|
||||
link = _make_link(test.id)
|
||||
db.add(link)
|
||||
db.commit()
|
||||
|
||||
round_data = TestRoundHistory(
|
||||
test_id=test.id, team="red", round_number=1,
|
||||
attack_success=AttackSuccessResult.successful, red_summary="Got a shell.",
|
||||
procedure_text="ran mimikatz", tool_used="mimikatz",
|
||||
review_notes="Evidence was incomplete, redo with screenshots",
|
||||
)
|
||||
mock_jira = MagicMock()
|
||||
mock_get_client.return_value = mock_jira
|
||||
|
||||
jira_service.push_round_archived(db, test, MagicMock(username="redlead"), round_data=round_data)
|
||||
|
||||
mock_jira.set_issue_status.assert_not_called()
|
||||
mock_jira.issue_add_comment.assert_called_once()
|
||||
comment = mock_jira.issue_add_comment.call_args[0][1]
|
||||
assert "Round 1" in comment
|
||||
assert "Got a shell." in comment
|
||||
assert "Evidence was incomplete" in comment
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"new_state,expected_status",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user