How do you Bulk Test URL Redirections?
One solution :
csv:
http://google.com;http://www.google.frhttp://domain.null;http://www.domain.null
code:
#!/bin/bashwhile IFS=";" read -r url1 url2; do ret=$(curl -s -o /dev/null -w "%{http_code}\n" "$url1") ((ret >= 200 && ret <= 400)) && echo 'url1 PASS' || echo 'url1 FAIL' echo "url2 $(curl -s -L -o /dev/null -w "%{http_code}\n" "$url2")"done < csv
If you need to know the real URL redirected (or not), use
curl -L -s -o /dev/null http://google.fr -w "%{url_effective}\n"
Feel free to improve to fit your needs.
Big thanks to StardustOne but I felt that I MUST be reinventing the wheel a little.
Ignoring the requirement to test in-browser and cover JS scenarios I looked again and the nicest solution I have found to-date was something sent out in the Devops Weekly newsletter
Smolder - https://github.com/sky-shiny/smolder
I know a member of staff working for one of our vendors was also working on a similar app that wrapped the Python requests library and I plan to back-to-back the two soon to find out which is actually best. I'll post back if his effort beats Smolder!