mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-05 07:55:23 -04:00
Register the 405 error handler properly. Enforce the appropriate methods for each route (GET or POST only, with OPTIONS disabled). Add tests for invalid methods. Add a friendlier 500 internal server error handler
This commit is contained in:
parent
5226a3b671
commit
92027345d0
11 changed files with 120 additions and 13 deletions
|
@ -452,6 +452,20 @@ class GuiBaseTest(unittest.TestCase):
|
|||
# We should have timed out now
|
||||
self.assertEqual(tab.get_mode().server_status.status, 0)
|
||||
|
||||
def hit_405(self, url, expected_resp, data = {}, methods = [] ):
|
||||
"""Test various HTTP methods and the response"""
|
||||
for method in methods:
|
||||
if method == "put":
|
||||
r = requests.put(url, data = data)
|
||||
if method == "post":
|
||||
r = requests.post(url, data = data)
|
||||
if method == "delete":
|
||||
r = requests.delete(url)
|
||||
if method == "options":
|
||||
r = requests.options(url)
|
||||
self.assertTrue(expected_resp in r.text)
|
||||
self.assertFalse('Werkzeug' in r.headers)
|
||||
|
||||
# Grouped tests follow from here
|
||||
|
||||
def run_all_common_setup_tests(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue