stormpath-sdk 1.6.0 → 1.7.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/CHANGES.md +11 -0
- data/README.md +23 -25
- data/lib/stormpath-sdk.rb +11 -2
- data/lib/stormpath-sdk/api_key.rb +0 -1
- data/lib/stormpath-sdk/auth/basic_authenticator.rb +7 -7
- data/lib/stormpath-sdk/auth/basic_login_attempt.rb +7 -11
- data/lib/stormpath-sdk/auth/create_factor.rb +1 -1
- data/lib/stormpath-sdk/auth/register_service_provider.rb +41 -0
- data/lib/stormpath-sdk/auth/username_password_request.rb +3 -5
- data/lib/stormpath-sdk/cache/cache.rb +3 -3
- data/lib/stormpath-sdk/cache/cache_entry.rb +2 -2
- data/lib/stormpath-sdk/cache/cache_manager.rb +3 -4
- data/lib/stormpath-sdk/cache/cache_stats.rb +1 -3
- data/lib/stormpath-sdk/cache/disabled_cache_store.rb +5 -8
- data/lib/stormpath-sdk/cache/memory_store.rb +1 -1
- data/lib/stormpath-sdk/cache/redis_store.rb +4 -4
- data/lib/stormpath-sdk/client.rb +35 -33
- data/lib/stormpath-sdk/data_store.rb +278 -257
- data/lib/stormpath-sdk/error.rb +18 -7
- data/lib/stormpath-sdk/http/authc/sauthc1_signer.rb +76 -82
- data/lib/stormpath-sdk/http/http_client_request_executor.rb +10 -8
- data/lib/stormpath-sdk/http/response.rb +5 -7
- data/lib/stormpath-sdk/id_site/id_site_result.rb +5 -6
- data/lib/stormpath-sdk/oauth/access_token_authentication_result.rb +5 -9
- data/lib/stormpath-sdk/oauth/authenticator.rb +2 -2
- data/lib/stormpath-sdk/oauth/error.rb +4 -4
- data/lib/stormpath-sdk/oauth/id_site_grant_request.rb +1 -1
- data/lib/stormpath-sdk/oauth/password_grant_request.rb +1 -1
- data/lib/stormpath-sdk/oauth/refresh_grant_request.rb +2 -2
- data/lib/stormpath-sdk/oauth/stormpath_grant_request.rb +2 -2
- data/lib/stormpath-sdk/provider/account_access.rb +0 -2
- data/lib/stormpath-sdk/provider/account_result.rb +1 -2
- data/lib/stormpath-sdk/provider/facebook/facebook_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/facebook/facebook_provider_data.rb +7 -3
- data/lib/stormpath-sdk/provider/github/github_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/github/github_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/google/google_provider.rb +7 -3
- data/lib/stormpath-sdk/provider/google/google_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/linkedin/linkedin_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/linkedin/linkedin_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/provider.rb +8 -4
- data/lib/stormpath-sdk/provider/provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/saml/saml_provider.rb +10 -4
- data/lib/stormpath-sdk/provider/saml/saml_provider_data.rb +6 -3
- data/lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb +6 -2
- data/lib/stormpath-sdk/provider/twitter/twitter_provider.rb +6 -2
- data/lib/stormpath-sdk/provider/twitter/twitter_provider_data.rb +6 -2
- data/lib/stormpath-sdk/resource/account.rb +46 -40
- data/lib/stormpath-sdk/resource/account_link.rb +9 -5
- data/lib/stormpath-sdk/resource/account_linking_policy.rb +8 -4
- data/lib/stormpath-sdk/resource/account_membership.rb +1 -1
- data/lib/stormpath-sdk/resource/account_overrides.rb +20 -16
- data/lib/stormpath-sdk/resource/account_store.rb +15 -11
- data/lib/stormpath-sdk/resource/account_store_mapping.rb +14 -13
- data/lib/stormpath-sdk/resource/application.rb +147 -136
- data/lib/stormpath-sdk/resource/application_web_config.rb +11 -7
- data/lib/stormpath-sdk/resource/associations.rb +36 -43
- data/lib/stormpath-sdk/resource/attribute_statement_mapping_rules.rb +8 -0
- data/lib/stormpath-sdk/resource/base.rb +201 -200
- data/lib/stormpath-sdk/resource/challenge.rb +12 -8
- data/lib/stormpath-sdk/resource/collection.rb +77 -76
- data/lib/stormpath-sdk/resource/custom_data.rb +60 -61
- data/lib/stormpath-sdk/resource/custom_data_hash_methods.rb +28 -25
- data/lib/stormpath-sdk/resource/custom_data_storage.rb +18 -16
- data/lib/stormpath-sdk/resource/directory.rb +37 -60
- data/lib/stormpath-sdk/resource/email_verification_token.rb +7 -3
- data/lib/stormpath-sdk/resource/error.rb +8 -4
- data/lib/stormpath-sdk/resource/expansion.rb +22 -20
- data/lib/stormpath-sdk/resource/factor.rb +12 -8
- data/lib/stormpath-sdk/resource/field.rb +8 -4
- data/lib/stormpath-sdk/resource/group.rb +21 -16
- data/lib/stormpath-sdk/resource/group_membership.rb +7 -5
- data/lib/stormpath-sdk/resource/instance.rb +10 -6
- data/lib/stormpath-sdk/resource/linked_account.rb +7 -3
- data/lib/stormpath-sdk/resource/oauth_policy.rb +7 -3
- data/lib/stormpath-sdk/resource/organization.rb +14 -10
- data/lib/stormpath-sdk/resource/organization_account_store_mapping.rb +8 -4
- data/lib/stormpath-sdk/resource/password_reset_token.rb +9 -5
- data/lib/stormpath-sdk/resource/phone.rb +8 -4
- data/lib/stormpath-sdk/resource/registered_saml_service_provider.rb +8 -0
- data/lib/stormpath-sdk/resource/saml_identity_provider.rb +14 -0
- data/lib/stormpath-sdk/resource/saml_identity_provider_metadata.rb +9 -0
- data/lib/stormpath-sdk/resource/saml_policy.rb +10 -0
- data/lib/stormpath-sdk/resource/saml_service_provider.rb +7 -0
- data/lib/stormpath-sdk/{provider/saml/saml_mapping_rules.rb → resource/saml_service_provider_metadata.rb} +6 -5
- data/lib/stormpath-sdk/resource/saml_service_provider_registration.rb +11 -0
- data/lib/stormpath-sdk/resource/schema.rb +8 -4
- data/lib/stormpath-sdk/resource/tenant.rb +11 -8
- data/lib/stormpath-sdk/resource/user_info_mapping_rules.rb +7 -3
- data/lib/stormpath-sdk/resource/utils.rb +7 -10
- data/lib/stormpath-sdk/resource/verification_email.rb +7 -3
- data/lib/stormpath-sdk/resource/x_509_certificate.rb +7 -0
- data/lib/stormpath-sdk/util/assert.rb +1 -3
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/auth/basic_authenticator_spec.rb +28 -24
- data/spec/auth/register_service_provider_spec.rb +68 -0
- data/spec/auth/sauthc1_signer_spec.rb +8 -4
- data/spec/cache/cache_entry_spec.rb +28 -29
- data/spec/cache/cache_spec.rb +9 -9
- data/spec/cache/cache_stats_spec.rb +1 -1
- data/spec/client_spec.rb +63 -63
- data/spec/data_store_spec.rb +23 -14
- data/spec/oauth/access_token_authentication_result_spec.rb +8 -2
- data/spec/provider/account_resolver_spec.rb +6 -4
- data/spec/provider/provider_spec.rb +6 -6
- data/spec/resource/account_creation_policy_spec.rb +1 -1
- data/spec/resource/account_link_spec.rb +7 -15
- data/spec/resource/account_spec.rb +17 -17
- data/spec/resource/account_store_mapping_spec.rb +16 -22
- data/spec/resource/account_store_spec.rb +3 -3
- data/spec/resource/application_spec.rb +324 -330
- data/spec/resource/base_spec.rb +7 -31
- data/spec/resource/collection_spec.rb +63 -114
- data/spec/resource/custom_data_spec.rb +1 -1
- data/spec/resource/directory_spec.rb +91 -87
- data/spec/resource/expansion_spec.rb +10 -10
- data/spec/resource/factor_spec.rb +1 -1
- data/spec/resource/group_spec.rb +1 -1
- data/spec/resource/linked_account_spec.rb +7 -7
- data/spec/resource/organization_spec.rb +12 -11
- data/spec/resource/phone_spec.rb +1 -1
- data/spec/resource/registered_saml_service_provider_spec.rb +35 -0
- data/spec/resource/saml_identity_provider_metadata_spec.rb +27 -0
- data/spec/resource/saml_identity_provider_spec.rb +94 -0
- data/spec/resource/saml_policy_spec.rb +27 -0
- data/spec/resource/saml_service_provider_registration_spec.rb +58 -0
- data/spec/resource/saml_service_provider_spec.rb +19 -0
- data/spec/resource/status_spec.rb +4 -3
- data/spec/resource/tenant_spec.rb +4 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/support/custom_data_save_period.rb +4 -0
- data/spec/support/custom_data_storage_behavior.rb +7 -8
- data/spec/support/mocked_provider_accounts.rb +101 -101
- data/spec/support/mocked_saml_responses.rb +130 -0
- data/spec/support/resource_factory.rb +4 -4
- data/spec/support/resource_helpers.rb +10 -4
- data/spec/support/resource_matchers.rb +4 -4
- data/spec/support/test_request_executor.rb +2 -2
- metadata +21 -8
- data/lib/stormpath-sdk/provider/saml/saml_provider_metadata.rb +0 -19
- data/spec/fixtures/response/create_saml_directory.json +0 -26
- data/spec/fixtures/response/create_saml_directory_mapping_rules.json +0 -12
- data/spec/fixtures/response/get_saml_directory_provider.json +0 -16
- data/spec/fixtures/response/get_saml_directory_provider_metadata.json +0 -12
data/spec/cache/cache_spec.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
require 'timecop'
|
|
3
3
|
|
|
4
4
|
describe Stormpath::Cache::Cache do
|
|
5
|
-
let(:cache) { Stormpath::Cache::Cache.new
|
|
5
|
+
let(:cache) { Stormpath::Cache::Cache.new(ttl_seconds: 7, tti_seconds: 3) }
|
|
6
6
|
let(:now) { Time.now }
|
|
7
7
|
|
|
8
8
|
before do
|
|
@@ -23,7 +23,7 @@ describe Stormpath::Cache::Cache do
|
|
|
23
23
|
describe '#get' do
|
|
24
24
|
context 'miss' do
|
|
25
25
|
before do
|
|
26
|
-
@foo = cache.get
|
|
26
|
+
@foo = cache.get('not-foo')
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it 'gets nil' do
|
|
@@ -35,7 +35,7 @@ describe Stormpath::Cache::Cache do
|
|
|
35
35
|
context 'live before tti' do
|
|
36
36
|
before do
|
|
37
37
|
Timecop.freeze now + 2
|
|
38
|
-
@foo = cache.get
|
|
38
|
+
@foo = cache.get('foo')
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'gets bar' do
|
|
@@ -47,9 +47,9 @@ describe Stormpath::Cache::Cache do
|
|
|
47
47
|
context 'live after tti' do
|
|
48
48
|
before do
|
|
49
49
|
Timecop.freeze now + 2
|
|
50
|
-
cache.get
|
|
50
|
+
cache.get('foo')
|
|
51
51
|
Timecop.freeze now + 5
|
|
52
|
-
@foo = cache.get
|
|
52
|
+
@foo = cache.get('foo')
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it 'gets bar' do
|
|
@@ -61,7 +61,7 @@ describe Stormpath::Cache::Cache do
|
|
|
61
61
|
context 'expired by tti' do
|
|
62
62
|
before do
|
|
63
63
|
Timecop.freeze now + 4
|
|
64
|
-
@foo = cache.get
|
|
64
|
+
@foo = cache.get('foo')
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it 'gets nil' do
|
|
@@ -73,11 +73,11 @@ describe Stormpath::Cache::Cache do
|
|
|
73
73
|
context 'expired by ttl' do
|
|
74
74
|
before do
|
|
75
75
|
Timecop.freeze now + 2
|
|
76
|
-
cache.get
|
|
76
|
+
cache.get('foo')
|
|
77
77
|
Timecop.freeze now + 5
|
|
78
|
-
cache.get
|
|
78
|
+
cache.get('foo')
|
|
79
79
|
Timecop.freeze now + 8
|
|
80
|
-
@foo = cache.get
|
|
80
|
+
@foo = cache.get('foo')
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it 'gets nil' do
|
data/spec/client_spec.rb
CHANGED
|
@@ -106,7 +106,7 @@ properties
|
|
|
106
106
|
end
|
|
107
107
|
let(:client) do
|
|
108
108
|
Stormpath::Client.new(
|
|
109
|
-
api_key_file_location: api_key_file_location
|
|
109
|
+
api_key_file_location: api_key_file_location
|
|
110
110
|
)
|
|
111
111
|
end
|
|
112
112
|
|
|
@@ -120,11 +120,13 @@ properties
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
it 'raises an error' do
|
|
123
|
-
expect { client }.to raise_error
|
|
123
|
+
expect { client }.to raise_error(
|
|
124
|
+
ArgumentError,
|
|
124
125
|
"No API id in properties. Please provide a 'apiKey.id' property in '" +
|
|
125
126
|
api_key_file_location +
|
|
126
|
-
"' or pass in an 'api_key_id_property_name' to the Stormpath::Client "
|
|
127
|
-
|
|
127
|
+
"' or pass in an 'api_key_id_property_name' to the Stormpath::Client " \
|
|
128
|
+
'constructor to specify an alternative property.'
|
|
129
|
+
)
|
|
128
130
|
end
|
|
129
131
|
end
|
|
130
132
|
|
|
@@ -232,8 +234,8 @@ properties
|
|
|
232
234
|
stub_request(:any, api_key_file_location).to_return(body: api_key_and_secret_properties)
|
|
233
235
|
data_store = client.instance_variable_get '@data_store'
|
|
234
236
|
cache_manager = data_store.cache_manager
|
|
235
|
-
@directories_cache = cache_manager.get_cache
|
|
236
|
-
@groups_cache = cache_manager.get_cache
|
|
237
|
+
@directories_cache = cache_manager.get_cache('directories')
|
|
238
|
+
@groups_cache = cache_manager.get_cache('groups')
|
|
237
239
|
end
|
|
238
240
|
|
|
239
241
|
it 'passes those params down to the caches' do
|
|
@@ -257,7 +259,7 @@ properties
|
|
|
257
259
|
end
|
|
258
260
|
|
|
259
261
|
let(:api_key) do
|
|
260
|
-
Stormpath::ApiKey.new
|
|
262
|
+
Stormpath::ApiKey.new(test_api_key_id, test_api_key_secret)
|
|
261
263
|
end
|
|
262
264
|
|
|
263
265
|
it 'initializes the request executor with the proxy' do
|
|
@@ -266,7 +268,7 @@ properties
|
|
|
266
268
|
.with(proxy: http_proxy)
|
|
267
269
|
.and_return request_executor
|
|
268
270
|
|
|
269
|
-
Stormpath::Client.new
|
|
271
|
+
Stormpath::Client.new(api_key: api_key, proxy: http_proxy)
|
|
270
272
|
end
|
|
271
273
|
end
|
|
272
274
|
end
|
|
@@ -295,6 +297,7 @@ properties
|
|
|
295
297
|
end
|
|
296
298
|
|
|
297
299
|
it 'accepts offset and limit' do
|
|
300
|
+
wait_for_resource_creation
|
|
298
301
|
expect(test_api_client.applications.limit(2).count).to be >= 3
|
|
299
302
|
expect(test_api_client.applications.offset(1).limit(2).count).to be >= 2
|
|
300
303
|
end
|
|
@@ -323,7 +326,7 @@ properties
|
|
|
323
326
|
|
|
324
327
|
context 'expanding a nested single resource' do
|
|
325
328
|
let(:cached_account) do
|
|
326
|
-
client.accounts.get
|
|
329
|
+
client.accounts.get(account.href, Stormpath::Resource::Expansion.new('directory'))
|
|
327
330
|
end
|
|
328
331
|
|
|
329
332
|
before { client.data_store.initialize_cache({}) }
|
|
@@ -336,7 +339,7 @@ properties
|
|
|
336
339
|
|
|
337
340
|
context 'expanding a nested collection resource' do
|
|
338
341
|
let(:cached_account) do
|
|
339
|
-
client.accounts.get
|
|
342
|
+
client.accounts.get(account.href, Stormpath::Resource::Expansion.new('groups'))
|
|
340
343
|
end
|
|
341
344
|
let(:group) { directory.groups.create(group_attrs) }
|
|
342
345
|
|
|
@@ -350,16 +353,18 @@ properties
|
|
|
350
353
|
end
|
|
351
354
|
|
|
352
355
|
context 'search' do
|
|
356
|
+
let(:app_name_1) { "ruby-test-app-#{random_number}" }
|
|
357
|
+
let(:app_name_2) { "ruby-test-app-#{random_number}" }
|
|
353
358
|
let!(:applications) do
|
|
354
359
|
[
|
|
355
|
-
test_api_client.applications.create(application_attrs(name:
|
|
356
|
-
test_api_client.applications.create(application_attrs(name:
|
|
360
|
+
test_api_client.applications.create(application_attrs(name: app_name_1)),
|
|
361
|
+
test_api_client.applications.create(application_attrs(name: app_name_2))
|
|
357
362
|
]
|
|
358
363
|
end
|
|
359
364
|
|
|
360
365
|
context 'by any attribute' do
|
|
361
366
|
let(:search_results) do
|
|
362
|
-
test_api_client.applications.search(
|
|
367
|
+
test_api_client.applications.search(app_name_1)
|
|
363
368
|
end
|
|
364
369
|
|
|
365
370
|
it 'returns the application' do
|
|
@@ -369,7 +374,7 @@ properties
|
|
|
369
374
|
|
|
370
375
|
context 'by an explicit attribute' do
|
|
371
376
|
let(:search_results) do
|
|
372
|
-
test_api_client.applications.search(name:
|
|
377
|
+
test_api_client.applications.search(name: app_name_1)
|
|
373
378
|
end
|
|
374
379
|
|
|
375
380
|
it 'returns the application' do
|
|
@@ -381,7 +386,7 @@ properties
|
|
|
381
386
|
end
|
|
382
387
|
|
|
383
388
|
describe '.create' do
|
|
384
|
-
let(:application_name) {
|
|
389
|
+
let(:application_name) { "rubyclientcreatespec-#{random_number}" }
|
|
385
390
|
|
|
386
391
|
let(:application_attributes) do
|
|
387
392
|
{
|
|
@@ -391,7 +396,7 @@ properties
|
|
|
391
396
|
end
|
|
392
397
|
|
|
393
398
|
context do
|
|
394
|
-
let(:application) { test_api_client.applications.create
|
|
399
|
+
let(:application) { test_api_client.applications.create(application_attributes) }
|
|
395
400
|
|
|
396
401
|
it 'creates that application' do
|
|
397
402
|
expect(application).to be
|
|
@@ -403,21 +408,18 @@ properties
|
|
|
403
408
|
end
|
|
404
409
|
|
|
405
410
|
describe 'auto directory creation' do
|
|
406
|
-
let(:application) { test_api_client.applications.create
|
|
407
|
-
|
|
408
|
-
let(:directories) do
|
|
409
|
-
test_api_client.directories
|
|
410
|
-
end
|
|
411
|
+
let(:application) { test_api_client.applications.create(application_attributes, options) }
|
|
411
412
|
|
|
412
413
|
context 'login source' do
|
|
414
|
+
let(:username) { "johnsmith-#{random_number}" }
|
|
413
415
|
let(:options) { { createDirectory: true } }
|
|
414
416
|
let!(:account) do
|
|
415
417
|
application.accounts.create(
|
|
416
|
-
account_attrs(username:
|
|
418
|
+
account_attrs(username: username, password: '4P@$$w0rd!')
|
|
417
419
|
)
|
|
418
420
|
end
|
|
419
421
|
let(:auth_request) do
|
|
420
|
-
Stormpath::Authentication::UsernamePasswordRequest.new
|
|
422
|
+
Stormpath::Authentication::UsernamePasswordRequest.new(username, '4P@$$w0rd!')
|
|
421
423
|
end
|
|
422
424
|
let(:auth_result) { application.authenticate_account(auth_request) }
|
|
423
425
|
|
|
@@ -433,7 +435,7 @@ properties
|
|
|
433
435
|
|
|
434
436
|
it 'creates directory named by appending "Directory" to app name' do
|
|
435
437
|
application
|
|
436
|
-
expect(directories.map(&:name)).to include("#{application_name} Directory")
|
|
438
|
+
expect(test_api_client.directories.map(&:name)).to include("#{application_name} Directory")
|
|
437
439
|
end
|
|
438
440
|
|
|
439
441
|
context 'and existing directory' do
|
|
@@ -441,7 +443,7 @@ properties
|
|
|
441
443
|
test_api_client.directories.each { |d| d.delete if "#{application_name} Directory" == d.name }
|
|
442
444
|
test_api_client.directories.create(name: "#{application_name} Directory")
|
|
443
445
|
application
|
|
444
|
-
expect(directories.map(&:name)).to include("#{application_name} Directory (2)")
|
|
446
|
+
expect(test_api_client.directories.map(&:name)).to include("#{application_name} Directory (2)")
|
|
445
447
|
end
|
|
446
448
|
end
|
|
447
449
|
end
|
|
@@ -451,12 +453,9 @@ properties
|
|
|
451
453
|
|
|
452
454
|
before { application }
|
|
453
455
|
|
|
454
|
-
#fails with Stormpath::Error: Authentication required.
|
|
455
456
|
it 'creates directory named "Client Application Create Test Directory"' do
|
|
456
|
-
expect(directories.map(&:name)).to include("#{application_name} Directory")
|
|
457
|
+
expect(test_api_client.directories.map(&:name)).to include("#{application_name} Directory")
|
|
457
458
|
end
|
|
458
|
-
|
|
459
|
-
it 'resolves naming conflict with existing directory throwing Stormpath::Error with status 409 and code 5010'
|
|
460
459
|
end
|
|
461
460
|
|
|
462
461
|
context 'with directory: ""' do
|
|
@@ -477,15 +476,17 @@ properties
|
|
|
477
476
|
before { application }
|
|
478
477
|
|
|
479
478
|
it 'creates no directory' do
|
|
480
|
-
|
|
479
|
+
wait_for_resource_creation
|
|
480
|
+
expect(test_api_client.directories.map(&:name)).not_to include("#{application_name} Directory")
|
|
481
481
|
end
|
|
482
482
|
end
|
|
483
483
|
|
|
484
484
|
after(:each) do |example|
|
|
485
|
+
wait_for_resource_creation
|
|
485
486
|
unless example.metadata[:skip_cleanup]
|
|
486
487
|
application.delete
|
|
487
488
|
test_api_client.directories.each do |d|
|
|
488
|
-
d.delete if ["#{application_name} Directory", "#{application_name} Directory (2)"
|
|
489
|
+
d.delete if ["#{application_name} Directory", "#{application_name} Directory (2)"].include?(d.name)
|
|
489
490
|
end
|
|
490
491
|
end
|
|
491
492
|
end
|
|
@@ -495,12 +496,12 @@ properties
|
|
|
495
496
|
|
|
496
497
|
describe '#directories' do
|
|
497
498
|
context 'given a collection' do
|
|
498
|
-
let(:
|
|
499
|
-
let(:directory) { directories.create(directory_attrs) }
|
|
499
|
+
let(:directory) { test_api_client.directories.create(directory_attrs) }
|
|
500
500
|
|
|
501
501
|
it 'returns the collection' do
|
|
502
|
-
|
|
503
|
-
expect(directories
|
|
502
|
+
wait_for_resource_creation
|
|
503
|
+
expect(test_api_client.directories).to be_kind_of(Stormpath::Resource::Collection)
|
|
504
|
+
expect(test_api_client.directories.count).to be >= 1
|
|
504
505
|
end
|
|
505
506
|
|
|
506
507
|
after { directory.delete }
|
|
@@ -516,19 +517,23 @@ properties
|
|
|
516
517
|
end
|
|
517
518
|
|
|
518
519
|
it 'should retrieve the number of directories described with the limit' do
|
|
520
|
+
wait_for_resource_creation
|
|
519
521
|
expect(test_api_client.directories.count).to be >= 2
|
|
520
522
|
end
|
|
521
523
|
end
|
|
522
524
|
|
|
523
525
|
describe '.create' do
|
|
526
|
+
let(:directory_name) { "rubysdkdir-#{random_number}" }
|
|
524
527
|
let(:directory) do
|
|
525
|
-
test_api_client.directories.create(
|
|
528
|
+
test_api_client.directories.create(
|
|
529
|
+
directory_attrs(name: directory_name, description: directory_name)
|
|
530
|
+
)
|
|
526
531
|
end
|
|
527
532
|
|
|
528
533
|
it 'creates that application' do
|
|
529
534
|
expect(directory).to be
|
|
530
|
-
expect(directory.name).to eq(
|
|
531
|
-
expect(directory.description).to eq(
|
|
535
|
+
expect(directory.name).to eq(directory_name)
|
|
536
|
+
expect(directory.description).to eq(directory_name)
|
|
532
537
|
end
|
|
533
538
|
|
|
534
539
|
after { directory.delete }
|
|
@@ -537,13 +542,13 @@ properties
|
|
|
537
542
|
|
|
538
543
|
describe '#organization' do
|
|
539
544
|
context 'search' do
|
|
540
|
-
let(:
|
|
545
|
+
let(:random_name_key) { "ruby-org-#{random_number}" }
|
|
541
546
|
let!(:organization) do
|
|
542
|
-
test_api_client.organizations.create(organization_attrs(name:
|
|
547
|
+
test_api_client.organizations.create(organization_attrs(name: random_name_key))
|
|
543
548
|
end
|
|
544
549
|
|
|
545
550
|
context 'by any attribute' do
|
|
546
|
-
let(:search_results) { test_api_client.organizations.search(
|
|
551
|
+
let(:search_results) { test_api_client.organizations.search(random_name_key) }
|
|
547
552
|
|
|
548
553
|
it 'returns the application' do
|
|
549
554
|
expect(search_results.count).to eq 1
|
|
@@ -551,7 +556,7 @@ properties
|
|
|
551
556
|
end
|
|
552
557
|
|
|
553
558
|
context 'by an explicit attribute' do
|
|
554
|
-
let(:search_results) { test_api_client.organizations.search(name:
|
|
559
|
+
let(:search_results) { test_api_client.organizations.search(name: random_name_key) }
|
|
555
560
|
|
|
556
561
|
it 'returns the application' do
|
|
557
562
|
expect(search_results.count).to eq 1
|
|
@@ -587,17 +592,22 @@ properties
|
|
|
587
592
|
end
|
|
588
593
|
|
|
589
594
|
describe '.create' do
|
|
595
|
+
let(:organization_name) { "rubysdkorg#{random_number}" }
|
|
590
596
|
let(:organization) do
|
|
591
|
-
test_api_client.organizations.create(
|
|
592
|
-
|
|
593
|
-
|
|
597
|
+
test_api_client.organizations.create(
|
|
598
|
+
organization_attrs(
|
|
599
|
+
name: organization_name,
|
|
600
|
+
name_key: organization_name,
|
|
601
|
+
description: organization_name
|
|
602
|
+
)
|
|
603
|
+
)
|
|
594
604
|
end
|
|
595
605
|
|
|
596
606
|
it 'creates an organization' do
|
|
597
607
|
expect(organization).to be
|
|
598
|
-
expect(organization.name).to eq(
|
|
599
|
-
expect(organization.name_key).to eq(
|
|
600
|
-
expect(organization.description).to eq(
|
|
608
|
+
expect(organization.name).to eq(organization_name)
|
|
609
|
+
expect(organization.name_key).to eq(organization_name)
|
|
610
|
+
expect(organization.description).to eq(organization_name)
|
|
601
611
|
end
|
|
602
612
|
|
|
603
613
|
after { organization.delete }
|
|
@@ -658,27 +668,17 @@ properties
|
|
|
658
668
|
end
|
|
659
669
|
|
|
660
670
|
describe '#account_links' do
|
|
661
|
-
let(:application)
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
let(:directory1) do
|
|
665
|
-
test_api_client.directories.create(name: 'ruby sdk dir 1')
|
|
666
|
-
end
|
|
667
|
-
let(:directory2) do
|
|
668
|
-
test_api_client.directories.create(name: 'ruby sdk dir 2')
|
|
669
|
-
end
|
|
671
|
+
let(:application) { test_api_client.applications.create(application_attrs) }
|
|
672
|
+
let(:directory1) { test_api_client.directories.create(directory_attrs) }
|
|
673
|
+
let(:directory2) { test_api_client.directories.create(directory_attrs) }
|
|
670
674
|
|
|
671
675
|
before do
|
|
672
676
|
map_account_store(application, directory1, 1, true, false)
|
|
673
677
|
map_account_store(application, directory2, 2, false, false)
|
|
674
678
|
end
|
|
675
679
|
|
|
676
|
-
let!(:account1)
|
|
677
|
-
|
|
678
|
-
end
|
|
679
|
-
let!(:account2) do
|
|
680
|
-
directory2.accounts.create(account_attrs(email: 'hyde', username: 'hyde'))
|
|
681
|
-
end
|
|
680
|
+
let!(:account1) { directory1.accounts.create(account_attrs) }
|
|
681
|
+
let!(:account2) { directory2.accounts.create(account_attrs) }
|
|
682
682
|
|
|
683
683
|
let(:link_accounts) do
|
|
684
684
|
test_api_client.account_links.create(
|
data/spec/data_store_spec.rb
CHANGED
|
@@ -6,9 +6,9 @@ shared_examples 'a data store' do
|
|
|
6
6
|
let(:data_store) do
|
|
7
7
|
Stormpath::DataStore.new(request_executor, test_api_key, store, nil)
|
|
8
8
|
end
|
|
9
|
-
let(:application_cache) { data_store.cache_manager.get_cache
|
|
10
|
-
let(:tenant_cache) { data_store.cache_manager.get_cache
|
|
11
|
-
let(:group_cache) { data_store.cache_manager.get_cache
|
|
9
|
+
let(:application_cache) { data_store.cache_manager.get_cache('applications') }
|
|
10
|
+
let(:tenant_cache) { data_store.cache_manager.get_cache('tenants') }
|
|
11
|
+
let(:group_cache) { data_store.cache_manager.get_cache('groups') }
|
|
12
12
|
let(:default_base_url) { Stormpath::DataStore::DEFAULT_BASE_URL }
|
|
13
13
|
|
|
14
14
|
after do
|
|
@@ -22,8 +22,10 @@ shared_examples 'a data store' do
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it 'pulls resource name from href if its custom data also' do
|
|
25
|
-
region = data_store.send(
|
|
26
|
-
|
|
25
|
+
region = data_store.send(
|
|
26
|
+
:region_for,
|
|
27
|
+
"#{default_base_url}/v1/accounts/7jWpcEVSgawKkAZp8XDIEw/customData"
|
|
28
|
+
)
|
|
27
29
|
expect(region).to eq('customData')
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -71,7 +73,7 @@ shared_examples 'a data store' do
|
|
|
71
73
|
href = resource['href']
|
|
72
74
|
request_executor.response = MultiJson.dump resource
|
|
73
75
|
data_store.get_resource href, Stormpath::Resource::Application
|
|
74
|
-
@cached = application_cache.get
|
|
76
|
+
@cached = application_cache.get(href)
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
it 'caches a shallow resource' do
|
|
@@ -109,7 +111,7 @@ shared_examples 'a data store' do
|
|
|
109
111
|
href = resource['href']
|
|
110
112
|
request_executor.response = MultiJson.dump resource
|
|
111
113
|
data_store.get_resource href, Stormpath::Resource::Application
|
|
112
|
-
@cached = application_cache.get
|
|
114
|
+
@cached = application_cache.get(href)
|
|
113
115
|
end
|
|
114
116
|
|
|
115
117
|
it 'caches a shallow resource' do
|
|
@@ -158,12 +160,14 @@ shared_examples 'a data store' do
|
|
|
158
160
|
|
|
159
161
|
context '#apply_default_user_agent' do
|
|
160
162
|
let(:request) do
|
|
161
|
-
Stormpath::Http::Request.new(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
Stormpath::Http::Request.new(
|
|
164
|
+
'get',
|
|
165
|
+
'http://example.com/resources/abc123',
|
|
166
|
+
nil,
|
|
167
|
+
{},
|
|
168
|
+
nil,
|
|
169
|
+
test_api_key
|
|
170
|
+
)
|
|
167
171
|
end
|
|
168
172
|
|
|
169
173
|
before do
|
|
@@ -187,7 +191,12 @@ describe Stormpath::DataStore do
|
|
|
187
191
|
end
|
|
188
192
|
|
|
189
193
|
context 'memcached store' do
|
|
190
|
-
let(:store)
|
|
194
|
+
let(:store) do
|
|
195
|
+
{
|
|
196
|
+
store: Stormpath::Cache::MemcachedStore,
|
|
197
|
+
store_opts: { host: 'localhost:11211', prefix_key: 'mem' }
|
|
198
|
+
}
|
|
199
|
+
end
|
|
191
200
|
it_should_behave_like 'a data store'
|
|
192
201
|
end
|
|
193
202
|
end
|