stormpath-sdk 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.ruby-gemset +0 -0
  4. data/.travis.yml +0 -0
  5. data/CHANGES.md +10 -0
  6. data/Gemfile +0 -0
  7. data/README.md +0 -0
  8. data/Rakefile +0 -0
  9. data/lib/stormpath-sdk.rb +7 -2
  10. data/lib/stormpath-sdk/api_key.rb +0 -0
  11. data/lib/stormpath-sdk/auth/authentication_result.rb +0 -0
  12. data/lib/stormpath-sdk/auth/basic_authenticator.rb +0 -0
  13. data/lib/stormpath-sdk/auth/basic_login_attempt.rb +0 -0
  14. data/lib/stormpath-sdk/auth/username_password_request.rb +0 -0
  15. data/lib/stormpath-sdk/cache/cache.rb +0 -0
  16. data/lib/stormpath-sdk/cache/cache_entry.rb +0 -0
  17. data/lib/stormpath-sdk/cache/cache_manager.rb +0 -0
  18. data/lib/stormpath-sdk/cache/cache_stats.rb +0 -0
  19. data/lib/stormpath-sdk/cache/disabled_cache_store.rb +0 -0
  20. data/lib/stormpath-sdk/cache/memory_store.rb +0 -0
  21. data/lib/stormpath-sdk/cache/redis_store.rb +0 -0
  22. data/lib/stormpath-sdk/client.rb +0 -0
  23. data/lib/stormpath-sdk/data_store.rb +0 -0
  24. data/lib/stormpath-sdk/error.rb +0 -0
  25. data/lib/stormpath-sdk/http/authc/sauthc1_signer.rb +0 -0
  26. data/lib/stormpath-sdk/http/http_client_request_executor.rb +0 -0
  27. data/lib/stormpath-sdk/http/request.rb +0 -0
  28. data/lib/stormpath-sdk/http/response.rb +0 -0
  29. data/lib/stormpath-sdk/http/utils.rb +0 -0
  30. data/lib/stormpath-sdk/id_site/id_site_result.rb +0 -0
  31. data/lib/stormpath-sdk/oauth/access_token_authentication_result.rb +0 -0
  32. data/lib/stormpath-sdk/oauth/authenticator.rb +11 -10
  33. data/lib/stormpath-sdk/oauth/error.rb +0 -0
  34. data/lib/stormpath-sdk/oauth/id_site_grant.rb +0 -0
  35. data/lib/stormpath-sdk/oauth/id_site_grant_request.rb +0 -0
  36. data/lib/stormpath-sdk/oauth/password_grant.rb +0 -0
  37. data/lib/stormpath-sdk/oauth/password_grant_request.rb +0 -0
  38. data/lib/stormpath-sdk/oauth/refresh_grant_request.rb +0 -0
  39. data/lib/stormpath-sdk/oauth/refresh_token.rb +0 -0
  40. data/lib/stormpath-sdk/oauth/stormpath_grant_request.rb +33 -0
  41. data/lib/stormpath-sdk/oauth/stormpath_token_grant.rb +16 -0
  42. data/lib/stormpath-sdk/oauth/verify_access_token.rb +0 -0
  43. data/lib/stormpath-sdk/oauth/verify_token.rb +0 -0
  44. data/lib/stormpath-sdk/provider/account_access.rb +0 -0
  45. data/lib/stormpath-sdk/provider/account_request.rb +0 -0
  46. data/lib/stormpath-sdk/provider/account_resolver.rb +0 -0
  47. data/lib/stormpath-sdk/provider/account_result.rb +0 -0
  48. data/lib/stormpath-sdk/provider/facebook/facebook_provider.rb +0 -0
  49. data/lib/stormpath-sdk/provider/facebook/facebook_provider_data.rb +0 -0
  50. data/lib/stormpath-sdk/provider/github/github_provider.rb +0 -0
  51. data/lib/stormpath-sdk/provider/github/github_provider_data.rb +0 -0
  52. data/lib/stormpath-sdk/provider/google/google_provider.rb +0 -0
  53. data/lib/stormpath-sdk/provider/google/google_provider_data.rb +0 -0
  54. data/lib/stormpath-sdk/provider/linkedin/linkedin_provider.rb +0 -0
  55. data/lib/stormpath-sdk/provider/linkedin/linkedin_provider_data.rb +0 -0
  56. data/lib/stormpath-sdk/provider/provider.rb +0 -0
  57. data/lib/stormpath-sdk/provider/provider_data.rb +0 -0
  58. data/lib/stormpath-sdk/provider/saml/saml_mapping_rules.rb +0 -0
  59. data/lib/stormpath-sdk/provider/saml/saml_provider.rb +0 -0
  60. data/lib/stormpath-sdk/provider/saml/saml_provider_data.rb +0 -0
  61. data/lib/stormpath-sdk/provider/saml/saml_provider_metadata.rb +0 -0
  62. data/lib/stormpath-sdk/provider/stormpath/stormpath_provider.rb +0 -0
  63. data/lib/stormpath-sdk/provider/stormpath/stormpath_provider_data.rb +0 -0
  64. data/lib/stormpath-sdk/resource/access_token.rb +0 -0
  65. data/lib/stormpath-sdk/resource/account.rb +3 -2
  66. data/lib/stormpath-sdk/resource/account_creation_policy.rb +15 -0
  67. data/lib/stormpath-sdk/resource/account_membership.rb +0 -0
  68. data/lib/stormpath-sdk/resource/account_overrides.rb +0 -0
  69. data/lib/stormpath-sdk/resource/account_store.rb +0 -0
  70. data/lib/stormpath-sdk/resource/account_store_mapping.rb +0 -0
  71. data/lib/stormpath-sdk/resource/{account_status.rb → api_key.rb} +9 -9
  72. data/lib/stormpath-sdk/resource/application.rb +2 -2
  73. data/lib/stormpath-sdk/resource/associations.rb +2 -1
  74. data/lib/stormpath-sdk/resource/base.rb +0 -0
  75. data/lib/stormpath-sdk/resource/collection.rb +0 -0
  76. data/lib/stormpath-sdk/resource/custom_data.rb +0 -0
  77. data/lib/stormpath-sdk/resource/custom_data_hash_methods.rb +0 -0
  78. data/lib/stormpath-sdk/resource/custom_data_storage.rb +0 -0
  79. data/lib/stormpath-sdk/resource/directory.rb +3 -2
  80. data/lib/stormpath-sdk/resource/email_template.rb +7 -0
  81. data/lib/stormpath-sdk/resource/email_verification_token.rb +0 -0
  82. data/lib/stormpath-sdk/resource/error.rb +0 -0
  83. data/lib/stormpath-sdk/resource/expansion.rb +0 -0
  84. data/lib/stormpath-sdk/resource/group.rb +1 -2
  85. data/lib/stormpath-sdk/resource/group_membership.rb +0 -0
  86. data/lib/stormpath-sdk/resource/instance.rb +0 -0
  87. data/lib/stormpath-sdk/resource/oauth_policy.rb +0 -0
  88. data/lib/stormpath-sdk/resource/organization.rb +0 -0
  89. data/lib/stormpath-sdk/resource/organization_account_store_mapping.rb +0 -0
  90. data/lib/stormpath-sdk/resource/password_policy.rb +10 -0
  91. data/lib/stormpath-sdk/resource/password_reset_token.rb +0 -0
  92. data/lib/stormpath-sdk/resource/password_strength.rb +16 -0
  93. data/lib/stormpath-sdk/resource/refresh_token.rb +0 -0
  94. data/lib/stormpath-sdk/resource/tenant.rb +0 -0
  95. data/lib/stormpath-sdk/resource/utils.rb +0 -0
  96. data/lib/stormpath-sdk/resource/verification_email.rb +0 -0
  97. data/lib/stormpath-sdk/util/assert.rb +0 -0
  98. data/lib/stormpath-sdk/version.rb +1 -1
  99. data/spec/api_key_spec.rb +0 -0
  100. data/spec/auth/basic_authenticator_spec.rb +0 -0
  101. data/spec/auth/sauthc1_signer_spec.rb +0 -0
  102. data/spec/cache/cache_entry_spec.rb +0 -0
  103. data/spec/cache/cache_spec.rb +0 -0
  104. data/spec/cache/cache_stats_spec.rb +0 -0
  105. data/spec/client_spec.rb +1 -1
  106. data/spec/data_store_spec.rb +0 -0
  107. data/spec/fixtures/response/create_saml_directory.json +0 -0
  108. data/spec/fixtures/response/create_saml_directory_mapping_rules.json +0 -0
  109. data/spec/fixtures/response/get_saml_directory_provider.json +0 -0
  110. data/spec/fixtures/response/get_saml_directory_provider_metadata.json +0 -0
  111. data/spec/oauth/access_token_authentication_result_spec.rb +0 -0
  112. data/spec/provider/account_resolver_spec.rb +0 -0
  113. data/spec/provider/provider_spec.rb +0 -0
  114. data/spec/resource/account_creation_policy_spec.rb +61 -0
  115. data/spec/resource/account_store_mapping_spec.rb +0 -0
  116. data/spec/resource/account_store_spec.rb +0 -0
  117. data/spec/resource/api_key_spec.rb +56 -0
  118. data/spec/resource/application_spec.rb +26 -3
  119. data/spec/resource/base_spec.rb +0 -0
  120. data/spec/resource/collection_spec.rb +0 -0
  121. data/spec/resource/custom_data_spec.rb +0 -0
  122. data/spec/resource/directory_spec.rb +13 -4
  123. data/spec/resource/email_template_spec.rb +59 -0
  124. data/spec/resource/expansion_spec.rb +0 -0
  125. data/spec/resource/group_membership_spec.rb +0 -0
  126. data/spec/resource/group_spec.rb +0 -0
  127. data/spec/resource/organization_spec.rb +0 -0
  128. data/spec/resource/password_policy_spec.rb +58 -0
  129. data/spec/resource/password_strength_spec.rb +69 -0
  130. data/spec/resource/status_spec.rb +2 -16
  131. data/spec/resource/tenant_spec.rb +0 -0
  132. data/spec/spec_helper.rb +0 -0
  133. data/spec/support/custom_data_storage_behavior.rb +0 -0
  134. data/spec/support/mocked_provider_accounts.rb +0 -0
  135. data/spec/support/resource_factory.rb +0 -0
  136. data/spec/support/resource_matchers.rb +0 -0
  137. data/spec/support/test_cache_stores.rb +0 -0
  138. data/spec/support/test_request_executor.rb +0 -0
  139. data/stormpath-sdk.gemspec +0 -0
  140. data/support/api.rb +0 -0
  141. metadata +13 -3
  142. data/lib/stormpath-sdk/resource/status.rb +0 -39
File without changes
@@ -0,0 +1,10 @@
1
+ module Stormpath
2
+ module Resource
3
+ class PasswordPolicy < Stormpath::Resource::Instance
4
+ prop_accessor :reset_token_ttl, :reset_email_status, :reset_success_email_status
5
+ has_one :strength, class_name: :passwordStrength
6
+ has_many :reset_email_templates, class_name: :emailTemplate
7
+ has_many :reset_success_email_templates, class_name: :emailTemplate
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ module Stormpath
2
+ module Resource
3
+ class PasswordStrength < Stormpath::Resource::Instance
4
+ prop_accessor(
5
+ :min_length,
6
+ :max_length,
7
+ :min_lower_case,
8
+ :min_upper_case,
9
+ :min_numeric,
10
+ :min_symbol,
11
+ :min_diacritic,
12
+ :prevent_reuse
13
+ )
14
+ end
15
+ end
16
+ end
File without changes
File without changes
File without changes
@@ -14,6 +14,6 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module Stormpath
17
- VERSION = '1.1.2'
17
+ VERSION = '1.1.3'
18
18
  VERSION_DATE = '2016-05-24'
19
19
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -648,7 +648,7 @@ properties
648
648
 
649
649
  context 'by an explicit attribute' do
650
650
  let(:search_results) do
651
- test_api_client.organizations.search(name: random_organization_name)
651
+ test_api_client.organizations.search(name: organization_name)
652
652
  end
653
653
 
654
654
  it 'returns the application' do
File without changes
File without changes
File without changes
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::AccountCreationPolicy, :vcr do
4
+ describe "instances should respond to attribute property methods" do
5
+ let(:application) { test_application }
6
+ let(:directory) { test_api_client.directories.create(name: random_directory_name) }
7
+ let(:account_creation_policy) { directory.account_creation_policy }
8
+
9
+ before do
10
+ test_api_client.account_store_mappings.create(
11
+ application: application,
12
+ account_store: directory,
13
+ list_index: 1,
14
+ is_default_account_store: false,
15
+ is_default_group_store: false
16
+ )
17
+ end
18
+
19
+ after { directory.delete }
20
+
21
+ it do
22
+ expect(account_creation_policy).to be_a Stormpath::Resource::AccountCreationPolicy
23
+
24
+ [:welcome_email_status,
25
+ :verification_email_status,
26
+ :verification_success_email_status].each do |property_accessor|
27
+ expect(account_creation_policy).to respond_to(property_accessor)
28
+ expect(account_creation_policy).to respond_to("#{property_accessor}=")
29
+ end
30
+
31
+ expect(account_creation_policy.verification_email_templates).to be_a Stormpath::Resource::Collection
32
+ expect(account_creation_policy.verification_success_email_templates).to be_a Stormpath::Resource::Collection
33
+ expect(account_creation_policy.welcome_email_templates).to be_a Stormpath::Resource::Collection
34
+
35
+ expect(account_creation_policy.verification_email_templates.first).to be_a Stormpath::Resource::EmailTemplate
36
+ expect(account_creation_policy.verification_success_email_templates.first).to be_a Stormpath::Resource::EmailTemplate
37
+ expect(account_creation_policy.welcome_email_templates.first).to be_a Stormpath::Resource::EmailTemplate
38
+ end
39
+
40
+ it 'can change welcome_email_status' do
41
+ expect(directory.account_creation_policy.welcome_email_status).to eq('DISABLED')
42
+ account_creation_policy.welcome_email_status = 'ENABLED'
43
+ account_creation_policy.save
44
+ expect(directory.account_creation_policy.welcome_email_status).to eq('ENABLED')
45
+ end
46
+
47
+ it 'can change verification_email_status' do
48
+ expect(directory.account_creation_policy.verification_email_status).to eq('DISABLED')
49
+ account_creation_policy.verification_email_status = 'ENABLED'
50
+ account_creation_policy.save
51
+ expect(directory.account_creation_policy.verification_email_status).to eq('ENABLED')
52
+ end
53
+
54
+ it 'can change verification_success_email_status' do
55
+ expect(directory.account_creation_policy.verification_success_email_status).to eq('DISABLED')
56
+ account_creation_policy.verification_success_email_status = 'ENABLED'
57
+ account_creation_policy.save
58
+ expect(directory.account_creation_policy.verification_success_email_status).to eq('ENABLED')
59
+ end
60
+ end
61
+ end
File without changes
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::ApiKey, :vcr do
4
+ let(:application) { test_application }
5
+ let(:tenant) { application.tenant }
6
+
7
+ let(:account) do
8
+ application.accounts.create(
9
+ email: 'test@example.com',
10
+ given_name: 'Ruby SDK',
11
+ password: 'P@$$w0rd',
12
+ surname: 'SDK'
13
+ )
14
+ end
15
+
16
+ let(:api_key) { account.api_keys.create({}) }
17
+
18
+ after { account.delete }
19
+
20
+ describe "instances should respond to attribute property methods" do
21
+ it do
22
+ [:name, :description, :status].each do |property_accessor|
23
+ expect(api_key).to respond_to(property_accessor)
24
+ expect(api_key).to respond_to("#{property_accessor}=")
25
+ end
26
+
27
+ [:id, :secret].each do |property_getter|
28
+ expect(api_key).to respond_to(property_getter)
29
+ expect(api_key.send property_getter).to be_a String
30
+ end
31
+
32
+ expect(api_key.tenant).to be_a Stormpath::Resource::Tenant
33
+ expect(api_key.account).to be_a Stormpath::Resource::Account
34
+ end
35
+ end
36
+
37
+ describe 'api_key_associations' do
38
+ it 'should belong_to account' do
39
+ expect(api_key.account).to eq(account)
40
+ end
41
+
42
+ it 'should belong_to tenant' do
43
+ expect(api_key.tenant).to eq(tenant)
44
+ end
45
+
46
+ it 'apps can fetch api keys' do
47
+ fetched_api_key = application.api_keys.search(id: api_key.id).first
48
+ expect(fetched_api_key).to eq(api_key)
49
+ end
50
+
51
+ it 'accounts can fetch api keys' do
52
+ api_key
53
+ expect(account.api_keys.count).to eq(1)
54
+ end
55
+ end
56
+ end
@@ -1037,10 +1037,9 @@ describe Stormpath::Resource::Application, :vcr do
1037
1037
  let(:account_data) { build_account }
1038
1038
  let(:password_grant_request) { Stormpath::Oauth::PasswordGrantRequest.new account_data[:email], account_data[:password] }
1039
1039
  let(:aquire_token) { application.authenticate_oauth(password_grant_request) }
1040
+ let(:account) { application.accounts.create account_data }
1040
1041
 
1041
- before do
1042
- application.accounts.create account_data
1043
- end
1042
+ before { account }
1044
1043
 
1045
1044
  context 'generate access token' do
1046
1045
  let(:password_grant_request) { Stormpath::Oauth::PasswordGrantRequest.new account_data[:email], account_data[:password] }
@@ -1059,6 +1058,30 @@ describe Stormpath::Resource::Application, :vcr do
1059
1058
  end
1060
1059
  end
1061
1060
 
1061
+ context 'generate access token from stormpath_request' do
1062
+ let(:stormpath_grant_request) do
1063
+ Stormpath::Oauth::StormpathGrantRequest.new(
1064
+ account,
1065
+ application,
1066
+ test_api_client.data_store.api_key
1067
+ )
1068
+ end
1069
+
1070
+ let(:authenticate_oauth) { application.authenticate_oauth(stormpath_grant_request) }
1071
+
1072
+ it 'should return access token response' do
1073
+ expect(authenticate_oauth).to be_kind_of(Stormpath::Oauth::AccessTokenAuthenticationResult)
1074
+ end
1075
+
1076
+ it 'response should contain token data' do
1077
+ expect(authenticate_oauth.access_token).not_to be_empty
1078
+ expect(authenticate_oauth.refresh_token).not_to be_empty
1079
+ expect(authenticate_oauth.token_type).not_to be_empty
1080
+ expect(authenticate_oauth.expires_in).not_to be_nil
1081
+ expect(authenticate_oauth.stormpath_access_token_href).not_to be_empty
1082
+ end
1083
+ end
1084
+
1062
1085
  context 'exchange id site token for access_token with invalid jwt' do
1063
1086
  let(:invalid_jwt_token) { 'invalid_token' }
1064
1087
 
File without changes
File without changes
File without changes
@@ -87,6 +87,11 @@ describe Stormpath::Resource::Directory, :vcr do
87
87
  end
88
88
  end
89
89
 
90
+ context '#password_policy' do
91
+ it 'should be able to fetch the password policy' do
92
+ expect(directory.password_policy).to be_kind_of(Stormpath::Resource::PasswordPolicy)
93
+ end
94
+ end
90
95
  end
91
96
 
92
97
  describe '#create_account' do
@@ -235,9 +240,11 @@ describe Stormpath::Resource::Directory, :vcr do
235
240
  end
236
241
 
237
242
  context 'with account data as hash' do
243
+ let(:account_email) { random_email }
244
+
238
245
  let(:created_account_with_hash) do
239
246
  directory.create_account({
240
- email: random_email,
247
+ email: account_email,
241
248
  given_name: 'Ruby SDK',
242
249
  password: 'P@$$w0rd',
243
250
  surname: 'SDK',
@@ -250,7 +257,7 @@ describe Stormpath::Resource::Directory, :vcr do
250
257
  end
251
258
 
252
259
  it 'creates an account with status ENABLED' do
253
- expect(created_account_with_hash.email).to eq(random_email)
260
+ expect(created_account_with_hash.email).to eq(account_email)
254
261
  expect(created_account_with_hash.given_name).to eq('Ruby SDK')
255
262
  expect(created_account_with_hash.surname).to eq('SDK')
256
263
  expect(created_account_with_hash.status).to eq("ENABLED")
@@ -260,7 +267,9 @@ describe Stormpath::Resource::Directory, :vcr do
260
267
  end
261
268
 
262
269
  describe '#create_directory_with_custom_data' do
263
- let(:directory) { test_api_client.directories.create name: random_directory_name, description: 'description_for_some_test_directory' }
270
+ let(:directory_name) { random_directory_name }
271
+
272
+ let(:directory) { test_api_client.directories.create name: directory_name, description: 'description_for_some_test_directory' }
264
273
 
265
274
  after do
266
275
  directory.delete if directory
@@ -270,7 +279,7 @@ describe Stormpath::Resource::Directory, :vcr do
270
279
  directory.custom_data["category"] = "classified"
271
280
 
272
281
  directory.save
273
- expect(directory.name).to eq(random_directory_name)
282
+ expect(directory.name).to eq(directory_name)
274
283
  expect(directory.description).to eq('description_for_some_test_directory')
275
284
  expect(directory.custom_data["category"]).to eq("classified")
276
285
  end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::EmailTemplate, :vcr do
4
+ describe "instances should respond to attribute property methods" do
5
+ let(:application) { test_application }
6
+ let(:directory) { test_api_client.directories.create(name: random_directory_name) }
7
+ let(:password_policy) { directory.password_policy }
8
+ let(:reset_email_template) { password_policy.reset_email_templates.first }
9
+
10
+ before do
11
+ test_api_client.account_store_mappings.create(
12
+ application: application,
13
+ account_store: directory,
14
+ list_index: 1,
15
+ is_default_account_store: false,
16
+ is_default_group_store: false
17
+ )
18
+ end
19
+
20
+ after { directory.delete }
21
+
22
+ it do
23
+ expect(reset_email_template).to be_a Stormpath::Resource::EmailTemplate
24
+
25
+ [:name,
26
+ :description,
27
+ :subject,
28
+ :from_email_address,
29
+ :text_body,
30
+ :html_body,
31
+ :mime_type].each do |property_accessor|
32
+ expect(reset_email_template).to respond_to(property_accessor)
33
+ expect(reset_email_template).to respond_to("#{property_accessor}=")
34
+ end
35
+ end
36
+
37
+ it 'can change attributes' do
38
+ reset_email_template.name = "Default Password Reset Template"
39
+ reset_email_template.description = "This is the password reset email template"
40
+ reset_email_template.subject = "Please reset your password"
41
+ reset_email_template.from_email_address = "email@stormpath.com"
42
+ reset_email_template.text_body = "You forgot your password! ${sptoken}"
43
+ reset_email_template.html_body = "<p> You forgot your password! </p> ${sptoken}"
44
+ reset_email_template.mime_type = "text/plain"
45
+
46
+ reset_email_template.save
47
+
48
+ reloaded_reset_email_template = password_policy.reset_email_templates.first
49
+
50
+ expect(reloaded_reset_email_template.name).to eq("Default Password Reset Template")
51
+ expect(reloaded_reset_email_template.description).to eq("This is the password reset email template")
52
+ expect(reloaded_reset_email_template.subject).to eq("Please reset your password")
53
+ expect(reloaded_reset_email_template.from_email_address).to eq("email@stormpath.com")
54
+ expect(reloaded_reset_email_template.text_body).to eq("You forgot your password! ${sptoken}")
55
+ expect(reloaded_reset_email_template.html_body).to eq("<p> You forgot your password! </p> ${sptoken}")
56
+ expect(reloaded_reset_email_template.mime_type).to eq("text/plain")
57
+ end
58
+ end
59
+ end
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stormpath::Resource::PasswordPolicy, :vcr do
4
+ describe "instances should respond to attribute property methods" do
5
+ let(:application) { test_application }
6
+ let(:directory) { test_api_client.directories.create(name: random_directory_name) }
7
+ let(:password_policy) { directory.password_policy }
8
+
9
+ before do
10
+ test_api_client.account_store_mappings.create(
11
+ application: application,
12
+ account_store: directory,
13
+ list_index: 1,
14
+ is_default_account_store: false,
15
+ is_default_group_store: false
16
+ )
17
+ end
18
+
19
+ after { directory.delete }
20
+
21
+ it do
22
+ expect(password_policy).to be_a Stormpath::Resource::PasswordPolicy
23
+
24
+ [:reset_token_ttl, :reset_email_status, :reset_success_email_status].each do |property_accessor|
25
+ expect(password_policy).to respond_to(property_accessor)
26
+ expect(password_policy).to respond_to("#{property_accessor}=")
27
+ end
28
+
29
+ expect(password_policy.strength).to be_a Stormpath::Resource::PasswordStrength
30
+ expect(password_policy.reset_email_templates).to be_a Stormpath::Resource::Collection
31
+ expect(password_policy.reset_success_email_templates).to be_a Stormpath::Resource::Collection
32
+
33
+ expect(password_policy.reset_email_templates.first).to be_a Stormpath::Resource::EmailTemplate
34
+ expect(password_policy.reset_success_email_templates.first).to be_a Stormpath::Resource::EmailTemplate
35
+ end
36
+
37
+ it 'can change reset_token_ttl' do
38
+ expect(directory.password_policy.reset_token_ttl).to eq(24)
39
+ password_policy.reset_token_ttl = 10
40
+ password_policy.save
41
+ expect(directory.password_policy.reset_token_ttl).to eq(10)
42
+ end
43
+
44
+ it 'can change reset_email_status' do
45
+ expect(directory.password_policy.reset_email_status).to eq("ENABLED")
46
+ password_policy.reset_email_status = "DISABLED"
47
+ password_policy.save
48
+ expect(directory.password_policy.reset_email_status).to eq("DISABLED")
49
+ end
50
+
51
+ it 'can change reset_success_email_status' do
52
+ expect(directory.password_policy.reset_success_email_status).to eq("ENABLED")
53
+ password_policy.reset_success_email_status = "DISABLED"
54
+ password_policy.save
55
+ expect(directory.password_policy.reset_success_email_status).to eq("DISABLED")
56
+ end
57
+ end
58
+ end