warden 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +3 -0
- data/lib/warden/test/helpers.rb +55 -0
- data/lib/warden/version.rb +1 -1
- data/spec/warden/test/helpers_spec.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2a3954f2157d76ec551f9c498a4e27e09a4a698
|
4
|
+
data.tar.gz: ea81f2cd654fbf09ebf9e2ef44d6836cd47bd920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74db07fcb955f8109cf57bd7e32868bb198f8c7c94a748ca450bfc7e281cacff1c869af942c1952a0ade3fb209bcd134dc7cf3a916d4d0a36417cc5e9a4790b2
|
7
|
+
data.tar.gz: 6d38527fbf7cbdf032ecf16ce5661584afe1d4fb9dbf4cb4c0d60a32b385b53f7e781eb92d4c1624b16de5fe688183af6f9a258cae079a942ca67bc3e69ddd9b
|
data/History.rdoc
CHANGED
data/lib/warden/test/helpers.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'rack'
|
4
|
+
|
3
5
|
module Warden
|
4
6
|
module Test
|
5
7
|
# A collection of test helpers for testing full stack rack applications using Warden
|
@@ -31,6 +33,59 @@ module Warden
|
|
31
33
|
proxy.logout(*scopes)
|
32
34
|
end
|
33
35
|
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
|
34
89
|
end
|
35
90
|
end
|
36
91
|
end
|
data/lib/warden/version.rb
CHANGED
@@ -85,6 +85,14 @@ 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
|
+
|
88
96
|
describe "#asset_paths" do
|
89
97
|
it "should default asset_paths to anything asset path regex" do
|
90
98
|
expect(Warden.asset_paths).to eq([/^\/assets\//] )
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Neighman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -98,3 +98,4 @@ signing_key:
|
|
98
98
|
specification_version: 4
|
99
99
|
summary: Rack middleware that provides authentication for rack applications
|
100
100
|
test_files: []
|
101
|
+
has_rdoc:
|