devise_g5_authenticatable 0.1.2 → 0.1.3
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/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/app/controllers/devise_g5_authenticatable/sessions_controller.rb +1 -1
- data/lib/devise_g5_authenticatable/version.rb +1 -1
- data/spec/controllers/sessions_controller_spec.rb +27 -19
- data/spec/g5/auth_password_validator_spec.rb +3 -3
- data/spec/models/g5_authenticatable_spec.rb +59 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 647e697e95fa5a4f468529c0c016c5e9a8f2a8bd
|
4
|
+
data.tar.gz: 5795af637ed1ba2bce1bc36eae8fc765ea9ce88b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a17aa3b3d6cdb0a1e3b2c93aa973df48e6b6a13d6ed923cc2da1b1be813c14e110e7dcebc4ffbdc6449c7224b099bd305234a3f1024b16efb3fe79b5ed788a1
|
7
|
+
data.tar.gz: a59a344ee27a3927e89bae41de06c72a654b9a12acd62e36c7ddfc7e5a05743a07bbeb237e6cab70cf8637c6be1b6ea3bef4b2c95dcef241b72ff05bf6a140bf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## v0.1.3 (2014-12-19)
|
2
|
+
|
3
|
+
* Fix sign out when there isn't a locally authenticated user
|
4
|
+
([#16](https://github.com/G5/devise_g5_authenticatable/pull/16)).
|
5
|
+
|
1
6
|
## v0.1.2 (2014-08-04)
|
2
7
|
* Use existing user with updated password on duplicate user creation with
|
3
8
|
duplicate email.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -145,39 +145,47 @@ describe DeviseG5Authenticatable::SessionsController do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
let(:model) { create(scope) }
|
148
|
-
|
149
|
-
before do
|
150
|
-
sign_in(scope, model)
|
151
|
-
allow(model).to receive(:revoke_g5_credentials!)
|
152
|
-
end
|
148
|
+
before { allow(model).to receive(:revoke_g5_credentials!) }
|
153
149
|
|
154
150
|
context 'with user scope' do
|
155
151
|
let(:scope) { :user }
|
156
152
|
|
157
|
-
|
158
|
-
|
159
|
-
end
|
153
|
+
context 'when there is a current user' do
|
154
|
+
before { sign_in(scope, model) }
|
160
155
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
156
|
+
it 'should sign out the user locally' do
|
157
|
+
expect { destroy_session }.to change { controller.current_user }.to(nil)
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should construct the sign out URL with the correct redirect URL' do
|
161
|
+
expect(auth_client).to receive(:sign_out_url).
|
162
|
+
with(root_url).
|
163
|
+
and_return(auth_sign_out_url)
|
164
|
+
destroy_session
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should redirect to the auth server to sign out globally' do
|
168
|
+
expect(destroy_session).to redirect_to(auth_sign_out_url)
|
169
|
+
end
|
167
170
|
|
168
|
-
|
169
|
-
|
171
|
+
it 'should revoke the g5 access token' do
|
172
|
+
expect(controller.current_user).to receive(:revoke_g5_credentials!)
|
173
|
+
destroy_session
|
174
|
+
end
|
170
175
|
end
|
171
176
|
|
172
|
-
|
173
|
-
|
174
|
-
|
177
|
+
context 'when there is not a current user' do
|
178
|
+
it 'should redirect to the auth server to sign out globally' do
|
179
|
+
expect(destroy_session).to redirect_to(auth_sign_out_url)
|
180
|
+
end
|
175
181
|
end
|
176
182
|
end
|
177
183
|
|
178
184
|
context 'with admin scope' do
|
179
185
|
let(:scope) { :admin }
|
180
186
|
|
187
|
+
before { sign_in(scope, model) }
|
188
|
+
|
181
189
|
it 'should sign out the admin locally' do
|
182
190
|
expect { destroy_session }.to change { controller.current_admin }.to(nil)
|
183
191
|
end
|
@@ -39,7 +39,7 @@ describe Devise::G5::AuthPasswordValidator do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should return true' do
|
42
|
-
expect(valid_password?).to
|
42
|
+
expect(valid_password?).to be_truthy
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -52,7 +52,7 @@ describe Devise::G5::AuthPasswordValidator do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should return false' do
|
55
|
-
expect(valid_password?).to
|
55
|
+
expect(valid_password?).to be_falsey
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,7 +61,7 @@ describe Devise::G5::AuthPasswordValidator do
|
|
61
61
|
let(:runtime_error) { RuntimeError.new('Insufficient credentials for access token. Supply a username/password or authentication code.') }
|
62
62
|
|
63
63
|
it 'should return false' do
|
64
|
-
expect(valid_password?).to
|
64
|
+
expect(valid_password?).to be_falsey
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -184,7 +184,7 @@ describe Devise::Models::G5Authenticatable do
|
|
184
184
|
|
185
185
|
context 'with valid input' do
|
186
186
|
it 'should return true' do
|
187
|
-
expect(update_with_password).to
|
187
|
+
expect(update_with_password).to be_truthy
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'should initialize the auth user updater' do
|
@@ -204,7 +204,7 @@ describe Devise::Models::G5Authenticatable do
|
|
204
204
|
let(:updated_email) { '' }
|
205
205
|
|
206
206
|
it 'should return false' do
|
207
|
-
expect(update_with_password).to
|
207
|
+
expect(update_with_password).to be_falsey
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'should not update the credentials on the auth server' do
|
@@ -226,7 +226,7 @@ describe Devise::Models::G5Authenticatable do
|
|
226
226
|
let(:current_password) { '' }
|
227
227
|
|
228
228
|
it 'should return false' do
|
229
|
-
expect(update_with_password).to
|
229
|
+
expect(update_with_password).to be_falsey
|
230
230
|
end
|
231
231
|
|
232
232
|
it 'should set an error on the current_password attribute' do
|
@@ -242,7 +242,7 @@ describe Devise::Models::G5Authenticatable do
|
|
242
242
|
let(:current_password) { 'something wrong' }
|
243
243
|
|
244
244
|
it 'should return false' do
|
245
|
-
expect(update_with_password).to
|
245
|
+
expect(update_with_password).to be_falsey
|
246
246
|
end
|
247
247
|
|
248
248
|
it 'should set an error on the current_password attribute' do
|
@@ -293,7 +293,7 @@ describe Devise::Models::G5Authenticatable do
|
|
293
293
|
let(:valid) { true }
|
294
294
|
|
295
295
|
it 'should return true' do
|
296
|
-
expect(valid_password?).to
|
296
|
+
expect(valid_password?).to be_truthy
|
297
297
|
end
|
298
298
|
|
299
299
|
it 'should initialize the validator with the model' do
|
@@ -309,7 +309,7 @@ describe Devise::Models::G5Authenticatable do
|
|
309
309
|
let(:valid) { false }
|
310
310
|
|
311
311
|
it 'should return false' do
|
312
|
-
expect(valid_password?).to
|
312
|
+
expect(valid_password?).to be_falsey
|
313
313
|
end
|
314
314
|
|
315
315
|
it 'should initialize the validator with the model' do
|
@@ -442,7 +442,7 @@ describe Devise::Models::G5Authenticatable do
|
|
442
442
|
|
443
443
|
it 'should not save the changes' do
|
444
444
|
update_g5_credentials
|
445
|
-
expect(model.g5_access_token_changed?).to
|
445
|
+
expect(model.g5_access_token_changed?).to be_truthy
|
446
446
|
end
|
447
447
|
end
|
448
448
|
|
@@ -499,19 +499,37 @@ describe Devise::Models::G5Authenticatable do
|
|
499
499
|
context 'with session data' do
|
500
500
|
let(:session) { {'omniauth.auth' => auth_data} }
|
501
501
|
|
502
|
-
it {
|
503
|
-
|
504
|
-
|
505
|
-
|
502
|
+
it { is_expected.to be_new_record }
|
503
|
+
|
504
|
+
it 'should set the email from the params' do
|
505
|
+
expect(new_with_session.email).to eq(email_param)
|
506
|
+
end
|
507
|
+
|
508
|
+
it 'should set the provider from the session' do
|
509
|
+
expect(new_with_session.provider).to eq(auth_data.provider)
|
510
|
+
end
|
511
|
+
|
512
|
+
it 'should set the uid from the session' do
|
513
|
+
expect(new_with_session.uid).to eq(auth_data.uid)
|
514
|
+
end
|
506
515
|
end
|
507
516
|
|
508
517
|
context 'without session data' do
|
509
518
|
let(:session) { Hash.new }
|
510
519
|
|
511
|
-
it {
|
512
|
-
|
513
|
-
|
514
|
-
|
520
|
+
it { is_expected.to be_new_record }
|
521
|
+
|
522
|
+
it 'should set the email from the params' do
|
523
|
+
expect(new_with_session.email).to eq(email_param)
|
524
|
+
end
|
525
|
+
|
526
|
+
it 'should not set the provider' do
|
527
|
+
expect(new_with_session.provider).to be_nil
|
528
|
+
end
|
529
|
+
|
530
|
+
it 'should not set the uid' do
|
531
|
+
expect(new_with_session.uid).to be_nil
|
532
|
+
end
|
515
533
|
end
|
516
534
|
end
|
517
535
|
|
@@ -521,19 +539,37 @@ describe Devise::Models::G5Authenticatable do
|
|
521
539
|
context 'with session data' do
|
522
540
|
let(:session) { {'omniauth.auth' => auth_data} }
|
523
541
|
|
524
|
-
it {
|
525
|
-
|
526
|
-
|
527
|
-
|
542
|
+
it { is_expected.to be_new_record }
|
543
|
+
|
544
|
+
it 'should set the email from the session' do
|
545
|
+
expect(new_with_session.email).to eq(auth_data.info[:email])
|
546
|
+
end
|
547
|
+
|
548
|
+
it 'should set the provider from the session' do
|
549
|
+
expect(new_with_session.provider).to eq(auth_data.provider)
|
550
|
+
end
|
551
|
+
|
552
|
+
it 'should set the uid from the session' do
|
553
|
+
expect(new_with_session.uid).to eq(auth_data.uid)
|
554
|
+
end
|
528
555
|
end
|
529
556
|
|
530
557
|
context 'without session data' do
|
531
558
|
let(:session) { Hash.new }
|
532
559
|
|
533
|
-
it {
|
534
|
-
|
535
|
-
|
536
|
-
|
560
|
+
it { is_expected.to be_new_record }
|
561
|
+
|
562
|
+
it 'should not set the email' do
|
563
|
+
expect(new_with_session.email).to be_blank
|
564
|
+
end
|
565
|
+
|
566
|
+
it 'should not set the provider' do
|
567
|
+
expect(new_with_session.provider).to be_nil
|
568
|
+
end
|
569
|
+
|
570
|
+
it 'should not set the uid' do
|
571
|
+
expect(new_with_session.uid).to be_nil
|
572
|
+
end
|
537
573
|
end
|
538
574
|
end
|
539
575
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_g5_authenticatable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maeve Revels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|