Wed, 31 Mar 2010
HTTP Server Headers via Cucumber
One of my little side projects is moving an old, configured in little steps over a long period of time, website from apache 1.3 to a much more sensible apache 2.2 server. I've been thinking about how to get the most out of the testing I need to do for the move and so today I decided to do some yak shaving and write some simple regression tests, play with Cucumber Nagios, rspec matchers and write a little ruby.
It's not exactly polished but after half an hour (mostly spent wrangling with has_key / have_key) I ended up with the following simplified example for testing HTTP headers:
Feature: http://www.unixdaemon.net/ response headers Scenario: Server header should be production quality When I fetch http://www.unixdaemon.net/ Then the "Server" header should be "Apache" Scenario: Response header should contain an Etag When I fetch http://www.unixdaemon.net/ Then the response should contain the "Etag" header Scenario: The Content-Type header should contain text/html When I fetch http://www.unixdaemon.net/ Then the "Content-Type" header should contain "text/html" Scenario: The Content-Type header should not contain text/xml When I fetch http://www.unixdaemon.net/ Then the "Content-Type" header should not contain "text/xml"
You can also find the cucumber-nagios steps for testing HTTP headers online. It's only a first step towards the full web server move safety net but it's useful one that'll stay in my toolkit.