devise_g5_authenticatable 0.2.3 → 0.2.4.beta
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad97f4949c57fec123b19a0cb9dfd4d562474a4
|
4
|
+
data.tar.gz: 74ed2ef0d3351498bb3b8a3b16e1b7bc88949c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86fe1453a3d4b41adaae28e90b1debc6a3c5169682ccdf27d8c82de6e2d882b14678d8a98de03edccde482b53e19cefa1de8df919dc35552976ffd36111f3771
|
7
|
+
data.tar.gz: 303fad6ef8fc9f7c01b63152d7c5836ed4b2e8cf1abf262a258935142512416b6be0a53c9d9610906f62448a77432c45ef5cf408ce4699d868635119cc083975
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## v0.2.4.beta (2015-12-03)
|
2
|
+
* Enforces uniqueness of email address in when looking for an email without UID
|
3
|
+
|
1
4
|
## v0.2.3 (2015-11-30)
|
2
5
|
* Pins version of devise to 3.5.1 due - https://github.com/plataformatec/devise/issues/3705
|
3
6
|
* Pins version of omniauth-g5 to v0.3.1 due - https://github.com/G5/omniauth-g5/pull/10
|
@@ -72,7 +72,9 @@ module Devise
|
|
72
72
|
|
73
73
|
module ClassMethods
|
74
74
|
def find_for_g5_oauth(oauth_data)
|
75
|
-
find_by_provider_and_uid(oauth_data.provider.to_s, oauth_data.uid.to_s)
|
75
|
+
found_user = find_by_provider_and_uid(oauth_data.provider.to_s, oauth_data.uid.to_s)
|
76
|
+
return found_user if found_user.present?
|
77
|
+
find_by_email_and_provider(oauth_data.info.email, oauth_data.provider.to_s)
|
76
78
|
end
|
77
79
|
|
78
80
|
def find_and_update_for_g5_oauth(oauth_data)
|
@@ -7,19 +7,18 @@ describe Devise::Models::G5Authenticatable do
|
|
7
7
|
let(:model) { model_class.new(attributes) }
|
8
8
|
let(:attributes) { Hash.new }
|
9
9
|
|
10
|
-
|
11
10
|
describe '#save!' do
|
12
11
|
subject(:save) { model.save! }
|
13
12
|
|
14
13
|
context 'when model is new' do
|
15
14
|
let(:attributes) do
|
16
|
-
{email: email,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
{ email: email,
|
16
|
+
password: password,
|
17
|
+
password_confirmation: password_confirmation,
|
18
|
+
provider: provider,
|
19
|
+
uid: uid,
|
20
|
+
current_password: current_password,
|
21
|
+
updated_by: updated_by }
|
23
22
|
end
|
24
23
|
|
25
24
|
let(:email) { 'test.email@test.host' }
|
@@ -158,10 +157,10 @@ describe Devise::Models::G5Authenticatable do
|
|
158
157
|
let(:model) { create(:user) }
|
159
158
|
|
160
159
|
let(:params) do
|
161
|
-
{current_password: current_password,
|
162
|
-
|
163
|
-
|
164
|
-
|
160
|
+
{ current_password: current_password,
|
161
|
+
password: updated_password,
|
162
|
+
password_confirmation: updated_password,
|
163
|
+
email: updated_email }
|
165
164
|
end
|
166
165
|
|
167
166
|
let(:current_password) {}
|
@@ -173,8 +172,9 @@ describe Devise::Models::G5Authenticatable do
|
|
173
172
|
|
174
173
|
let(:password_validator) { double(:auth_password_validator) }
|
175
174
|
before do
|
176
|
-
allow(Devise::G5::AuthPasswordValidator)
|
177
|
-
|
175
|
+
allow(Devise::G5::AuthPasswordValidator)
|
176
|
+
.to receive(:new)
|
177
|
+
.and_return(password_validator)
|
178
178
|
end
|
179
179
|
|
180
180
|
context 'with valid current password' do
|
@@ -266,13 +266,15 @@ describe Devise::Models::G5Authenticatable do
|
|
266
266
|
let(:password) { 'foobarbaz' }
|
267
267
|
|
268
268
|
it 'should change the password to nil' do
|
269
|
-
expect { clean_up_passwords }
|
270
|
-
|
269
|
+
expect { clean_up_passwords }
|
270
|
+
.to change { model.password }
|
271
|
+
.from(password).to(nil)
|
271
272
|
end
|
272
273
|
|
273
274
|
it 'should change the password_confirmation to nil' do
|
274
|
-
expect { clean_up_passwords }
|
275
|
-
|
275
|
+
expect { clean_up_passwords }
|
276
|
+
.to change { model.password_confirmation }
|
277
|
+
.from(password).to(nil)
|
276
278
|
end
|
277
279
|
end
|
278
280
|
|
@@ -326,13 +328,10 @@ describe Devise::Models::G5Authenticatable do
|
|
326
328
|
subject(:find_and_update) { model_class.find_and_update_for_g5_oauth(auth_data) }
|
327
329
|
|
328
330
|
let(:auth_data) do
|
329
|
-
OmniAuth::AuthHash.new(
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
email: 'foo@bar.com'},
|
334
|
-
credentials: {token: 'abc123'}
|
335
|
-
})
|
331
|
+
OmniAuth::AuthHash.new(provider: 'g5',
|
332
|
+
uid: '123999',
|
333
|
+
info: { name: 'Foo Bar', email: 'foo@bar.com' },
|
334
|
+
credentials: { token: 'abc123' })
|
336
335
|
end
|
337
336
|
|
338
337
|
context 'when model exists' do
|
@@ -364,19 +363,17 @@ describe Devise::Models::G5Authenticatable do
|
|
364
363
|
subject(:find_for_g5_oauth) { model_class.find_for_g5_oauth(auth_data) }
|
365
364
|
|
366
365
|
let(:auth_data) do
|
367
|
-
OmniAuth::AuthHash.new(
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
email: 'foo@bar.com'},
|
372
|
-
credentials: {token: 'abc123'}
|
373
|
-
})
|
366
|
+
OmniAuth::AuthHash.new(provider: 'g5',
|
367
|
+
uid: uid,
|
368
|
+
info: { name: 'Foo Bar', email: 'foo@bar.com' },
|
369
|
+
credentials: { token: 'abc123' })
|
374
370
|
end
|
375
371
|
|
376
372
|
context 'when model exists' do
|
377
373
|
let!(:model) do
|
378
|
-
create(:user,
|
379
|
-
|
374
|
+
create(:user, email: 'foo@bar.com',
|
375
|
+
provider: auth_data.provider,
|
376
|
+
uid: uid.to_s)
|
380
377
|
end
|
381
378
|
|
382
379
|
context 'when auth data uid is an integer' do
|
@@ -404,6 +401,34 @@ describe Devise::Models::G5Authenticatable do
|
|
404
401
|
end
|
405
402
|
end
|
406
403
|
|
404
|
+
context 'given a model with invalid arguments' do
|
405
|
+
let(:uid) { 42 }
|
406
|
+
|
407
|
+
context 'having an un-existing uid' do
|
408
|
+
let!(:model) do
|
409
|
+
create(:user, email: 'foo@bar.com',
|
410
|
+
provider: auth_data.provider,
|
411
|
+
uid: 0)
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'finds the record by email address' do
|
415
|
+
expect(find_for_g5_oauth).to eq(model)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
context 'having an un-existing uid' do
|
420
|
+
let!(:model) do
|
421
|
+
create(:user, email: 'foo@bar.com',
|
422
|
+
provider: auth_data.provider,
|
423
|
+
uid: 0)
|
424
|
+
end
|
425
|
+
|
426
|
+
it 'finds the record by email address' do
|
427
|
+
expect(find_for_g5_oauth).to eq(model)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
407
432
|
context 'when model does not exist' do
|
408
433
|
let(:uid) { '42' }
|
409
434
|
|
@@ -421,13 +446,10 @@ describe Devise::Models::G5Authenticatable do
|
|
421
446
|
subject(:update_g5_credentials) { model.update_g5_credentials(auth_data) }
|
422
447
|
|
423
448
|
let(:auth_data) do
|
424
|
-
OmniAuth::AuthHash.new(
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
email: 'foo@bar.com'},
|
429
|
-
credentials: {token: 'abc123'}
|
430
|
-
})
|
449
|
+
OmniAuth::AuthHash.new(provider: 'g5',
|
450
|
+
uid: '123999',
|
451
|
+
info: { name: 'Foo Bar', email: 'foo@bar.com' },
|
452
|
+
credentials: { token: 'abc123' })
|
431
453
|
end
|
432
454
|
|
433
455
|
let(:model) do
|
@@ -483,21 +505,20 @@ describe Devise::Models::G5Authenticatable do
|
|
483
505
|
subject(:new_with_session) { model_class.new_with_session(params, session) }
|
484
506
|
|
485
507
|
let(:auth_data) do
|
486
|
-
OmniAuth::AuthHash.new(
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
email: 'foo@bar.com'},
|
491
|
-
credentials: {token: 'abc123'}
|
492
|
-
})
|
508
|
+
OmniAuth::AuthHash.new(provider: 'g5',
|
509
|
+
uid: '123999',
|
510
|
+
info: { name: 'Foo Bar', email: 'foo@bar.com' },
|
511
|
+
credentials: { token: 'abc123' })
|
493
512
|
end
|
494
513
|
|
495
514
|
context 'with params' do
|
496
|
-
let(:params)
|
515
|
+
let(:params) do
|
516
|
+
{ 'email' => email_param }
|
517
|
+
end
|
497
518
|
let(:email_param) { 'my.email.param@test.host' }
|
498
519
|
|
499
520
|
context 'with session data' do
|
500
|
-
let(:session) { {'omniauth.auth' => auth_data} }
|
521
|
+
let(:session) { { 'omniauth.auth' => auth_data } }
|
501
522
|
|
502
523
|
it { is_expected.to be_new_record }
|
503
524
|
|
@@ -537,7 +558,9 @@ describe Devise::Models::G5Authenticatable do
|
|
537
558
|
let(:params) { Hash.new }
|
538
559
|
|
539
560
|
context 'with session data' do
|
540
|
-
let(:session)
|
561
|
+
let(:session) do
|
562
|
+
{ 'omniauth.auth' => auth_data }
|
563
|
+
end
|
541
564
|
|
542
565
|
it { is_expected.to be_new_record }
|
543
566
|
|
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.2.
|
4
|
+
version: 0.2.4.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maeve Revels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -194,9 +194,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
|
-
- - "
|
197
|
+
- - ">"
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version:
|
199
|
+
version: 1.3.1
|
200
200
|
requirements: []
|
201
201
|
rubyforge_project:
|
202
202
|
rubygems_version: 2.2.2
|
@@ -293,4 +293,3 @@ test_files:
|
|
293
293
|
- spec/support/shared_examples/registration_error.rb
|
294
294
|
- spec/support/user_feature_methods.rb
|
295
295
|
- spec/tasks/export_users_spec.rb
|
296
|
-
has_rdoc:
|