Moved cookie option tests to common test script.

This commit is contained in:
Matt Atterbury
2014-05-19 09:27:26 -04:00
parent 94ab5c33f8
commit 8a8f62fefa
2 changed files with 2 additions and 101 deletions
-99
View File
@@ -2396,105 +2396,6 @@ test_decent_browsers "New Opera" \
WGETRC=$OLD_WGETRC
WGET_ARGS=""
# Test that we can set options using cookies.
test_filter collapse_whitespace
start_test Cookie options on: by default comments not removed, whitespace is
HOST_NAME="http://options-by-cookies-enabled.example.com"
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html"
echo wget $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL)"
check_from "$OUT" grep -q '<!--'
check_not_from "$OUT" grep -q ' '
start_test Cookie options on: set option by cookie takes effect
echo wget --header=Cookie:PageSpeedFilters=%2bremove_comments $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --no-cookies \
--header=Cookie:PageSpeedFilters=%2bremove_comments $URL)"
check_not_from "$OUT" grep -q '<!--'
check_not_from "$OUT" grep -q ' '
start_test Cookie options on: invalid cookie does not take effect
# The '+' must be encoded as %2b for the cookie parsing code to accept it.
echo wget --header=Cookie:PageSpeedFilters=+remove_comments $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --no-cookies \
--header=Cookie:PageSpeedFilters=+remove_comments $URL)"
check_from "$OUT" grep -q '<!--'
check_not_from "$OUT" grep -q ' '
start_test Cookie options off: by default comments nor whitespace removed
HOST_NAME="http://options-by-cookies-disabled.example.com"
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html"
echo wget $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $URL)"
check_from "$OUT" grep -q '<!--'
check_from "$OUT" grep -q ' '
start_test Cookie options off: set option by cookie has no effect
echo wget --header=Cookie:PageSpeedFilters=%2bremove_comments $URL
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP --no-cookies \
--header=Cookie:PageSpeedFilters=%2bremove_comments $URL)"
check_from "$OUT" grep -q '<!--'
check_from "$OUT" grep -q ' '
# Test that we can make options sticky using cookies.
HOST_NAME="http://options-by-cookies-enabled.example.com"
URL="$HOST_NAME/mod_pagespeed_test/forbidden.html"
start_test Sticky option cookies: initially remove_comments only
COOKIES=""
PARAMS=""
echo wget $COOKIES $URL$PARAMS
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $COOKIES $URL$PARAMS)"
check_from "$OUT" grep -q '<!-- This comment should not be deleted -->'
check_not_from "$OUT" grep -q ' '
check_not_from "$OUT" grep -q 'Cookie'
start_test Sticky option cookies: wrong token has no effect
PARAMS="?PageSpeedStickyQueryParameters=wrong_secret"
PARAMS+="&PageSpeedFilters=+remove_comments"
echo wget $COOKIES $URL$PARAMS
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $COOKIES $URL$PARAMS)"
check_not_from "$OUT" grep -q '<!-- This comment should not be deleted -->'
check_not_from "$OUT" grep -q ' '
check_not_from "$OUT" grep -q 'Set-Cookie'
start_test Sticky option cookies: right token IS adhesive
PARAMS="?PageSpeedStickyQueryParameters=sticky_secret"
PARAMS+="&PageSpeedFilters=+remove_comments"
echo wget $COOKIES $URL$PARAMS
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $COOKIES $URL$PARAMS)"
check_not_from "$OUT" grep -q '<!-- This comment should not be deleted -->'
check_not_from "$OUT" grep -q ' '
check_from "$OUT" grep -q 'Set-Cookie: PageSpeedFilters=%2bremove_comments;'
start_test Sticky option cookies: no token leaves option cookies untouched
COOKIES=--no-cookies$(echo "$OUT" | extract_cookies)
PARAMS=""
echo wget $COOKIES $URL$PARAMS
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $COOKIES $URL$PARAMS)"
check_not_from "$OUT" grep -q '<!-- This comment should not be deleted -->'
check_not_from "$OUT" grep -q ' '
check_not_from "$OUT" grep -q 'Set-Cookie'
start_test Sticky option cookies: wrong token expires option cookies
PARAMS="?PageSpeedStickyQueryParameters=off"
echo wget $COOKIES $URL$PARAMS
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $COOKIES $URL$PARAMS)"
check_not_from "$OUT" grep -q '<!-- This comment should not be deleted -->'
check_not_from "$OUT" grep -q ' '
check_from "$OUT" grep -q 'Cookie: PageSpeedFilters; Expires=Thu, 01 Jan 1970'
COOKIES=$(echo "$OUT" | grep -v 'Expires=Thu, 01 Jan 1970'| extract_cookies)
check [ -z "$COOKIES" ]
start_test Sticky option cookies: back to remove_comments only
PARAMS=""
echo wget $COOKIES $URL$PARAMS
OUT="$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP $COOKIES $URL$PARAMS)"
check_from "$OUT" grep -q '<!-- This comment should not be deleted -->'
check_not_from "$OUT" grep -q ' '
check_not_from "$OUT" grep -q 'Cookie'
start_test Request Option Override : Correct values are passed
HOST_NAME="http://request-option-override.example.com"
OPTS="?ModPagespeed=on"