added test that verifies proper basic auth caching behavior

This commit is contained in:
Bryan Gilbert 2016-09-15 12:33:31 -04:00
parent 0bcd04d2ab
commit 712b1d5ea0
5 changed files with 66 additions and 1 deletions

View file

@ -0,0 +1,17 @@
# -*- coding: utf-8 -
def main(request, response):
image_url = str.replace(request.url, "securedimage.py", "image.png")
if "authorization" not in request.headers:
response.status = 401
response.headers.set("WWW-Authenticate", "Basic")
return response
else:
auth = request.headers.get("Authorization")
if auth != "Basic dGVzdHVzZXI6dGVzdHBhc3M=":
response.set_error(403, "Invalid username or password - " + auth)
return response
response.status = 301
response.headers.set("Location", image_url)