Skip to content

Commit

Permalink
Fix signoffs for emergency shutoff (#3277)
Browse files Browse the repository at this point in the history
We need to pass information about the role from the request body into
post_signoffs_scheduled_change.

Fixes #3276
  • Loading branch information
jcristau authored Jan 14, 2025
1 parent 89885d7 commit ef706d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/auslib/web/admin/emergency_shutoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def delete_scheduled_deletion(sc_id, data_version, changed_by, transaction):
@requirelogin
@transactionHandler
@handleGeneralExceptions
def scheduled_changes_signoffs(sc_id, transaction, changed_by):
def scheduled_changes_signoffs(sc_id, sc_post_signoffs_body, transaction, changed_by):
return post_signoffs_scheduled_change(
signoffs_table=dbo.emergencyShutoffs.scheduled_changes.signoffs, sc_id=sc_id, transaction=transaction, changed_by=changed_by
signoffs_table=dbo.emergencyShutoffs.scheduled_changes.signoffs, sc_id=sc_id, what=sc_post_signoffs_body, transaction=transaction, changed_by=changed_by
)


Expand Down
20 changes: 18 additions & 2 deletions tests/admin/views/test_emergency_shutoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TestEmergencyShutoff(ViewTest):
def setUp(self):
super(TestEmergencyShutoff, self).setUp()
dbo.emergencyShutoffs.t.insert().execute(product="Firefox", channel="nightly", data_version=1)
dbo.emergencyShutoffs.t.insert().execute(product="Firefox", channel="release", data_version=1)
dbo.emergencyShutoffs.t.insert().execute(product="Fennec", channel="beta", comment="Fennec panic!()", data_version=1)
dbo.emergencyShutoffs.t.insert().execute(product="Thunderbird", channel="nightly", data_version=1)
dbo.emergencyShutoffs.scheduled_changes.t.insert().execute(
Expand All @@ -17,16 +18,21 @@ def setUp(self):
dbo.emergencyShutoffs.scheduled_changes.t.insert().execute(
sc_id=2, scheduled_by="bill", change_type="delete", data_version=1, base_product="Thunderbird", base_channel="nightly", base_data_version=1
)
dbo.emergencyShutoffs.scheduled_changes.t.insert().execute(
sc_id=3, scheduled_by="bill", change_type="delete", data_version=1, base_product="Firefox", base_channel="release", base_data_version=1
)
dbo.emergencyShutoffs.scheduled_changes.conditions.t.insert().execute(sc_id=1, data_version=1, when=1000000)
dbo.emergencyShutoffs.scheduled_changes.conditions.t.insert().execute(sc_id=2, data_version=1, when=1000000)
dbo.emergencyShutoffs.scheduled_changes.conditions.t.insert().execute(sc_id=3, data_version=1, when=1000000)
dbo.emergencyShutoffs.scheduled_changes.signoffs.t.insert().execute(sc_id=1, username="bill", role="releng")
dbo.productRequiredSignoffs.t.insert().execute(product="Firefox", channel="nightly", role="releng", signoffs_required=1, data_version=1)
dbo.productRequiredSignoffs.t.insert().execute(product="Firefox", channel="release", role="releng", signoffs_required=1, data_version=1)

def test_get_emergency_shutoff_list(self):
resp = self._get("/emergency_shutoff")
self.assertStatusCode(resp, 200)
data = resp.get_json()
self.assertEqual(data["count"], 3)
self.assertEqual(data["count"], 4)
self.assertIn("shutoffs", data)

def test_get_by_id(self):
Expand Down Expand Up @@ -97,7 +103,7 @@ def test_get_scheduled_changes(self):
resp = self._get("/scheduled_changes/emergency_shutoff")
self.assertStatusCode(resp, 200)
resp_data = resp.get_json()
self.assertEqual(resp_data["count"], 2)
self.assertEqual(resp_data["count"], 3)

@mock.patch("time.time", mock.MagicMock(return_value=300))
def test_schedule_deletion(self):
Expand Down Expand Up @@ -162,3 +168,13 @@ def test_enact_updates_scheduled_for_reactivation_without_signoff(self):
self.assertStatusCode(resp, 200)
shutoffs = dbo.emergencyShutoffs.select(where=dict(product="Thunderbird", channel="nightly"))
self.assertFalse(shutoffs)

def test_signoff_and_enact_reactivation(self):
resp = self._post("/scheduled_changes/emergency_shutoff/3/signoffs", data={"role": "relman"})
self.assertStatusCode(resp, 403)
resp = self._post("/scheduled_changes/emergency_shutoff/3/signoffs", data={"role": "releng"})
self.assertStatusCode(resp, 200)
resp = self._post("/scheduled_changes/emergency_shutoff/3/enact")
self.assertStatusCode(resp, 200)
shutoffs = dbo.emergencyShutoffs.select(where=dict(product="Firefox", channel="release"))
self.assertFalse(shutoffs)

0 comments on commit ef706d2

Please sign in to comment.