|
1 | | -# Copyright The IETF Trust 2011-2019, All Rights Reserved |
| 1 | +# Copyright The IETF Trust 2011-2020, All Rights Reserved |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 |
|
4 | 4 |
|
@@ -1035,13 +1035,39 @@ def submit_bad_file(self, name, formats): |
1035 | 1035 |
|
1036 | 1036 | return r, q, m |
1037 | 1037 |
|
| 1038 | + def submit_bad_doc_name_with_ext(self, name, formats): |
| 1039 | + group = None |
| 1040 | + url = urlreverse('ietf.submit.views.upload_submission') |
| 1041 | + |
| 1042 | + # submit |
| 1043 | + files = {} |
| 1044 | + for format in formats: |
| 1045 | + rev = '00.%s' % format |
| 1046 | + files[format], author = submission_file(name, rev, group, format, "test_submission.%s" % format) |
| 1047 | + files[format].name = "%s-%s.%s" % (name, 00, format) |
| 1048 | + |
| 1049 | + r = self.client.post(url, files) |
| 1050 | + |
| 1051 | + self.assertEqual(r.status_code, 200) |
| 1052 | + q = PyQuery(r.content) |
| 1053 | + self.assertTrue(len(q("form .has-error")) > 0) |
| 1054 | + m = q('div.has-error div.alert').text() |
| 1055 | + |
| 1056 | + return r, q, m |
| 1057 | + |
1038 | 1058 | def test_submit_bad_file_txt(self): |
1039 | 1059 | r, q, m = self.submit_bad_file("some name", ["txt"]) |
1040 | 1060 | self.assertIn('Invalid characters were found in the name', m) |
1041 | 1061 | self.assertIn('Expected the TXT file to have extension ".txt"', m) |
1042 | 1062 | self.assertIn('Expected an TXT file of type "text/plain"', m) |
1043 | 1063 | self.assertIn('document does not contain a legitimate name', m) |
1044 | 1064 |
|
| 1065 | + def test_submit_bad_doc_name_txt(self): |
| 1066 | + r, q, m = self.submit_bad_doc_name_with_ext("draft-foo.dot-bar", ["txt"]) |
| 1067 | + self.assertIn('contains a disallowed character with byte code: 46', m) |
| 1068 | + r, q, m = self.submit_bad_doc_name_with_ext("draft-foo-bar", ["xml"]) |
| 1069 | + self.assertIn('Did you include a filename extension in the name by mistake?', m) |
| 1070 | + |
1045 | 1071 | def test_submit_bad_file_xml(self): |
1046 | 1072 | r, q, m = self.submit_bad_file("some name", ["xml"]) |
1047 | 1073 | self.assertIn('Invalid characters were found in the name', m) |
|
0 commit comments