Skip to content

Commit cf21b8f

Browse files
fix: Only POST to rfceditor in production (ietf-tools#7241)
* fix: Only POST to rfceditor in production * test: Test server mode checking
1 parent 79416cf commit cf21b8f

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

ietf/sync/rfceditor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,10 @@ def post_approved_draft(url, name):
802802
the data from the Datatracker and start processing it. Returns
803803
response and error (empty string if no error)."""
804804

805+
if settings.SERVER_MODE != "production":
806+
log(f"In production, would have posted RFC-Editor notification of approved I-D '{name}' to '{url}'")
807+
return "", ""
808+
805809
# HTTP basic auth
806810
username = "dtracksync"
807811
password = settings.RFC_EDITOR_SYNC_PASSWORD

ietf/sync/tests.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,29 @@ def test_update_draft_auth48_url(self):
597597
auth48_docurl = draft.documenturl_set.filter(tag_id='auth48').first()
598598
self.assertIsNone(auth48_docurl)
599599

600+
def test_post_approved_draft_in_production_only(self):
601+
self.requests_mock.post("https://rfceditor.example.com/", status_code=200, text="OK")
602+
603+
# be careful playing with SERVER_MODE!
604+
with override_settings(SERVER_MODE="test"):
605+
self.assertEqual(
606+
rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"),
607+
("", "")
608+
)
609+
self.assertFalse(self.requests_mock.called)
610+
with override_settings(SERVER_MODE="development"):
611+
self.assertEqual(
612+
rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"),
613+
("", "")
614+
)
615+
self.assertFalse(self.requests_mock.called)
616+
with override_settings(SERVER_MODE="production"):
617+
self.assertEqual(
618+
rfceditor.post_approved_draft("https://rfceditor.example.com/", "some-draft"),
619+
("", "")
620+
)
621+
self.assertTrue(self.requests_mock.called)
622+
600623

601624
class DiscrepanciesTests(TestCase):
602625
def test_discrepancies(self):
@@ -636,6 +659,7 @@ def test_discrepancies(self):
636659
r = self.client.get(urlreverse("ietf.sync.views.discrepancies"))
637660
self.assertContains(r, doc.name)
638661

662+
639663
class RFCEditorUndoTests(TestCase):
640664
def test_rfceditor_undo(self):
641665
draft = WgDraftFactory()

0 commit comments

Comments
 (0)