diff --git a/ietf/doc/tests_ballot.py b/ietf/doc/tests_ballot.py index 8420e411e29..517a2ce0563 100644 --- a/ietf/doc/tests_ballot.py +++ b/ietf/doc/tests_ballot.py @@ -3,7 +3,6 @@ import datetime -from unittest import mock from pyquery import PyQuery @@ -716,11 +715,8 @@ def verify_can_see(username, url): verify_can_see(username, url) class ApproveBallotTests(TestCase): - @mock.patch('ietf.sync.rfceditor.requests.post', autospec=True) - def test_approve_ballot(self, mock_urlopen): - mock_urlopen.return_value.text = b'OK' - mock_urlopen.return_value.status_code = 200 - # + def test_approve_ballot(self): + ad = Person.objects.get(name="Areaư Irector") draft = IndividualDraftFactory(ad=ad, intended_std_level_id='ps') draft.set_state(State.objects.get(used=True, type="draft-iesg", slug="iesg-eva")) # make sure it's approvable diff --git a/ietf/doc/tests_draft.py b/ietf/doc/tests_draft.py index 21a873c5c03..db9dbc2baff 100644 --- a/ietf/doc/tests_draft.py +++ b/ietf/doc/tests_draft.py @@ -6,7 +6,6 @@ import os import datetime import io -from unittest import mock from collections import Counter from pathlib import Path @@ -1549,11 +1548,8 @@ def test_confirm_submission_no_doc_ad(self): class RequestPublicationTests(TestCase): - @mock.patch('ietf.sync.rfceditor.requests.post', autospec=True) - def test_request_publication(self, mockobj): - mockobj.return_value.text = b'OK' - mockobj.return_value.status_code = 200 - # + def test_request_publication(self): + draft = IndividualDraftFactory(stream_id='iab',group__acronym='iab',intended_std_level_id='inf',states=[('draft-stream-iab','approved')]) url = urlreverse('ietf.doc.views_draft.request_publication', kwargs=dict(name=draft.name)) diff --git a/ietf/doc/views_ballot.py b/ietf/doc/views_ballot.py index 03cf01a4a16..29aadfdb9b7 100644 --- a/ietf/doc/views_ballot.py +++ b/ietf/doc/views_ballot.py @@ -939,16 +939,6 @@ def approve_ballot(request, name): if ballot_writeup_event.pk == None: ballot_writeup_event.save() - if new_state.slug == "ann" and new_state.slug != prev_state.slug: - # start by notifying the RFC Editor - import ietf.sync.rfceditor - response, error = ietf.sync.rfceditor.post_approved_draft(settings.RFC_EDITOR_SYNC_NOTIFICATION_URL, doc.name) - if error: - return render(request, 'doc/draft/rfceditor_post_approved_draft_failed.html', - dict(name=doc.name, - response=response, - error=error)) - doc.set_state(new_state) doc.tags.remove(*prev_tags) diff --git a/ietf/doc/views_draft.py b/ietf/doc/views_draft.py index c5faf1140b5..0f5ea49f5d4 100644 --- a/ietf/doc/views_draft.py +++ b/ietf/doc/views_draft.py @@ -1276,15 +1276,6 @@ class PublicationForm(forms.Form): if form.is_valid(): events = [] - # start by notifying the RFC Editor - import ietf.sync.rfceditor - response, error = ietf.sync.rfceditor.post_approved_draft(settings.RFC_EDITOR_SYNC_NOTIFICATION_URL, doc.name) - if error: - return render(request, 'doc/draft/rfceditor_post_approved_draft_failed.html', - dict(name=doc.name, - response=response, - error=error)) - m.subject = form.cleaned_data["subject"] m.body = form.cleaned_data["body"] m.save() diff --git a/ietf/settings.py b/ietf/settings.py index aac0eabc908..95f2ffefd76 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -893,10 +893,7 @@ def skip_unreadable_post(record): IANA_SYNC_CHANGES_URL = "https://datatracker.iana.org:4443/data-tracker/changes" IANA_SYNC_PROTOCOLS_URL = "https://www.iana.org/protocols/" -RFC_EDITOR_SYNC_PASSWORD="secret" -RFC_EDITOR_SYNC_NOTIFICATION_URL = "https://www.rfc-editor.org/parser/parser.php" RFC_EDITOR_GROUP_NOTIFICATION_EMAIL = "webmaster@rfc-editor.org" -#RFC_EDITOR_GROUP_NOTIFICATION_URL = "https://www.rfc-editor.org/notification/group.php" RFC_EDITOR_QUEUE_URL = "https://www.rfc-editor.org/queue2.xml" RFC_EDITOR_INDEX_URL = "https://www.rfc-editor.org/rfc/rfc-index.xml" RFC_EDITOR_ERRATA_JSON_URL = "https://www.rfc-editor.org/errata.json" diff --git a/ietf/sync/rfceditor.py b/ietf/sync/rfceditor.py index aa0e643b20a..347b58efbb2 100644 --- a/ietf/sync/rfceditor.py +++ b/ietf/sync/rfceditor.py @@ -2,20 +2,15 @@ # -*- coding: utf-8 -*- -import base64 import datetime import re -import requests from typing import Iterator, Optional, Union -from urllib.parse import urlencode from xml.dom import pulldom, Node -from django.conf import settings from django.db import transaction from django.db.models import Subquery, OuterRef, F, Q from django.utils import timezone -from django.utils.encoding import smart_bytes, force_str import debug # pyflakes:ignore @@ -847,50 +842,4 @@ def parse_relation_list(rel_list: list[str]) -> list[Document]: ).update(document=F("subseries_target")) -def post_approved_draft(url, name): - """Post an approved draft to the RFC Editor so they can retrieve - 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 - headers = { - "Content-type": "application/x-www-form-urlencoded", - "Accept": "text/plain", - "Authorization": "Basic %s" % force_str(base64.encodebytes(smart_bytes("%s:%s" % (username, password)))).replace("\n", ""), - } - - log("Posting RFC-Editor notification of approved Internet-Draft '%s' to '%s'" % (name, url)) - text = error = "" - - try: - r = requests.post( - url, - headers=headers, - data=smart_bytes(urlencode({ 'draft': name })), - timeout=settings.DEFAULT_REQUESTS_TIMEOUT, - ) - - log("RFC-Editor notification result for Internet-Draft '%s': %s:'%s'" % (name, r.status_code, r.text)) - - if r.status_code != 200: - raise RuntimeError("Status code is not 200 OK (it's %s)." % r.status_code) - - if force_str(r.text) != "OK": - raise RuntimeError('Response is not "OK" (it\'s "%s").' % r.text) - - except Exception as e: - # catch everything so we don't leak exceptions, convert them - # into string instead - msg = "Exception on RFC-Editor notification for Internet-Draft '%s': %s: %s" % (name, type(e), str(e)) - log(msg) - if settings.SERVER_MODE == 'test': - debug.say(msg) - error = str(e) - return text, error diff --git a/ietf/sync/tests.py b/ietf/sync/tests.py index e83b6a5e0ac..207c78cf6ae 100644 --- a/ietf/sync/tests.py +++ b/ietf/sync/tests.py @@ -795,30 +795,6 @@ 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): diff --git a/ietf/templates/doc/draft/rfceditor_post_approved_draft_failed.html b/ietf/templates/doc/draft/rfceditor_post_approved_draft_failed.html deleted file mode 100644 index f976ead9265..00000000000 --- a/ietf/templates/doc/draft/rfceditor_post_approved_draft_failed.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends "base.html" %} -{# Copyright The IETF Trust 2015, All Rights Reserved #} -{% load origin %} -{% block title %}Posting approved I-D to RFC Editor failed{% endblock %} -{% block content %} - {% origin %} -
- Sorry, when trying to notify the RFC Editor through HTTP, we hit an - error. -
-- We have not changed the Internet-Draft state or sent the announcement - yet so if this is an intermittent error, you can go back and try - again. -
-
- The error was: {{ error }}
-
- The response from the RFC Editor was:
- {{ response|linebreaksbr }}
-