g5_authentication_client 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/g5_authentication_client/user.rb +26 -0
- data/lib/g5_authentication_client/version.rb +1 -1
- data/spec/g5_authentication_client/client_spec.rb +85 -32
- data/spec/g5_authentication_client/configuration_spec.rb +260 -81
- data/spec/g5_authentication_client/token_info_spec.rb +31 -9
- data/spec/g5_authentication_client/user_spec.rb +106 -14
- data/spec/support/module_configured_attribute.rb +11 -3
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da8c28deb98850c7e6b1174c64163c2dc694104
|
4
|
+
data.tar.gz: b8530a5eb42cab81dc1ceb2c3cc32a6010f56115
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3a70a125ba261f7580db5ba0873c21a3b6c9b12857b80908ee45ed5a6b1324a610261056c3dfb57eb6752ae34597b73bd7a641ffbf23a6ed94d60ec8082c7ad
|
7
|
+
data.tar.gz: 0a5f34d64d22f3194ad5e7b9ec90383c15e305e3c3668125360929b118aa70b2245f667b6561dc54a80dc710b146d92f69461fbd59a1e0432661d91b5ad0e256
|
@@ -4,6 +4,7 @@ module G5AuthenticationClient
|
|
4
4
|
|
5
5
|
#A G5 Authentication User
|
6
6
|
class User < Modelish::Base
|
7
|
+
ignore_unknown_properties!
|
7
8
|
# @!attribute [rw] email
|
8
9
|
# @return [String]
|
9
10
|
# The user's email address.
|
@@ -24,6 +25,31 @@ module G5AuthenticationClient
|
|
24
25
|
# The user's id. Not required to create a user.
|
25
26
|
property :id, type: Integer
|
26
27
|
|
28
|
+
# @!attribute [rw] first_name
|
29
|
+
# @return [String]
|
30
|
+
# The user's first name. Not required to create a user.
|
31
|
+
property :first_name, type: String
|
32
|
+
|
33
|
+
# @!attribute [rw] last_name
|
34
|
+
# @return [String]
|
35
|
+
# The user's last name. Not required to create a user.
|
36
|
+
property :last_name, type: String
|
37
|
+
|
38
|
+
# @!attribute [rw] title
|
39
|
+
# @return [String]
|
40
|
+
# The user's title. Not required to create a user.
|
41
|
+
property :title, type: String
|
42
|
+
|
43
|
+
# @!attribute [rw] organization_name
|
44
|
+
# @return [String]
|
45
|
+
# The user's organization name. Not required to create a user.
|
46
|
+
property :organization_name, type: String
|
47
|
+
|
48
|
+
# @!attribute [rw] phone_number
|
49
|
+
# @return [String]
|
50
|
+
# The user's phone number. Not required to create a user.
|
51
|
+
property :phone_number, type: String
|
52
|
+
|
27
53
|
def validate_for_create!
|
28
54
|
validate!
|
29
55
|
raise ArgumentError.new("Password required for new user.") unless !password.nil?
|
@@ -2,12 +2,10 @@ require 'spec_helper'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
describe G5AuthenticationClient::Client do
|
5
|
-
subject {
|
5
|
+
subject(:client) { G5AuthenticationClient::Client.new(options) }
|
6
6
|
|
7
7
|
after { G5AuthenticationClient.reset }
|
8
8
|
|
9
|
-
let(:client) { G5AuthenticationClient::Client.new(options) }
|
10
|
-
|
11
9
|
let(:debug) { true }
|
12
10
|
let(:logger) { double() }
|
13
11
|
let(:username) {'username'}
|
@@ -53,29 +51,63 @@ describe G5AuthenticationClient::Client do
|
|
53
51
|
let(:returned_user){{id: user_id,email: email}}
|
54
52
|
|
55
53
|
context 'with default configuration' do
|
56
|
-
|
57
|
-
|
58
|
-
it
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
54
|
+
subject(:client) { G5AuthenticationClient::Client.new }
|
55
|
+
|
56
|
+
it 'should not be debug' do
|
57
|
+
expect(client.debug?).to_not be true
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should have a logger' do
|
61
|
+
expect(client.logger).to be_an_instance_of(Logger)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should not have a user name' do
|
65
|
+
expect(client.username).to be_nil
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should not have a password' do
|
69
|
+
expect(client.password).to be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should have default client id' do
|
73
|
+
expect(client.client_id).to eq(G5AuthenticationClient::DEFAULT_CLIENT_ID)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should have default client secret' do
|
77
|
+
expect(client.client_secret).to eq(G5AuthenticationClient::DEFAULT_CLIENT_SECRET)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should have default redirect uri' do
|
81
|
+
expect(client.redirect_uri).to eq(G5AuthenticationClient::DEFAULT_REDIRECT_URI)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should have default endpoint' do
|
85
|
+
expect(client.endpoint).to eq(G5AuthenticationClient::DEFAULT_ENDPOINT)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should have nil authorization code' do
|
89
|
+
expect(client.authorization_code).to be_nil
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should have nil access token' do
|
93
|
+
expect(client.access_token).to be_nil
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should have default allow_password_credentials' do
|
97
|
+
expect(client.allow_password_credentials).to eq('true')
|
98
|
+
end
|
69
99
|
end
|
70
100
|
|
71
101
|
context 'with non-default configuration' do
|
72
|
-
|
73
|
-
|
102
|
+
|
103
|
+
it 'should have debug' do
|
104
|
+
expect(client.debug).to be true
|
105
|
+
end
|
74
106
|
|
75
107
|
describe '#debug=' do
|
76
108
|
subject { client.debug = new_debug }
|
77
109
|
|
78
|
-
|
110
|
+
context 'with nil debug' do
|
79
111
|
let(:new_debug) { nil }
|
80
112
|
|
81
113
|
context 'when there is a debug flag configured at the top-level module' do
|
@@ -135,37 +167,58 @@ describe G5AuthenticationClient::Client do
|
|
135
167
|
end
|
136
168
|
end
|
137
169
|
|
138
|
-
|
170
|
+
it 'should have username' do
|
171
|
+
expect(client.username).to eq(username)
|
172
|
+
end
|
139
173
|
|
140
174
|
it_should_behave_like 'a module configured attribute',:username, nil
|
141
175
|
|
142
|
-
|
176
|
+
it 'should have password' do
|
177
|
+
expect(client.password).to eq(password)
|
178
|
+
end
|
143
179
|
|
144
180
|
it_should_behave_like 'a module configured attribute', :password, nil
|
145
181
|
|
146
|
-
|
182
|
+
it 'should have endpoint' do
|
183
|
+
expect(client.endpoint).to eq(endpoint)
|
184
|
+
end
|
147
185
|
|
148
186
|
it_should_behave_like 'a module configured attribute', :endpoint,G5AuthenticationClient::DEFAULT_ENDPOINT
|
149
187
|
|
150
|
-
|
188
|
+
it 'should have client_id' do
|
189
|
+
expect(client.client_id).to eq(client_id)
|
190
|
+
end
|
151
191
|
|
152
192
|
it_should_behave_like 'a module configured attribute', :client_id, G5AuthenticationClient::DEFAULT_CLIENT_ID
|
153
193
|
|
154
|
-
|
194
|
+
it 'should have client_secret' do
|
195
|
+
expect(client.client_secret).to eq(client_secret)
|
196
|
+
end
|
155
197
|
|
156
198
|
it_should_behave_like 'a module configured attribute', :client_secret, G5AuthenticationClient::DEFAULT_CLIENT_SECRET
|
157
199
|
|
158
|
-
|
200
|
+
it 'should have redirect_uri' do
|
201
|
+
expect(client.redirect_uri).to eq(redirect_uri)
|
202
|
+
end
|
159
203
|
|
160
204
|
it_should_behave_like 'a module configured attribute', :redirect_uri, G5AuthenticationClient::DEFAULT_REDIRECT_URI
|
161
205
|
|
162
|
-
|
206
|
+
it 'should have authorization_code' do
|
207
|
+
expect(client.authorization_code).to eq(authorization_code)
|
208
|
+
end
|
209
|
+
|
163
210
|
it_should_behave_like 'a module configured attribute', :authorization_code, nil
|
164
211
|
|
165
|
-
|
212
|
+
it 'should have access_token' do
|
213
|
+
expect(client.access_token).to eq(access_token)
|
214
|
+
end
|
215
|
+
|
166
216
|
it_should_behave_like 'a module configured attribute', :access_token, nil
|
167
217
|
|
168
|
-
|
218
|
+
it 'should have allow_password_credentials' do
|
219
|
+
expect(client.allow_password_credentials).to eq(allow_password_credentials)
|
220
|
+
end
|
221
|
+
|
169
222
|
it_should_behave_like 'a module configured attribute', :allow_password_credentials, 'true'
|
170
223
|
end
|
171
224
|
|
@@ -178,7 +231,7 @@ describe G5AuthenticationClient::Client do
|
|
178
231
|
context 'with non-nil username and password' do
|
179
232
|
|
180
233
|
it 'should be true' do
|
181
|
-
expect(subject).to
|
234
|
+
expect(subject).to be true
|
182
235
|
end
|
183
236
|
end
|
184
237
|
|
@@ -186,7 +239,7 @@ describe G5AuthenticationClient::Client do
|
|
186
239
|
let(:username) {}
|
187
240
|
|
188
241
|
it 'should be false' do
|
189
|
-
expect(subject).to
|
242
|
+
expect(subject).to be false
|
190
243
|
end
|
191
244
|
end
|
192
245
|
|
@@ -194,7 +247,7 @@ describe G5AuthenticationClient::Client do
|
|
194
247
|
let(:password) {}
|
195
248
|
|
196
249
|
it 'should be false' do
|
197
|
-
expect(subject).to
|
250
|
+
expect(subject).to be false
|
198
251
|
end
|
199
252
|
end
|
200
253
|
end
|
@@ -203,7 +256,7 @@ describe G5AuthenticationClient::Client do
|
|
203
256
|
let(:allow_password_credentials) {'false'}
|
204
257
|
|
205
258
|
it 'should be false' do
|
206
|
-
expect(subject).to
|
259
|
+
expect(subject).to be false
|
207
260
|
end
|
208
261
|
end
|
209
262
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe G5AuthenticationClient::Configuration do
|
4
|
-
|
4
|
+
subject(:test_module) do
|
5
5
|
module TestModule
|
6
6
|
extend G5AuthenticationClient::Configuration
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
subject { test_module }
|
11
|
-
|
12
10
|
let(:logger) { double() }
|
13
11
|
let(:username) {'username'}
|
14
12
|
let(:password) {'password'}
|
@@ -19,23 +17,63 @@ describe G5AuthenticationClient::Configuration do
|
|
19
17
|
let(:authorization_code){ 'code' }
|
20
18
|
let(:access_token) { 'access_token_test' }
|
21
19
|
let(:allow_password_credentials) { 'false' }
|
20
|
+
let(:first_name) { 'Joe' }
|
21
|
+
let(:last_name) { 'Person' }
|
22
|
+
let(:organization_name) { 'Things, Inc.' }
|
23
|
+
let(:phone_number) { '8675309123' }
|
24
|
+
let(:title) { 'Developer' }
|
22
25
|
|
23
26
|
after { test_module.reset }
|
24
27
|
|
25
|
-
it
|
28
|
+
it 'should respond to configure' do
|
29
|
+
expect(test_module).to respond_to(:configure)
|
30
|
+
end
|
26
31
|
|
27
32
|
context 'with default configuration' do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
|
34
|
+
it 'should not be debug' do
|
35
|
+
expect(test_module.debug?).to be false
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have a logger' do
|
39
|
+
expect(test_module.logger).to be_instance_of(Logger)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have nil username' do
|
43
|
+
expect(test_module.username).to be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should have nil password' do
|
47
|
+
expect(test_module.password).to be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should have default client id' do
|
51
|
+
expect(test_module.client_id).to eq(G5AuthenticationClient::DEFAULT_CLIENT_ID)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have default client_secret' do
|
55
|
+
expect(test_module.client_secret).to eq(G5AuthenticationClient::DEFAULT_CLIENT_SECRET)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have default redirect_uri' do
|
59
|
+
expect(test_module.redirect_uri).to eq(G5AuthenticationClient::DEFAULT_REDIRECT_URI)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should have default endpoint' do
|
63
|
+
expect(test_module.endpoint).to eq(G5AuthenticationClient::DEFAULT_ENDPOINT)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should have nil authorization_code' do
|
67
|
+
expect(test_module.authorization_code).to be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should have nil access_token' do
|
71
|
+
expect(test_module.access_token).to be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should allow password credentials' do
|
75
|
+
expect(test_module.allow_password_credentials).to eq(G5AuthenticationClient::DEFAULT_ALLOW_PASSWORD_CREDENTIALS)
|
76
|
+
end
|
39
77
|
end
|
40
78
|
|
41
79
|
context 'with environment variable configuration' do
|
@@ -44,8 +82,8 @@ describe G5AuthenticationClient::Configuration do
|
|
44
82
|
ENV['G5_AUTH_CLIENT_SECRET'] = client_secret
|
45
83
|
ENV['G5_AUTH_REDIRECT_URI'] = redirect_uri
|
46
84
|
ENV['G5_AUTH_ENDPOINT'] = endpoint
|
47
|
-
ENV['G5_AUTH_USERNAME'] =
|
48
|
-
ENV['G5_AUTH_ALLOW_PASSWORD_CREDENTIALS'] =
|
85
|
+
ENV['G5_AUTH_USERNAME'] = new_username
|
86
|
+
ENV['G5_AUTH_ALLOW_PASSWORD_CREDENTIALS'] = new_allow_password_credentials
|
49
87
|
end
|
50
88
|
|
51
89
|
after do
|
@@ -55,22 +93,58 @@ describe G5AuthenticationClient::Configuration do
|
|
55
93
|
ENV['G5_AUTH_ENDPOINT'] = nil
|
56
94
|
end
|
57
95
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
96
|
+
let(:new_username) { 'foo' }
|
97
|
+
|
98
|
+
let(:new_allow_password_credentials) { 'false' }
|
99
|
+
|
100
|
+
it 'should not be debug' do
|
101
|
+
expect(test_module.debug?).to be false
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should have a logger' do
|
105
|
+
expect(test_module.logger).to be_instance_of(Logger)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should have username' do
|
109
|
+
expect(test_module.username).to eq(new_username)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should have nil password' do
|
113
|
+
expect(test_module.password).to be_nil
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should have default client id' do
|
117
|
+
expect(test_module.client_id).to eq(client_id)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should have default client_secret' do
|
121
|
+
expect(test_module.client_secret).to eq(client_secret)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should have default redirect_uri' do
|
125
|
+
expect(test_module.redirect_uri).to eq(redirect_uri)
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should have default endpoint' do
|
129
|
+
expect(test_module.endpoint).to eq(endpoint)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should have nil authorization_code' do
|
133
|
+
expect(test_module.authorization_code).to be_nil
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should have nil access_token' do
|
137
|
+
expect(test_module.access_token).to be_nil
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should not allow password credentials' do
|
141
|
+
expect(test_module.allow_password_credentials).to eq(new_allow_password_credentials)
|
142
|
+
end
|
69
143
|
|
70
144
|
end
|
71
145
|
|
72
146
|
describe '.configure' do
|
73
|
-
subject { test_module.configure(&config_block) }
|
147
|
+
subject(:configure) { test_module.configure(&config_block) }
|
74
148
|
|
75
149
|
context 'with full configuration' do
|
76
150
|
let(:config_block) do
|
@@ -89,41 +163,107 @@ describe G5AuthenticationClient::Configuration do
|
|
89
163
|
end
|
90
164
|
end
|
91
165
|
|
92
|
-
it
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
166
|
+
it 'should be debug' do
|
167
|
+
expect(configure.debug?).to be true
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'should have a logger' do
|
171
|
+
expect(configure.logger).to eq(logger)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should have username' do
|
175
|
+
expect(configure.username).to eq(username)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'should have the correct password' do
|
179
|
+
expect(configure.password).to eq(password)
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should have the correct client id' do
|
183
|
+
expect(configure.client_id).to eq(client_id)
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should have the correct client_secret' do
|
187
|
+
expect(configure.client_secret).to eq(client_secret)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should have the correct redirect_uri' do
|
191
|
+
expect(configure.redirect_uri).to eq(redirect_uri)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should have the correct endpoint' do
|
195
|
+
expect(configure.endpoint).to eq(endpoint)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should have the correct authorization_code' do
|
199
|
+
expect(configure.authorization_code).to eq(authorization_code)
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should have the correct access_token' do
|
203
|
+
expect(configure.access_token).to eq(access_token)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should have the correct value for allowing password credentials' do
|
207
|
+
expect(configure.allow_password_credentials).to eq(allow_password_credentials)
|
208
|
+
end
|
104
209
|
end
|
105
210
|
|
106
211
|
context 'with partial configuration' do
|
107
212
|
let(:config_block) do
|
108
213
|
lambda do |config|
|
109
|
-
config.debug =
|
110
|
-
config.username =
|
111
|
-
config.password =
|
214
|
+
config.debug = new_debug
|
215
|
+
config.username = new_username
|
216
|
+
config.password = new_password
|
112
217
|
end
|
113
218
|
end
|
114
219
|
|
115
|
-
|
220
|
+
let(:new_username) { 'foo' }
|
221
|
+
let(:new_password) { 'bar' }
|
222
|
+
let(:new_debug) { true }
|
116
223
|
|
117
|
-
it
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
224
|
+
it 'should be debug' do
|
225
|
+
expect(configure.debug?).to be new_debug
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'should have a logger' do
|
229
|
+
expect(configure.logger).to be_instance_of(Logger)
|
230
|
+
end
|
231
|
+
|
232
|
+
it 'should have username' do
|
233
|
+
expect(configure.username).to eq(new_username)
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should have the correct password' do
|
237
|
+
expect(configure.password).to eq(new_password)
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'should have default client id' do
|
241
|
+
expect(test_module.client_id).to eq(G5AuthenticationClient::DEFAULT_CLIENT_ID)
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'should have default client_secret' do
|
245
|
+
expect(test_module.client_secret).to eq(G5AuthenticationClient::DEFAULT_CLIENT_SECRET)
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should have default redirect_uri' do
|
249
|
+
expect(test_module.redirect_uri).to eq(G5AuthenticationClient::DEFAULT_REDIRECT_URI)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should have default endpoint' do
|
253
|
+
expect(test_module.endpoint).to eq(G5AuthenticationClient::DEFAULT_ENDPOINT)
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'should have nil authorization_code' do
|
257
|
+
expect(configure.authorization_code).to be_nil
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'should have nil access_token' do
|
261
|
+
expect(configure.access_token).to be_nil
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'should not allow password credentials' do
|
265
|
+
expect(configure.allow_password_credentials).to eq(G5AuthenticationClient::DEFAULT_ALLOW_PASSWORD_CREDENTIALS)
|
266
|
+
end
|
127
267
|
|
128
268
|
context 'when there is an env variable default' do
|
129
269
|
|
@@ -137,13 +277,16 @@ describe G5AuthenticationClient::Configuration do
|
|
137
277
|
ENV['G5_AUTH_ACCESS_TOKEN']=nil
|
138
278
|
end
|
139
279
|
|
140
|
-
|
141
|
-
|
280
|
+
it 'should have correct access_token' do
|
281
|
+
expect(configure.access_token).to eq(access_token_value)
|
282
|
+
end
|
142
283
|
end
|
143
284
|
end
|
144
285
|
end
|
145
286
|
|
146
|
-
it
|
287
|
+
it 'should reset' do
|
288
|
+
expect(test_module).to respond_to(:reset)
|
289
|
+
end
|
147
290
|
|
148
291
|
describe '.reset' do
|
149
292
|
before do
|
@@ -162,18 +305,51 @@ describe G5AuthenticationClient::Configuration do
|
|
162
305
|
end
|
163
306
|
end
|
164
307
|
|
165
|
-
subject { test_module.reset;test_module }
|
308
|
+
subject(:reset) { test_module.reset;test_module }
|
309
|
+
|
310
|
+
it 'should not be debug' do
|
311
|
+
expect(reset.debug?).to be false
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'should have a logger' do
|
315
|
+
expect(reset.logger).to be_instance_of(Logger)
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'should have nil username' do
|
319
|
+
expect(reset.username).to be_nil
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'should have nil password' do
|
323
|
+
expect(reset.password).to be_nil
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'should have default client id' do
|
327
|
+
expect(reset.client_id).to eq(G5AuthenticationClient::DEFAULT_CLIENT_ID)
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'should have default client_secret' do
|
331
|
+
expect(reset.client_secret).to eq(G5AuthenticationClient::DEFAULT_CLIENT_SECRET)
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'should have default redirect_uri' do
|
335
|
+
expect(reset.redirect_uri).to eq(G5AuthenticationClient::DEFAULT_REDIRECT_URI)
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should have default endpoint' do
|
339
|
+
expect(reset.endpoint).to eq(G5AuthenticationClient::DEFAULT_ENDPOINT)
|
340
|
+
end
|
341
|
+
|
342
|
+
it 'should have nil authorization_code' do
|
343
|
+
expect(reset.authorization_code).to be_nil
|
344
|
+
end
|
166
345
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
its(:logger){ should be_instance_of(Logger) }
|
175
|
-
its(:access_token) { should be_nil }
|
176
|
-
its(:allow_password_credentials) { should == 'true' }
|
346
|
+
it 'should have nil access_token' do
|
347
|
+
expect(reset.access_token).to be_nil
|
348
|
+
end
|
349
|
+
|
350
|
+
it 'should allow password credentials' do
|
351
|
+
expect(reset.allow_password_credentials).to eq(G5AuthenticationClient::DEFAULT_ALLOW_PASSWORD_CREDENTIALS)
|
352
|
+
end
|
177
353
|
end
|
178
354
|
|
179
355
|
describe '.options' do
|
@@ -193,18 +369,21 @@ describe G5AuthenticationClient::Configuration do
|
|
193
369
|
end
|
194
370
|
end
|
195
371
|
|
196
|
-
subject { test_module.options }
|
372
|
+
subject(:options) { test_module.options }
|
197
373
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
374
|
+
it "should have correct options" do
|
375
|
+
options.should include(
|
376
|
+
debug: 'true',
|
377
|
+
username: username,
|
378
|
+
password: password,
|
379
|
+
endpoint: endpoint,
|
380
|
+
client_id: client_id,
|
381
|
+
client_secret: client_secret,
|
382
|
+
redirect_uri: redirect_uri,
|
383
|
+
authorization_code: authorization_code,
|
384
|
+
access_token: access_token,
|
385
|
+
allow_password_credentials: allow_password_credentials
|
386
|
+
)
|
387
|
+
end
|
209
388
|
end
|
210
389
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe G5AuthenticationClient::TokenInfo do
|
4
|
-
subject { token_info }
|
4
|
+
subject(:token) { token_info }
|
5
5
|
let(:token_info) { described_class.new(attributes) }
|
6
6
|
|
7
7
|
let(:attributes) do
|
@@ -21,16 +21,38 @@ describe G5AuthenticationClient::TokenInfo do
|
|
21
21
|
context 'with default initialization' do
|
22
22
|
let(:attributes) {}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
it 'should have nil resource_owner_id' do
|
25
|
+
expect(token.resource_owner_id).to be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should have nil scopes' do
|
29
|
+
expect(token.scopes).to be_empty
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have nil expires_in_seconds' do
|
33
|
+
expect(token.expires_in_seconds).to be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have nil application_uid' do
|
37
|
+
expect(token.application_uid).to be_nil
|
38
|
+
end
|
28
39
|
end
|
29
40
|
|
30
41
|
context 'with full initialization' do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
it 'should have resource_owner_id' do
|
43
|
+
expect(token.resource_owner_id).to eq(resource_owner_id.to_s)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should have scopes' do
|
47
|
+
expect(token.scopes).to eq(scopes)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should have expires_in_seconds' do
|
51
|
+
expect(token.expires_in_seconds).to eq(expires_in_seconds.to_i)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have application_uid' do
|
55
|
+
expect(token.application_uid).to eq(application_uid)
|
56
|
+
end
|
35
57
|
end
|
36
58
|
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe G5AuthenticationClient::User do
|
4
|
-
subject {
|
5
|
-
let(:user){G5AuthenticationClient::User.new(attributes)}
|
4
|
+
subject(:user) { G5AuthenticationClient::User.new(attributes) }
|
6
5
|
|
7
6
|
let(:attributes) do
|
8
|
-
{email: email,
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
{ email: email,
|
8
|
+
password: password,
|
9
|
+
password_confirmation: password_confirmation,
|
10
|
+
id: id,
|
11
|
+
first_name: first_name,
|
12
|
+
last_name: last_name,
|
13
|
+
title: title,
|
14
|
+
organization_name: organization_name,
|
15
|
+
phone_number: phone_number
|
12
16
|
}
|
13
17
|
end
|
14
18
|
|
@@ -16,21 +20,69 @@ describe G5AuthenticationClient::User do
|
|
16
20
|
let(:password) { 'foobarbaz' }
|
17
21
|
let(:password_confirmation) { 'notamatch' }
|
18
22
|
let(:id) {1}
|
23
|
+
let(:first_name) { 'Joe' }
|
24
|
+
let(:last_name) { 'Person' }
|
25
|
+
let(:organization_name) { 'Things, Inc.' }
|
26
|
+
let(:phone_number) { '8675309123' }
|
27
|
+
let(:title) { 'Developer' }
|
19
28
|
|
20
29
|
context 'with default initialization' do
|
21
30
|
let(:attributes){}
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
it 'should have nil email' do
|
33
|
+
expect(user.email).to be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have nil password' do
|
37
|
+
expect(user.password).to be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have nil id ' do
|
41
|
+
expect(user.id).to be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have nil password_confirmation' do
|
45
|
+
expect(user.password_confirmation).to be_nil
|
46
|
+
end
|
27
47
|
end
|
28
48
|
|
29
49
|
context 'with full initialization' do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
50
|
+
|
51
|
+
it 'should have correct email' do
|
52
|
+
expect(user.email).to eq(email)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should have correct password' do
|
56
|
+
expect(user.password).to eq(password)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should have correct password_confirmation' do
|
60
|
+
expect(user.password_confirmation).to eq(password_confirmation)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should have correct id' do
|
64
|
+
expect(user.id).to eq(id)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should have correct first_name' do
|
68
|
+
expect(user.first_name).to eq(first_name)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should have correct last_name' do
|
72
|
+
expect(user.last_name).to eq(last_name)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should have correct title' do
|
76
|
+
expect(user.title).to eq(title)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should have correct phone_number' do
|
80
|
+
expect(user.phone_number).to eq(phone_number)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should have correct organization_name' do
|
84
|
+
expect(user.organization_name).to eq(organization_name)
|
85
|
+
end
|
34
86
|
end
|
35
87
|
|
36
88
|
describe '#validate!' do
|
@@ -67,6 +119,46 @@ describe G5AuthenticationClient::User do
|
|
67
119
|
expect { validate! }.to_not raise_error
|
68
120
|
end
|
69
121
|
end
|
122
|
+
|
123
|
+
context 'without first_name' do
|
124
|
+
let(:first_name) {}
|
125
|
+
|
126
|
+
it 'should not raise an error' do
|
127
|
+
expect { validate! }.to_not raise_error
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'without last_name' do
|
132
|
+
let(:last_name) {}
|
133
|
+
|
134
|
+
it 'should not raise an error' do
|
135
|
+
expect { validate! }.to_not raise_error
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'without title' do
|
140
|
+
let(:title) {}
|
141
|
+
|
142
|
+
it 'should not raise an error' do
|
143
|
+
expect { validate! }.to_not raise_error
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'without phone_number' do
|
148
|
+
let(:phone_number) {}
|
149
|
+
|
150
|
+
it 'should not raise an error' do
|
151
|
+
expect { validate! }.to_not raise_error
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'without organization_name' do
|
156
|
+
let(:organization_name) {}
|
157
|
+
|
158
|
+
it 'should not raise an error' do
|
159
|
+
expect { validate! }.to_not raise_error
|
160
|
+
end
|
161
|
+
end
|
70
162
|
end
|
71
163
|
|
72
164
|
describe '#validate_for_create!' do
|
@@ -20,18 +20,26 @@ shared_examples_for 'a module configured attribute' do |attribute_name,default_v
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
it "should have correct #{attribute_name}" do
|
24
|
+
expect(subject.send(attribute_name)).to eq(configured_value)
|
25
|
+
end
|
26
|
+
|
24
27
|
end
|
25
28
|
|
26
29
|
context 'without module configured #{attribute_name}' do
|
27
|
-
|
30
|
+
|
31
|
+
it "should have correct #{attribute_name}" do
|
32
|
+
expect(subject.send(attribute_name)).to eq(default_value)
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
37
|
context 'with new #{attribute_name.to_s}' do
|
32
38
|
let(:new_value){ 'userdude' }
|
33
39
|
|
34
|
-
|
40
|
+
it "should have correct #{attribute_name}" do
|
41
|
+
expect(subject.send(attribute_name)).to eq(new_value)
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g5_authentication_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Revels
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: modelish
|
@@ -244,9 +244,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
version: '0'
|
245
245
|
requirements: []
|
246
246
|
rubyforge_project: g5_authentication_client
|
247
|
-
rubygems_version: 2.
|
247
|
+
rubygems_version: 2.1.11
|
248
248
|
signing_key:
|
249
249
|
specification_version: 4
|
250
250
|
summary: Client for the G5 Auth service
|
251
|
-
test_files:
|
251
|
+
test_files:
|
252
|
+
- spec/g5_authentication_client/client_spec.rb
|
253
|
+
- spec/g5_authentication_client/configuration_spec.rb
|
254
|
+
- spec/g5_authentication_client/token_info_spec.rb
|
255
|
+
- spec/g5_authentication_client/user_spec.rb
|
256
|
+
- spec/g5_authentication_client_spec.rb
|
257
|
+
- spec/spec_helper.rb
|
258
|
+
- spec/support/module_configured_attribute.rb
|
259
|
+
- spec/support/oauth_protected_resource.rb
|
252
260
|
has_rdoc:
|