From 77b7577451f9f3aac0f37a56229ac597a0b1b068 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Tue, 15 Oct 2013 14:52:44 +0100 Subject: We now allow "with cache busting", and "without cache busting". --- lib/custodian/protocoltest/http.rb | 33 ++++++++++++++++++++++++++------- t/test-custodian-parser.rb | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb index c9aedaf..f9e3b85 100644 --- a/lib/custodian/protocoltest/http.rb +++ b/lib/custodian/protocoltest/http.rb @@ -133,6 +133,17 @@ module Custodian if ( line =~ /not following redirects?/i ) @redirect = false end + + # + # Do we use cache-busting? + # + @cache_busting = true + if ( line =~ /with\s+cache\s+busting/ ) + @cache_busting = true + end + if ( line =~ /without\s+cache\s+busting/ ) + @cache_busting = false + end end @@ -157,6 +168,12 @@ module Custodian @redirect end + # + # Do we have cache-busting? + # + def cache_busting? + @cache_busting + end # # Allow this test to be serialized. @@ -192,18 +209,20 @@ module Custodian period = settings.timeout() # - # The URL we'll fetch, which has a cache-busting - # query-string + # The URL we'll fetch/poll. # test_url = @url # - # Parse and append a query-string if not present. + # Parse and append a query-string if not present, if we're + # running with cache-busting. # - u = URI.parse( test_url ) - if ( ! u.query ) - u.query = "ctime=#{Time.now.to_i}" - test_url = u.to_s + if ( @cache_busting ) + u = URI.parse( test_url ) + if ( ! u.query ) + u.query = "ctime=#{Time.now.to_i}" + test_url = u.to_s + end end diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb index 9dadeeb..400193c 100755 --- a/t/test-custodian-parser.rb +++ b/t/test-custodian-parser.rb @@ -313,6 +313,43 @@ EOF + # + # Test that the parser works for cache-busting. + # + def test_http_cache_busting + + # + # test data + # + data = { + "http://example must run http." => true, + "http://example must run http with status 200." => true, + "http://example must run http with content 'bar'." => true, + "http://example must run http without cache busting." => false, + } + + data.each do |str,cb| + assert_nothing_raised do + + # + # Create the new parser + # + obj = Custodian::TestFactory.create( str ) + + assert(obj) + + if ( cb ) + assert( obj.cache_busting? ) + else + assert( ! obj.cache_busting? ) + end + end + end + end + + + + # # Test that the text we're going to use in alerters is present. # -- cgit v1.2.1