stormpath-sdk 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +3 -3
- data/CHANGES.md +8 -0
- data/lib/stormpath-sdk.rb +8 -0
- data/lib/stormpath-sdk/auth/create_factor.rb +64 -0
- data/lib/stormpath-sdk/data_store.rb +17 -1
- data/lib/stormpath-sdk/oauth/authenticator.rb +2 -1
- data/lib/stormpath-sdk/oauth/challenge_factor_grant.rb +25 -0
- data/lib/stormpath-sdk/oauth/challenge_factor_grant_request.rb +16 -0
- data/lib/stormpath-sdk/resource/account.rb +6 -0
- data/lib/stormpath-sdk/resource/account_link.rb +1 -1
- data/lib/stormpath-sdk/resource/challenge.rb +26 -0
- data/lib/stormpath-sdk/resource/collection.rb +0 -1
- data/lib/stormpath-sdk/resource/directory.rb +1 -0
- data/lib/stormpath-sdk/resource/factor.rb +26 -0
- data/lib/stormpath-sdk/resource/field.rb +20 -0
- data/lib/stormpath-sdk/resource/linked_account.rb +1 -1
- data/lib/stormpath-sdk/resource/phone.rb +21 -0
- data/lib/stormpath-sdk/resource/schema.rb +21 -0
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/auth/create_factor_spec.rb +92 -0
- data/spec/auth/http_basic_authentication_spec.rb +3 -3
- data/spec/auth/http_bearer_authentication_spec.rb +3 -3
- data/spec/client_spec.rb +25 -25
- data/spec/oauth/access_token_authentication_result_spec.rb +3 -3
- data/spec/provider/provider_spec.rb +2 -2
- data/spec/resource/account_creation_policy_spec.rb +2 -2
- data/spec/resource/account_link_spec.rb +2 -2
- data/spec/resource/account_spec.rb +196 -12
- data/spec/resource/account_store_mapping_spec.rb +3 -3
- data/spec/resource/account_store_spec.rb +4 -4
- data/spec/resource/api_key_spec.rb +3 -3
- data/spec/resource/application_spec.rb +74 -33
- data/spec/resource/challenge_spec.rb +53 -0
- data/spec/resource/collection_spec.rb +6 -6
- data/spec/resource/custom_data_spec.rb +2 -2
- data/spec/resource/directory_spec.rb +27 -21
- data/spec/resource/email_template_spec.rb +2 -2
- data/spec/resource/factor_spec.rb +124 -0
- data/spec/resource/field_spec.rb +35 -0
- data/spec/resource/group_membership_spec.rb +3 -3
- data/spec/resource/group_spec.rb +3 -3
- data/spec/resource/linked_account_spec.rb +2 -2
- data/spec/resource/organization_spec.rb +6 -6
- data/spec/resource/password_policy_spec.rb +2 -2
- data/spec/resource/password_strength_spec.rb +2 -2
- data/spec/resource/phone_spec.rb +63 -0
- data/spec/resource/schema_spec.rb +39 -0
- data/spec/resource/status_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -3
- data/spec/support/custom_data_storage_behavior.rb +2 -2
- data/spec/support/mocked_provider_accounts.rb +106 -0
- data/spec/support/resource_helpers.rb +20 -16
- metadata +16 -2
@@ -28,6 +28,30 @@ module Stormpath
|
|
28
28
|
MultiJson.dump(STORMPATH_GRANT_RESPONSE)
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.mocked_challenge_factor_grant_response
|
32
|
+
MultiJson.dump(STORMPATH_GRANT_RESPONSE)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.mocked_factor_response
|
36
|
+
MultiJson.dump(FACTOR_RESPONSE)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.mocked_empty_challenge_response
|
40
|
+
MultiJson.dump(EMPTY_CHALLENGE_COLLECTION_RESPONSE)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.mocked_challenges_response
|
44
|
+
MultiJson.dump(CHALLENGE_COLLECTION_RESPONSE)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.mocked_challenge
|
48
|
+
MultiJson.dump(CHALLENGE)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.mocked_successfull_challenge
|
52
|
+
MultiJson.dump(SUCCESSFULL_CHALLENGE)
|
53
|
+
end
|
54
|
+
|
31
55
|
FACEBOOK_ACCOUNT = {
|
32
56
|
href: "https://api.stormpath.com/v1/accounts/7jdiPam0PWES317hwRR5a7",
|
33
57
|
username: "damir.svrtan",
|
@@ -140,5 +164,87 @@ module Stormpath
|
|
140
164
|
'expires_in' => 3600,
|
141
165
|
'stormpath_access_token_href' => 'random_href'
|
142
166
|
}.freeze
|
167
|
+
|
168
|
+
FACTOR_RESPONSE = {
|
169
|
+
'href' => 'https://api.stormpath.com/v1/factors/29300284904',
|
170
|
+
'type' => 'SMS',
|
171
|
+
'verificationStatus' => 'UNVERIFIED',
|
172
|
+
'status' => 'ENABLED',
|
173
|
+
'account' => {
|
174
|
+
'href' => 'https://api.stormpath.com/v1/accounts/20959204030'
|
175
|
+
},
|
176
|
+
'phone' => {
|
177
|
+
'href' => 'https://api.stormpath.com/v1/phones/28394029583'
|
178
|
+
},
|
179
|
+
'mostRecentChallenge' => {
|
180
|
+
'href' => 'https://api.stormpath.com/v1/challenges/70xfDsguePApNdnExample'
|
181
|
+
},
|
182
|
+
'challenges' => {
|
183
|
+
'href' => 'https://api.stormpath.com/v1/factors/29300284904/challenges'
|
184
|
+
}
|
185
|
+
}.freeze
|
186
|
+
|
187
|
+
EMPTY_CHALLENGE_COLLECTION_RESPONSE = {
|
188
|
+
'href' => 'https://api.stormpath.com/v1/factors/29300284904/challenges',
|
189
|
+
'type' => 'SMS',
|
190
|
+
'createdAt' => '2016-09-22T21:34:00.881Z',
|
191
|
+
'modifiedAt' => '2016-09-22T21:34:00.881Z',
|
192
|
+
'status' => 'ENABLED',
|
193
|
+
'verificationStatus' => 'UNVERIFIED',
|
194
|
+
'offset' => 0,
|
195
|
+
'limit' => 25,
|
196
|
+
'size' => 0
|
197
|
+
}.freeze
|
198
|
+
|
199
|
+
CHALLENGE_COLLECTION_RESPONSE = {
|
200
|
+
'href' => 'https://api.stormpath.com/v1/factors/29300284904/challenges',
|
201
|
+
'type' => 'SMS',
|
202
|
+
'createdAt' => '2016-09-22T21:34:00.881Z',
|
203
|
+
'modifiedAt' => '2016-09-22T21:34:00.881Z',
|
204
|
+
'status' => 'ENABLED',
|
205
|
+
'verificationStatus' => 'UNVERIFIED',
|
206
|
+
'offset' => 0,
|
207
|
+
'limit' => 25,
|
208
|
+
'size' => 1,
|
209
|
+
'items' => [
|
210
|
+
{
|
211
|
+
'href' => 'https://api.stormpath.com/v1/challenges/70xfDsguePApNdnExample',
|
212
|
+
'createdAt' => '2016-09-22T22:35:44.799Z',
|
213
|
+
'modifiedAt' => '2016-09-22T22:39:06.822Z',
|
214
|
+
'message' => 'For the sake of example, your code is ${code}.',
|
215
|
+
'factor' => {
|
216
|
+
'href' => 'https://api.stormpath.com/v1/factors/29300284904'
|
217
|
+
},
|
218
|
+
'account' => {
|
219
|
+
'href' => 'https://api.stormpath.com/v1/accounts/5IvkjoqcYNe3TYMYiX98vc'
|
220
|
+
},
|
221
|
+
'status' => 'SUCCESS'
|
222
|
+
}
|
223
|
+
]
|
224
|
+
}.freeze
|
225
|
+
|
226
|
+
CHALLENGE = {
|
227
|
+
'href' => 'https://api.stormpath.com/v1/challenges/70xfDsguePApNdnExample',
|
228
|
+
'createdAt' => '2016-09-22T22:35:44.799Z',
|
229
|
+
'modifiedAt' => '2016-09-22T22:39:06.822Z',
|
230
|
+
'message' => 'For the sake of example, your code is ${code}.',
|
231
|
+
'factor' => {
|
232
|
+
'href' => 'https://api.stormpath.com/v1/factors/29300284904'
|
233
|
+
},
|
234
|
+
'account' => {
|
235
|
+
'href' => 'https://api.stormpath.com/v1/accounts/5IvkjoqcYNe3TYMYiX98vc'
|
236
|
+
},
|
237
|
+
'status' => 'SUCCESS'
|
238
|
+
}.freeze
|
239
|
+
|
240
|
+
SUCCESSFULL_CHALLENGE = {
|
241
|
+
'href' => 'https://api.stormpath.com/v1/challenges/2p5jkx09ykTSDWMmyMDdgU',
|
242
|
+
'createdAt' => '2016-11-17T14:01:40.138Z',
|
243
|
+
'modifiedAt' => '2016-11-17T14:02:38.773Z',
|
244
|
+
'status' => 'SUCCESS',
|
245
|
+
'message' => '${code}',
|
246
|
+
'account' => { 'href' => 'https://api.stormpath.com/v1/accounts/1vxQr1xUSxftDytaO45KH2' },
|
247
|
+
'factor' => { 'href' => 'https://api.stormpath.com/v1/factors/2p5jktg54AATahGvm6MN4Q' }
|
248
|
+
}.freeze
|
143
249
|
end
|
144
250
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Stormpath
|
2
2
|
module Test
|
3
3
|
module ResourceHelpers
|
4
|
-
def
|
4
|
+
def account_attrs(opts = {})
|
5
5
|
opts.tap do |o|
|
6
6
|
if !opts[:email].blank? && opts[:email]
|
7
7
|
if opts[:email].include?('@')
|
@@ -13,9 +13,9 @@ module Stormpath
|
|
13
13
|
end
|
14
14
|
o[:username] = (!opts[:username].blank? && opts[:username]) || "ruby#{random_number}"
|
15
15
|
o[:password] = (!opts[:password].blank? && opts[:password]) || 'P@$$w0rd'
|
16
|
-
o[:surname] = (!opts[:surname].blank? && opts[:surname]) || '
|
17
|
-
o[:given_name] = (!opts[:given_name].blank? && opts[:given_name]) || '
|
18
|
-
o[:middle_name] = (!opts[:middle_name].blank? && opts[:middle_name]) || '
|
16
|
+
o[:surname] = (!opts[:surname].blank? && opts[:surname]) || 'ruby'
|
17
|
+
o[:given_name] = (!opts[:given_name].blank? && opts[:given_name]) || 'ruby'
|
18
|
+
o[:middle_name] = (!opts[:middle_name].blank? && opts[:middle_name]) || 'ruby'
|
19
19
|
o[:status] = (!opts[:status].blank? && opts[:status]) || 'ENABLED'
|
20
20
|
end
|
21
21
|
end
|
@@ -24,30 +24,34 @@ module Stormpath
|
|
24
24
|
'@testmail.stormpath.com'
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def test_host
|
28
|
+
Stormpath::DataStore::DEFAULT_SERVER_HOST
|
29
|
+
end
|
30
|
+
|
31
|
+
def application_attrs(opts = {})
|
28
32
|
opts.tap do |o|
|
29
|
-
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby
|
30
|
-
o[:description] = (!opts[:description].blank? && opts[:description]) ||
|
33
|
+
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-app-#{random_number}"
|
34
|
+
o[:description] = (!opts[:description].blank? && opts[:description]) || 'ruby desc'
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
|
-
def
|
38
|
+
def directory_attrs(opts = {})
|
35
39
|
opts.tap do |o|
|
36
|
-
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby
|
37
|
-
o[:description] = (!opts[:description].blank? && opts[:description]) ||
|
40
|
+
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-dir-#{random_number}"
|
41
|
+
o[:description] = (!opts[:description].blank? && opts[:description]) || 'ruby desc'
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
|
-
def
|
45
|
+
def organization_attrs(opts = {})
|
42
46
|
opts.tap do |o|
|
43
|
-
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby
|
44
|
-
o[:name_key] = (!opts[:name_key].blank? && opts[:name_key]) || "ruby
|
47
|
+
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-org-#{random_number}"
|
48
|
+
o[:name_key] = (!opts[:name_key].blank? && opts[:name_key]) || "ruby-org-#{random_number}"
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
48
|
-
def
|
52
|
+
def group_attrs(opts = {})
|
49
53
|
opts.tap do |o|
|
50
|
-
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby
|
54
|
+
o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-group-#{random_number}"
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
@@ -77,7 +81,7 @@ module Stormpath
|
|
77
81
|
end
|
78
82
|
|
79
83
|
def random_number
|
80
|
-
|
84
|
+
SecureRandom.hex(15)
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stormpath-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stormpath, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-11-
|
12
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -324,6 +324,7 @@ files:
|
|
324
324
|
- lib/stormpath-sdk/auth/authentication_result.rb
|
325
325
|
- lib/stormpath-sdk/auth/basic_authenticator.rb
|
326
326
|
- lib/stormpath-sdk/auth/basic_login_attempt.rb
|
327
|
+
- lib/stormpath-sdk/auth/create_factor.rb
|
327
328
|
- lib/stormpath-sdk/auth/http_basic_authentication.rb
|
328
329
|
- lib/stormpath-sdk/auth/http_bearer_authentication.rb
|
329
330
|
- lib/stormpath-sdk/auth/username_password_request.rb
|
@@ -346,6 +347,8 @@ files:
|
|
346
347
|
- lib/stormpath-sdk/id_site/id_site_result.rb
|
347
348
|
- lib/stormpath-sdk/oauth/access_token_authentication_result.rb
|
348
349
|
- lib/stormpath-sdk/oauth/authenticator.rb
|
350
|
+
- lib/stormpath-sdk/oauth/challenge_factor_grant.rb
|
351
|
+
- lib/stormpath-sdk/oauth/challenge_factor_grant_request.rb
|
349
352
|
- lib/stormpath-sdk/oauth/client_credentials_grant.rb
|
350
353
|
- lib/stormpath-sdk/oauth/client_credentials_grant_request.rb
|
351
354
|
- lib/stormpath-sdk/oauth/error.rb
|
@@ -395,6 +398,7 @@ files:
|
|
395
398
|
- lib/stormpath-sdk/resource/application.rb
|
396
399
|
- lib/stormpath-sdk/resource/associations.rb
|
397
400
|
- lib/stormpath-sdk/resource/base.rb
|
401
|
+
- lib/stormpath-sdk/resource/challenge.rb
|
398
402
|
- lib/stormpath-sdk/resource/collection.rb
|
399
403
|
- lib/stormpath-sdk/resource/custom_data.rb
|
400
404
|
- lib/stormpath-sdk/resource/custom_data_hash_methods.rb
|
@@ -404,6 +408,8 @@ files:
|
|
404
408
|
- lib/stormpath-sdk/resource/email_verification_token.rb
|
405
409
|
- lib/stormpath-sdk/resource/error.rb
|
406
410
|
- lib/stormpath-sdk/resource/expansion.rb
|
411
|
+
- lib/stormpath-sdk/resource/factor.rb
|
412
|
+
- lib/stormpath-sdk/resource/field.rb
|
407
413
|
- lib/stormpath-sdk/resource/group.rb
|
408
414
|
- lib/stormpath-sdk/resource/group_membership.rb
|
409
415
|
- lib/stormpath-sdk/resource/instance.rb
|
@@ -414,7 +420,9 @@ files:
|
|
414
420
|
- lib/stormpath-sdk/resource/password_policy.rb
|
415
421
|
- lib/stormpath-sdk/resource/password_reset_token.rb
|
416
422
|
- lib/stormpath-sdk/resource/password_strength.rb
|
423
|
+
- lib/stormpath-sdk/resource/phone.rb
|
417
424
|
- lib/stormpath-sdk/resource/refresh_token.rb
|
425
|
+
- lib/stormpath-sdk/resource/schema.rb
|
418
426
|
- lib/stormpath-sdk/resource/tenant.rb
|
419
427
|
- lib/stormpath-sdk/resource/utils.rb
|
420
428
|
- lib/stormpath-sdk/resource/verification_email.rb
|
@@ -423,6 +431,7 @@ files:
|
|
423
431
|
- lib/stormpath-sdk/version.rb
|
424
432
|
- spec/api_key_spec.rb
|
425
433
|
- spec/auth/basic_authenticator_spec.rb
|
434
|
+
- spec/auth/create_factor_spec.rb
|
426
435
|
- spec/auth/http_basic_authentication_spec.rb
|
427
436
|
- spec/auth/http_bearer_authentication_spec.rb
|
428
437
|
- spec/auth/sauthc1_signer_spec.rb
|
@@ -446,17 +455,22 @@ files:
|
|
446
455
|
- spec/resource/api_key_spec.rb
|
447
456
|
- spec/resource/application_spec.rb
|
448
457
|
- spec/resource/base_spec.rb
|
458
|
+
- spec/resource/challenge_spec.rb
|
449
459
|
- spec/resource/collection_spec.rb
|
450
460
|
- spec/resource/custom_data_spec.rb
|
451
461
|
- spec/resource/directory_spec.rb
|
452
462
|
- spec/resource/email_template_spec.rb
|
453
463
|
- spec/resource/expansion_spec.rb
|
464
|
+
- spec/resource/factor_spec.rb
|
465
|
+
- spec/resource/field_spec.rb
|
454
466
|
- spec/resource/group_membership_spec.rb
|
455
467
|
- spec/resource/group_spec.rb
|
456
468
|
- spec/resource/linked_account_spec.rb
|
457
469
|
- spec/resource/organization_spec.rb
|
458
470
|
- spec/resource/password_policy_spec.rb
|
459
471
|
- spec/resource/password_strength_spec.rb
|
472
|
+
- spec/resource/phone_spec.rb
|
473
|
+
- spec/resource/schema_spec.rb
|
460
474
|
- spec/resource/status_spec.rb
|
461
475
|
- spec/resource/tenant_spec.rb
|
462
476
|
- spec/spec_helper.rb
|