warden-github-rails 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59b7ef20208b4fc31f37b9647b14c136e1b65294
4
- data.tar.gz: 8a193975cdef69665791456cf3c14f803e95685a
3
+ metadata.gz: 7f3cc06e90da76617d5fd6e220ebba3827b86c97
4
+ data.tar.gz: eb0ee4af0658eb0cf9b5a5e7e1b7a8dd200284e3
5
5
  SHA512:
6
- metadata.gz: 8bb8fbfcbc533ef853b20c8f41c7d335070878f2937597df3ad7665ad2317bfc46914dc27390641ff0826386cf232bccc735abe1472346d75bfb65eb27a8899c
7
- data.tar.gz: 77dd68fa6b1e0f99ddc6d06c9dcf2efeb891b4e0ebe51e95835a7a1caea59cb8facc4f2e2d9ff735dd7d28a8dc3cae4d5452d52d3a2785cf044f2c728eef798f
6
+ metadata.gz: 1c2ce60318b2cb2b9e6c5b1f47609d85fd364809fb71831aaf0a2ed2c746f1c387f6f00d0b2025df8a004353585c471b24fe8d6b6a7b9a0141a4f2a8728e88b1
7
+ data.tar.gz: beaa4a6322bc4a4ac0ebe41dac94fe459c37f55c007fee66decf4faa2a02fe585711126af781fe4cde136c7128aae34239422bdefbbccbafbc145d03db6615f4
data/.travis.yml CHANGED
@@ -11,11 +11,12 @@ env:
11
11
  global:
12
12
  - JRUBY_OPTS="--2.0"
13
13
  matrix:
14
- - RAILS_VERSION=3
15
14
  - RAILS_VERSION=4
15
+ - RAILS_VERSION=5.beta
16
16
  - RAILS_VERSION=master
17
17
  matrix:
18
18
  fast_finish: true
19
19
  allow_failures:
20
+ - env: RAILS_VERSION=5.beta
20
21
  - env: RAILS_VERSION=master
21
22
  - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.2.3
4
+
5
+ - Use custom session serialization for proper compatibility with mock users
6
+ (#16)
7
+
3
8
  ## v1.2.2
4
9
 
5
10
  - Improve serialization and devise compatibility
data/README.md CHANGED
@@ -85,7 +85,7 @@ To play with it, follow these steps:
85
85
  To use this gem, add it to your `Gemfile`:
86
86
 
87
87
  ```ruby
88
- gem 'warden-github-rails', '~> 1.1.0'
88
+ gem 'warden-github-rails'
89
89
  ```
90
90
 
91
91
  If you're using devise, make sure to use version 2.2.4 or newer.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.3
@@ -2,6 +2,13 @@ module Warden
2
2
  module GitHub
3
3
  module Rails
4
4
  class Railtie < ::Rails::Railtie
5
+ SERIALIZE_FROM_SESSION = -> ((class_name, data)) do
6
+ class_name.constantize.new.tap { |user| user.marshal_load(data) }
7
+ end
8
+ SERIALIZE_INTO_SESSION = -> (user) do
9
+ [user.class.name, user.marshal_dump]
10
+ end
11
+
5
12
  initializer 'warden-github-rails.warden' do |app|
6
13
  # When devise is used, it inserts a warden middlware. Multiple warden
7
14
  # middlewares do not work properly. Devise allows for a block to be
@@ -28,8 +35,8 @@ module Warden
28
35
  Rails.scopes.each do |scope, scope_config|
29
36
  config.scope_defaults scope, strategies: [:github],
30
37
  config: scope_config
31
- config.serialize_from_session(scope) { |key| Verifier.load(key) }
32
- config.serialize_into_session(scope) { |user| Verifier.dump(user) }
38
+ config.serialize_from_session(scope, &SERIALIZE_FROM_SESSION)
39
+ config.serialize_into_session(scope, &SERIALIZE_INTO_SESSION)
33
40
  end
34
41
  end
35
42
 
@@ -31,7 +31,8 @@ module Warden
31
31
  end
32
32
 
33
33
  def marshal_load(data)
34
- @memberships, super_data = data
34
+ memberships, super_data = data
35
+ @memberships = memberships.symbolize_keys
35
36
  super(super_data)
36
37
  end
37
38
  end
@@ -79,14 +79,14 @@ describe 'controller helpers' do
79
79
 
80
80
  context 'when not logged in' do
81
81
  it 'returns nil' do
82
- expect(request.body).to be_blank
82
+ expect(request.body).to eq('null')
83
83
  end
84
84
  end
85
85
 
86
86
  context 'when logged in' do
87
87
  it "returns the user's session" do
88
88
  github_login(scope)
89
- expect(request.body).to eq({ foo: :bar }.to_s)
89
+ expect(request.body).to eq({ foo: :bar }.to_json)
90
90
  end
91
91
  end
92
92
  end
@@ -1,28 +1,28 @@
1
1
  class ScopedController < ActionController::Base
2
2
  def authenticate
3
3
  github_authenticate!(:admin)
4
- render nothing: true
4
+ head :ok
5
5
  end
6
6
 
7
7
  def logout
8
8
  was_logged_in = !github_user(:admin).nil?
9
9
  github_logout(:admin)
10
- render text: was_logged_in
10
+ render plain: was_logged_in
11
11
  end
12
12
 
13
13
  def authenticated
14
- render text: github_authenticated?(:admin)
14
+ render plain: github_authenticated?(:admin)
15
15
  end
16
16
 
17
17
  def user
18
- render text: github_user(:admin)
18
+ render plain: github_user(:admin)
19
19
  end
20
20
 
21
21
  def session
22
- if (session = github_session(:admin))
23
- session[:foo] = :bar
22
+ if github_session(:admin)
23
+ github_session(:admin)[:foo] = :bar
24
24
  end
25
25
 
26
- render text: github_session(:admin)
26
+ render json: github_session(:admin)
27
27
  end
28
28
  end
@@ -1,28 +1,28 @@
1
1
  class UnscopedController < ActionController::Base
2
2
  def authenticate
3
3
  github_authenticate!
4
- render nothing: true
4
+ head :ok
5
5
  end
6
6
 
7
7
  def logout
8
8
  was_logged_in = !github_user.nil?
9
9
  github_logout
10
- render text: was_logged_in
10
+ render plain: was_logged_in
11
11
  end
12
12
 
13
13
  def authenticated
14
- render text: github_authenticated?
14
+ render plain: github_authenticated?
15
15
  end
16
16
 
17
17
  def user
18
- render text: github_user
18
+ render plain: github_user
19
19
  end
20
20
 
21
21
  def session
22
- if (session = github_session)
23
- session[:foo] = :bar
22
+ if github_session
23
+ github_session[:foo] = :bar
24
24
  end
25
25
 
26
- render text: github_session
26
+ render json: github_session
27
27
  end
28
28
  end
@@ -3,7 +3,6 @@ RailsApp::Application.configure do
3
3
  config.cache_classes = true
4
4
  config.consider_all_requests_local = false
5
5
  config.action_controller.perform_caching = true
6
- config.serve_static_assets = false
7
6
  config.i18n.fallbacks = true
8
7
  config.active_support.deprecation = :notify
9
8
  end
@@ -1,8 +1,6 @@
1
1
  RailsApp::Application.configure do
2
2
  config.eager_load = true
3
3
  config.cache_classes = true
4
- config.serve_static_assets = true
5
- config.static_cache_control = "public, max-age=3600"
6
4
  config.whiny_nils = true
7
5
  config.consider_all_requests_local = true
8
6
  config.action_controller.perform_caching = false
@@ -0,0 +1 @@
1
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ development: &dev
2
+ secret_key_base: '566d4b32c28c60a1d533156df89a3ee3e44c2a35de63833f3ef912b7c69547d4f5d0c412e221fe635640b75295f452340c5456bb79466abf5fec59b6006ea859'
3
+
4
+ test: *dev
@@ -19,10 +19,14 @@ describe Warden::GitHub::Rails::TestHelpers::MockUser do
19
19
  end
20
20
  end
21
21
 
22
- it 'can be marshaled' do
22
+ it 'can be serialized and deserialized with JSON' do
23
23
  user = described_class.new
24
24
  user.stub_membership(org: ['apple', 'facebook'], team: [12, 34])
25
- marshaled_user = Marshal.load(Marshal.dump(user))
25
+
26
+ json = ActiveSupport::JSON.encode(user.marshal_dump)
27
+ marshaled_user = described_class.new.tap do |u|
28
+ u.marshal_load(ActiveSupport::JSON.decode(json))
29
+ end
26
30
 
27
31
  expect(marshaled_user.memberships).to eq(user.memberships)
28
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-github-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-10 00:00:00.000000000 Z
11
+ date: 2016-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -156,11 +156,13 @@ files:
156
156
  - spec/rails_app/config/environments/development.rb
157
157
  - spec/rails_app/config/environments/production.rb
158
158
  - spec/rails_app/config/environments/test.rb
159
+ - spec/rails_app/config/initializers/cookies_serializer.rb
159
160
  - spec/rails_app/config/initializers/secret_token.rb
160
161
  - spec/rails_app/config/initializers/session_store.rb
161
162
  - spec/rails_app/config/initializers/warden_github_rails.rb
162
163
  - spec/rails_app/config/initializers/wrap_parameters.rb
163
164
  - spec/rails_app/config/routes.rb
165
+ - spec/rails_app/config/secrets.yml
164
166
  - spec/rails_app/script/rails
165
167
  - spec/spec_helper.rb
166
168
  - spec/unit/config_spec.rb
@@ -209,11 +211,13 @@ test_files:
209
211
  - spec/rails_app/config/environments/development.rb
210
212
  - spec/rails_app/config/environments/production.rb
211
213
  - spec/rails_app/config/environments/test.rb
214
+ - spec/rails_app/config/initializers/cookies_serializer.rb
212
215
  - spec/rails_app/config/initializers/secret_token.rb
213
216
  - spec/rails_app/config/initializers/session_store.rb
214
217
  - spec/rails_app/config/initializers/warden_github_rails.rb
215
218
  - spec/rails_app/config/initializers/wrap_parameters.rb
216
219
  - spec/rails_app/config/routes.rb
220
+ - spec/rails_app/config/secrets.yml
217
221
  - spec/rails_app/script/rails
218
222
  - spec/spec_helper.rb
219
223
  - spec/unit/config_spec.rb