changeset 6749:be3fd5e9577e

Add test for incorrect url. Test using '/_bad>' url path. Make sure it returns 404 and encodes the '>' in the returned html.
author John Rouillard <rouilj@ieee.org>
date Sun, 03 Jul 2022 13:13:04 -0400
parents 647f806d54b8
children c63ddea96fcb
files test/test_liveserver.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_liveserver.py	Sat Jul 02 16:00:16 2022 -0400
+++ b/test/test_liveserver.py	Sun Jul 03 13:13:04 2022 -0400
@@ -545,6 +545,15 @@
         self.assertDictEqual({ key: value for (key, value) in f.headers.items() if key in expected }, expected)
 
 
+    def test_bad_path(self):
+        f = requests.get(self.url_base() + '/_bad>',
+                         headers = { 'Accept-Encoding': 'gzip, foo',
+                                     'Accept': '*/*'})
+
+        # test that returned text is encoded.
+        self.assertEqual(f.content, b'Not found: _bad&gt;')
+        self.assertEqual(f.status_code, 404)
+
     def test_compression_gzipfile(self):
         '''Get the compressed dummy file'''
 

Roundup Issue Tracker: http://roundup-tracker.org/