rails-session_cookie 0.2.0 → 0.3.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 +5 -5
- data/.github/workflows/branch.yml +45 -0
- data/.github/workflows/ci.yml +50 -0
- data/.gitignore +1 -2
- data/.rubocop.yml +21 -2
- data/Appraisals +42 -18
- data/Gemfile +28 -1
- data/LICENSE +21 -0
- data/README.md +102 -34
- data/Rakefile +8 -1
- data/bin/console +1 -0
- data/gemfiles/rails_5.2.gemfile +22 -0
- data/gemfiles/rails_5.2_warden.gemfile +24 -0
- data/gemfiles/rails_6.0.gemfile +22 -0
- data/gemfiles/rails_6.0_warden.gemfile +24 -0
- data/gemfiles/rails_6.1.gemfile +22 -0
- data/gemfiles/rails_6.1_warden.gemfile +24 -0
- data/gemfiles/rails_7.0.gemfile +22 -0
- data/gemfiles/rails_7.0_warden.gemfile +24 -0
- data/lib/rails/session_cookie/app.rb +5 -3
- data/lib/rails/session_cookie/env.rb +40 -0
- data/lib/rails/session_cookie/version.rb +3 -1
- data/lib/rails/session_cookie/warden_app.rb +10 -2
- data/lib/rails/session_cookie.rb +5 -2
- data/lib/rails-session_cookie.rb +1 -0
- data/rails-session_cookie.gemspec +2 -16
- metadata +19 -174
- data/.travis.yml +0 -18
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_4.2.gemfile.lock +0 -202
- data/gemfiles/rails_4.2_warden.gemfile +0 -10
- data/gemfiles/rails_4.2_warden.gemfile.lock +0 -217
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_5.0.gemfile.lock +0 -208
- data/gemfiles/rails_5.0_warden.gemfile +0 -10
- data/gemfiles/rails_5.0_warden.gemfile.lock +0 -223
- data/gemfiles/rails_5.1.gemfile +0 -8
- data/gemfiles/rails_5.1.gemfile.lock +0 -208
- data/gemfiles/rails_5.1_warden.gemfile +0 -10
- data/gemfiles/rails_5.1_warden.gemfile.lock +0 -223
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 710f09ff0bcd2904b3553ae18b55d2951343ea28a4a3d8d75cb7abaef2a6d45f
|
4
|
+
data.tar.gz: 11bd83b9cb85e58618f0c8d7d9e11b95578d20d5041645ad86e03511e70c9245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3468e309eceaf7cf1d76274e4172b552c013e563b633fa74d5414f36e839f0cb71b6a9ea9c91418061ae2a6988c9d2ef683586233ae8301c1ba18a71a3d5fa
|
7
|
+
data.tar.gz: 0fb49d0514c5036353548656ccb2dbb88c0d6b5b959fca79a331f8c8befd9a600fbfff7400951e35d93c6cd408f0db04f6f593ae3dd7a6dbd57af4f56ffac66b
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: branch
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches-ignore:
|
5
|
+
- master
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
ruby: [ '2.6', '2.7', '3.0', '3.1' ]
|
12
|
+
gemfile: [ 'gemfiles/rails_5.2.gemfile', 'gemfiles/rails_5.2_warden.gemfile', 'gemfiles/rails_6.0.gemfile', 'gemfiles/rails_6.0_warden.gemfile', 'gemfiles/rails_6.1.gemfile', 'gemfiles/rails_6.1_warden.gemfile', 'gemfiles/rails_7.0.gemfile', 'gemfiles/rails_7.0_warden.gemfile' ]
|
13
|
+
exclude:
|
14
|
+
- ruby: '2.6'
|
15
|
+
gemfile: 'gemfiles/rails_7.0.gemfile'
|
16
|
+
- ruby: '2.6'
|
17
|
+
gemfile: 'gemfiles/rails_7.0_warden.gemfile'
|
18
|
+
- ruby: '3.0'
|
19
|
+
gemfile: 'gemfiles/rails_5.2.gemfile'
|
20
|
+
- ruby: '3.0'
|
21
|
+
gemfile: 'gemfiles/rails_5.2_warden.gemfile'
|
22
|
+
- ruby: '3.1'
|
23
|
+
gemfile: 'gemfiles/rails_5.2.gemfile'
|
24
|
+
- ruby: '3.1'
|
25
|
+
gemfile: 'gemfiles/rails_5.2_warden.gemfile'
|
26
|
+
name: Ruby ${{ matrix.ruby }}, Gemfile ${{ matrix.gemfile }}
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v2
|
29
|
+
- uses: actions/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
32
|
+
- uses: actions/cache@v2
|
33
|
+
with:
|
34
|
+
path: vendor/bundle
|
35
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles('Gemfile', 'gemfiles/**.gemfile') }}
|
36
|
+
restore-keys: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles('Gemfile', 'gemfiles/**.gemfile') }}
|
37
|
+
- name: Test
|
38
|
+
env:
|
39
|
+
CI: true
|
40
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
41
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
42
|
+
run: |
|
43
|
+
bundle config path vendor/bundle
|
44
|
+
bundle install --jobs 4 --retry 3
|
45
|
+
bundle exec rake ci
|
@@ -0,0 +1,50 @@
|
|
1
|
+
name: ci
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
types:
|
5
|
+
- opened
|
6
|
+
- synchronize
|
7
|
+
- reopened
|
8
|
+
push:
|
9
|
+
branches:
|
10
|
+
- master
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby: [ '2.6', '2.7', '3.0', '3.1' ]
|
17
|
+
gemfile: [ 'gemfiles/rails_5.2.gemfile', 'gemfiles/rails_5.2_warden.gemfile', 'gemfiles/rails_6.0.gemfile', 'gemfiles/rails_6.0_warden.gemfile', 'gemfiles/rails_6.1.gemfile', 'gemfiles/rails_6.1_warden.gemfile', 'gemfiles/rails_7.0.gemfile', 'gemfiles/rails_7.0_warden.gemfile' ]
|
18
|
+
exclude:
|
19
|
+
- ruby: '2.6'
|
20
|
+
gemfile: 'gemfiles/rails_7.0.gemfile'
|
21
|
+
- ruby: '2.6'
|
22
|
+
gemfile: 'gemfiles/rails_7.0_warden.gemfile'
|
23
|
+
- ruby: '3.0'
|
24
|
+
gemfile: 'gemfiles/rails_5.2.gemfile'
|
25
|
+
- ruby: '3.0'
|
26
|
+
gemfile: 'gemfiles/rails_5.2_warden.gemfile'
|
27
|
+
- ruby: '3.1'
|
28
|
+
gemfile: 'gemfiles/rails_5.2.gemfile'
|
29
|
+
- ruby: '3.1'
|
30
|
+
gemfile: 'gemfiles/rails_5.2_warden.gemfile'
|
31
|
+
name: Ruby ${{ matrix.ruby }}, Gemfile ${{ matrix.gemfile }}
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
- uses: actions/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
37
|
+
- uses: actions/cache@v2
|
38
|
+
with:
|
39
|
+
path: vendor/bundle
|
40
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles('Gemfile', 'gemfiles/**.gemfile') }}
|
41
|
+
restore-keys: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles('Gemfile', 'gemfiles/**.gemfile') }}
|
42
|
+
- name: Test
|
43
|
+
env:
|
44
|
+
CI: true
|
45
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
46
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
47
|
+
run: |
|
48
|
+
bundle config path vendor/bundle
|
49
|
+
bundle install --jobs 4 --retry 3
|
50
|
+
bundle exec rake ci
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,11 +1,30 @@
|
|
1
1
|
AllCops:
|
2
|
+
NewCops: enable
|
2
3
|
Exclude:
|
4
|
+
- 'lib/rails-session_cookie.rb'
|
3
5
|
- 'gemfiles/vendor/**/*'
|
4
|
-
|
5
|
-
Max:
|
6
|
+
Layout/LineLength:
|
7
|
+
Max: 180
|
6
8
|
Style/MultilineBlockChain:
|
7
9
|
Enabled: false
|
8
10
|
Metrics/BlockLength:
|
9
11
|
Enabled: false
|
10
12
|
Lint/AmbiguousBlockAssociation:
|
11
13
|
Enabled: false
|
14
|
+
Style/StringLiterals:
|
15
|
+
Enabled: false
|
16
|
+
Gemspec/OrderedDependencies:
|
17
|
+
Enabled: false
|
18
|
+
Gemspec/RequiredRubyVersion:
|
19
|
+
Enabled: false
|
20
|
+
Style/OptionalBooleanParameter:
|
21
|
+
Enabled: false
|
22
|
+
Style/Documentation:
|
23
|
+
Enabled: false
|
24
|
+
Bundler/OrderedGems:
|
25
|
+
Enabled: false
|
26
|
+
Gemspec/RequireMFA:
|
27
|
+
Enabled: false
|
28
|
+
Style/FrozenStringLiteralComment:
|
29
|
+
Exclude:
|
30
|
+
- 'gemfiles/*'
|
data/Appraisals
CHANGED
@@ -1,32 +1,56 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
WARDEN_VERSION = '>= 1.2'
|
4
|
+
DEVISE_VERSION = '~> 4.8'
|
5
|
+
|
6
|
+
appraise 'rails-5.2' do
|
7
|
+
gem 'rails', '~> 5.2.8'
|
8
|
+
gem 'rspec-rails', '~> 5.1.2'
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise 'rails-5.2-warden' do
|
12
|
+
gem 'rails', '~> 5.2.8'
|
13
|
+
gem 'rspec-rails', '~> 5.1.2'
|
14
|
+
|
15
|
+
gem 'warden', WARDEN_VERSION
|
16
|
+
gem 'devise', DEVISE_VERSION
|
17
|
+
end
|
18
|
+
|
19
|
+
appraise 'rails-6.0' do
|
20
|
+
gem 'rails', '~> 6.0.5'
|
21
|
+
gem 'rspec-rails', '~> 5.1.2'
|
3
22
|
end
|
4
23
|
|
5
|
-
appraise 'rails-
|
6
|
-
gem 'rails', '~>
|
24
|
+
appraise 'rails-6.0-warden' do
|
25
|
+
gem 'rails', '~> 6.0.5'
|
26
|
+
gem 'rspec-rails', '~> 5.1.2'
|
7
27
|
|
8
|
-
gem 'warden',
|
9
|
-
gem 'devise',
|
28
|
+
gem 'warden', WARDEN_VERSION
|
29
|
+
gem 'devise', DEVISE_VERSION
|
10
30
|
end
|
11
31
|
|
12
|
-
appraise 'rails-
|
13
|
-
gem 'rails', '~>
|
32
|
+
appraise 'rails-6.1' do
|
33
|
+
gem 'rails', '~> 6.1.6'
|
34
|
+
gem 'rspec-rails', '6.0.0.rc1'
|
14
35
|
end
|
15
36
|
|
16
|
-
appraise 'rails-
|
17
|
-
gem 'rails', '~>
|
37
|
+
appraise 'rails-6.1-warden' do
|
38
|
+
gem 'rails', '~> 6.1.6'
|
39
|
+
gem 'rspec-rails', '6.0.0.rc1'
|
18
40
|
|
19
|
-
gem 'warden',
|
20
|
-
gem 'devise',
|
41
|
+
gem 'warden', WARDEN_VERSION
|
42
|
+
gem 'devise', DEVISE_VERSION
|
21
43
|
end
|
22
44
|
|
23
|
-
appraise 'rails-
|
24
|
-
gem 'rails', '~>
|
45
|
+
appraise 'rails-7.0' do
|
46
|
+
gem 'rails', '~> 7.0.3'
|
47
|
+
gem 'rspec-rails', '6.0.0.rc1'
|
25
48
|
end
|
26
49
|
|
27
|
-
appraise 'rails-
|
28
|
-
gem 'rails', '~>
|
50
|
+
appraise 'rails-7.0-warden' do
|
51
|
+
gem 'rails', '~> 7.0.3'
|
52
|
+
gem 'rspec-rails', '6.0.0.rc1'
|
29
53
|
|
30
|
-
gem 'warden',
|
31
|
-
gem 'devise',
|
54
|
+
gem 'warden', WARDEN_VERSION
|
55
|
+
gem 'devise', DEVISE_VERSION
|
32
56
|
end
|
data/Gemfile
CHANGED
@@ -1,7 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
|
-
|
5
|
+
gem 'rspec'
|
6
|
+
gem 'rspec-rails'
|
7
|
+
gem 'rspec-benchmark', '~> 0.3'
|
8
|
+
gem 'rspec-github', '~> 2.3'
|
9
|
+
|
10
|
+
gem 'rubocop', '~> 1.29'
|
11
|
+
gem 'rubocop-rake', '~> 0.6'
|
12
|
+
gem 'rubocop-rspec', '~> 2.10'
|
13
|
+
gem 'rubocop-performance', '~> 1.13'
|
14
|
+
|
15
|
+
gem 'simplecov', '~> 0.21'
|
16
|
+
gem 'codecov', require: false
|
17
|
+
|
18
|
+
# test devise with memory database
|
19
|
+
gem 'devise', '~> 4.8.1' if ENV.fetch('BUNDLE_GEMFILE', nil) =~ /warden/
|
20
|
+
gem 'sqlite3', '~> 1.4'
|
21
|
+
|
22
|
+
# benchmarking test
|
23
|
+
gem 'capybara', '~> 2.15', require: false
|
24
|
+
gem 'benchmark-ips', '~> 2.7', require: false
|
25
|
+
|
26
|
+
# dev
|
27
|
+
gem 'rake'
|
28
|
+
gem 'appraisal', '~> 2.4', require: false
|
4
29
|
|
30
|
+
# be sure to generate gemfiles like
|
31
|
+
# CI=1 bundle exec appraisal generate
|
5
32
|
gem 'pry-byebug' unless ENV['CI']
|
6
33
|
|
7
34
|
# Specify your gem's dependencies in rails-session_cookie.gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Vlad Bokov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -2,10 +2,15 @@
|
|
2
2
|
|
3
3
|
Fast, loosely coupled requests specs for a cookie-authenticated application.
|
4
4
|
|
5
|
-
|
6
|
-
[
|
6
|
+
[](https://badge.fury.io/rb/rails-session_cookie)
|
7
|
+
[](undefined)
|
8
8
|
|
9
|
+
Key goals:
|
10
|
+
|
11
|
+
- how to login under any user in request tests quickly
|
12
|
+
- how to speed up capybara, selenium tests
|
13
|
+
- how to login under any user in production using rails console
|
9
14
|
## Why
|
10
15
|
|
11
16
|
Probably, you might have seen a lot code like this:
|
@@ -14,7 +19,7 @@ Probably, you might have seen a lot code like this:
|
|
14
19
|
# config/initializers/session_store.rb
|
15
20
|
Rails.application.config.session_store :cookie_store
|
16
21
|
|
17
|
-
#
|
22
|
+
# authenticating method (maybe Devise or whatever)
|
18
23
|
session[:current_user_id] = current_user.id
|
19
24
|
|
20
25
|
# somewhere in helper for request specs
|
@@ -23,7 +28,7 @@ def login(current_user)
|
|
23
28
|
end
|
24
29
|
|
25
30
|
# now every request spec is calling login request
|
26
|
-
RSpec.describe 'User
|
31
|
+
RSpec.describe 'User interface', type: :request do
|
27
32
|
let(:user) { create :user }
|
28
33
|
|
29
34
|
before do
|
@@ -37,13 +42,18 @@ end
|
|
37
42
|
```
|
38
43
|
|
39
44
|
In a usual user-driven application this tightly couples *all* request specs, which require authentication, to the login process.
|
40
|
-
If it fails - everything fails. If it's not
|
45
|
+
If it fails - everything fails. If it's not blazing fast - it slows the whole suite down.
|
46
|
+
|
47
|
+
One may move to token-based authentication, especially when having API. That's reasonable and nice.
|
48
|
+
But HTTP is stateless, really we don't need to do several requests, we can think about a session cookie
|
49
|
+
as a token passed in a special header!
|
41
50
|
|
42
|
-
|
43
|
-
|
51
|
+
You can easily pass headers in tests, the only hard thing is getting the cookie value.
|
52
|
+
Rails may change how a state is serialized into the session cookie. It can be encrypted or not, marshalled
|
53
|
+
(an old story for rails-3 legacy) or JSONed. Long story short: only rails knows how to generate cookie from data.
|
44
54
|
|
45
|
-
This gem replaces your usual process with the simplest
|
46
|
-
Rails is modular, that's cool :)
|
55
|
+
This gem replaces your usual process of getting session cookie with the simplest rack app utilizing
|
56
|
+
2 rails middlewares. Rails is modular, that's cool :)
|
47
57
|
|
48
58
|
## Installation
|
49
59
|
|
@@ -73,7 +83,7 @@ Now you can cache `raw_session_cookie` globally or per-thread depending on `curr
|
|
73
83
|
|
74
84
|
You can also use the `raw_session_cookie` directly like this:
|
75
85
|
|
76
|
-
```
|
86
|
+
```ruby
|
77
87
|
get "/", {}, { "HTTP_COOKIE" => raw_session_cookie }
|
78
88
|
```
|
79
89
|
|
@@ -85,13 +95,12 @@ However, never saw this in practice, and consider caching of requests in before-
|
|
85
95
|
If you need more sophisticated logic:
|
86
96
|
|
87
97
|
```ruby
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
98
|
+
auth_app = proc { |env|
|
99
|
+
# do your magic
|
100
|
+
env[Rails::SessionCookie::RACK_SESSION].merge!(context)
|
101
|
+
[200, {}, []]
|
102
|
+
}
|
103
|
+
raw_session_cookie = Rails::SessionCookie::App.new(auth_app).session_cookie
|
95
104
|
```
|
96
105
|
|
97
106
|
Of course, you can just make use (and reuse!) of as many procs as you wish.
|
@@ -117,9 +126,33 @@ Capybara.current_session.driver.browser.set_cookie raw_session_cookie
|
|
117
126
|
|
118
127
|
*TODO:* Only tested with `:rack_test` driver!
|
119
128
|
|
129
|
+
## Login under any devise user in rails production
|
130
|
+
|
131
|
+
If you're in production rails console:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
Rails::SessionCookie::WardenApp.new(User.last).session_cookie
|
135
|
+
```
|
136
|
+
|
137
|
+
If you're on remote/developer instance:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
# take values from production console:
|
141
|
+
secret_key_base = Rails.application.env_config['action_dispatch.secret_key_base']
|
142
|
+
data = User.serialize_into_session(user) # [[user.id], user.encrypted_password[0,29]]
|
143
|
+
opts = Rails.application.config.session_options
|
144
|
+
|
145
|
+
# in remote rails console:
|
146
|
+
key = "warden.user.user.key" # "warden.user.#{scope}.key"
|
147
|
+
Rails::SessionCookie::App.new({ key => data }, opts).session_cookie(secret_key_base: secret_key_base)
|
148
|
+
```
|
149
|
+
|
150
|
+
Then inject the value inside `cookies` in browser devtools.
|
151
|
+
This another friendly reminder, why you need to keep your `SECRET_KEY_BASE` secure!
|
152
|
+
|
120
153
|
## Benchmarks
|
121
154
|
|
122
|
-
*NOTE:* Sometimes devise's `
|
155
|
+
*NOTE:* Sometimes devise's `sign_in` is still faster than `SessionCookie` (a little though),
|
123
156
|
because Warden uses an [ugly hack, in my opinion,](https://github.com/hassox/warden/blob/master/lib/warden/test/helpers.rb#L18L23)
|
124
157
|
to support test-mode authentication.
|
125
158
|
|
@@ -128,7 +161,9 @@ Besides, authentication becomes as transparent as possible and should increase r
|
|
128
161
|
if you understand HTTP session cookies principles.
|
129
162
|
|
130
163
|
```sh
|
131
|
-
$ appraisal rails-5.1-warden rspec -t performance spec/benchmarks
|
164
|
+
$ appraisal rails-5.1-warden rspec -t performance spec/benchmarks/feature_spec.rb
|
165
|
+
# or just
|
166
|
+
$ BUNDLE_GEMFILE=gemfiles/rails_6.0_warden.gemfile bundle exec rspec
|
132
167
|
|
133
168
|
Speed using capybara in feature test
|
134
169
|
correctness of
|
@@ -140,6 +175,34 @@ Speed using capybara in feature test
|
|
140
175
|
is obviously slower separately
|
141
176
|
is not slower than devise helpers if using cache and executing multiple specs in a suite
|
142
177
|
|
178
|
+
Warming up --------------------------------------
|
179
|
+
devise sign_in
|
180
|
+
70.000 i/100ms
|
181
|
+
session cookie
|
182
|
+
70.000 i/100ms
|
183
|
+
session cookie (no cache)
|
184
|
+
62.000 i/100ms
|
185
|
+
Calculating -------------------------------------
|
186
|
+
devise sign_in
|
187
|
+
700.554 (± 5.3%) i/s - 3.500k in 5.011356s
|
188
|
+
session cookie
|
189
|
+
686.868 (± 4.7%) i/s - 3.430k in 5.005542s
|
190
|
+
session cookie (no cache)
|
191
|
+
611.439 (± 4.9%) i/s - 3.100k in 5.083986s
|
192
|
+
|
193
|
+
Comparison:
|
194
|
+
devise sign_in : 700.6 i/s
|
195
|
+
session cookie : 686.9 i/s - same-ish: difference falls within error
|
196
|
+
session cookie (no cache): 611.4 i/s - 1.15x slower
|
197
|
+
|
198
|
+
```
|
199
|
+
|
200
|
+
But when it comes with comparison to a simple custom authentication (see `spec/support/rails_app.rb`),
|
201
|
+
this gem is several times faster! (custom action checks password, hits database, request touches the whole rails middleware stack)
|
202
|
+
|
203
|
+
```sh
|
204
|
+
$ appraisal rails-5.1-warden rspec -t performance spec/benchmarks/request_spec.rb
|
205
|
+
|
143
206
|
Speed using custom sign-in in request test
|
144
207
|
correctness of
|
145
208
|
SessionCookie
|
@@ -149,18 +212,23 @@ Speed using custom sign-in in request test
|
|
149
212
|
against custom sign in route
|
150
213
|
is faster separately without cache
|
151
214
|
|
152
|
-
|
153
|
-
|
215
|
+
Warming up --------------------------------------
|
216
|
+
custom sign in
|
217
|
+
1.000 i/100ms
|
218
|
+
session cookie
|
219
|
+
1.759k i/100ms
|
220
|
+
session cookie (no cache)
|
221
|
+
482.000 i/100ms
|
222
|
+
Calculating -------------------------------------
|
223
|
+
custom sign in
|
224
|
+
11.219 (± 0.0%) i/s - 57.000 in 5.082143s
|
225
|
+
session cookie
|
226
|
+
17.573k (± 2.0%) i/s - 87.950k in 5.006754s
|
227
|
+
session cookie (no cache)
|
228
|
+
4.714k (± 5.0%) i/s - 23.618k in 5.023448s
|
229
|
+
|
230
|
+
Comparison:
|
231
|
+
session cookie : 17573.4 i/s
|
232
|
+
session cookie (no cache): 4714.3 i/s - 3.73x slower
|
233
|
+
custom sign in : 11.2 i/s - 1566.44x slower
|
154
234
|
```
|
155
|
-
|
156
|
-
## Contributing
|
157
|
-
|
158
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/razum2um/rails-session_cookie.
|
159
|
-
|
160
|
-
[Gem Version]: https://rubygems.org/gems/rails-session_cookie
|
161
|
-
[Build Status]: https://travis-ci.org/razum2um/rails-session_cookie
|
162
|
-
[Coverage]: https://codeclimate.com/github/razum2um/rails-session_cookie/coverage
|
163
|
-
|
164
|
-
[GV img]: https://badge.fury.io/rb/rails-session_cookie.svg
|
165
|
-
[BS img]: https://travis-ci.org/razum2um/rails-session_cookie.png
|
166
|
-
[CV img]: https://codeclimate.com/github/razum2um/rails-session_cookie/badges/coverage.svg
|
data/Rakefile
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rspec/core/rake_task'
|
3
5
|
require 'rubocop/rake_task'
|
4
6
|
|
5
7
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
-
RuboCop::RakeTask.new
|
8
|
+
RuboCop::RakeTask.new
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec_github) do |t|
|
11
|
+
t.rspec_opts = '--format RSpec::Github::Formatter -f documentation'
|
12
|
+
end
|
7
13
|
|
14
|
+
task ci: %i[rubocop spec_github]
|
8
15
|
task default: %i[rubocop spec]
|
data/bin/console
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rspec"
|
6
|
+
gem "rspec-rails", "~> 5.1.2"
|
7
|
+
gem "rspec-benchmark", "~> 0.3"
|
8
|
+
gem "rspec-github", "~> 2.3"
|
9
|
+
gem "rubocop", "~> 1.29"
|
10
|
+
gem "rubocop-rake", "~> 0.6"
|
11
|
+
gem "rubocop-rspec", "~> 2.10"
|
12
|
+
gem "rubocop-performance", "~> 1.13"
|
13
|
+
gem "simplecov", "~> 0.21"
|
14
|
+
gem "codecov", require: false
|
15
|
+
gem "sqlite3", "~> 1.4"
|
16
|
+
gem "capybara", "~> 2.15", require: false
|
17
|
+
gem "benchmark-ips", "~> 2.7", require: false
|
18
|
+
gem "rake"
|
19
|
+
gem "appraisal", "~> 2.4", require: false
|
20
|
+
gem "rails", "~> 5.2.8"
|
21
|
+
|
22
|
+
gemspec path: "../"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rspec"
|
6
|
+
gem "rspec-rails", "~> 5.1.2"
|
7
|
+
gem "rspec-benchmark", "~> 0.3"
|
8
|
+
gem "rspec-github", "~> 2.3"
|
9
|
+
gem "rubocop", "~> 1.29"
|
10
|
+
gem "rubocop-rake", "~> 0.6"
|
11
|
+
gem "rubocop-rspec", "~> 2.10"
|
12
|
+
gem "rubocop-performance", "~> 1.13"
|
13
|
+
gem "simplecov", "~> 0.21"
|
14
|
+
gem "codecov", require: false
|
15
|
+
gem "sqlite3", "~> 1.4"
|
16
|
+
gem "capybara", "~> 2.15", require: false
|
17
|
+
gem "benchmark-ips", "~> 2.7", require: false
|
18
|
+
gem "rake"
|
19
|
+
gem "appraisal", "~> 2.4", require: false
|
20
|
+
gem "rails", "~> 5.2.8"
|
21
|
+
gem "warden", ">= 1.2"
|
22
|
+
gem "devise", "~> 4.8"
|
23
|
+
|
24
|
+
gemspec path: "../"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rspec"
|
6
|
+
gem "rspec-rails", "~> 5.1.2"
|
7
|
+
gem "rspec-benchmark", "~> 0.3"
|
8
|
+
gem "rspec-github", "~> 2.3"
|
9
|
+
gem "rubocop", "~> 1.29"
|
10
|
+
gem "rubocop-rake", "~> 0.6"
|
11
|
+
gem "rubocop-rspec", "~> 2.10"
|
12
|
+
gem "rubocop-performance", "~> 1.13"
|
13
|
+
gem "simplecov", "~> 0.21"
|
14
|
+
gem "codecov", require: false
|
15
|
+
gem "sqlite3", "~> 1.4"
|
16
|
+
gem "capybara", "~> 2.15", require: false
|
17
|
+
gem "benchmark-ips", "~> 2.7", require: false
|
18
|
+
gem "rake"
|
19
|
+
gem "appraisal", "~> 2.4", require: false
|
20
|
+
gem "rails", "~> 6.0.5"
|
21
|
+
|
22
|
+
gemspec path: "../"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rspec"
|
6
|
+
gem "rspec-rails", "~> 5.1.2"
|
7
|
+
gem "rspec-benchmark", "~> 0.3"
|
8
|
+
gem "rspec-github", "~> 2.3"
|
9
|
+
gem "rubocop", "~> 1.29"
|
10
|
+
gem "rubocop-rake", "~> 0.6"
|
11
|
+
gem "rubocop-rspec", "~> 2.10"
|
12
|
+
gem "rubocop-performance", "~> 1.13"
|
13
|
+
gem "simplecov", "~> 0.21"
|
14
|
+
gem "codecov", require: false
|
15
|
+
gem "sqlite3", "~> 1.4"
|
16
|
+
gem "capybara", "~> 2.15", require: false
|
17
|
+
gem "benchmark-ips", "~> 2.7", require: false
|
18
|
+
gem "rake"
|
19
|
+
gem "appraisal", "~> 2.4", require: false
|
20
|
+
gem "rails", "~> 6.0.5"
|
21
|
+
gem "warden", ">= 1.2"
|
22
|
+
gem "devise", "~> 4.8"
|
23
|
+
|
24
|
+
gemspec path: "../"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rspec"
|
6
|
+
gem "rspec-rails", "6.0.0.rc1"
|
7
|
+
gem "rspec-benchmark", "~> 0.3"
|
8
|
+
gem "rspec-github", "~> 2.3"
|
9
|
+
gem "rubocop", "~> 1.29"
|
10
|
+
gem "rubocop-rake", "~> 0.6"
|
11
|
+
gem "rubocop-rspec", "~> 2.10"
|
12
|
+
gem "rubocop-performance", "~> 1.13"
|
13
|
+
gem "simplecov", "~> 0.21"
|
14
|
+
gem "codecov", require: false
|
15
|
+
gem "sqlite3", "~> 1.4"
|
16
|
+
gem "capybara", "~> 2.15", require: false
|
17
|
+
gem "benchmark-ips", "~> 2.7", require: false
|
18
|
+
gem "rake"
|
19
|
+
gem "appraisal", "~> 2.4", require: false
|
20
|
+
gem "rails", "~> 6.1.6"
|
21
|
+
|
22
|
+
gemspec path: "../"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rspec"
|
6
|
+
gem "rspec-rails", "6.0.0.rc1"
|
7
|
+
gem "rspec-benchmark", "~> 0.3"
|
8
|
+
gem "rspec-github", "~> 2.3"
|
9
|
+
gem "rubocop", "~> 1.29"
|
10
|
+
gem "rubocop-rake", "~> 0.6"
|
11
|
+
gem "rubocop-rspec", "~> 2.10"
|
12
|
+
gem "rubocop-performance", "~> 1.13"
|
13
|
+
gem "simplecov", "~> 0.21"
|
14
|
+
gem "codecov", require: false
|
15
|
+
gem "sqlite3", "~> 1.4"
|
16
|
+
gem "capybara", "~> 2.15", require: false
|
17
|
+
gem "benchmark-ips", "~> 2.7", require: false
|
18
|
+
gem "rake"
|
19
|
+
gem "appraisal", "~> 2.4", require: false
|
20
|
+
gem "rails", "~> 6.1.6"
|
21
|
+
gem "warden", ">= 1.2"
|
22
|
+
gem "devise", "~> 4.8"
|
23
|
+
|
24
|
+
gemspec path: "../"
|