frikandel 1.0.0 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/.travis.yml +42 -4
- data/Gemfile.rails-3.2.x +9 -0
- data/Gemfile.rails-4.0.x +9 -0
- data/Gemfile.rails-4.1.x +9 -0
- data/Gemfile.rails-4.2.x +10 -0
- data/Gemfile.rails-5.0.x +8 -0
- data/Gemfile.rails-5.1.x +8 -0
- data/Gemfile.rails-5.2.x +8 -0
- data/Gemfile.rails-head +6 -0
- data/Guardfile +3 -4
- data/README.md +42 -8
- data/frikandel.gemspec +6 -2
- data/lib/frikandel.rb +3 -30
- data/lib/frikandel/bind_session_to_ip_address.rb +43 -0
- data/lib/frikandel/configuration.rb +4 -2
- data/lib/frikandel/limit_session_lifetime.rb +44 -0
- data/lib/frikandel/session_invalidation.rb +12 -0
- data/lib/frikandel/version.rb +1 -1
- data/spec/controllers/bind_session_to_ip_address_controller_spec.rb +162 -0
- data/spec/controllers/combined_controller_spec.rb +117 -0
- data/spec/controllers/customized_on_invalid_session_controller_spec.rb +42 -0
- data/spec/controllers/limit_session_lifetime_controller_spec.rb +380 -0
- data/spec/dummy/config/application.rb +2 -0
- data/spec/dummy/config/database.yml +6 -6
- data/spec/dummy/config/environments/test.rb +7 -2
- data/spec/lib/frikandel/configuration_spec.rb +17 -17
- data/spec/rails_helper.rb +76 -0
- data/spec/spec_helper.rb +88 -7
- data/spec/support/application_controller.rb +14 -6
- metadata +79 -42
- data/spec/controllers/application_controller_spec.rb +0 -57
- data/spec/controllers/customized_on_expired_cookie_controller_spec.rb +0 -39
- data/spec/dummy/db/test.sqlite3 +0 -0
@@ -1,57 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "support/application_controller"
|
3
|
-
|
4
|
-
describe ApplicationController do
|
5
|
-
|
6
|
-
it "holds the session for at least .1 seconds" do
|
7
|
-
get :home
|
8
|
-
session[:user_id] = 1337
|
9
|
-
sleep 0.1
|
10
|
-
get :home
|
11
|
-
|
12
|
-
session[:user_id].should be_present
|
13
|
-
session[:user_id].should eq 1337
|
14
|
-
end
|
15
|
-
|
16
|
-
it "destroys the session after SESSION_TTL" do
|
17
|
-
get :home
|
18
|
-
session[:user_id] = 2337
|
19
|
-
request.session[:ttl] = (Frikandel::Configuration.ttl + 1.minute).seconds.ago
|
20
|
-
get :home
|
21
|
-
|
22
|
-
session[:user_id].should be_blank
|
23
|
-
end
|
24
|
-
|
25
|
-
it "destroys the session after SESSION_MAX_TTL" do
|
26
|
-
get :home
|
27
|
-
session[:user_id] = 3337
|
28
|
-
|
29
|
-
request.session[:max_ttl] = 1.minute.ago
|
30
|
-
get :home
|
31
|
-
|
32
|
-
session[:user_id].should be_blank
|
33
|
-
end
|
34
|
-
|
35
|
-
it "works when there was no session in the request" do
|
36
|
-
get :home
|
37
|
-
session[:user_id] = 4337
|
38
|
-
request.session = nil
|
39
|
-
get :home
|
40
|
-
|
41
|
-
session[:user_id].should be_blank
|
42
|
-
end
|
43
|
-
|
44
|
-
it "is configurable" do
|
45
|
-
old_value = Frikandel::Configuration.ttl
|
46
|
-
Frikandel::Configuration.ttl = 1.minute
|
47
|
-
get :home
|
48
|
-
session[:ttl] = 30.minutes.ago
|
49
|
-
session[:user_id] = 5337
|
50
|
-
|
51
|
-
get :home
|
52
|
-
session[:user_id].should be_blank
|
53
|
-
|
54
|
-
Frikandel::Configuration.ttl = old_value
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "support/application_controller"
|
3
|
-
|
4
|
-
class SessionExpiredError < StandardError; end
|
5
|
-
|
6
|
-
class CustomizedOnExpiredSessionController < ApplicationController
|
7
|
-
def on_expired_session
|
8
|
-
raise SessionExpiredError.new("Your Session is DEAD!")
|
9
|
-
end
|
10
|
-
alias my_on_expired_session on_expired_session
|
11
|
-
end
|
12
|
-
|
13
|
-
describe CustomizedOnExpiredSessionController do
|
14
|
-
|
15
|
-
it "uses the overwritten on_expired_cookie function" do
|
16
|
-
get :home
|
17
|
-
request.session[:max_ttl] = 1.minute.ago
|
18
|
-
|
19
|
-
expect { get :home }.to raise_error SessionExpiredError
|
20
|
-
end
|
21
|
-
|
22
|
-
it "can revert the on_expired_cookie function back to the original" do
|
23
|
-
# NOTE: Don't confuse original_on_expired_session with my_on_expired_session!
|
24
|
-
class CustomizedOnExpiredSessionController < ApplicationController
|
25
|
-
alias on_expired_session original_on_expired_session # Setting it to the Gems original
|
26
|
-
end
|
27
|
-
|
28
|
-
get :home
|
29
|
-
request.session[:max_ttl] = 1.minute.ago
|
30
|
-
|
31
|
-
begin
|
32
|
-
expect { get :home }.to_not raise_error
|
33
|
-
ensure
|
34
|
-
class CustomizedOnExpiredSessionController < ApplicationController
|
35
|
-
alias on_expired_session my_on_expired_session # Reverting it back to the Customized function thats defined in this test
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/spec/dummy/db/test.sqlite3
DELETED
File without changes
|