Skip to content
Permalink
Browse files

Instead of 200 OK issue a 404 for shortcuts not found

  • Loading branch information
mavcunha committed Nov 27, 2019
1 parent bc62255 commit 2c2b66d51dbc4a0fb1a8a5aedb97f409754a5dbb
Showing with 4 additions and 4 deletions.
  1. +1 −1 passenger_wsgi.py
  2. +3 −3 test_passenger_wsgi.py
@@ -17,6 +17,6 @@ def application(environ, start_response):
if valid_key(path) and path in shorts:
start_response('303 See Other', [('Location', shorts[path])])
else:
start_response('200 OK', [('Content-type', 'text/plain')])
start_response('404 Not Found', [('Content-type', 'text/plain')])

return []
@@ -12,7 +12,7 @@ def setUp(self):

def test_empty_path_info_does_not_redirect(self, parse):
passenger_wsgi.application({'PATH_INFO': ''}, self.response)
self.response.assert_called_with('200 OK', [('Content-type', 'text/plain')])
self.response.assert_called_with('404 Not Found', [('Content-type', 'text/plain')])

def test_valid_path_returns_false_for_invalid(self, parse):
paths = ['/some/path', '/ ', '/ ', '/$#@', '/?this=that', ' ']
@@ -29,11 +29,11 @@ def test_with_path_returns_valid_path_without_leading_slash(self, parse):

def test_not_redirect_if_not_found(self, parse):
passenger_wsgi.application({'PATH_INFO': '/non-existent'}, self.response)
self.response.assert_called_with('200 OK', [('Content-type', 'text/plain')])
self.response.assert_called_with('404 Not Found', [('Content-type', 'text/plain')])

def test_not_redirect_if_path_info_missing(self, parse):
passenger_wsgi.application({}, self.response)
self.response.assert_called_with('200 OK', [('Content-type', 'text/plain')])
self.response.assert_called_with('404 Not Found', [('Content-type', 'text/plain')])

def test_redirects_if_key_found(self, parse):
passenger_wsgi.application({'PATH_INFO': '/key'}, self.response)

0 comments on commit 2c2b66d

Please sign in to comment.
You can’t perform that action at this time.