diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2022-04-07 04:04:19 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 09:04:19 -0700 |
commit | dc72e607d9fbfd39c8362eafd5d3be951f3b2fc0 (patch) | |
tree | 216604d14e529f8de278b93cef2ad52441336d0d /test/spec_response.rb | |
parent | 140db09640a4dfa45a9681f64b93fbbb233ae89b (diff) | |
download | rack-dc72e607d9fbfd39c8362eafd5d3be951f3b2fc0.tar.gz |
Don't bother pattern matching existing set-cookie for deletion. (#1844)
Diffstat (limited to 'test/spec_response.rb')
-rw-r--r-- | test/spec_response.rb | 100 |
1 files changed, 46 insertions, 54 deletions
diff --git a/test/spec_response.rb b/test/spec_response.rb index d828dd86..c8fe17a3 100644 --- a/test/spec_response.rb +++ b/test/spec_response.rb @@ -235,6 +235,7 @@ describe Rack::Response do response.set_cookie "foo2", "bar2" response.delete_cookie "foo" response["Set-Cookie"].must_equal [ + "foo=bar", "foo2=bar2", "foo=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" ] @@ -244,11 +245,22 @@ describe Rack::Response do response = Rack::Response.new response.set_cookie "foo", { value: "bar", domain: "sample.example.com" } response.set_cookie "foo", { value: "bar", domain: ".example.com" } - response["Set-Cookie"].must_equal ["foo=bar; domain=sample.example.com", "foo=bar; domain=.example.com"] + response["Set-Cookie"].must_equal [ + "foo=bar; domain=sample.example.com", + "foo=bar; domain=.example.com" + ] + response.delete_cookie "foo", domain: ".example.com" - response["Set-Cookie"].must_equal ["foo=bar; domain=sample.example.com", "foo=; domain=.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT"] + response["Set-Cookie"].must_equal [ + "foo=bar; domain=sample.example.com", + "foo=bar; domain=.example.com", + "foo=; domain=.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ] + response.delete_cookie "foo", domain: "sample.example.com" response["Set-Cookie"].must_equal [ + "foo=bar; domain=sample.example.com", + "foo=bar; domain=.example.com", "foo=; domain=.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT", "foo=; domain=sample.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" ] @@ -258,11 +270,22 @@ describe Rack::Response do response = Rack::Response.new response.set_cookie "foo", { value: "bar", domain: "example.com.example.com" } response.set_cookie "foo", { value: "bar", domain: "example.com" } - response["Set-Cookie"].must_equal ["foo=bar; domain=example.com.example.com", "foo=bar; domain=example.com"] + response["Set-Cookie"].must_equal [ + "foo=bar; domain=example.com.example.com", + "foo=bar; domain=example.com" + ] + response.delete_cookie "foo", { domain: "example.com" } - response["Set-Cookie"].must_equal ["foo=bar; domain=example.com.example.com", "foo=; domain=example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT"] + response["Set-Cookie"].must_equal [ + "foo=bar; domain=example.com.example.com", + "foo=bar; domain=example.com", + "foo=; domain=example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ] + response.delete_cookie "foo", { domain: "example.com.example.com" } response["Set-Cookie"].must_equal [ + "foo=bar; domain=example.com.example.com", + "foo=bar; domain=example.com", "foo=; domain=example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT", "foo=; domain=example.com.example.com; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" ] @@ -272,74 +295,43 @@ describe Rack::Response do response = Rack::Response.new response.set_cookie "foo", { value: "bar", path: "/" } response.set_cookie "foo", { value: "bar", path: "/path" } - response["Set-Cookie"].must_equal ["foo=bar; path=/", - "foo=bar; path=/path"] + + response["Set-Cookie"].must_equal [ + "foo=bar; path=/", + "foo=bar; path=/path" + ] response.delete_cookie "foo", path: "/path" - response["Set-Cookie"].must_equal ["foo=bar; path=/", - "foo=; path=/path; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT"] + response["Set-Cookie"].must_equal [ + "foo=bar; path=/", + "foo=bar; path=/path", + "foo=; path=/path; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ] end it "only delete cookies with the path specified" do response = Rack::Response.new - response.set_cookie "foo", value: "bar", path: "/" - response.set_cookie "foo", value: "bar", path: "/a" response.set_cookie "foo", value: "bar", path: "/a/b" - response["Set-Cookie"].must_equal ["foo=bar; path=/", - "foo=bar; path=/a", - "foo=bar; path=/a/b"] + response["Set-Cookie"].must_equal( + "foo=bar; path=/a/b" + ) response.delete_cookie "foo", path: "/a" - response["Set-Cookie"].must_equal ["foo=bar; path=/", - "foo=bar; path=/a/b", - "foo=; path=/a; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT"] - end - - it "only delete cookies with the domain and path specified" do - response = Rack::Response.new - response.set_cookie "foo", value: "bar", path: "/" - response.set_cookie "foo", value: "bar", path: "/a" - response.set_cookie "foo", value: "bar", path: "/a/b" - response.set_cookie "foo", value: "bar", path: "/", domain: "example.com.example.com" - response.set_cookie "foo", value: "bar", path: "/a", domain: "example.com.example.com" - response.set_cookie "foo", value: "bar", path: "/a/b", domain: "example.com.example.com" - response.set_cookie "foo", value: "bar", path: "/", domain: "example.com" - response.set_cookie "foo", value: "bar", path: "/a", domain: "example.com" - response.set_cookie "foo", value: "bar", path: "/a/b", domain: "example.com" response["Set-Cookie"].must_equal [ - "foo=bar; path=/", - "foo=bar; path=/a", "foo=bar; path=/a/b", - "foo=bar; domain=example.com.example.com; path=/", - "foo=bar; domain=example.com.example.com; path=/a", - "foo=bar; domain=example.com.example.com; path=/a/b", - "foo=bar; domain=example.com; path=/", - "foo=bar; domain=example.com; path=/a", - "foo=bar; domain=example.com; path=/a/b", + "foo=; path=/a; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT" ] + end + it "only delete cookies with the domain and path specified" do + response = Rack::Response.new response.delete_cookie "foo", path: "/a", domain: "example.com" - response["Set-Cookie"].must_equal [ - "foo=bar; path=/", - "foo=bar; path=/a", - "foo=bar; path=/a/b", - "foo=bar; domain=example.com.example.com; path=/", - "foo=bar; domain=example.com.example.com; path=/a", - "foo=bar; domain=example.com.example.com; path=/a/b", - "foo=bar; domain=example.com; path=/", - "foo=bar; domain=example.com; path=/a/b", + response["Set-Cookie"].must_equal( "foo=; domain=example.com; path=/a; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT", - ] + ) response.delete_cookie "foo", path: "/a/b", domain: "example.com" response["Set-Cookie"].must_equal [ - "foo=bar; path=/", - "foo=bar; path=/a", - "foo=bar; path=/a/b", - "foo=bar; domain=example.com.example.com; path=/", - "foo=bar; domain=example.com.example.com; path=/a", - "foo=bar; domain=example.com.example.com; path=/a/b", - "foo=bar; domain=example.com; path=/", "foo=; domain=example.com; path=/a; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT", "foo=; domain=example.com; path=/a/b; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT", ] |