Merge pull request #735 from pagespeed/crowell-accept-invalid-signatures

add tests for accepting invalid signatures.
This commit is contained in:
Jeffrey Crowell
2014-06-20 16:36:42 -04:00
2 changed files with 22 additions and 29 deletions
-29
View File
@@ -2442,35 +2442,6 @@ echo wget $OPTS $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $OPTS $URL)"
check_from "$OUT" grep -q '<!--'
start_test Signed Urls : Correct URL signature is passed
HOST_NAME="http://signed-urls.example.com"
URL_PATH="/mod_pagespeed_test/unauthorized/inline_css.html"
OPTS="?PageSpeedFilters=rewrite_images,rewrite_css"
URL="$HOST_NAME$URL_PATH$OPTS"
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET $URL -O - 2>&1)"
REGEX="http:\/\/[^[:space:]]+css\.pagespeed[^[:space:]]+\.css"
URL="$(echo $OUT | grep -Eo "$REGEX")"
check test -n "$URL"
echo http_proxy=$SECONDARY_HOSTNAME wget $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET $URL -O - 2>&1)"
check_from "$OUT" fgrep -q ".yellow{background-color:#ff0}.blue{color:#00f}"
start_test Signed Urls : Incorrect URL signature is passed
# Substring, all but last 14 characters to remove the signature and extension.
URL="${URL:0:-14}"
FINAL_URL="${URL}AAAAAAAAAA.css"
echo http_proxy=$SECONDARY_HOSTNAME wget $FINAL_URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET $FINAL_URL -O - 2>&1)"
check_from "$OUT" egrep -q "403 Forbidden|404 Not Found"
# TODO(jcrowell): Handle transition period between signatures turned on and
# signatures enforced.
start_test Signed Urls : No signature is passed
FINAL_URL="$URL.css"
echo wget $FINAL_URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET $FINAL_URL -O - 2>&1)"
check_from "$OUT" egrep -q "403 Forbidden|404 Not Found"
start_test JS gzip headers
JS_URL="$HOSTNAME/pagespeed_custom_static/js_defer.$HASH.js"
+22
View File
@@ -955,6 +955,28 @@ http {
pagespeed DisableFilters remove_comments,add_instrumentation;
}
# For testing signed URLs, ignoring signature validity.
server {
listen @@SECONDARY_PORT@@;
server_name signed-urls-transition.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
pagespeed UrlSigningKey helloworld;
pagespeed AcceptInvalidSignatures true;
pagespeed RewriteLevel Passthrough;
pagespeed EnableFilters collapse_whitespace,rewrite_images;
pagespeed DisableFilters remove_comments,add_instrumentation;
}
server {
listen @@SECONDARY_PORT@@;
server_name unsigned-urls-transition.example.com;
pagespeed FileCachePath "@@SECONDARY_CACHE@@";
# This server will not sign URLs, but AcceptInvalidSignature is on.
pagespeed AcceptInvalidSignatures true;
pagespeed RewriteLevel Passthrough;
pagespeed EnableFilters collapse_whitespace,rewrite_images;
pagespeed DisableFilters remove_comments,add_instrumentation;
}
# Proxy + IPRO a gzip'd file for testing Issue 896.
server {
listen @@SECONDARY_PORT@@;