Skip to content

Commit

Permalink
fix: Only POST to rfceditor in production (#7241)
Browse files Browse the repository at this point in the history
* fix: Only POST to rfceditor in production

* test: Test server mode checking
  • Loading branch information
jennifer-richards authored Mar 21, 2024
1 parent 79416cf commit cf21b8f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ietf/sync/rfceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions ietf/sync/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit cf21b8f

Please sign in to comment.