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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97c68343930b548666879d796904ea3345cd791b
4
- data.tar.gz: 9a41e522f8fd8ab0ded0d797ce29d2292b272dac
3
+ metadata.gz: 9da8c28deb98850c7e6b1174c64163c2dc694104
4
+ data.tar.gz: b8530a5eb42cab81dc1ceb2c3cc32a6010f56115
5
5
  SHA512:
6
- metadata.gz: 8ff4eeaa114f7693c555bffc53a360a762897fb3f60e8dccee176eaf64c82af9d9e957e044f482826ecc33df5242a0692878c59a8b552a354c49bffed3c73290
7
- data.tar.gz: 1d377a2678b5435e6f11f8003417cb5a25148fe0889f728d23a266160b09fbeb2dbd4356822a83f9531e3d949da9f5818afd39ef9e1887ae2a4b4c3c05ae8687
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?
@@ -1,3 +1,3 @@
1
1
  module G5AuthenticationClient
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -2,12 +2,10 @@ require 'spec_helper'
2
2
  require 'json'
3
3
 
4
4
  describe G5AuthenticationClient::Client do
5
- subject { client }
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
- let(:client) { G5AuthenticationClient::Client.new }
57
-
58
- it { should_not be_debug }
59
- its(:logger) { should be_an_instance_of(Logger) }
60
- its(:username) { should be_nil }
61
- its(:password) { should be_nil }
62
- its(:client_id) { should == G5AuthenticationClient::DEFAULT_CLIENT_ID }
63
- its(:client_secret) { should == G5AuthenticationClient::DEFAULT_CLIENT_SECRET }
64
- its(:redirect_uri) { should == G5AuthenticationClient::DEFAULT_REDIRECT_URI }
65
- its(:endpoint){ should == G5AuthenticationClient::DEFAULT_ENDPOINT}
66
- its(:authorization_code){ should be_nil}
67
- its(:access_token) { should be_nil }
68
- its(:allow_password_credentials) { should == 'true'}
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
- it { should be_debug }
73
- its(:logger) { should == logger }
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
- context 'with nil debug' do
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
- its(:username) { should == username }
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
- its(:password) { should == password }
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
- its(:endpoint){ should == endpoint}
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
- its(:client_id) { should == client_id}
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
- its(:client_secret) {should ==client_secret}
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
- its(:redirect_uri) {should ==redirect_uri}
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
- its(:authorization_code) { should == authorization_code}
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
- its(:access_token) { should == access_token_value }
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
- its(:allow_password_credentials) { should == allow_password_credentials }
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 be_true
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 be_false
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 be_false
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 be_false
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
- let(:test_module) do
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 { should respond_to(:configure) }
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
- it { should_not be_debug }
29
- its(:logger) { should be_an_instance_of(Logger) }
30
- its(:username) {should be_nil}
31
- its(:password) {should be_nil}
32
- its(:client_id) {should == G5AuthenticationClient::DEFAULT_CLIENT_ID}
33
- its(:client_secret) {should == G5AuthenticationClient::DEFAULT_CLIENT_SECRET}
34
- its(:redirect_uri) {should == G5AuthenticationClient::DEFAULT_REDIRECT_URI}
35
- its(:endpoint){should == G5AuthenticationClient::DEFAULT_ENDPOINT}
36
- its(:authorization_code){ should be_nil }
37
- its(:access_token) { should be_nil }
38
- its(:allow_password_credentials) { should eq('true') }
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'] = 'foo'
48
- ENV['G5_AUTH_ALLOW_PASSWORD_CREDENTIALS'] = 'false'
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
- it { should_not be_debug }
59
- its(:logger) { should be_an_instance_of(Logger) }
60
- its(:username) { should eq('foo')}
61
- its(:password) { should be_nil }
62
- its(:client_id) { should == client_id }
63
- its(:client_secret) { should == client_secret }
64
- its(:redirect_uri) { should == redirect_uri }
65
- its(:endpoint) { should == endpoint }
66
- its(:authorization_code) { should be_nil }
67
- its(:access_token) { should be_nil }
68
- its(:allow_password_credentials) { should == allow_password_credentials }
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 { should == test_module }
93
- it { should be_debug }
94
- its(:logger) { should == logger }
95
- its(:username){ should == username }
96
- its(:password){ should == password }
97
- its(:client_id){ should == client_id }
98
- its(:client_secret){ should == client_secret }
99
- its(:redirect_uri){ should == redirect_uri}
100
- its(:endpoint){ should == endpoint}
101
- its(:authorization_code){ should == authorization_code}
102
- its(:access_token) { should == access_token }
103
- its(:allow_password_credentials) { should == allow_password_credentials }
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 = true
110
- config.username = 'foo'
111
- config.password = 'bar'
214
+ config.debug = new_debug
215
+ config.username = new_username
216
+ config.password = new_password
112
217
  end
113
218
  end
114
219
 
115
- it { should == test_module }
220
+ let(:new_username) { 'foo' }
221
+ let(:new_password) { 'bar' }
222
+ let(:new_debug) { true }
116
223
 
117
- it { should be_debug }
118
- its(:logger) { should be_an_instance_of(Logger) }
119
- its(:username) { should == 'foo' }
120
- its(:password) { should == 'bar' }
121
- its(:client_id){ should == G5AuthenticationClient::DEFAULT_CLIENT_ID }
122
- its(:client_secret){ should == G5AuthenticationClient::DEFAULT_CLIENT_SECRET }
123
- its(:redirect_uri){ should == G5AuthenticationClient::DEFAULT_REDIRECT_URI }
124
- its(:endpoint){ should == G5AuthenticationClient::DEFAULT_ENDPOINT}
125
- its(:authorization_code){ should be_nil}
126
- its(:access_token) { should be_nil }
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
- its(:access_token) { should eq(access_token_value) }
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 { should respond_to(:reset) }
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
- its(:username) {should be_nil}
168
- its(:password) {should be_nil}
169
- its(:endpoint) {should == G5AuthenticationClient::DEFAULT_ENDPOINT}
170
- its(:client_id) {should == G5AuthenticationClient::DEFAULT_CLIENT_ID}
171
- its(:client_secret) {should == G5AuthenticationClient::DEFAULT_CLIENT_SECRET}
172
- its(:redirect_uri) {should == G5AuthenticationClient::DEFAULT_REDIRECT_URI}
173
- its(:debug?){ should be_false }
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
- its([:debug]) { should be_true }
199
- its([:logger]) { should == logger }
200
- its([:username]) { should == username }
201
- its([:password]) { should == password }
202
- its([:endpoint]) { should == endpoint }
203
- its([:client_id]) { should == client_id }
204
- its([:client_secret]) { should == client_secret }
205
- its([:redirect_uri]) { should == redirect_uri}
206
- its([:authorization_code]){ should == authorization_code }
207
- its([:access_token]) { should == access_token }
208
- its([:allow_password_credentials]) { should == allow_password_credentials }
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
- its(:resource_owner_id) { should be_nil }
25
- its(:scopes) { should be_empty }
26
- its(:expires_in_seconds) { should be_nil }
27
- its(:application_uid) { should be_nil }
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
- its(:resource_owner_id) { should == resource_owner_id.to_s }
32
- its(:scopes) { should == scopes }
33
- its(:expires_in_seconds) { should == expires_in_seconds.to_i }
34
- its(:application_uid) { should == application_uid }
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 { user }
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
- password: password,
10
- password_confirmation: password_confirmation,
11
- id: id
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
- its(:email) { should be_nil}
24
- its(:password) { should be_nil}
25
- its(:id){ should be_nil}
26
- its(:password_confirmation) { should be_nil }
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
- its(:email) { should == email }
31
- its(:password){ should == password }
32
- its(:password_confirmation) { should == password_confirmation }
33
- its(:id) { should == id}
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
- its(attribute_name){ should == configured_value }
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
- its(attribute_name){ should == default_value }
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
- its(attribute_name){ should == new_value }
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.0
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-03-10 00:00:00.000000000 Z
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.2.0
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: