redis-actionpack 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e260a35f3177c2653275cb7a46c7b8f8d6c0ca1b886dba6dc9c073d7a5103eff
4
- data.tar.gz: f55b9b23b39f07735cfc4824c1d42235142ddf8baa9d57502b318c63a6840d12
3
+ metadata.gz: 28f0d4976af13727e86f22c78bc411c6f87f98c6073b864376efa1902c9e17c2
4
+ data.tar.gz: bd544e2fe6845154d55aad77d3c1cac832224b3f770e50740e67da8a5e30d20d
5
5
  SHA512:
6
- metadata.gz: 9a54c1a095f8516b88ad2fd37a754d99fc88519dc75121cafe8cb78b5a9960f79166b7db3542db5d343e53edd504ab7fde752fa56509fa32601cc702534b818c
7
- data.tar.gz: b2c25b73ae1c6e6ab982971a8935a75f5bedc9e3ccbb45f4578b4ca37bcc9431b6272b00c91a00a9ebbe9af85b1a916b6eedf2e385b1bcc3ad34243ce6b8e670
6
+ metadata.gz: ab5b3822d6b8bf9cf3e297b950b6c16fa2f37cf3b944da3036affe468e52591b8d83485ce9ae65f102150c3bd2b61932a6e41332d8c056630fa7b327423a90cb
7
+ data.tar.gz: 4358c1cc800ae2b542e66432045c6afaa0db2d08ef8ff712b9c436f3a7b62f9826e81d39f11f359f7b02df650ebb49fb4b981600521fef2638abd8ec396e995b
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -1,14 +1,21 @@
1
1
  name: CI
2
+
2
3
  on:
3
4
  push:
4
- branches-ignore: [master]
5
+ branches:
6
+ - master
5
7
  tags-ignore: [v*]
8
+ pull_request:
9
+ branches:
10
+ - master
11
+
6
12
  concurrency:
7
13
  group: ${{ github.workflow }}-${{ github.ref }}
8
14
  cancel-in-progress: true
15
+
9
16
  jobs:
10
17
  test:
11
- name: "test (ruby: ${{ matrix.ruby }}, redis.rb: ${{ matrix.redis }})"
18
+ name: "test (ruby: ${{ matrix.ruby }}, rails: ${{ matrix.rails }})"
12
19
  runs-on: ubuntu-latest
13
20
  continue-on-error: ${{ contains(matrix.ruby, 'head') }}
14
21
  strategy:
@@ -18,45 +25,77 @@ jobs:
18
25
  - "2.7"
19
26
  - "3.0"
20
27
  - "3.1"
28
+ - "3.2"
29
+ - "3.3"
21
30
  # - 'head'
22
- - "jruby"
31
+ # - "jruby"
23
32
  # - 'jruby-head'
24
- - "truffleruby"
33
+ # - "truffleruby"
25
34
  # - 'truffleruby-head'
26
- redis:
27
- - 4_0_x
28
- - 4_1_x
29
- - 4_x
35
+ rails:
36
+ - rails_8.0
37
+ - rails_7.2
38
+ - rails_7.1
39
+ - rails_7.0
40
+ - rails_6.1
41
+ - rails_6.0
42
+ - rails_5.2
43
+ - rails_5.1
44
+ - rails_5.0
45
+
46
+ exclude:
47
+ - ruby: '2.7'
48
+ rails: 'rails_7.2'
49
+ - ruby: '2.7'
50
+ rails: 'rails_8.0'
51
+
52
+ - ruby: '3.0'
53
+ rails: 'rails_5.0'
54
+ - ruby: '3.0'
55
+ rails: 'rails_5.1'
56
+ - ruby: '3.0'
57
+ rails: 'rails_5.2'
58
+ - ruby: '3.0'
59
+ rails: 'rails_7.2'
60
+ - ruby: '3.0'
61
+ rails: 'rails_8.0'
62
+
63
+ - ruby: '3.1'
64
+ rails: 'rails_5.0'
65
+ - ruby: '3.1'
66
+ rails: 'rails_5.1'
67
+ - ruby: '3.1'
68
+ rails: 'rails_5.2'
69
+ - ruby: '3.1'
70
+ rails: 'rails_8.0'
71
+
72
+ - ruby: '3.2'
73
+ rails: 'rails_5.0'
74
+ - ruby: '3.2'
75
+ rails: 'rails_5.1'
76
+ - ruby: '3.2'
77
+ rails: 'rails_5.2'
78
+
79
+ - ruby: '3.3'
80
+ rails: 'rails_5.0'
81
+ - ruby: '3.3'
82
+ rails: 'rails_5.1'
83
+ - ruby: '3.3'
84
+ rails: 'rails_5.2'
85
+
30
86
  env:
31
- BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/redis_${{ matrix.redis }}.gemfile
87
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.rails }}.gemfile
88
+
32
89
  services:
33
90
  redis:
34
91
  image: redis
35
92
  ports:
36
93
  - 6379:6379
37
- distributed1:
38
- image: redis
39
- ports:
40
- - 6380:6380
41
- distributed2:
42
- image: redis
43
- ports:
44
- - 6381:6381
94
+
45
95
  steps:
46
- - uses: actions/checkout@v3
96
+ - uses: actions/checkout@v4
47
97
  - uses: ruby/setup-ruby@v1
48
98
  with:
49
99
  ruby-version: ${{ matrix.ruby }}
50
100
  bundler-cache: true
51
101
  - run: bundle exec rake
52
- lint:
53
- runs-on: ubuntu-latest
54
- steps:
55
- - uses: actions/checkout@v3
56
- with:
57
- fetch-depth: 0
58
- - uses: ruby/setup-ruby@v1
59
- with:
60
- ruby-version: 3.1
61
- bundler-cache: true
62
- - run: bundle exec rake lint
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ gemfiles/*.lock
4
4
  tmp/
5
5
  stdout
6
6
  gemfiles/vendor
7
+ .DS_Store
data/Appraisals CHANGED
@@ -1,23 +1,64 @@
1
- appraise 'rails-5.0.x' do
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails_5.0' do
2
4
  gem 'redis-store'
3
5
  gem 'redis-rack'
4
6
  gem 'actionpack', '~> 5.0.0'
7
+ gem 'tzinfo', '~> 1.2'
5
8
  end
6
9
 
7
- appraise 'rails-5.1.x' do
10
+ appraise 'rails_5.1' do
8
11
  gem 'redis-store'
9
12
  gem 'redis-rack'
10
13
  gem 'actionpack', '~> 5.1.0'
14
+ gem 'tzinfo', '~> 1.2'
11
15
  end
12
16
 
13
- appraise 'rails-5.2.x' do
17
+ appraise 'rails_5.2' do
14
18
  gem 'redis-store'
15
19
  gem 'redis-rack'
16
- gem 'actionpack', '~> 5.1.0'
20
+ gem 'actionpack', '~> 5.2.0'
21
+ gem 'tzinfo', '~> 1.2'
17
22
  end
18
23
 
19
- appraise 'rails-6.0.x' do
24
+ appraise 'rails_6.0' do
20
25
  gem 'redis-store'
21
26
  gem 'redis-rack'
22
27
  gem 'actionpack', '~> 6.0.0'
28
+ gem 'tzinfo', '~> 1.2'
29
+ end
30
+
31
+ appraise 'rails_6.1' do
32
+ gem 'redis-store'
33
+ gem 'redis-rack'
34
+ gem 'actionpack', '~> 6.1.0'
35
+ end
36
+
37
+ appraise 'rails_7.0' do
38
+ gem 'redis-store'
39
+ gem 'redis-rack'
40
+ gem 'actionpack', '~> 7.0.0'
41
+ end
42
+
43
+ appraise 'rails_7.1' do
44
+ gem 'redis-store'
45
+ gem 'redis-rack'
46
+ gem 'actionpack', '~> 7.1.0'
47
+ end
48
+
49
+ appraise 'rails_7.2' do
50
+ gem 'redis-store'
51
+ gem 'redis-rack'
52
+ gem 'actionpack', '~> 7.2.0'
53
+ end
54
+
55
+ appraise 'rails_8.0' do
56
+ gem 'redis-store'
57
+ gem 'redis-rack'
58
+ gem 'actionpack', '~> 8.0.0'
59
+
60
+ # TODO: remove me when one of this PR is merged:
61
+ # * https://github.com/minitest/minitest-rails/pull/258
62
+ # * https://github.com/minitest/minitest-rails/pull/259
63
+ gem 'minitest-rails', git: 'https://github.com/n-rodriguez/minitest-rails.git', branch: 'wip/rails8'
23
64
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ v5.4.0 (2023-12-05)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Update gemspec to contain source code url
5
+ Igor Drozdov
6
+
7
+ * Allow redis-rack 3.x
8
+ Nicolas Rodriguez
9
+
1
10
  v5.3.0 (2022-01-17)
2
11
  --------------------------------------------------------------------------------
3
12
 
data/Gemfile CHANGED
@@ -1,10 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
3
5
 
4
- gem 'rake', '>= 12.3.3'
5
- gem 'bundler', '~> 2.1'
6
+ gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
7
+
8
+ gem 'cgi'
9
+ gem 'minitest-rails'
6
10
  gem 'mocha', '~> 0.14.0', require: 'mocha/setup'
7
- gem 'tzinfo', '~> 1.2'
8
- gem 'appraisal', '~> 2.2'
11
+ gem 'rake', '>= 12.3.3'
9
12
  gem 'redis-store-testing', github: 'redis-store/testing'
10
- gem 'minitest-rails'
13
+ gem 'tzinfo'
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Redis stores for ActionPack
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/redis-actionpack.svg)](http://badge.fury.io/rb/redis-actionpack)
4
+ [![Build Status](https://github.com/redis-store/redis-actionpack/workflows/CI/badge.svg)](https://github.com/redis-store/redis-actionpack/actions)
5
+ [![Code Climate](https://codeclimate.com/github/redis-store/redis-actionpack.svg)](https://codeclimate.com/github/redis-store/redis-actionpack)
6
+
3
7
  __`redis-actionpack`__ provides a session store for __ActionPack__, specifically for __ActionDispatch__. See the main [redis-store readme](https://github.com/redis-store/redis-store) for general guidelines.
4
8
 
5
9
  For guidelines on using our underlying cache store, see the main [redis-store readme](https://github.com/redis-store/redis-store).
@@ -58,12 +62,6 @@ bundle exec rake
58
62
 
59
63
  If you are on **Snow Leopard** you have to run `env ARCHFLAGS="-arch x86_64" bundle exec rake`
60
64
 
61
- ## Status
62
-
63
- [![Gem Version](https://badge.fury.io/rb/redis-actionpack.svg)](http://badge.fury.io/rb/redis-actionpack)
64
- [![Build Status](https://secure.travis-ci.org/redis-store/redis-actionpack.svg?branch=master)](http://travis-ci.org/redis-store/redis-actionpack?branch=master)
65
- [![Code Climate](https://codeclimate.com/github/redis-store/redis-actionpack.svg)](https://codeclimate.com/github/redis-store/redis-actionpack)
66
-
67
65
  ## Copyright
68
66
 
69
67
  2009 - 2013 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  require 'rake'
3
5
  require 'bundler/gem_tasks'
@@ -2,13 +2,13 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rake", ">= 12.3.3"
6
- gem "bundler", "~> 2.1"
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
7
8
  gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
- gem "tzinfo", "~> 1.2"
9
- gem "appraisal", "~> 2.2"
9
+ gem "rake", ">= 12.3.3"
10
10
  gem "redis-store-testing", github: "redis-store/testing"
11
- gem "minitest-rails"
11
+ gem "tzinfo", "~> 1.2"
12
12
  gem "redis-store"
13
13
  gem "redis-rack"
14
14
  gem "actionpack", "~> 5.0.0"
@@ -2,13 +2,13 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rake", ">= 12.3.3"
6
- gem "bundler", "~> 2.1"
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
7
8
  gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
- gem "tzinfo", "~> 1.2"
9
- gem "appraisal", "~> 2.2"
9
+ gem "rake", ">= 12.3.3"
10
10
  gem "redis-store-testing", github: "redis-store/testing"
11
- gem "minitest-rails"
11
+ gem "tzinfo", "~> 1.2"
12
12
  gem "redis-store"
13
13
  gem "redis-rack"
14
14
  gem "actionpack", "~> 5.1.0"
@@ -2,15 +2,15 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rake", ">= 12.3.3"
6
- gem "bundler", "~> 2.1"
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
7
8
  gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
- gem "tzinfo", "~> 1.2"
9
- gem "appraisal", "~> 2.2"
9
+ gem "rake", ">= 12.3.3"
10
10
  gem "redis-store-testing", github: "redis-store/testing"
11
- gem "minitest-rails"
11
+ gem "tzinfo", "~> 1.2"
12
12
  gem "redis-store"
13
13
  gem "redis-rack"
14
- gem "actionpack", "~> 5.1.0"
14
+ gem "actionpack", "~> 5.2.0"
15
15
 
16
16
  gemspec path: "../"
@@ -2,13 +2,13 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rake", ">= 12.3.3"
6
- gem "bundler", "~> 2.1"
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
7
8
  gem "mocha", "~> 0.14.0", require: "mocha/setup"
8
- gem "tzinfo", "~> 1.2"
9
- gem "appraisal", "~> 2.2"
9
+ gem "rake", ">= 12.3.3"
10
10
  gem "redis-store-testing", github: "redis-store/testing"
11
- gem "minitest-rails"
11
+ gem "tzinfo", "~> 1.2"
12
12
  gem "redis-store"
13
13
  gem "redis-rack"
14
14
  gem "actionpack", "~> 6.0.0"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
8
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
9
+ gem "rake", ">= 12.3.3"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "tzinfo"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 6.1.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
8
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
9
+ gem "rake", ">= 12.3.3"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "tzinfo"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 7.0.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
8
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
9
+ gem "rake", ">= 12.3.3"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "tzinfo"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 7.1.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails"
8
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
9
+ gem "rake", ">= 12.3.3"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "tzinfo"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 7.2.0"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/thoughtbot/appraisal.git"
6
+ gem "cgi"
7
+ gem "minitest-rails", git: "https://github.com/n-rodriguez/minitest-rails.git", branch: "wip/rails8"
8
+ gem "mocha", "~> 0.14.0", require: "mocha/setup"
9
+ gem "rake", ">= 12.3.3"
10
+ gem "redis-store-testing", github: "redis-store/testing"
11
+ gem "tzinfo"
12
+ gem "redis-store"
13
+ gem "redis-rack"
14
+ gem "actionpack", "~> 8.0.0"
15
+
16
+ gemspec path: "../"
@@ -35,6 +35,7 @@ module ActionDispatch
35
35
 
36
36
  def wrap_in_request(env)
37
37
  return env if env.is_a?(ActionDispatch::Request)
38
+
38
39
  ActionDispatch::Request.new(env)
39
40
  end
40
41
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Redis
2
4
  module ActionPack
3
- VERSION = '5.4.0'
5
+ VERSION = '5.5.0'
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'redis-store'
2
4
  require 'action_pack'
3
5
  require 'redis/actionpack/version'
@@ -1,27 +1,25 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'redis/actionpack/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/redis/actionpack/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'redis-actionpack'
7
7
  s.version = Redis::ActionPack::VERSION
8
8
  s.authors = ['Luca Guidi']
9
9
  s.email = ['me@lucaguidi.com']
10
- s.homepage = 'http://redis-store.org/redis-actionpack'
11
- s.summary = %q{Redis session store for ActionPack}
10
+ s.homepage = 'https://redis-store.org/redis-actionpack/'
11
+ s.summary = 'Redis session store for ActionPack'
12
12
  s.description = "#{s.summary}. Used for storing the Rails session in Redis."
13
13
  s.license = 'MIT'
14
14
  s.metadata = {
15
- "source_code_uri" => "https://github.com/redis-store/redis-actionpack"
15
+ 'source_code_uri' => 'https://github.com/redis-store/redis-actionpack'
16
16
  }
17
17
 
18
- s.files = `git ls-files`.split("\n")
19
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = []
21
- s.require_paths = ['lib']
22
- s.required_ruby_version = '>= 2.3.0'
18
+ s.required_ruby_version = '>= 2.7.0'
19
+
20
+ s.files = `git ls-files`.split("\n")
23
21
 
24
- s.add_runtime_dependency 'redis-store', '>= 1.1.0', '< 2'
25
- s.add_runtime_dependency 'redis-rack', '>= 2.1.0', '< 4'
26
- s.add_runtime_dependency 'actionpack', '>= 5', '< 8'
22
+ s.add_dependency 'actionpack', '>= 5'
23
+ s.add_dependency 'redis-rack', '>= 2.1.0', '< 4'
24
+ s.add_dependency 'redis-store', '>= 1.1.0', '< 2'
27
25
  end
@@ -1,5 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
+ return unless Gem::Version.new(ActiveSupport.version) < Gem::Version.new('7.2')
4
+
3
5
  class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
4
6
  SessionKey = '_session_id'
5
7
  SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33'
@@ -95,7 +97,11 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
95
97
  cookie = cookies.instance_variable_get('@cookies').first
96
98
  options = cookie.instance_variable_get('@options')
97
99
 
98
- assert options.key?('HttpOnly')
100
+ if Gem::Version.new(ActiveSupport.version) < Gem::Version.new('7.1')
101
+ assert options.key?('HttpOnly')
102
+ else
103
+ assert options.key?('httponly')
104
+ end
99
105
  end
100
106
  end
101
107
 
@@ -107,7 +113,11 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
107
113
  cookie = cookies.instance_variable_get('@cookies').first
108
114
  options = cookie.instance_variable_get('@options')
109
115
 
110
- assert !options.key?('HttpOnly')
116
+ if Gem::Version.new(ActiveSupport.version) < Gem::Version.new('7.1')
117
+ assert !options.key?('HttpOnly')
118
+ else
119
+ assert !options.key?('httponly')
120
+ end
111
121
  end
112
122
  end
113
123
 
@@ -244,7 +254,7 @@ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
244
254
  test "session store with all domains" do
245
255
  with_test_route_set(:domain => :all) do
246
256
  get '/set_session_value'
247
- assert_match(/domain=\.example\.com/, headers['Set-Cookie'])
257
+ assert_match(/domain=\.?example\.com/, headers['Set-Cookie'])
248
258
  end
249
259
  end
250
260
 
@@ -0,0 +1,342 @@
1
+ require 'test_helper'
2
+
3
+ return unless Gem::Version.new(ActiveSupport.version) >= Gem::Version.new('7.2')
4
+
5
+ class RedisStoreIntegrationTest < ::ActionDispatch::IntegrationTest
6
+ SessionKey = '_session_id'
7
+ SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33'
8
+
9
+ test "reads the data" do
10
+ with_test_route_set do
11
+ get '/set_session_value'
12
+ assert_response :success
13
+ assert cookies['_session_id'].present?
14
+
15
+ get '/get_session_value'
16
+ assert_response :success
17
+ assert_equal response.body, 'foo: "bar"'
18
+ end
19
+ end
20
+
21
+ test "should get nil session value" do
22
+ with_test_route_set do
23
+ get '/get_session_value'
24
+ assert_response :success
25
+ assert_equal 'foo: nil', response.body
26
+ end
27
+ end
28
+
29
+ test "should delete the data after session reset" do
30
+ with_test_route_set do
31
+ get '/set_session_value'
32
+ assert_response :success
33
+ assert cookies['_session_id'].present?
34
+ if cookies.respond_to?(:get_cookie)
35
+ session_cookie = cookies.get_cookie('_session_id')
36
+ else
37
+ session_cookie = cookies.send(:hash_for)['_session_id']
38
+ end
39
+
40
+ get '/call_reset_session'
41
+ assert_response :success
42
+ assert !headers['Set-Cookie'].blank?
43
+
44
+ cookies << session_cookie
45
+
46
+ get '/get_session_value'
47
+ assert_response :success
48
+ assert_equal 'foo: nil', response.body
49
+ end
50
+ end
51
+
52
+ test "should set a non-secure cookie by default" do
53
+ with_test_route_set do
54
+ https!
55
+
56
+ get '/set_session_value'
57
+ assert_response :success
58
+
59
+ cookie = cookies.instance_variable_get('@cookies').first
60
+
61
+ assert !cookie.secure?
62
+ end
63
+ end
64
+
65
+ test "should set a secure cookie when the 'secure' option is set" do
66
+ cookie_options(secure: true)
67
+
68
+ with_test_route_set do
69
+ https!
70
+
71
+ get '/set_session_value'
72
+ assert_response :success
73
+
74
+ cookie = cookies.instance_variable_get('@cookies').first
75
+
76
+ assert cookie.secure?
77
+ end
78
+ end
79
+
80
+ test "should set a signed cookie when the 'signed' option is set" do
81
+ cookie_options(signed: true)
82
+
83
+ with_test_route_set do
84
+ https!
85
+
86
+ get '/set_session_value'
87
+ assert_response :success
88
+
89
+ cookie = cookies.instance_variable_get('@cookies').first
90
+
91
+ assert_includes cookie.raw, '_session_id='
92
+ end
93
+ end
94
+
95
+
96
+ test "should set a http-only cookie by default" do
97
+ with_test_route_set do
98
+ get '/set_session_value'
99
+ assert_response :success
100
+
101
+ cookie = cookies.instance_variable_get('@cookies').first
102
+ options = cookie.instance_variable_get('@options')
103
+
104
+ if Gem::Version.new(ActiveSupport.version) < Gem::Version.new('7.1')
105
+ assert options.key?('HttpOnly')
106
+ else
107
+ assert options.key?('httponly')
108
+ end
109
+ end
110
+ end
111
+
112
+ test "should set a non-http-only cookie when the 'httponlty' option is set to false" do
113
+ cookie_options(httponly: false)
114
+
115
+ with_test_route_set do
116
+ get '/set_session_value'
117
+ assert_response :success
118
+
119
+ cookie = cookies.instance_variable_get('@cookies').first
120
+ options = cookie.instance_variable_get('@options')
121
+
122
+ if Gem::Version.new(ActiveSupport.version) < Gem::Version.new('7.1')
123
+ assert !options.key?('HttpOnly')
124
+ else
125
+ assert !options.key?('httponly')
126
+ end
127
+ end
128
+ end
129
+
130
+ test "should not send cookies on write, not read" do
131
+ with_test_route_set do
132
+ get '/get_session_value'
133
+ assert_response :success
134
+ assert_equal 'foo: nil', response.body
135
+ assert cookies['_session_id'].nil?
136
+ end
137
+ end
138
+
139
+ test "should set session value after session reset" do
140
+ with_test_route_set do
141
+ get '/set_session_value'
142
+ assert_response :success
143
+ assert cookies['_session_id'].present?
144
+ session_id = cookies['_session_id']
145
+
146
+ get '/call_reset_session'
147
+ assert_response :success
148
+ assert !headers['Set-Cookie'].blank?
149
+
150
+ get '/get_session_value'
151
+ assert_response :success
152
+ assert_equal 'foo: nil', response.body
153
+
154
+ get '/get_session_id'
155
+ assert_response :success
156
+ assert(response.body != session_id)
157
+ end
158
+ end
159
+
160
+ test "should be able to read session id without accessing the session hash" do
161
+ with_test_route_set do
162
+ get '/set_session_value'
163
+ assert_response :success
164
+ assert cookies['_session_id'].present?
165
+ session_id = cookies['_session_id']
166
+
167
+ get '/get_session_id'
168
+ assert_response :success
169
+ assert_equal response.body, session_id
170
+ end
171
+ end
172
+
173
+ test "should auto-load unloaded class" do
174
+ with_test_route_set do
175
+ with_autoload_path "session_autoload_test" do
176
+ get '/set_serialized_session_value'
177
+ assert_response :success
178
+ assert cookies['_session_id'].present?
179
+ end
180
+
181
+ with_autoload_path "session_autoload_test" do
182
+ get '/get_session_id'
183
+ assert_response :success
184
+ end
185
+
186
+ with_autoload_path "session_autoload_test" do
187
+ get '/get_session_value'
188
+ assert_response :success
189
+ assert_equal response.body, 'foo: #<SessionAutoloadTest::Foo bar:"baz">'
190
+ end
191
+ end
192
+ end
193
+
194
+ test "should not resend the cookie again if session_id cookie is already exists" do
195
+ with_test_route_set do
196
+ get '/set_session_value'
197
+ assert_response :success
198
+ assert cookies['_session_id'].present?
199
+
200
+ get '/get_session_value'
201
+ assert_response :success
202
+ assert headers['Set-Cookie'].nil?
203
+ end
204
+ end
205
+
206
+ test "should prevent session fixation" do
207
+ with_test_route_set do
208
+ get '/get_session_value'
209
+ assert_response :success
210
+ assert_equal 'foo: nil', response.body
211
+ session_id = cookies['_session_id']
212
+
213
+ reset!
214
+
215
+ get '/set_session_value', headers: { _session_id: session_id }
216
+ assert_response :success
217
+ assert(cookies['_session_id'] != session_id)
218
+ end
219
+ end
220
+
221
+ test "should write the data with expiration time" do
222
+ with_test_route_set do
223
+ get '/set_session_value_with_expiry'
224
+ assert_response :success
225
+
226
+ get '/get_session_value'
227
+ assert_response :success
228
+ assert_equal response.body, 'foo: "bar"'
229
+
230
+ sleep 1
231
+
232
+ get '/get_session_value'
233
+ assert_response :success
234
+ assert_equal 'foo: nil', response.body
235
+ end
236
+ end
237
+
238
+ test "session store with explicit domain" do
239
+ cookie_options(:domain => "example.es")
240
+
241
+ with_test_route_set do
242
+ get '/set_session_value'
243
+ assert_match(/domain=example\.es/, headers['Set-Cookie'])
244
+ headers['Set-Cookie']
245
+ end
246
+ end
247
+
248
+ test "session store without domain" do
249
+ with_test_route_set do
250
+ get '/set_session_value'
251
+ assert_no_match(/domain\=/, headers['Set-Cookie'])
252
+ end
253
+ end
254
+
255
+ test "session store with nil domain" do
256
+ cookie_options(:domain => nil)
257
+
258
+ with_test_route_set do
259
+ get '/set_session_value'
260
+ assert_no_match(/domain\=/, headers['Set-Cookie'])
261
+ end
262
+ end
263
+
264
+ test "session store with all domains" do
265
+ cookie_options(:domain => :all)
266
+
267
+ with_test_route_set do
268
+ get '/set_session_value'
269
+ assert_match(/domain=\.?example\.com/, headers['Set-Cookie'])
270
+ end
271
+ end
272
+
273
+ private
274
+
275
+ def cookie_options(options = {})
276
+ (@cookie_options ||= { key: SessionKey }).merge!(options)
277
+ end
278
+
279
+ def app
280
+ @app ||= self.class.build_app do |middleware|
281
+ middleware.use ActionDispatch::Session::RedisStore, cookie_options
282
+ end
283
+ end
284
+
285
+ # from actionpack/test/abstract_unit.rb
286
+ class RoutedRackApp
287
+ class Config < Struct.new(:middleware)
288
+ end
289
+
290
+ attr_reader :routes
291
+
292
+ def initialize(routes, &blk)
293
+ @routes = routes
294
+ @stack = ActionDispatch::MiddlewareStack.new(&blk)
295
+ @app = @stack.build(@routes)
296
+ @secret = SecureRandom.hex
297
+ @key_generator = ActiveSupport::CachingKeyGenerator.new(
298
+ ActiveSupport::KeyGenerator.new(@secret, iterations: 2)
299
+ )
300
+ end
301
+ def call(env)
302
+ env[ActionDispatch::Cookies::GENERATOR_KEY] = @key_generator
303
+ env[ActionDispatch::Cookies::SIGNED_COOKIE_SALT] = SecureRandom.hex
304
+ if defined? ActionDispatch::Cookies::COOKIES_ROTATIONS
305
+ env[ActionDispatch::Cookies::COOKIES_ROTATIONS] = ActiveSupport::Messages::RotationConfiguration.new
306
+ end
307
+ @app.call(env)
308
+ end
309
+ def config
310
+ Config.new(@stack)
311
+ end
312
+ end
313
+
314
+ # from actionpack/test/abstract_unit.rb
315
+ def self.build_app(routes = nil)
316
+ RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
317
+ middleware.use ActionDispatch::DebugExceptions
318
+ middleware.use ActionDispatch::Callbacks
319
+ # middleware.use ActionDispatch::ParamsParser
320
+ middleware.use ActionDispatch::Cookies
321
+ middleware.use ActionDispatch::Flash
322
+ middleware.use Rack::Head
323
+ yield(middleware) if block_given?
324
+ end
325
+ end
326
+
327
+ # from actionpack/test/dispatch/session/cookie_store_test.rb
328
+ def with_test_route_set
329
+ with_routing do |set|
330
+ set.draw do
331
+ get :no_session_access, to: 'test#no_session_access'
332
+ get :set_session_value, to: 'test#set_session_value'
333
+ get :set_session_value_with_expiry, to: 'test#set_session_value_with_expiry'
334
+ get :set_serialized_session_value, to: 'test#set_serialized_session_value'
335
+ get :get_session_value, to: 'test#get_session_value'
336
+ get :get_session_id, to: 'test#get_session_id'
337
+ get :call_reset_session, to: 'test#call_reset_session'
338
+ end
339
+ yield
340
+ end
341
+ end
342
+ end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'minitest/autorun'
3
+ require 'active_support'
3
4
  require 'active_support/core_ext/numeric/time'
4
5
 
5
6
  ENV["RAILS_ENV"] = "test"
@@ -8,17 +9,33 @@ require "rails/test_help"
8
9
 
9
10
  Rails.backtrace_cleaner.remove_silencers!
10
11
 
11
- def with_autoload_path(path)
12
- path = File.join(File.dirname(__FILE__), "fixtures", path)
13
- if ActiveSupport::Dependencies.autoload_paths.include?(path)
14
- yield
15
- else
16
- begin
17
- ActiveSupport::Dependencies.autoload_paths << path
12
+
13
+ if Gem::Version.new(ActiveSupport.version) > Gem::Version.new('7.0')
14
+ # See: https://github.com/rails/rails/blob/v7.0.0/actionpack/test/abstract_unit.rb#L161
15
+ def with_autoload_path(path)
16
+ path = File.join(__dir__, "fixtures", path)
17
+ Zeitwerk.with_loader do |loader|
18
+ loader.push_dir(path)
19
+ loader.setup
18
20
  yield
19
21
  ensure
20
- ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
21
- ActiveSupport::Dependencies.clear
22
+ loader.unload
23
+ end
24
+ end
25
+ else
26
+ # See: https://github.com/rails/rails/blob/v6.1.0/actionpack/test/abstract_unit.rb#L162
27
+ def with_autoload_path(path)
28
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
29
+ if ActiveSupport::Dependencies.autoload_paths.include?(path)
30
+ yield
31
+ else
32
+ begin
33
+ ActiveSupport::Dependencies.autoload_paths << path
34
+ yield
35
+ ensure
36
+ ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
37
+ ActiveSupport::Dependencies.clear
38
+ end
22
39
  end
23
40
  end
24
41
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.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: 2023-12-04 00:00:00.000000000 Z
11
+ date: 2024-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: redis-store
14
+ name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2'
19
+ version: '5'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 1.1.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2'
26
+ version: '5'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: redis-rack
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -51,25 +45,25 @@ dependencies:
51
45
  - !ruby/object:Gem::Version
52
46
  version: '4'
53
47
  - !ruby/object:Gem::Dependency
54
- name: actionpack
48
+ name: redis-store
55
49
  requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
51
  - - ">="
58
52
  - !ruby/object:Gem::Version
59
- version: '5'
53
+ version: 1.1.0
60
54
  - - "<"
61
55
  - !ruby/object:Gem::Version
62
- version: '8'
56
+ version: '2'
63
57
  type: :runtime
64
58
  prerelease: false
65
59
  version_requirements: !ruby/object:Gem::Requirement
66
60
  requirements:
67
61
  - - ">="
68
62
  - !ruby/object:Gem::Version
69
- version: '5'
63
+ version: 1.1.0
70
64
  - - "<"
71
65
  - !ruby/object:Gem::Version
72
- version: '8'
66
+ version: '2'
73
67
  description: Redis session store for ActionPack. Used for storing the Rails session
74
68
  in Redis.
75
69
  email:
@@ -79,6 +73,7 @@ extensions: []
79
73
  extra_rdoc_files: []
80
74
  files:
81
75
  - ".github/auto-assign-issues.yml"
76
+ - ".github/dependabot.yml"
82
77
  - ".github/release.yml"
83
78
  - ".github/workflows/ci.yml"
84
79
  - ".github/workflows/publish.yml"
@@ -90,11 +85,15 @@ files:
90
85
  - MIT-LICENSE
91
86
  - README.md
92
87
  - Rakefile
93
- - bin/bundler-version-options.rb
94
- - gemfiles/rails_5.0.x.gemfile
95
- - gemfiles/rails_5.1.x.gemfile
96
- - gemfiles/rails_5.2.x.gemfile
97
- - gemfiles/rails_6.0.x.gemfile
88
+ - gemfiles/rails_5.0.gemfile
89
+ - gemfiles/rails_5.1.gemfile
90
+ - gemfiles/rails_5.2.gemfile
91
+ - gemfiles/rails_6.0.gemfile
92
+ - gemfiles/rails_6.1.gemfile
93
+ - gemfiles/rails_7.0.gemfile
94
+ - gemfiles/rails_7.1.gemfile
95
+ - gemfiles/rails_7.2.gemfile
96
+ - gemfiles/rails_8.0.gemfile
98
97
  - lib/action_dispatch/middleware/session/redis_store.rb
99
98
  - lib/redis-actionpack.rb
100
99
  - lib/redis/actionpack/version.rb
@@ -109,12 +108,11 @@ files:
109
108
  - test/dummy/config/boot.rb
110
109
  - test/dummy/config/environment.rb
111
110
  - test/dummy/config/routes.rb
112
- - test/dummy/script/rails
113
111
  - test/fixtures/session_autoload_test/session_autoload_test/foo.rb
114
- - test/gemfiles/Gemfile.rails-6.0.x
115
- - test/integration/redis_store_integration_test.rb
112
+ - test/integration/default/redis_store_integration_test.rb
113
+ - test/integration/rails7.2/redis_store_integration_test.rb
116
114
  - test/test_helper.rb
117
- homepage: http://redis-store.org/redis-actionpack
115
+ homepage: https://redis-store.org/redis-actionpack/
118
116
  licenses:
119
117
  - MIT
120
118
  metadata:
@@ -127,30 +125,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
125
  requirements:
128
126
  - - ">="
129
127
  - !ruby/object:Gem::Version
130
- version: 2.3.0
128
+ version: 2.7.0
131
129
  required_rubygems_version: !ruby/object:Gem::Requirement
132
130
  requirements:
133
131
  - - ">="
134
132
  - !ruby/object:Gem::Version
135
133
  version: '0'
136
134
  requirements: []
137
- rubygems_version: 3.3.16
135
+ rubygems_version: 3.4.10
138
136
  signing_key:
139
137
  specification_version: 4
140
138
  summary: Redis session store for ActionPack
141
- test_files:
142
- - test/dummy/.gitignore
143
- - test/dummy/Rakefile
144
- - test/dummy/app/controllers/test_controller.rb
145
- - test/dummy/app/views/test/get_session_id.html.erb
146
- - test/dummy/app/views/test/get_session_value.html.erb
147
- - test/dummy/config.ru
148
- - test/dummy/config/application.rb
149
- - test/dummy/config/boot.rb
150
- - test/dummy/config/environment.rb
151
- - test/dummy/config/routes.rb
152
- - test/dummy/script/rails
153
- - test/fixtures/session_autoload_test/session_autoload_test/foo.rb
154
- - test/gemfiles/Gemfile.rails-6.0.x
155
- - test/integration/redis_store_integration_test.rb
156
- - test/test_helper.rb
139
+ test_files: []
@@ -1 +0,0 @@
1
- puts '-v 1.13.1' if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new('2.3.0')
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,10 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec :path => './../..'
3
-
4
- gem 'redis-store'
5
-
6
- gem 'redis-rack', github: 'redis-store/redis-rack'
7
-
8
- gem 'actionpack', '~> 6.0.0'
9
-
10
- gem 'minitest-rails'