diff options
author | ianb <devnull@localhost> | 2006-12-01 01:01:10 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2006-12-01 01:01:10 +0000 |
commit | 018dcb22ae3ee018db904451bcb6da1ebe0ece5f (patch) | |
tree | 0aab64be5c482bea844982cec87a3b53bfe318cc /tests/test_errordocument.py | |
parent | 26ef27e0a6cf5fa942c5368cc8016dfa607cd400 (diff) | |
download | paste-018dcb22ae3ee018db904451bcb6da1ebe0ece5f.tar.gz |
Test for errordocument header-preserving problem (currently broken)
Diffstat (limited to 'tests/test_errordocument.py')
-rw-r--r-- | tests/test_errordocument.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test_errordocument.py b/tests/test_errordocument.py index 57a01ab..f448ffc 100644 --- a/tests/test_errordocument.py +++ b/tests/test_errordocument.py @@ -9,7 +9,7 @@ def simple_app(environ, start_response): def not_found_app(environ, start_response): start_response("404 Not found", [('Content-type', 'text/plain')]) return ['requested page returned'] - + def test_ok(): app = TestApp(simple_app) res = app.get('') @@ -59,3 +59,25 @@ def test_forward(): # Note changed response assert 'Page not found' in res +def auth_required_app(environ, start_response): + start_response('401 Unauthorized', [('content-type', 'text/plain'), ('www-authenticate', 'Basic realm="Foo"')]) + return ['Sign in!'] + +def auth_docs_app(environ, start_response): + if environ['PATH_INFO'] == '/auth': + return auth_required_app(environ, start_response) + elif environ['PATH_INFO'] == '/auth_doc': + start_response("200 OK", [('Content-type', 'text/html')]) + return ['<html>Login!</html>'] + else: + return simple_app(environ, start_response) + +def test_auth_docs_app(): + app = forward(auth_docs_app, codes={401: '/auth_doc'}) + app = TestApp(auth_docs_app) + res = app.get('/auth_doc') + assert res.header('content-type') == 'text/html' + res = app.get('/auth', status=401) + assert res.header('content-type') == 'text/html' + assert res.header('www-authenticate') == 'Basic realm="Foo"' + assert res.body == '<html>Login!</html>' |