rack 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9142cfb8ba777286d8118d2b094a23c1fe4698b302c99966cb80670041c67f5
4
- data.tar.gz: 341991ef42232bfecf702d98a17e671ffbbf6a95a8ff70bcca40f7c9aa9f5e85
3
+ metadata.gz: 9b0768103afcff14e04b93b0f4d359289b26b21d2ac7c80a42a31d74c0467e23
4
+ data.tar.gz: 84164353b9192f85a1ee40813ce9402dfca3f4850704718c6b103a3f062bc813
5
5
  SHA512:
6
- metadata.gz: 012e3ac8b25a2fa3c75e7cfbed5f5f4875010ecf96ee887aa9d4ed844badc614fa7decf04bfb889983004d0c310780763e8f9328c4dfb5243388a086f05ef059
7
- data.tar.gz: 312252b7e153667c49c11fea9bdceaf679813d6e3176c6e8599fbe4741c326abc43510c3c0a48136a36d2027393e8286f11771a5c353c68269088a6f606b8372
6
+ metadata.gz: fe9cdddbc606c1898db93ab17308de607d0ac9f93d6cf0554e444eea18901d144740718aedfe37b6a9353dae5169152315c00a2b971394fa2d6785ae0ad82203
7
+ data.tar.gz: e06d452659054f852edd963fb9ec776e450526f7918dedb937298b4f0ca938eeb047901d3c48c463a5ce1291070221dda1602cf96b042603c4e531cc6873dcbd
@@ -18,7 +18,7 @@ module Rack
18
18
  VERSION.join(".")
19
19
  end
20
20
 
21
- RELEASE = "2.0.8"
21
+ RELEASE = "2.0.9"
22
22
 
23
23
  # Return the Rack release as a dotted string.
24
24
  def self.release
@@ -26,9 +26,9 @@ module Rack
26
26
  end
27
27
 
28
28
  alias :cookie_value :public_id
29
+ alias :to_s :public_id
29
30
 
30
31
  def empty?; false; end
31
- def to_s; raise; end
32
32
  def inspect; public_id.inspect; end
33
33
 
34
34
  private
@@ -442,7 +442,7 @@ module Rack
442
442
  def [](key)
443
443
  if key == "session_id"
444
444
  load_for_read!
445
- id.public_id
445
+ id.public_id if id
446
446
  else
447
447
  super
448
448
  end
@@ -252,6 +252,8 @@ module Rack
252
252
  case value[:same_site]
253
253
  when false, nil
254
254
  nil
255
+ when :none, 'None', :None
256
+ '; SameSite=None'.freeze
255
257
  when :lax, 'Lax', :Lax
256
258
  '; SameSite=Lax'.freeze
257
259
  when true, :strict, 'Strict', :Strict
@@ -115,6 +115,24 @@ describe Rack::Response do
115
115
  response["Set-Cookie"].must_equal "foo=bar"
116
116
  end
117
117
 
118
+ it "can set SameSite cookies with symbol value :none" do
119
+ response = Rack::Response.new
120
+ response.set_cookie "foo", { value: "bar", same_site: :none }
121
+ response["Set-Cookie"].must_equal "foo=bar; SameSite=None"
122
+ end
123
+
124
+ it "can set SameSite cookies with symbol value :None" do
125
+ response = Rack::Response.new
126
+ response.set_cookie "foo", { value: "bar", same_site: :None }
127
+ response["Set-Cookie"].must_equal "foo=bar; SameSite=None"
128
+ end
129
+
130
+ it "can set SameSite cookies with string value 'None'" do
131
+ response = Rack::Response.new
132
+ response.set_cookie "foo", { value: "bar", same_site: "None" }
133
+ response["Set-Cookie"].must_equal "foo=bar; SameSite=None"
134
+ end
135
+
118
136
  it "can set SameSite cookies with symbol value :lax" do
119
137
  response = Rack::Response.new
120
138
  response.set_cookie "foo", {:value => "bar", :same_site => :lax}
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/global_expectations/autorun'
4
+ require 'rack/session/abstract/id'
5
+
6
+ describe Rack::Session::Abstract::PersistedSecure::SecureSessionHash do
7
+ attr_reader :hash
8
+
9
+ def setup
10
+ super
11
+ @store = Class.new do
12
+ def load_session(req)
13
+ [Rack::Session::SessionId.new("id"), { foo: :bar, baz: :qux }]
14
+ end
15
+ def session_exists?(req)
16
+ true
17
+ end
18
+ end
19
+ @hash = Rack::Session::Abstract::PersistedSecure::SecureSessionHash.new(@store.new, nil)
20
+ end
21
+
22
+ it "returns keys" do
23
+ assert_equal ["foo", "baz"], hash.keys
24
+ end
25
+
26
+ it "returns values" do
27
+ assert_equal [:bar, :qux], hash.values
28
+ end
29
+
30
+ describe "#[]" do
31
+ it "returns value for a matching key" do
32
+ assert_equal :bar, hash[:foo]
33
+ end
34
+
35
+ it "returns value for a 'session_id' key" do
36
+ assert_equal "id", hash['session_id']
37
+ end
38
+
39
+ it "returns nil value for missing 'session_id' key" do
40
+ store = @store.new
41
+ def store.load_session(req)
42
+ [nil, {}]
43
+ end
44
+ @hash = Rack::Session::Abstract::PersistedSecure::SecureSessionHash.new(store, nil)
45
+ assert_nil hash['session_id']
46
+ end
47
+ end
48
+
49
+ describe "#fetch" do
50
+ it "returns value for a matching key" do
51
+ assert_equal :bar, hash.fetch(:foo)
52
+ end
53
+
54
+ it "works with a default value" do
55
+ assert_equal :default, hash.fetch(:unknown, :default)
56
+ end
57
+
58
+ it "works with a block" do
59
+ assert_equal :default, hash.fetch(:unkown) { :default }
60
+ end
61
+
62
+ it "it raises when fetching unknown keys without defaults" do
63
+ lambda { hash.fetch(:unknown) }.must_raise KeyError
64
+ end
65
+ end
66
+
67
+ describe "#stringify_keys" do
68
+ it "returns hash or session hash with keys stringified" do
69
+ assert_equal({ "foo" => :bar, "baz" => :qux }, hash.send(:stringify_keys, hash).to_h)
70
+ end
71
+ end
72
+ end
73
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leah Neukirchen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-18 00:00:00.000000000 Z
11
+ date: 2020-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -239,6 +239,7 @@ files:
239
239
  - test/spec_session_abstract_session_hash.rb
240
240
  - test/spec_session_cookie.rb
241
241
  - test/spec_session_memcache.rb
242
+ - test/spec_session_persisted_secure_secure_session_hash.rb
242
243
  - test/spec_session_pool.rb
243
244
  - test/spec_show_exceptions.rb
244
245
  - test/spec_show_status.rb
@@ -274,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
275
  - !ruby/object:Gem::Version
275
276
  version: '0'
276
277
  requirements: []
277
- rubygems_version: 3.0.3
278
+ rubygems_version: 3.1.2
278
279
  signing_key:
279
280
  specification_version: 4
280
281
  summary: a modular Ruby webserver interface
@@ -301,6 +302,7 @@ test_files:
301
302
  - test/spec_chunked.rb
302
303
  - test/spec_show_exceptions.rb
303
304
  - test/spec_runtime.rb
305
+ - test/spec_session_persisted_secure_secure_session_hash.rb
304
306
  - test/spec_fastcgi.rb
305
307
  - test/spec_common_logger.rb
306
308
  - test/spec_builder.rb