warden 1.2.4 → 1.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c615ae4a3d5433cece12ea5d28a93e8f5ed3f8ff
4
- data.tar.gz: fc9bae1ddd9b9872aa890235d905147ef7898b72
3
+ metadata.gz: e2a3954f2157d76ec551f9c498a4e27e09a4a698
4
+ data.tar.gz: ea81f2cd654fbf09ebf9e2ef44d6836cd47bd920
5
5
  SHA512:
6
- metadata.gz: c16efdf510c03e0f5455c496044f81b050d9f8887cc88dbb656ea920a01d722bd1557e824f34f107e7dcee4f9d8dbffbbeb3e37d4d77217f65cbe2d822a016c2
7
- data.tar.gz: f83439dd79f0edc6b822750838a131c0f64c772a1f038f0ae371e2362c0ff401e5ef47f4e184390422c3e53f25a484cc64e86c8b01e26733c51f1f4b0d8df4cf
6
+ metadata.gz: 74db07fcb955f8109cf57bd7e32868bb198f8c7c94a748ca450bfc7e281cacff1c869af942c1952a0ade3fb209bcd134dc7cf3a916d4d0a36417cc5e9a4790b2
7
+ data.tar.gz: 6d38527fbf7cbdf032ecf16ce5661584afe1d4fb9dbf4cb4c0d60a32b385b53f7e781eb92d4c1624b16de5fe688183af6f9a258cae079a942ca67bc3e69ddd9b
@@ -1,3 +1,6 @@
1
+ == Version 1.2.5 / 2016-01-28
2
+ * Expands on the test helpers available to make it easier for testing gems
3
+
1
4
  == Version 1.2.3 / 2013-07-14
2
5
  * Fix an issue with lazy loaded sessions
3
6
 
@@ -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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Warden
3
- VERSION = "1.2.4".freeze
3
+ VERSION = "1.2.5".freeze
4
4
  end
@@ -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
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: 2015-12-09 00:00:00.000000000 Z
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: