redis-rack 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68b8d92fa59d3d7167cf87bd16e1e62ca34ba905a901964a6d386b47155f8da0
4
- data.tar.gz: 3c8b27ef07b66c2050d053287c03eb3aee64860fda3e4ff806200d9cc663f7ec
3
+ metadata.gz: bd358598a3b5173b0af0e6af5a0eb8544d33beb746a24c0d4ae01cb01e5e82c1
4
+ data.tar.gz: 9afa606f06fc3a5b6812ac5d5a961bc440df74b2ac27160a03536fa0f69d7474
5
5
  SHA512:
6
- metadata.gz: 351e468a771f67ed2e05c3620735636f23f7ad40e338d420c3662a2f7bfc1abdf82e3cf30c1e9a8268452ed1451e87740cc7fabb110b5c60251717a84b2c70f4
7
- data.tar.gz: b93772d79076558bf42e60effd452a47699e215538e73435ec70f500ee8e2902b65b7c1f2eb40d4019884c12fbf81ab57b940702657b4295581abe820483631d
6
+ metadata.gz: a88c2a36dca22320e1e8d015fbfd0ece8b71f814c60e7a90cb1036ae8cee9f713f3321389f286c707b982a5a82c8b5078ffe93b58c37e17367fec6aa8544e209
7
+ data.tar.gz: 41722398d1973c7390155fb71c9fe17e3e99e1b0093db1b7d588c77dec01487390b4208a8e04ff0a8050d0f03029c606d619e68da7cbfed9e3bdf397159c0502
@@ -0,0 +1 @@
1
+ 2.6.2
@@ -1,17 +1,18 @@
1
1
  language: ruby
2
2
  script: bundle exec rake
3
3
  rvm:
4
- - 2.2.3
5
- - 2.3.1
6
- - ruby-head
7
- - jruby-head
4
+ - 2.2
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
9
+ - 2.7
10
+ - ruby-head
11
+ - jruby-head
8
12
  matrix:
9
13
  allow_failures:
10
14
  - rvm: jruby-head
11
15
  - rvm: ruby-head
12
- gemfile:
13
- - gemfiles/rack_2.gemfile
14
- - gemfiles/rack_1.gemfile
15
16
  deploy:
16
17
  provider: rubygems
17
18
  api_key:
@@ -5,7 +5,7 @@ require 'redis/rack/connection'
5
5
 
6
6
  module Rack
7
7
  module Session
8
- class Redis < Abstract::ID
8
+ class Redis < Abstract::PersistedSecure
9
9
  attr_reader :mutex
10
10
 
11
11
  DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge(
@@ -24,18 +24,18 @@ module Rack
24
24
  loop do
25
25
  sid = generate_sid
26
26
  first = with do |c|
27
- [*c.setnx(sid, session, @default_options)].first
27
+ [*c.setnx(sid.private_id, session, @default_options)].first
28
28
  end
29
29
  break sid if [1, true].include?(first)
30
30
  end
31
31
  end
32
32
 
33
- def get_session(env, sid)
34
- if env['rack.session.options'][:skip]
33
+ def find_session(req, sid)
34
+ if req.session.options[:skip]
35
35
  [generate_sid, {}]
36
36
  else
37
- with_lock(env, [nil, {}]) do
38
- unless sid and session = with { |c| c.get(sid) }
37
+ with_lock(req, [nil, {}]) do
38
+ unless sid and session = get_session_with_fallback(sid)
39
39
  session = {}
40
40
  sid = generate_unique_sid(session)
41
41
  end
@@ -44,16 +44,19 @@ module Rack
44
44
  end
45
45
  end
46
46
 
47
- def set_session(env, session_id, new_session, options)
48
- with_lock(env, false) do
49
- with { |c| c.set session_id, new_session, options }
50
- session_id
47
+ def write_session(req, sid, new_session, options)
48
+ with_lock(req, false) do
49
+ with { |c| c.set sid.private_id, new_session, options }
50
+ sid
51
51
  end
52
52
  end
53
53
 
54
- def destroy_session(env, session_id, options)
55
- with_lock(env) do
56
- with { |c| c.del(session_id) }
54
+ def delete_session(req, sid, options)
55
+ with_lock(req) do
56
+ with do |c|
57
+ c.del(sid.public_id)
58
+ c.del(sid.private_id)
59
+ end
57
60
  generate_sid unless options[:drop]
58
61
  end
59
62
  end
@@ -62,8 +65,8 @@ module Rack
62
65
  @default_options.fetch(:threadsafe, true)
63
66
  end
64
67
 
65
- def with_lock(env, default=nil)
66
- @mutex.lock if env['rack.multithread'] && threadsafe?
68
+ def with_lock(req, default=nil)
69
+ @mutex.lock if req.multithread? && threadsafe?
67
70
  yield
68
71
  rescue Errno::ECONNREFUSED
69
72
  if $VERBOSE
@@ -78,6 +81,12 @@ module Rack
78
81
  def with(&block)
79
82
  @conn.with(&block)
80
83
  end
84
+
85
+ private
86
+
87
+ def get_session_with_fallback(sid)
88
+ with { |c| c.get(sid.private_id) || c.get(sid.public_id) }
89
+ end
81
90
  end
82
91
  end
83
92
  end
@@ -1,6 +1,5 @@
1
1
  class Redis
2
2
  module Rack
3
- VERSION = '2.0.6'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
6
-
@@ -12,18 +12,16 @@ Gem::Specification.new do |s|
12
12
  s.description = %q{Redis Store for Rack applications}
13
13
  s.license = 'MIT'
14
14
 
15
- s.rubyforge_project = 'redis-rack'
16
-
17
15
  s.files = `git ls-files`.split("\n")
18
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
17
  s.executables = []
20
18
  s.require_paths = ["lib"]
21
19
 
22
20
  s.add_runtime_dependency 'redis-store', ['< 2', '>= 1.2']
23
- s.add_runtime_dependency 'rack', '>= 1.5', '< 3'
21
+ s.add_runtime_dependency 'rack', '>= 2.0.8', '< 3'
24
22
 
25
23
  s.add_development_dependency 'rake', '~> 10'
26
- s.add_development_dependency 'bundler', '~> 1.3'
24
+ s.add_development_dependency 'bundler', '> 1', '< 3'
27
25
  s.add_development_dependency 'mocha', '~> 0.14.0'
28
26
  s.add_development_dependency 'minitest', '~> 5'
29
27
  s.add_development_dependency 'redis-store-testing'
@@ -93,7 +93,7 @@ describe Rack::Session::Redis do
93
93
  it "does not store a blank session" do
94
94
  session_store = Rack::Session::Redis.new(incrementor)
95
95
  sid = session_store.generate_unique_sid({})
96
- session_store.with { |c| c.get(sid).must_be_nil }
96
+ session_store.with { |c| c.get(sid.private_id).must_be_nil }
97
97
  end
98
98
 
99
99
  it "locks the store mutex" do
@@ -102,7 +102,9 @@ describe Rack::Session::Redis do
102
102
  sesion_store = Rack::Session::Redis.new(incrementor)
103
103
  sesion_store.instance_variable_set(:@mutex, mutex)
104
104
  was_yielded = false
105
- sesion_store.with_lock({'rack.multithread' => true}) { was_yielded = true}
105
+ request = Minitest::Mock.new
106
+ request.expect(:multithread?, true)
107
+ sesion_store.with_lock(request) { was_yielded = true}
106
108
  was_yielded.must_equal(true)
107
109
  end
108
110
 
@@ -118,7 +120,9 @@ describe Rack::Session::Redis do
118
120
  sesion_store = Rack::Session::Redis.new(incrementor, :threadsafe => false)
119
121
  sesion_store.instance_variable_set(:@mutex, mutex)
120
122
  was_yielded = false
121
- sesion_store.with_lock({'rack.multithread' => true}) { was_yielded = true}
123
+ request = Minitest::Mock.new
124
+ request.expect(:multithread?, true)
125
+ sesion_store.with_lock(request) { was_yielded = true}
122
126
  was_yielded.must_equal(true)
123
127
  end
124
128
  end
@@ -295,10 +299,11 @@ describe Rack::Session::Redis do
295
299
 
296
300
  res0 = req.get("/")
297
301
  session_id = (cookie = res0["Set-Cookie"])[session_match, 1]
298
- ses0 = pool.with { |c| c.get(session_id) }
302
+ sid = Rack::Session::SessionId.new(session_id)
303
+ ses0 = pool.with { |c| c.get(sid.private_id) }
299
304
 
300
305
  req.get("/", "HTTP_COOKIE" => cookie)
301
- ses1 = pool.with { |c| c.get(session_id) }
306
+ ses1 = pool.with { |c| c.get(sid.private_id) }
302
307
 
303
308
  ses1.wont_equal(ses0)
304
309
  end
@@ -318,6 +323,7 @@ describe Rack::Session::Redis do
318
323
  res.body.must_equal('{"counter"=>1}')
319
324
  cookie = res["Set-Cookie"]
320
325
  session_id = cookie[session_match, 1]
326
+ sid = Rack::Session::SessionId.new(session_id)
321
327
 
322
328
  delta_incrementor = lambda do |env|
323
329
  # emulate disconjoinment of threading
@@ -339,7 +345,7 @@ describe Rack::Session::Redis do
339
345
  request.body.must_include('"counter"=>2')
340
346
  end
341
347
 
342
- session = pool.with { |c| c.get(session_id) }
348
+ session = pool.with { |c| c.get(sid.private_id) }
343
349
  session.size.must_equal(tnum+1) # counter
344
350
  session['counter'].must_equal(2) # meeeh
345
351
 
@@ -356,7 +362,7 @@ describe Rack::Session::Redis do
356
362
  request.body.must_include('"counter"=>3')
357
363
  end
358
364
 
359
- session = pool.with { |c| c.get(session_id) }
365
+ session = pool.with { |c| c.get(sid.private_id) }
360
366
  session.size.must_equal(tnum+1)
361
367
  session['counter'].must_equal(3)
362
368
 
@@ -378,7 +384,7 @@ describe Rack::Session::Redis do
378
384
  request.body.must_include('"foo"=>"bar"')
379
385
  end
380
386
 
381
- session = pool.with { |c| c.get(session_id) }
387
+ session = pool.with { |c| c.get(sid.private_id) }
382
388
  session.size.must_equal(r.size+1)
383
389
  session['counter'].must_be_nil
384
390
  session['foo'].must_equal('bar')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-store
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '1.5'
39
+ version: 2.0.8
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '3'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '1.5'
49
+ version: 2.0.8
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3'
@@ -68,16 +68,22 @@ dependencies:
68
68
  name: bundler
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">"
72
+ - !ruby/object:Gem::Version
73
+ version: '1'
74
+ - - "<"
72
75
  - !ruby/object:Gem::Version
73
- version: '1.3'
76
+ version: '3'
74
77
  type: :development
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
77
80
  requirements:
78
- - - "~>"
81
+ - - ">"
82
+ - !ruby/object:Gem::Version
83
+ version: '1'
84
+ - - "<"
79
85
  - !ruby/object:Gem::Version
80
- version: '1.3'
86
+ version: '3'
81
87
  - !ruby/object:Gem::Dependency
82
88
  name: mocha
83
89
  requirement: !ruby/object:Gem::Requirement
@@ -157,8 +163,8 @@ extra_rdoc_files: []
157
163
  files:
158
164
  - ".github/auto-assign-issues.yml"
159
165
  - ".gitignore"
166
+ - ".ruby-version"
160
167
  - ".travis.yml"
161
- - Appraisals
162
168
  - CODEOWNERS
163
169
  - Gemfile
164
170
  - MIT-LICENSE
@@ -166,8 +172,6 @@ files:
166
172
  - Rakefile
167
173
  - bin/appraisal
168
174
  - bin/rake
169
- - gemfiles/rack_1.gemfile
170
- - gemfiles/rack_2.gemfile
171
175
  - lib/rack/session/redis.rb
172
176
  - lib/redis-rack.rb
173
177
  - lib/redis/rack/connection.rb
data/Appraisals DELETED
@@ -1,7 +0,0 @@
1
- appraise 'rack-2' do
2
- gem 'rack', '~> 2'
3
- end
4
-
5
- appraise 'rack-1' do
6
- gem 'rack', '~> 1'
7
- end
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rack", "~> 1"
6
-
7
- gemspec :path => "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rack", "~> 2"
6
-
7
- gemspec :path => "../"