omniauth-identity 3.0.2 → 3.0.7

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.
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples 'instance with instance methods' do
4
+ describe '#initialize' do
5
+ it 'does not raise an error' do
6
+ block_is_expected.not_to raise_error
7
+ end
8
+ end
9
+
10
+ describe '#uid' do
11
+ it 'defaults to #id' do
12
+ allow(instance).to receive(:respond_to?).with(:id).and_return(true)
13
+ allow(instance).to receive(:id).and_return 'wakka-do'
14
+ expect(instance.uid).to eq('wakka-do')
15
+ end
16
+
17
+ it 'stringifies it' do
18
+ allow(instance).to receive(:id).and_return 123
19
+ expect(instance.uid).to eq('123')
20
+ end
21
+
22
+ it 'raises NotImplementedError if #id is not defined' do
23
+ allow(instance).to receive(:respond_to?).with(:id).and_return(false)
24
+ expect { instance.uid }.to raise_error(NotImplementedError)
25
+ end
26
+ end
27
+
28
+ describe '#auth_key' do
29
+ it 'defaults to #email' do
30
+ allow(instance).to receive(:respond_to?).with(:email).and_return(true)
31
+ allow(instance).to receive(:email).and_return('bob@bob.com')
32
+ expect(instance.auth_key).to eq('bob@bob.com')
33
+ end
34
+
35
+ it 'uses the class .auth_key' do
36
+ instance.class.auth_key 'login'
37
+ allow(instance).to receive(:login).and_return 'bob'
38
+ expect(instance.auth_key).to eq('bob')
39
+ instance.class.auth_key nil
40
+ end
41
+ end
42
+
43
+ describe '#auth_key=' do
44
+ it 'defaults to setting email' do
45
+ allow(instance).to receive(:respond_to?).with(:email=).and_return(true)
46
+ expect(instance).to receive(:email=).with 'abc'
47
+
48
+ instance.auth_key = 'abc'
49
+ end
50
+
51
+ it 'uses a custom .auth_key if one is provided' do
52
+ instance.class.auth_key 'login'
53
+ allow(instance).to receive(:respond_to?).with(:login=).and_return(true)
54
+ expect(instance).to receive(:login=).with('abc')
55
+
56
+ instance.auth_key = 'abc'
57
+ end
58
+ end
59
+
60
+ describe '#info' do
61
+ it 'includes all attributes as they have been set' do
62
+ allow(instance).to receive(:name).and_return('Bob Bobson')
63
+ allow(instance).to receive(:nickname).and_return('bob')
64
+
65
+ expect(instance.info).to include({
66
+ 'name' => 'Bob Bobson',
67
+ 'nickname' => 'bob'
68
+ })
69
+ end
70
+
71
+ it 'uses firstname and lastname, over nickname, to set missing name' do
72
+ allow(instance).to receive(:first_name).and_return('shoeless')
73
+ allow(instance).to receive(:last_name).and_return('joe')
74
+ allow(instance).to receive(:nickname).and_return('george')
75
+ instance.info['name'] == 'shoeless joe'
76
+ end
77
+
78
+ it 'uses nickname to set missing name when first and last are not set' do
79
+ allow(instance).to receive(:nickname).and_return('bob')
80
+ instance.info['name'] == 'bob'
81
+ end
82
+
83
+ it 'does not overwrite a provided name' do
84
+ allow(instance).to receive(:name).and_return('Awesome Dude')
85
+ allow(instance).to receive(:first_name).and_return('Frank')
86
+ expect(instance.info['name']).to eq('Awesome Dude')
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_examples 'model with class methods' do
4
+ describe 'class definition' do
5
+ it 'does not raise an error' do
6
+ block_is_expected.not_to raise_error
7
+ end
8
+ end
9
+
10
+ describe '::authenticate' do
11
+ it 'calls locate and then authenticate' do
12
+ mocked_instance = double('ExampleModel', authenticate: 'abbadoo')
13
+ allow(model_klass).to receive(:locate).with('email' => 'example').and_return(mocked_instance)
14
+ expect(model_klass.authenticate({ 'email' => 'example' }, 'pass')).to eq('abbadoo')
15
+ end
16
+
17
+ it 'calls locate with additional scopes when provided' do
18
+ mocked_instance = double('ExampleModel', authenticate: 'abbadoo')
19
+ allow(model_klass).to receive(:locate).with('email' => 'example',
20
+ 'user_type' => 'admin').and_return(mocked_instance)
21
+ expect(model_klass.authenticate({ 'email' => 'example', 'user_type' => 'admin' }, 'pass')).to eq('abbadoo')
22
+ end
23
+
24
+ it 'recovers gracefully if locate is nil' do
25
+ allow(model_klass).to receive(:locate).and_return(nil)
26
+ expect(model_klass.authenticate('blah', 'foo')).to be false
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.shared_context 'persistable model' do
4
+ include_context 'model with class methods'
5
+
6
+ describe 'instance methods' do
7
+ subject(:instance) { model_klass.new }
8
+
9
+ include_context 'instance with instance methods'
10
+
11
+ describe '#save' do
12
+ subject(:save) do
13
+ instance.email = DEFAULT_EMAIL
14
+ instance.password = DEFAULT_PASSWORD
15
+ instance.password_confirmation = DEFAULT_PASSWORD
16
+ instance.save
17
+ end
18
+
19
+ it 'does not raise an error' do
20
+ save
21
+ end
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-identity
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-02-14 00:00:00.000000000 Z
13
+ date: 2021-03-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bcrypt
@@ -41,75 +41,61 @@ dependencies:
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
- name: anonymous_active_record
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.0.7
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 1.0.7
57
- - !ruby/object:Gem::Dependency
58
- name: mongoid
44
+ name: rack-test
59
45
  requirement: !ruby/object:Gem::Requirement
60
46
  requirements:
61
47
  - - "~>"
62
48
  - !ruby/object:Gem::Version
63
- version: '7'
49
+ version: '1'
64
50
  type: :development
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
54
  - - "~>"
69
55
  - !ruby/object:Gem::Version
70
- version: '7'
56
+ version: '1'
71
57
  - !ruby/object:Gem::Dependency
72
- name: rack-test
58
+ name: rake
73
59
  requirement: !ruby/object:Gem::Requirement
74
60
  requirements:
75
61
  - - "~>"
76
62
  - !ruby/object:Gem::Version
77
- version: '1'
63
+ version: '13'
78
64
  type: :development
79
65
  prerelease: false
80
66
  version_requirements: !ruby/object:Gem::Requirement
81
67
  requirements:
82
68
  - - "~>"
83
69
  - !ruby/object:Gem::Version
84
- version: '1'
70
+ version: '13'
85
71
  - !ruby/object:Gem::Dependency
86
- name: rake
72
+ name: rspec
87
73
  requirement: !ruby/object:Gem::Requirement
88
74
  requirements:
89
75
  - - "~>"
90
76
  - !ruby/object:Gem::Version
91
- version: '13'
77
+ version: '3'
92
78
  type: :development
93
79
  prerelease: false
94
80
  version_requirements: !ruby/object:Gem::Requirement
95
81
  requirements:
96
82
  - - "~>"
97
83
  - !ruby/object:Gem::Version
98
- version: '13'
84
+ version: '3'
99
85
  - !ruby/object:Gem::Dependency
100
- name: rspec
86
+ name: rspec-block_is_expected
101
87
  requirement: !ruby/object:Gem::Requirement
102
88
  requirements:
103
89
  - - "~>"
104
90
  - !ruby/object:Gem::Version
105
- version: '3'
91
+ version: '1.0'
106
92
  type: :development
107
93
  prerelease: false
108
94
  version_requirements: !ruby/object:Gem::Requirement
109
95
  requirements:
110
96
  - - "~>"
111
97
  - !ruby/object:Gem::Version
112
- version: '3'
98
+ version: '1.0'
113
99
  - !ruby/object:Gem::Dependency
114
100
  name: sqlite3
115
101
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +110,7 @@ dependencies:
124
110
  - - "~>"
125
111
  - !ruby/object:Gem::Version
126
112
  version: '1.4'
127
- description: Internal authentication handlers for OmniAuth.
113
+ description: Traditional username/password based authentication system for OmniAuth
128
114
  email:
129
115
  executables: []
130
116
  extensions: []
@@ -141,15 +127,19 @@ files:
141
127
  - lib/omniauth/identity/models/active_record.rb
142
128
  - lib/omniauth/identity/models/couch_potato.rb
143
129
  - lib/omniauth/identity/models/mongoid.rb
130
+ - lib/omniauth/identity/models/nobrainer.rb
131
+ - lib/omniauth/identity/models/sequel.rb
144
132
  - lib/omniauth/identity/secure_password.rb
145
133
  - lib/omniauth/strategies/identity.rb
146
134
  - spec/omniauth/identity/model_spec.rb
147
135
  - spec/omniauth/identity/models/active_record_spec.rb
148
- - spec/omniauth/identity/models/couch_potato_spec.rb
149
- - spec/omniauth/identity/models/mongoid_spec.rb
136
+ - spec/omniauth/identity/models/sequel_spec.rb
150
137
  - spec/omniauth/identity/secure_password_spec.rb
151
138
  - spec/omniauth/strategies/identity_spec.rb
152
139
  - spec/spec_helper.rb
140
+ - spec/support/shared_contexts/instance_with_instance_methods.rb
141
+ - spec/support/shared_contexts/model_with_class_methods.rb
142
+ - spec/support/shared_contexts/persistable_model.rb
153
143
  homepage: http://github.com/omniauth/omniauth-identity
154
144
  licenses:
155
145
  - MIT
@@ -170,15 +160,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
160
  - !ruby/object:Gem::Version
171
161
  version: 1.3.6
172
162
  requirements: []
173
- rubygems_version: 3.2.3
163
+ rubygems_version: 3.2.9
174
164
  signing_key:
175
165
  specification_version: 4
176
- summary: Internal authentication handlers for OmniAuth.
166
+ summary: Traditional username/password based authentication system for OmniAuth
177
167
  test_files:
178
- - spec/omniauth/identity/model_spec.rb
168
+ - spec/spec_helper.rb
169
+ - spec/support/shared_contexts/persistable_model.rb
170
+ - spec/support/shared_contexts/model_with_class_methods.rb
171
+ - spec/support/shared_contexts/instance_with_instance_methods.rb
179
172
  - spec/omniauth/identity/models/active_record_spec.rb
180
- - spec/omniauth/identity/models/couch_potato_spec.rb
181
- - spec/omniauth/identity/models/mongoid_spec.rb
173
+ - spec/omniauth/identity/models/sequel_spec.rb
182
174
  - spec/omniauth/identity/secure_password_spec.rb
175
+ - spec/omniauth/identity/model_spec.rb
183
176
  - spec/omniauth/strategies/identity_spec.rb
184
- - spec/spec_helper.rb
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe(OmniAuth::Identity::Models::CouchPotatoModule, db: true) do
4
- class CouchPotatoTestIdentity
5
- include CouchPotato::Persistence
6
- include OmniAuth::Identity::Models::CouchPotatoModule
7
- auth_key :ham_sandwich
8
- end
9
-
10
- describe 'model', type: :model do
11
- subject { CouchPotatoTestIdentity }
12
-
13
- it 'delegates locate to the where query method' do
14
- allow(subject).to receive(:where).with('ham_sandwich' => 'open faced',
15
- 'category' => 'sandwiches').and_return(['wakka'])
16
- expect(subject.locate('ham_sandwich' => 'open faced', 'category' => 'sandwiches')).to eq('wakka')
17
- end
18
- end
19
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe(OmniAuth::Identity::Models::Mongoid, db: true) do
4
- class MongoidTestIdentity
5
- include Mongoid::Document
6
- include OmniAuth::Identity::Models::Mongoid
7
- auth_key :ham_sandwich
8
- store_in database: 'db1', collection: 'mongoid_test_identities', client: 'secondary'
9
- end
10
-
11
- describe 'model', type: :model do
12
- subject { MongoidTestIdentity }
13
-
14
- it { is_expected.to be_mongoid_document }
15
-
16
- it 'does not munge collection name' do
17
- expect(subject).to be_stored_in(database: 'db1', collection: 'mongoid_test_identities', client: 'secondary')
18
- end
19
-
20
- it 'delegates locate to the where query method' do
21
- allow(subject).to receive(:where).with('ham_sandwich' => 'open faced',
22
- 'category' => 'sandwiches').and_return(['wakka'])
23
- expect(subject.locate('ham_sandwich' => 'open faced', 'category' => 'sandwiches')).to eq('wakka')
24
- end
25
- end
26
- end