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

@ -37486,9 +37486,36 @@
"url": "/dom/lists/DOMTokenList-Iterable.html"
}
]
},
"reftest": {
"http/basic-auth-cache-test.html": [
{
"path": "http/basic-auth-cache-test.html",
"references": [
[
"/http/basic-auth-cache-test-ref.html",
"=="
]
],
"url": "/http/basic-auth-cache-test.html"
}
]
}
},
"reftest_nodes": {}
"reftest_nodes": {
"http/reftest-basic-auth-cache-test.html": [
{
"path": "http/basic-auth-cache-test.html",
"references": [
[
"/http/basic-auth-cache-test-ref.html",
"=="
]
],
"url": "/http/basic-auth-cache-test.html"
}
]
}
},
"reftest_nodes": {
"2dcontext/building-paths/canvas_complexshapes_arcto_001.htm": [

View file

@ -0,0 +1,6 @@
<!doctype html>
<meta charset="utf-8">
<html>
<img src="resources/image.png">
<img src="resources/image.png">
</html>

View file

@ -0,0 +1,15 @@
<!doctype html>
<meta charset="utf-8">
<link rel="match" href="basic-auth-cache-test-ref.html">
<html>
<div id="auth"> </div>
<div id="noauth"> </div>
<script type="text/javascript">
var authImg = '<img src="http://testuser:testpass@' + window.location.host + '/http/resources/securedimage.py">';
document.getElementById('auth').innerHTML = authImg;
setTimeout(function() {
var noAuthImg = '<img src="http://' + window.location.host + '/http/resources/securedimage.py">';
document.getElementById('noauth').innerHTML = noAuthImg;
}, 100);
</script>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

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)