From 71e140a32dfaa515e1ae204ec5cd0f84ccac7a51 Mon Sep 17 00:00:00 2001 From: cce Date: Sun, 1 Jan 2006 20:58:49 +0000 Subject: - fixed logic/definition problem /w multi-entry headers; __call__ now always returns a string value - renamed resolve to values in HTTPHeader to better reflect the public-interface for this (esp for multi-entry headers) - a few bugs in mult-entry headers - added common CGI headers to httpheaders; I know they don't really belong here, but error checking is nice - updated auth.digest and auth.basic to use httpheaders (this is what prompted the above changes) - added WWW_AUTHENTICATe header which will build a response to a digest challenge - fixed capitalization error in fileapp and added corresponding test --- tests/test_auth/test_auth_digest.py | 12 +++++++----- tests/test_fileapp.py | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_auth/test_auth_digest.py b/tests/test_auth/test_auth_digest.py index c97b7d2..62c3b24 100644 --- a/tests/test_auth/test_auth_digest.py +++ b/tests/test_auth/test_auth_digest.py @@ -6,10 +6,11 @@ from paste.auth.digest import * from paste.wsgilib import raw_interactive from paste.response import header_value from paste.httpexceptions import * +from paste.httpheaders import AUTHORIZATION, WWW_AUTHENTICATE, REMOTE_USER import os def application(environ, start_response): - content = environ.get('REMOTE_USER','') + content = REMOTE_USER(environ) start_response("200 OK",(('Content-Type', 'text/plain'), ('Content-Length', len(content)))) return content @@ -31,9 +32,10 @@ def check(username, password, path="/"): (status,headers,content,errors) = \ raw_interactive(application,path, accept='text/html') assert status.startswith("401") - challenge = header_value(headers,'WWW-Authenticate') - response = digest_response(challenge, realm, path, username, password) - assert "Digest" in response + challenge = WWW_AUTHENTICATE(headers) + response = AUTHORIZATION(username=username, password=password, + challenge=challenge, path=path) + assert "Digest" in response and username in response (status,headers,content,errors) = \ raw_interactive(application,path, HTTP_AUTHORIZATION=response) @@ -75,7 +77,7 @@ if os.environ.get("TEST_SOCKET",""): def test_failure(): # urllib tries 5 more times before it gives up - server.accept(5) + server.accept(5) try: authfetch('bing','wrong') assert False, "this should raise an exception" diff --git a/tests/test_fileapp.py b/tests/test_fileapp.py index c02da52..c3188e3 100644 --- a/tests/test_fileapp.py +++ b/tests/test_fileapp.py @@ -148,6 +148,7 @@ def test_range(): app = DataApp(content) return TestApp(app).get("/",headers={'Range': range}, status=status) _excercize_range(build,content) + build('bytes=0-%d' % (len(content)+1), 416) def test_file_range(): from paste import fileapp -- cgit v1.2.1