diff options
author | James Hannah <jhannah@bytemark.co.uk> | 2017-03-27 10:49:37 +0100 |
---|---|---|
committer | James Hannah <jhannah@bytemark.co.uk> | 2017-03-27 10:49:37 +0100 |
commit | a3272a6fd29fe2983c0ab63f47b639b6bc0da8b3 (patch) | |
tree | 0aae9dfd987c73ab118e91c9f7c873eaa57c17af /t/test-custodian-parser.rb | |
parent | a3d7eb874eedbe3c065451bd0377f5236873e36a (diff) |
First stab at allowing custom SSL expiry days
Diffstat (limited to 't/test-custodian-parser.rb')
-rwxr-xr-x | t/test-custodian-parser.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb index cfecbb3..1bcf5bc 100755 --- a/t/test-custodian-parser.rb +++ b/t/test-custodian-parser.rb @@ -1,6 +1,5 @@ #!/usr/bin/ruby -I./lib/ -I../lib/ - require 'test/unit' require 'custodian/parser' @@ -430,7 +429,54 @@ EOF end end + # + # HTTP/HTTPS tests might specify custom expiry + # + def test_https_custom_expiry + + parser = Custodian::Parser.new + # + # A series of tests to parse + # + expiries = {} + expiries['https://example.com/ must run https'] = 14 + expiries['https://example.com/ must run https and cannot expire within 14 days'] = 14 + expiries['https://example.com/ must run https and cannot expire within 45 days'] = 45 + expiries['https://example.com/ must run https and cannot expire within 300 days'] = 300 + + # + # Test the parser with this text + # + expiries.each do |str,days| + assert_nothing_raised do + + # + # Create the new parser + # + obj = Custodian::TestFactory.create(str) + assert(!obj.nil?) + assert(obj.kind_of?(Array)) + + # There are *TWO* registered tests for http URLs. + assert(obj.size == 2) + + found_days = -1 + + # Test both of them to make sure we got our expiry period. + obj.each do |x| + if ( x.class.name =~ /SSL/ ) + found_days = x.expiry_days + end + end + + # Ensure we did find a match. + assert(found_days != -1 ) + assert(found_days == days) + + end + end + end # |