From a6a4222384230a7cacb7b5a97b66990293f521c9 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 11 Jan 2020 07:23:10 +0900 Subject: [PATCH] rack 2.1.0 changed expires date format from rfc2822 to httpdate See https://github.com/rack/rack/pull/1144. --- Gemfile | 3 +++ Gemfile.lock | 9 +++++++- actionpack/test/dispatch/cookies_test.rb | 22 +++++++++---------- actionpack/test/dispatch/response_test.rb | 2 +- .../dispatch/session/cookie_store_test.rb | 6 ++--- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index dc043d9135d..7767383b452 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,9 @@ gem "rake", ">= 11.1" gem "capybara", ">= 3.26" gem "selenium-webdriver", ">= 3.141.592" +# TODO: Remove the line once next version has released. +gem "rack", github: "rack/rack", ref: "1b82d84" + gem "rack-cache", "~> 1.2" gem "sass-rails" gem "turbolinks", "~> 5" diff --git a/Gemfile.lock b/Gemfile.lock index ed805b6a701..c48370f877d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,13 @@ GIT event_emitter websocket +GIT + remote: https://github.com/rack/rack.git + revision: 1b82d84d80c7d02a04122517da4a3874e5b78ba7 + ref: 1b82d84 + specs: + rack (2.2.0) + PATH remote: . specs: @@ -367,7 +374,6 @@ GEM thor raabro (1.1.6) racc (1.4.16) - rack (2.0.8) rack-cache (1.10.0) rack (>= 0.4) rack-protection (2.0.7) @@ -575,6 +581,7 @@ DEPENDENCIES queue_classic! qunit-selenium racc (>= 1.4.6) + rack! rack-cache (~> 1.2) rails! rake (>= 11.1) diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb index 61da099c605..4cc21869b1c 100644 --- a/actionpack/test/dispatch/cookies_test.rb +++ b/actionpack/test/dispatch/cookies_test.rb @@ -413,13 +413,13 @@ class CookiesTest < ActionController::TestCase def test_setting_cookie_for_fourteen_days get :authenticate_for_fourteen_days - assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 GMT; SameSite=Lax" assert_equal({ "user_name" => "david" }, @response.cookies) end def test_setting_cookie_for_fourteen_days_with_symbols get :authenticate_for_fourteen_days_with_symbols - assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 GMT; SameSite=Lax" assert_equal({ "user_name" => "david" }, @response.cookies) end @@ -454,7 +454,7 @@ class CookiesTest < ActionController::TestCase def test_multiple_cookies get :set_multiple_cookies assert_equal 2, @response.cookies.size - assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000; SameSite=Lax\nlogin=XJ-122; path=/; SameSite=Lax" + assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 GMT; SameSite=Lax\nlogin=XJ-122; path=/; SameSite=Lax" assert_equal({ "login" => "XJ-122", "user_name" => "david" }, @response.cookies) end @@ -465,14 +465,14 @@ class CookiesTest < ActionController::TestCase def test_expiring_cookie request.cookies[:user_name] = "Joe" get :logout - assert_cookie_header "user_name=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax" assert_equal({ "user_name" => nil }, @response.cookies) end def test_delete_cookie_with_path request.cookies[:user_name] = "Joe" get :delete_cookie_with_path - assert_cookie_header "user_name=; path=/beaten; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=; path=/beaten; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax" end def test_delete_unexisting_cookie @@ -749,7 +749,7 @@ class CookiesTest < ActionController::TestCase def test_delete_and_set_cookie request.cookies[:user_name] = "Joe" get :delete_and_set_cookie - assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=david; path=/; expires=Mon, 10 Oct 2005 05:00:00 GMT; SameSite=Lax" assert_equal({ "user_name" => "david" }, @response.cookies) end @@ -991,7 +991,7 @@ class CookiesTest < ActionController::TestCase request.cookies[:user_name] = "Joe" get :delete_cookie_with_domain assert_response :success - assert_cookie_header "user_name=; domain=.nextangle.com; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=; domain=.nextangle.com; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax" end def test_cookie_with_all_domain_option_and_tld_length @@ -1025,7 +1025,7 @@ class CookiesTest < ActionController::TestCase request.cookies[:user_name] = "Joe" get :delete_cookie_with_domain_and_tld assert_response :success - assert_cookie_header "user_name=; domain=.nextangle.com; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=; domain=.nextangle.com; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax" end def test_cookie_with_several_preset_domains_using_one_of_these_domains @@ -1054,7 +1054,7 @@ class CookiesTest < ActionController::TestCase request.cookies[:user_name] = "Joe" get :delete_cookie_with_domains assert_response :success - assert_cookie_header "user_name=; domain=example2.com; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=; domain=example2.com; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax" end def test_deletings_cookie_with_several_preset_domains_using_other_domain @@ -1062,7 +1062,7 @@ class CookiesTest < ActionController::TestCase request.cookies[:user_name] = "Joe" get :delete_cookie_with_domains assert_response :success - assert_cookie_header "user_name=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax" end def test_cookies_hash_is_indifferent_access @@ -1207,7 +1207,7 @@ class CookiesTest < ActionController::TestCase def test_vanilla_cookie_with_expires_set_relatively travel_to Time.utc(2017, 8, 15) do get :cookie_expires_in_two_hours - assert_cookie_header "user_name=assain; path=/; expires=Tue, 15 Aug 2017 02:00:00 -0000; SameSite=Lax" + assert_cookie_header "user_name=assain; path=/; expires=Tue, 15 Aug 2017 02:00:00 GMT; SameSite=Lax" end end diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index 0c9735f9178..1877afb1b63 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -238,7 +238,7 @@ class ResponseTest < ActiveSupport::TestCase @response.set_cookie("user_name", value: "david", path: "/") @response.set_cookie("login", value: "foo&bar", path: "/", expires: Time.utc(2005, 10, 10, 5)) _status, headers, _body = @response.to_a - assert_equal "user_name=david; path=/\nlogin=foo%26bar; path=/; expires=Mon, 10 Oct 2005 05:00:00 -0000", headers["Set-Cookie"] + assert_equal "user_name=david; path=/\nlogin=foo%26bar; path=/; expires=Mon, 10 Oct 2005 05:00:00 GMT", headers["Set-Cookie"] assert_equal({ "login" => "foo&bar", "user_name" => "david" }, @response.cookies) end diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb index 05fc4a04559..f34a8b75bd0 100644 --- a/actionpack/test/dispatch/session/cookie_store_test.rb +++ b/actionpack/test/dispatch/session/cookie_store_test.rb @@ -300,7 +300,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest time = Time.local(2008, 4, 24) Time.stub :now, time do - expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d %b %Y %H:%M:%S -0000") + expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") get "/set_session_value" @@ -311,7 +311,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest # Second request does not access the session time = time + 3.hours Time.stub :now, time do - expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d %b %Y %H:%M:%S -0000") + expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") get "/no_session_access" @@ -327,7 +327,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest time = Time.local(2017, 11, 12) Time.stub :now, time do - expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d %b %Y %H:%M:%S -0000") + expected_expiry = (time + 5.hours).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") get "/set_session_value" get "/get_session_value"