[前][次][番号順一覧][スレッド一覧]

ruby-changes:20375

From: sorah <ko1@a...>
Date: Wed, 6 Jul 2011 22:13:16 +0900 (JST)
Subject: [ruby-changes:20375] sorah:r32423 (trunk): * test/cgi/test_cgi_header.rb(test_cgi_header_nph): Validate date in

sorah	2011-07-06 22:13:09 +0900 (Wed, 06 Jul 2011)

  New Revision: 32423

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32423

  Log:
    * test/cgi/test_cgi_header.rb(test_cgi_header_nph): Validate date in
      "Date:" header

  Modified files:
    trunk/ChangeLog
    trunk/test/cgi/test_cgi_header.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 32422)
+++ ChangeLog	(revision 32423)
@@ -1,3 +1,8 @@
+Wed Jul  6 22:11:12 2011  Shota Fukumori  <sorah@t...>
+
+	* 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@g...>
 
 	* cont.c (fiber_machine_stack_alloc): cleanup pointer arithmetic.
Index: test/cgi/test_cgi_header.rb
===================================================================
--- test/cgi/test_cgi_header.rb	(revision 32422)
+++ test/cgi/test_cgi_header.rb	(revision 32423)
@@ -1,5 +1,6 @@
 require 'test/unit'
 require 'cgi'
+require 'time'
 
 
 class CGIHeaderTest < Test::Unit::TestCase
@@ -130,6 +131,7 @@
 
 
   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 @@
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]