Skip to content

Commit dd72649

Browse files
committed
More robust error handling in search, fix the urls tests to reflect the new schema
- Legacy-Id: 2871
1 parent b740db3 commit dd72649

3 files changed

Lines changed: 94 additions & 5 deletions

File tree

ietf/idrfc/testsREDESIGN.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353

5454
class IdRfcUrlTestCase(SimpleUrlTestCase):
5555
def testUrls(self):
56-
self.doTestUrls(__file__)
56+
#self.doTestUrls(__file__)
57+
self.doTestUrls(os.path.join(os.path.dirname(os.path.abspath(__file__)), "testurlREDESIGN.list"))
5758

5859
def make_test_data():
5960
# groups

ietf/idrfc/testurlREDESIGN.list

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
200 /
2+
200 /doc/
3+
200,heavy /doc/all/
4+
200,heavy /doc/active/
5+
6+
# draft that's now RFC
7+
200 /doc/draft-ietf-avt-rtp-atrac-family/
8+
200 /doc/draft-ietf-avt-rtp-atrac-family/doc.json
9+
200 /doc/draft-ietf-avt-rtp-atrac-family/ballot.json
10+
200 /doc/draft-ietf-avt-rtp-atrac-family/_ballot.data
11+
12+
# replaced draft, never went to IESG
13+
200 /doc/draft-eronen-mobike-mopo/
14+
404 /doc/draft-eronen-mobike-mopo/ballot.json
15+
404 /doc/draft-eronen-mobike-mopo/_ballot.data
16+
17+
# expired draft
18+
200 /doc/draft-eronen-eap-sim-aka-80211/
19+
20+
# Normal RFC
21+
200 /doc/rfc4739/
22+
200 /doc/rfc4739/doc.json
23+
200 /doc/rfc4739/ballot.json # has ballot from I-D
24+
200 /doc/rfc4739/_ballot.data
25+
26+
# RFC that's evaluated in IESG
27+
200 /doc/rfc3852/
28+
200 /doc/rfc3852/doc.json
29+
200 /doc/rfc3852/ballot.json
30+
200 /doc/rfc3852/_ballot.data
31+
32+
# old RFC
33+
200 /doc/rfc822/
34+
200 /doc/rfc822/doc.json
35+
36+
# ballot sets
37+
200 /doc/rfc3550/ballot.json
38+
200 /doc/rfc3550/_ballot.data
39+
200 /doc/rfc3551/ballot.json
40+
200 /doc/rfc3551/_ballot.data
41+
200 /doc/draft-irtf-dtnrg-ltp/ballot.json
42+
200 /doc/draft-irtf-dtnrg-ltp/_ballot.data
43+
44+
# file formats
45+
200 /doc/rfc9/ # PDF only
46+
200 /doc/rfc2490/ # TXT+PDF+PS
47+
200 /doc/rfc500/ # not online
48+
49+
404 /doc/draft-no-such-draft/
50+
404 /doc/rfc4637/
51+
52+
200 /doc/rfc2444/doc.json # foreignkey problem with Django 1.x
53+
54+
# current AD -- needs to be updated at some point
55+
200 /doc/ad/robert.sparks/
56+
# former AD
57+
200 /doc/ad/sam.hartman/
58+
404 /doc/ad/no.body/
59+
60+
# ballot exists, but it's not issued
61+
404 /doc/draft-ietf-aaa-diameter-api/ballot.json
62+
404 /doc/draft-ietf-aaa-diameter-api/_ballot.data
63+
# ballot does not exist
64+
404 /doc/draft-zeilenga-cldap/ballot.json
65+
404 /doc/draft-zeilenga-cldap/_ballot.data
66+
# comment with created_by=999
67+
200 /doc/draft-ietf-l3vpn-2547bis-mcast-bgp/
68+
# comment with created_by=0 (and no idinternal entry)
69+
200 /doc/draft-ietf-proto-wgdocument-states/
70+
71+
200 /doc/search/
72+
200 /doc/search/?rfcs=on&name=snmp
73+
200 /doc/search/?rfcs=on&name=nfs&by=ad&ad=lars.eggert%40nokia.com
74+
200 /doc/search/?activeDrafts=on&name=sipping
75+
200 /doc/search/?oldDrafts=on&name=tls
76+
200 /doc/search/?activeDrafts=on&oldDrafts=on&ad=lars.eggert%40nokia.com&by=ad
77+
200 /doc/search/?activeDrafts=on&state=iesg-eva&by=state
78+
200 /doc/search/?activeDrafts=on&oldDrafts=on&subState=need-rev&by=state
79+
200 /doc/search/?activeDrafts=on&oldDrafts=on&rfcs=on&ad=lars.eggert%40nokia.com&name=nfs&by=ad
80+
200 /doc/search/?rfcs=on&group=tls&by=group
81+
200 /doc/search/?activeDrafts=on&group=tls&by=group
82+
200 /doc/search/?activeDrafts=on&oldDrafts=on&rfcs=on&author=eronen&by=author
83+
200 /doc/search/?activeDrafts=on&oldDrafts=on&rfcs=on&area=178&name=ldap&by=area
84+
200 /doc/search/?activeDrafts=on&name=asdfsadfsdfasdf
85+
200 /doc/search/?activeDrafts=on&name=%EF%BD%8C #non-ASCII
86+
87+
# Test case for missing publication date
88+
200 /doc/search/?oldDrafts=on&name=ppvpn

ietf/idrfc/views_search.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from django.views.decorators.cache import cache_page
3939
from ietf.idtracker.models import IDState, IESGLogin, IDSubState, Area, InternetDraft, Rfc, IDInternal, IETFWG
4040
from ietf.idrfc.models import RfcIndex
41-
from django.http import Http404, HttpResponse, HttpResponsePermanentRedirect
41+
from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponsePermanentRedirect
4242
from ietf.idrfc.idrfc_wrapper import IdWrapper,RfcWrapper,IdRfcWrapper
4343
from ietf.utils import normalize_draftname
4444
from django.conf import settings
@@ -296,9 +296,9 @@ def clean(self):
296296
q = self.cleaned_data
297297
# Reset query['by'] if needed
298298
for k in ('author','group','area','ad'):
299-
if (q['by'] == k) and not q[k]:
299+
if (q['by'] == k) and (k not in q or not q[k]):
300300
q['by'] = None
301-
if (q['by'] == 'state') and not (q['state'] or q['subState']):
301+
if (q['by'] == 'state') and (not 'state' in q or not 'subState' in q or not (q['state'] or q['subState'])):
302302
q['by'] = None
303303
# Reset other fields
304304
for k in ('author','group','area','ad'):
@@ -456,7 +456,7 @@ def search_results(request):
456456
return search_main(request)
457457
form = SearchForm(dict(request.REQUEST.items()))
458458
if not form.is_valid():
459-
return HttpResponse("form not valid?", mimetype="text/plain")
459+
return HttpResponseBadRequest("form not valid?", mimetype="text/plain")
460460
(results,meta) = search_query(form.cleaned_data)
461461
meta['searching'] = True
462462
meta['by'] = form.cleaned_data['by']

0 commit comments

Comments
 (0)