summaryrefslogtreecommitdiff
path: root/t/test-custodian-parser.rb
diff options
context:
space:
mode:
authorJames Hannah <jhannah@bytemark.co.uk>2017-03-27 10:49:37 +0100
committerJames Hannah <jhannah@bytemark.co.uk>2017-03-27 10:49:37 +0100
commita3272a6fd29fe2983c0ab63f47b639b6bc0da8b3 (patch)
tree0aae9dfd987c73ab118e91c9f7c873eaa57c17af /t/test-custodian-parser.rb
parenta3d7eb874eedbe3c065451bd0377f5236873e36a (diff)
First stab at allowing custom SSL expiry days
Diffstat (limited to 't/test-custodian-parser.rb')
-rwxr-xr-xt/test-custodian-parser.rb48
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
#