warden 1.2.4 → 1.2.9

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.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitignore +6 -0
  4. data/.rspec +3 -0
  5. data/{History.rdoc → CHANGELOG.md} +80 -36
  6. data/Gemfile +3 -2
  7. data/LICENSE +2 -1
  8. data/README.md +18 -0
  9. data/Rakefile +4 -8
  10. data/lib/warden.rb +2 -0
  11. data/lib/warden/config.rb +1 -0
  12. data/lib/warden/errors.rb +2 -1
  13. data/lib/warden/hooks.rb +1 -0
  14. data/lib/warden/manager.rb +2 -1
  15. data/lib/warden/mixins/common.rb +1 -0
  16. data/lib/warden/proxy.rb +24 -4
  17. data/lib/warden/session_serializer.rb +1 -0
  18. data/lib/warden/strategies.rb +1 -0
  19. data/lib/warden/strategies/base.rb +3 -1
  20. data/lib/warden/test/helpers.rb +2 -1
  21. data/lib/warden/test/mock.rb +69 -0
  22. data/lib/warden/test/warden_helpers.rb +1 -0
  23. data/lib/warden/version.rb +2 -1
  24. data/warden.gemspec +19 -18
  25. metadata +19 -35
  26. data/README.textile +0 -9
  27. data/spec/helpers/request_helper.rb +0 -51
  28. data/spec/helpers/strategies/fail_with_user.rb +0 -10
  29. data/spec/helpers/strategies/failz.rb +0 -8
  30. data/spec/helpers/strategies/invalid.rb +0 -8
  31. data/spec/helpers/strategies/pass.rb +0 -8
  32. data/spec/helpers/strategies/pass_with_message.rb +0 -8
  33. data/spec/helpers/strategies/password.rb +0 -13
  34. data/spec/helpers/strategies/single.rb +0 -12
  35. data/spec/spec_helper.rb +0 -24
  36. data/spec/warden/authenticated_data_store_spec.rb +0 -114
  37. data/spec/warden/config_spec.rb +0 -48
  38. data/spec/warden/errors_spec.rb +0 -47
  39. data/spec/warden/hooks_spec.rb +0 -373
  40. data/spec/warden/manager_spec.rb +0 -340
  41. data/spec/warden/proxy_spec.rb +0 -1050
  42. data/spec/warden/scoped_session_serializer.rb +0 -123
  43. data/spec/warden/session_serializer_spec.rb +0 -53
  44. data/spec/warden/strategies/base_spec.rb +0 -313
  45. data/spec/warden/strategies_spec.rb +0 -94
  46. data/spec/warden/test/helpers_spec.rb +0 -93
  47. data/spec/warden/test/test_mode_spec.rb +0 -75
@@ -1,94 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Warden::Strategies do
5
- it "should let me add a strategy via a block" do
6
- Warden::Strategies.add(:strategy1) do
7
- def authenticate!
8
- success("foo")
9
- end
10
- end
11
- expect(Warden::Strategies[:strategy1].ancestors).to include(Warden::Strategies::Base)
12
- end
13
-
14
- it "should raise an error if I add a strategy via a block, that does not have an authenticate! method" do
15
- expect {
16
- Warden::Strategies.add(:strategy2) do
17
- end
18
- }.to raise_error(NoMethodError)
19
- end
20
-
21
- it "should raise an error if I add a strategy that does not extend Warden::Strategies::Base" do
22
- non_base = Class.new do
23
- def authenticate!
24
- end
25
- end
26
- expect do
27
- Warden::Strategies.add(:strategy_non_base, non_base)
28
- end.to raise_error(/is not a Warden::Strategies::Base/)
29
- end
30
-
31
- it "should allow me to get access to a particular strategy" do
32
- Warden::Strategies.add(:strategy3) do
33
- def authenticate!; end
34
- end
35
- strategy = Warden::Strategies[:strategy3]
36
- expect(strategy).not_to be_nil
37
- expect(strategy.ancestors).to include(Warden::Strategies::Base)
38
- end
39
-
40
- it "should allow me to add a strategy with the required methods" do
41
- class MyStrategy < Warden::Strategies::Base
42
- def authenticate!; end
43
- end
44
-
45
- expect {
46
- Warden::Strategies.add(:strategy4, MyStrategy)
47
- }.not_to raise_error
48
- end
49
-
50
- it "should not allow a strategy that does not have an authenticate! method" do
51
- class MyOtherStrategy
52
- end
53
- expect {
54
- Warden::Strategies.add(:strategy5, MyOtherStrategy)
55
- }.to raise_error(NoMethodError)
56
- end
57
-
58
- it "should allow me to change a class when providing a block and class" do
59
- class MyStrategy < Warden::Strategies::Base
60
- end
61
-
62
- Warden::Strategies.add(:foo, MyStrategy) do
63
- def authenticate!; end
64
- end
65
-
66
- expect(Warden::Strategies[:foo].ancestors).to include(MyStrategy)
67
- end
68
-
69
- it "should allow me to update a previously given strategy" do
70
- class MyStrategy < Warden::Strategies::Base
71
- def authenticate!; end
72
- end
73
-
74
- Warden::Strategies.add(:strategy6, MyStrategy)
75
-
76
- new_module = Module.new
77
- Warden::Strategies.update(:strategy6) do
78
- include new_module
79
- end
80
-
81
- expect(Warden::Strategies[:strategy6].ancestors).to include(new_module)
82
- end
83
-
84
- it "should allow me to clear the strategies" do
85
- Warden::Strategies.add(:foobar) do
86
- def authenticate!
87
- :foo
88
- end
89
- end
90
- expect(Warden::Strategies[:foobar]).not_to be_nil
91
- Warden::Strategies.clear!
92
- expect(Warden::Strategies[:foobar]).to be_nil
93
- end
94
- end
@@ -1,93 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Warden::Test::Helpers do
5
- before{ $captures = [] }
6
- after{ Warden.test_reset! }
7
-
8
- it "should log me in as a user" do
9
- user = "A User"
10
- login_as user
11
- app = lambda{|e|
12
- $captures << :run
13
- expect(e['warden']).to be_authenticated
14
- expect(e['warden'].user).to eq("A User")
15
- valid_response
16
- }
17
- setup_rack(app).call(env_with_params)
18
- expect($captures).to eq([:run])
19
- end
20
-
21
- it "should log me in as a user of a given scope" do
22
- user = {:some => "user"}
23
- login_as user, :scope => :foo_scope
24
- app = lambda{|e|
25
- $captures << :run
26
- w = e['warden']
27
- expect(w).to be_authenticated(:foo_scope)
28
- expect(w.user(:foo_scope)).to eq(some: "user")
29
- }
30
- setup_rack(app).call(env_with_params)
31
- expect($captures).to eq([:run])
32
- end
33
-
34
- it "should login multiple users with different scopes" do
35
- user = "A user"
36
- foo_user = "A foo user"
37
- login_as user
38
- login_as foo_user, :scope => :foo
39
- app = lambda{|e|
40
- $captures << :run
41
- w = e['warden']
42
- expect(w.user).to eq("A user")
43
- expect(w.user(:foo)).to eq("A foo user")
44
- expect(w).to be_authenticated
45
- expect(w).to be_authenticated(:foo)
46
- }
47
- setup_rack(app).call(env_with_params)
48
- expect($captures).to eq([:run])
49
- end
50
-
51
- it "should log out all users" do
52
- user = "A user"
53
- foo = "Foo"
54
- login_as user
55
- login_as foo, :scope => :foo
56
- app = lambda{|e|
57
- $captures << :run
58
- w = e['warden']
59
- expect(w.user).to eq("A user")
60
- expect(w.user(:foo)).to eq("Foo")
61
- w.logout
62
- expect(w.user).to be_nil
63
- expect(w.user(:foo)).to be_nil
64
- expect(w).not_to be_authenticated
65
- expect(w).not_to be_authenticated(:foo)
66
- }
67
- setup_rack(app).call(env_with_params)
68
- expect($captures).to eq([:run])
69
- end
70
-
71
- it "should logout a specific user" do
72
- user = "A User"
73
- foo = "Foo"
74
- login_as user
75
- login_as foo, :scope => :foo
76
- app = lambda{|e|
77
- $captures << :run
78
- w = e['warden']
79
- w.logout :foo
80
- expect(w.user).to eq("A User")
81
- expect(w.user(:foo)).to be_nil
82
- expect(w).not_to be_authenticated(:foo)
83
- }
84
- setup_rack(app).call(env_with_params)
85
- expect($captures).to eq([:run])
86
- end
87
-
88
- describe "#asset_paths" do
89
- it "should default asset_paths to anything asset path regex" do
90
- expect(Warden.asset_paths).to eq([/^\/assets\//] )
91
- end
92
- end
93
- end
@@ -1,75 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Warden::Test::WardenHelpers do
5
- before :all do
6
- Warden.test_mode!
7
- end
8
-
9
- before do
10
- $captures = []
11
- @app = lambda{|e| valid_response }
12
- end
13
-
14
- after do
15
- Warden.test_reset!
16
- end
17
-
18
- it{ expect(Warden).to respond_to(:test_mode!) }
19
- it{ expect(Warden).to respond_to(:on_next_request) }
20
- it{ expect(Warden).to respond_to(:test_reset!) }
21
-
22
- it "should execute the on_next_request block on the next request" do
23
- Warden.on_next_request do |warden|
24
- $captures << warden
25
- end
26
-
27
- setup_rack(@app).call(env_with_params)
28
- expect($captures.length).to eq(1)
29
- expect($captures.first).to be_an_instance_of(Warden::Proxy)
30
- end
31
-
32
- it "should execute many on_next_request blocks on the next request" do
33
- Warden.on_next_request{|w| $captures << :first }
34
- Warden.on_next_request{|w| $captures << :second }
35
- setup_rack(@app).call(env_with_params)
36
- expect($captures).to eq([:first, :second])
37
- end
38
-
39
- it "should not execute on_next_request blocks on subsequent requests" do
40
- app = setup_rack(@app)
41
- Warden.on_next_request{|w| $captures << :first }
42
- app.call(env_with_params)
43
- expect($captures).to eq([:first])
44
- $captures.clear
45
- app.call(env_with_params)
46
- expect($captures).to be_empty
47
- end
48
-
49
- it "should allow me to set new_on_next_request items to execute in the same test" do
50
- app = setup_rack(@app)
51
- Warden.on_next_request{|w| $captures << :first }
52
- app.call(env_with_params)
53
- expect($captures).to eq([:first])
54
- Warden.on_next_request{|w| $captures << :second }
55
- app.call(env_with_params)
56
- expect($captures).to eq([:first, :second])
57
- end
58
-
59
- it "should remove the on_next_request items when test is reset" do
60
- app = setup_rack(@app)
61
- Warden.on_next_request{|w| $captures << :first }
62
- Warden.test_reset!
63
- app.call(env_with_params)
64
- expect($captures).to eq([])
65
- end
66
-
67
- context "asset requests" do
68
- it "should not execute on_next_request blocks if this is an asset request" do
69
- app = setup_rack(@app)
70
- Warden.on_next_request{|w| $captures << :first }
71
- app.call(env_with_params("/assets/fun.gif"))
72
- expect($captures).to eq([])
73
- end
74
- end
75
- end