warden 1.2.5 → 1.2.6
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 +4 -4
- data/History.rdoc +3 -0
- data/lib/warden.rb +1 -0
- data/lib/warden/test/helpers.rb +0 -55
- data/lib/warden/test/mock.rb +68 -0
- data/lib/warden/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/warden/test/helpers_spec.rb +0 -8
- data/spec/warden/test/mock_spec.rb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d3845a89eca007240194b1aef074f91c8d729c8
|
4
|
+
data.tar.gz: 380d5b071552bc8e36628dd790f08da17ea77ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f293bc8c35385e59c260c3b32d3c15cff84849a76632ed81947a80a82c3ec25d459136c672df735dd2289b6dc38e73ea2f19346bff4aa564128ff9f1f9a8af96
|
7
|
+
data.tar.gz: f6a8f255f1e8e1d70ea810bd1c8410a16e330904dde200c8f5f507403e5300e4824c0e340102767a1032c673c991bd56e5459934dc32755ab1c19991d18ba76d
|
data/History.rdoc
CHANGED
data/lib/warden.rb
CHANGED
data/lib/warden/test/helpers.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'rack'
|
4
|
-
|
5
3
|
module Warden
|
6
4
|
module Test
|
7
5
|
# A collection of test helpers for testing full stack rack applications using Warden
|
@@ -33,59 +31,6 @@ module Warden
|
|
33
31
|
proxy.logout(*scopes)
|
34
32
|
end
|
35
33
|
end
|
36
|
-
|
37
|
-
# A helper method that provides the warden object by mocking the env variable.
|
38
|
-
# @api public
|
39
|
-
def warden
|
40
|
-
@warden ||= begin
|
41
|
-
env['warden']
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def env
|
48
|
-
@env ||= begin
|
49
|
-
request = Rack::MockRequest.env_for(
|
50
|
-
"/?#{Rack::Utils.build_query({})}",
|
51
|
-
{ 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET' }
|
52
|
-
)
|
53
|
-
app.call(request)
|
54
|
-
|
55
|
-
request
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def app
|
60
|
-
@app ||= begin
|
61
|
-
opts = {
|
62
|
-
failure_app: lambda {
|
63
|
-
[401, { 'Content-Type' => 'text/plain' }, ['You Fail!']]
|
64
|
-
},
|
65
|
-
default_strategies: :password,
|
66
|
-
default_serializers: :session
|
67
|
-
}
|
68
|
-
Rack::Builder.new do
|
69
|
-
use Warden::Test::Helpers::Session
|
70
|
-
use Warden::Manager, opts, &proc {}
|
71
|
-
run lambda { |e|
|
72
|
-
[200, { 'Content-Type' => 'text/plain' }, ['You Win']]
|
73
|
-
}
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class Session
|
79
|
-
attr_accessor :app
|
80
|
-
def initialize(app,configs = {})
|
81
|
-
@app = app
|
82
|
-
end
|
83
|
-
|
84
|
-
def call(e)
|
85
|
-
e['rack.session'] ||= {}
|
86
|
-
@app.call(e)
|
87
|
-
end
|
88
|
-
end # session
|
89
34
|
end
|
90
35
|
end
|
91
36
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rack'
|
4
|
+
|
5
|
+
module Warden
|
6
|
+
module Test
|
7
|
+
# A mock of an application to get a Warden object to test on
|
8
|
+
# Note: During the teardown phase of your specs you should include: Warden.test_reset!
|
9
|
+
module Mock
|
10
|
+
def self.included(base)
|
11
|
+
::Warden.test_mode!
|
12
|
+
end
|
13
|
+
|
14
|
+
# A helper method that provides the warden object by mocking the env variable.
|
15
|
+
# @api public
|
16
|
+
def warden
|
17
|
+
@warden ||= begin
|
18
|
+
env['warden']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def env
|
25
|
+
@env ||= begin
|
26
|
+
request = Rack::MockRequest.env_for(
|
27
|
+
"/?#{Rack::Utils.build_query({})}",
|
28
|
+
{ 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET' }
|
29
|
+
)
|
30
|
+
app.call(request)
|
31
|
+
|
32
|
+
request
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def app
|
37
|
+
@app ||= begin
|
38
|
+
opts = {
|
39
|
+
failure_app: lambda {
|
40
|
+
[401, { 'Content-Type' => 'text/plain' }, ['You Fail!']]
|
41
|
+
},
|
42
|
+
default_strategies: :password,
|
43
|
+
default_serializers: :session
|
44
|
+
}
|
45
|
+
Rack::Builder.new do
|
46
|
+
use Warden::Test::Mock::Session
|
47
|
+
use Warden::Manager, opts, &proc {}
|
48
|
+
run lambda { |e|
|
49
|
+
[200, { 'Content-Type' => 'text/plain' }, ['You Win']]
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class Session
|
56
|
+
attr_accessor :app
|
57
|
+
def initialize(app,configs = {})
|
58
|
+
@app = app
|
59
|
+
end
|
60
|
+
|
61
|
+
def call(e)
|
62
|
+
e['rack.session'] ||= {}
|
63
|
+
@app.call(e)
|
64
|
+
end
|
65
|
+
end # session
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/warden/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -15,6 +15,7 @@ end
|
|
15
15
|
RSpec.configure do |config|
|
16
16
|
config.include(Warden::Spec::Helpers)
|
17
17
|
config.include(Warden::Test::Helpers)
|
18
|
+
config.include(Warden::Test::Mock)
|
18
19
|
|
19
20
|
def load_strategies
|
20
21
|
Dir[File.join(File.dirname(__FILE__), "helpers", "strategies", "**/*.rb")].each do |f|
|
@@ -85,14 +85,6 @@ describe Warden::Test::Helpers do
|
|
85
85
|
expect($captures).to eq([:run])
|
86
86
|
end
|
87
87
|
|
88
|
-
it "should return a valid mocked warden" do
|
89
|
-
user = "A User"
|
90
|
-
login_as user
|
91
|
-
|
92
|
-
expect(warden.class).to eq(Warden::Proxy)
|
93
|
-
expect(warden.user).to eq(user)
|
94
|
-
end
|
95
|
-
|
96
88
|
describe "#asset_paths" do
|
97
89
|
it "should default asset_paths to anything asset path regex" do
|
98
90
|
expect(Warden.asset_paths).to eq([/^\/assets\//] )
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Warden::Test::Mock do
|
5
|
+
before{ $captures = [] }
|
6
|
+
after{ Warden.test_reset! }
|
7
|
+
|
8
|
+
it "should return a valid mocked warden" do
|
9
|
+
user = "A User"
|
10
|
+
login_as user
|
11
|
+
|
12
|
+
expect(warden.class).to eq(Warden::Proxy)
|
13
|
+
expect(warden.user).to eq(user)
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/warden/strategies.rb
|
49
49
|
- lib/warden/strategies/base.rb
|
50
50
|
- lib/warden/test/helpers.rb
|
51
|
+
- lib/warden/test/mock.rb
|
51
52
|
- lib/warden/test/warden_helpers.rb
|
52
53
|
- lib/warden/version.rb
|
53
54
|
- spec/helpers/request_helper.rb
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- spec/warden/strategies/base_spec.rb
|
71
72
|
- spec/warden/strategies_spec.rb
|
72
73
|
- spec/warden/test/helpers_spec.rb
|
74
|
+
- spec/warden/test/mock_spec.rb
|
73
75
|
- spec/warden/test/test_mode_spec.rb
|
74
76
|
- warden.gemspec
|
75
77
|
homepage: http://github.com/hassox/warden
|