Skip to content

Instantly share code, notes, and snippets.

@RGustBardon
Created June 27, 2012 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RGustBardon/3007325 to your computer and use it in GitHub Desktop.
Save RGustBardon/3007325 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Test case for issue #1879.
# https://github.com/symfony/symfony/issues/1879
# Written in 2012 by Robert Gust-Bardon <http://robert.gust-bardon.org/>.
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.
# It is assumed that a Web server is listening on $SERVER_PATH
# and points to the $SYMFONY_PATH.
# Tested under Ubuntu 12.04 LTS.
SERVER_PATH="http://localhost"
SYMFONY_PATH="/tmp/symfony"
function check {
echo "$1"
cd /
sudo rm -rf "$SYMFONY_PATH"
git clone -q https://github.com/symfony/symfony-standard "$SYMFONY_PATH"
cd "$SYMFONY_PATH"
git checkout -q "$1" 2>&1 > /dev/null
if [ -f "composer.json" ]
then
curl -s http://getcomposer.org/installer | php > /dev/null
php composer.phar -q install
else
php bin/vendors install > /dev/null
fi
chmod -R a+w "$SYMFONY_PATH/app/cache" "$SYMFONY_PATH/app/logs"
sed -i \
-e '/^\s*login:$/{N;N;N;d;};' \
-e 's!\(demo/secured/login\)\(_check\)*!\1.json!g' \
-e 's/#\(anonymous: ~\)/\1/' \
-e 's/^\(\s*\)\(login_path:.*\)/\1\2\n\1failure_forward: true/' \
"$SYMFONY_PATH/app/config/security.yml"
sed -i 's!\(@Route("/login\)"!\1.{_format}"!' \
"$SYMFONY_PATH/src/Acme/DemoBundle/Controller/SecuredController.php"
echo '{error: "{{error.message}}"}' > \
"$SYMFONY_PATH/src/Acme/DemoBundle/Resources/views/Secured/login.json.twig"
echo '######################################################################'
curl -s -i -k -L --data '_username=admin&_password=adminpas$' -b \
"$(echo $(curl -s -i -k \
"$SERVER_PATH/app_dev.php/demo/secured/login.json" | \
grep -o '^Set-Cookie:\s*[^=]*=\([^;]*\)' | cut -d':' -f2))" \
"$SERVER_PATH/app_dev.php/demo/secured/login.json" | \
grep -v '^\s*$' | \
grep -v '^HTTP/' | \
grep -v -i \
'^\(cache-[^:]*\|connection\|[^:]*-length\|date\|server\|vary\|x-[^:]*\):'
}
check "v2.0.15"
check "v2.1.0-BETA1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment