1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
sorah 2011-07-06 13:13:09 +00:00
parent 0242fe816c
commit 2ab094ba4d
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Wed Jul 6 22:11:12 2011 Shota Fukumori <sorah@tubusu.net>
* test/cgi/test_cgi_header.rb(test_cgi_header_nph): Validate date in
"Date:" header
Wed Jul 6 21:29:33 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> Wed Jul 6 21:29:33 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* cont.c (fiber_machine_stack_alloc): cleanup pointer arithmetic. * cont.c (fiber_machine_stack_alloc): cleanup pointer arithmetic.

View file

@ -1,5 +1,6 @@
require 'test/unit' require 'test/unit'
require 'cgi' require 'cgi'
require 'time'
class CGIHeaderTest < Test::Unit::TestCase class CGIHeaderTest < Test::Unit::TestCase
@ -130,6 +131,7 @@ class CGIHeaderTest < Test::Unit::TestCase
def test_cgi_header_nph def test_cgi_header_nph
time_start = Time.now.to_i
cgi = CGI.new cgi = CGI.new
## 'nph' is true ## 'nph' is true
ENV['SERVER_SOFTWARE'] = 'Apache 2.2.0' ENV['SERVER_SOFTWARE'] = 'Apache 2.2.0'
@ -142,9 +144,11 @@ class CGIHeaderTest < Test::Unit::TestCase
ENV['SERVER_SOFTWARE'] = 'IIS/5.0' ENV['SERVER_SOFTWARE'] = 'IIS/5.0'
actual4 = cgi.header actual4 = cgi.header
actual5 = cgi.header('status'=>'REDIRECT', 'location'=>'http://www.example.com/') 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| [actual1, actual2, actual3].each do |actual|
assert_match(date, 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") actual.sub!(date, "Date: DATE_IS_REMOVED\r\n")
end end
## assertion ## assertion