summaryrefslogtreecommitdiff
path: root/test/cgi/test_cgi_header.rb
diff options
context:
space:
mode:
authorsorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-06 13:13:09 +0000
committersorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-06 13:13:09 +0000
commit2ab094ba4dc078747bf2393693aca88cbeb99735 (patch)
tree642d204604376f4662b6f492936e386b685b968f /test/cgi/test_cgi_header.rb
parent0242fe816ca736a927d551f64e9ba5d2263fed32 (diff)
* test/cgi/test_cgi_header.rb(test_cgi_header_nph): Validate date in
"Date:" header git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi/test_cgi_header.rb')
-rw-r--r--test/cgi/test_cgi_header.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/cgi/test_cgi_header.rb b/test/cgi/test_cgi_header.rb
index 2e074b0b22e..c9d939bd49e 100644
--- a/test/cgi/test_cgi_header.rb
+++ b/test/cgi/test_cgi_header.rb
@@ -1,5 +1,6 @@
require 'test/unit'
require 'cgi'
+require 'time'
class CGIHeaderTest < Test::Unit::TestCase
@@ -130,6 +131,7 @@ class CGIHeaderTest < Test::Unit::TestCase
def test_cgi_header_nph
+ time_start = Time.now.to_i
cgi = CGI.new
## 'nph' is true
ENV['SERVER_SOFTWARE'] = 'Apache 2.2.0'
@@ -142,9 +144,11 @@ class CGIHeaderTest < Test::Unit::TestCase
ENV['SERVER_SOFTWARE'] = 'IIS/5.0'
actual4 = cgi.header
actual5 = cgi.header('status'=>'REDIRECT', 'location'=>'http://www.example.com/')
- date = /^Date: [A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} \d\d:\d\d:\d\d GMT\r\n/
+ time_end = Time.now.to_i
+ date = /^Date: ([A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} \d\d:\d\d:\d\d GMT)\r\n/
[actual1, actual2, actual3].each do |actual|
assert_match(date, actual)
+ assert_includes(time_start..time_end, date =~ actual && Time.parse($1).to_i)
actual.sub!(date, "Date: DATE_IS_REMOVED\r\n")
end
## assertion