From 6ea208df02a38271d81c840b985cdb21a72072ad Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Thu, 21 Mar 2024 11:16:00 +1000 Subject: [PATCH 1/2] fix: Only POST to rfceditor in production --- ietf/sync/rfceditor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ietf/sync/rfceditor.py b/ietf/sync/rfceditor.py index 8ae13541392..d3371ea36c5 100644 --- a/ietf/sync/rfceditor.py +++ b/ietf/sync/rfceditor.py @@ -802,6 +802,10 @@ def post_approved_draft(url, name): the data from the Datatracker and start processing it. Returns response and error (empty string if no error).""" + if settings.SERVER_MODE != "production": + log(f"In production, would have posted RFC-Editor notification of approved I-D '{name}' to '{url}'") + return "", "" + # HTTP basic auth username = "dtracksync" password = settings.RFC_EDITOR_SYNC_PASSWORD From b7bfbaffd18ec0c73e33d695aa6cf3eef871c28c Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Thu, 21 Mar 2024 11:31:20 +1000 Subject: [PATCH 2/2] test: Test server mode checking --- ietf/sync/tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ietf/sync/tests.py b/ietf/sync/tests.py index fec353a97c9..d59b31a95d9 100644 --- a/ietf/sync/tests.py +++ b/ietf/sync/tests.py @@ -597,6 +597,29 @@ def test_update_draft_auth48_url(self): auth48_docurl = draft.documenturl_set.filter(tag_id='auth48').first() self.assertIsNone(auth48_docurl) + def test_post_approved_draft_in_production_only(self): + self.requests_mock.post("https://rfceditor.example.com/", status_code=200, text="OK") + + # be careful playing with SERVER_MODE! + with override_settings(SERVER_MODE="test"): + self.assertEqual( + rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"), + ("", "") + ) + self.assertFalse(self.requests_mock.called) + with override_settings(SERVER_MODE="development"): + self.assertEqual( + rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"), + ("", "") + ) + self.assertFalse(self.requests_mock.called) + with override_settings(SERVER_MODE="production"): + self.assertEqual( + rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"), + ("", "") + ) + self.assertTrue(self.requests_mock.called) + class DiscrepanciesTests(TestCase): def test_discrepancies(self): @@ -636,6 +659,7 @@ def test_discrepancies(self): r = self.client.get(urlreverse("ietf.sync.views.discrepancies")) self.assertContains(r, doc.name) + class RFCEditorUndoTests(TestCase): def test_rfceditor_undo(self): draft = WgDraftFactory()