Merge pull request #46 from reedloden/master

Allow HSTS max_age values to be a string or an integer
This commit is contained in:
Neil Matatall 2013-04-09 18:49:04 -07:00
Родитель ef556d7593 01c9bc755a
Коммит 65bbdc3b09
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -41,7 +41,7 @@ module SecureHeaders
if @config.is_a? Hash
if !@config[:max_age]
raise STSBuildError.new("No max-age was supplied.")
elsif @config[:max_age] !~ /\A\d+\z/
elsif @config[:max_age].to_s !~ /\A\d+\z/
raise STSBuildError.new("max-age must be a number. #{@config[:max_age]} was supplied.")
end
else

Просмотреть файл

@ -28,6 +28,18 @@ module SecureHeaders
context "with an invalid configuration" do
context "with a hash argument" do
it "should allow string values for max-age" do
lambda {
StrictTransportSecurity.new(:max_age => '1234')
}.should_not raise_error
end
it "should allow integer values for max-age" do
lambda {
StrictTransportSecurity.new(:max_age => 1234)
}.should_not raise_error
end
it "raises an exception with an invalid max-age" do
lambda {
StrictTransportSecurity.new(:max_age => 'abc123')