Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions ietf/doc/tests_ballot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


import datetime
from unittest import mock

from pyquery import PyQuery

Expand Down Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions ietf/doc/tests_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import datetime
import io
from unittest import mock

from collections import Counter
from pathlib import Path
Expand Down Expand Up @@ -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))
Expand Down
10 changes: 0 additions & 10 deletions ietf/doc/views_ballot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 0 additions & 9 deletions ietf/doc/views_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions ietf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
51 changes: 0 additions & 51 deletions ietf/sync/rfceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
24 changes: 0 additions & 24 deletions ietf/sync/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
26 changes: 0 additions & 26 deletions ietf/templates/doc/draft/rfceditor_post_approved_draft_failed.html

This file was deleted.

3 changes: 1 addition & 2 deletions k8s/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ stringData:
DATATRACKER_NOMCOM_APP_SECRET_B64: "m9pzMezVoFNJfsvU9XSZxGnXnwup6P5ZgCQeEnROOoQ=" # secret

DATATRACKER_IANA_SYNC_PASSWORD: "this-is-the-iana-sync-password" # secret
DATATRACKER_RFC_EDITOR_SYNC_PASSWORD: "this-is-the-rfc-editor-sync-password" # secret
DATATRACKER_YOUTUBE_API_KEY: "this-is-the-youtube-api-key" # secret
DATATRACKER_GITHUB_BACKUP_API_KEY: "this-is-the-github-backup-api-key" # secret

Expand Down Expand Up @@ -80,4 +79,4 @@ stringData:

# Scout configuration
DATATRACKER_SCOUT_KEY: "this-is-the-scout-key"
DATATRACKER_SCOUT_NAME: "StagingDatatracker"
DATATRACKER_SCOUT_NAME: "StagingDatatracker"
6 changes: 0 additions & 6 deletions k8s/settings_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ def _multiline_to_list(s):
else:
raise RuntimeError("DATATRACKER_IANA_SYNC_PASSWORD must be set")

_RFC_EDITOR_SYNC_PASSWORD = os.environ.get("DATATRACKER_RFC_EDITOR_SYNC_PASSWORD", None)
if _RFC_EDITOR_SYNC_PASSWORD is not None:
RFC_EDITOR_SYNC_PASSWORD = os.environ.get("DATATRACKER_RFC_EDITOR_SYNC_PASSWORD")
else:
raise RuntimeError("DATATRACKER_RFC_EDITOR_SYNC_PASSWORD must be set")

_YOUTUBE_API_KEY = os.environ.get("DATATRACKER_YOUTUBE_API_KEY", None)
if _YOUTUBE_API_KEY is not None:
YOUTUBE_API_KEY = _YOUTUBE_API_KEY
Expand Down
Loading