module Stormpath::Test::ResourceHelpers
Public Instance Methods
account_attrs(opts = {})
click to toggle source
# File spec/support/resource_helpers.rb 4 def account_attrs(opts = {}) 5 opts.tap do |o| 6 if !opts[:email].blank? && opts[:email] 7 if opts[:email].include?('@') 8 raise( 9 ArgumentError, 10 'Invalid email format. Please send the email without the domain. For example,' \ 11 " 'anakin.skywalker', instead of 'anakin.skywalker@darkside.com'" 12 ) 13 end 14 o[:email] = "#{opts[:email]}#{default_domain}" 15 else 16 o[:email] = "ruby#{random_number}#{default_domain}" 17 end 18 o[:username] = (!opts[:username].blank? && opts[:username]) || "ruby#{random_number}" 19 o[:password] = (!opts[:password].blank? && opts[:password]) || 'P@$$w0rd' 20 o[:surname] = (!opts[:surname].blank? && opts[:surname]) || 'ruby' 21 o[:given_name] = (!opts[:given_name].blank? && opts[:given_name]) || 'ruby' 22 o[:middle_name] = (!opts[:middle_name].blank? && opts[:middle_name]) || 'ruby' 23 o[:status] = (!opts[:status].blank? && opts[:status]) || 'ENABLED' 24 end 25 end
application_attrs(opts = {})
click to toggle source
# File spec/support/resource_helpers.rb 35 def application_attrs(opts = {}) 36 opts.tap do |o| 37 o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-app-#{random_number}" 38 o[:description] = (!opts[:description].blank? && opts[:description]) || 'ruby desc' 39 end 40 end
default_domain()
click to toggle source
# File spec/support/resource_helpers.rb 27 def default_domain 28 '@testmail.stormpath.com' 29 end
directory_attrs(opts = {})
click to toggle source
# File spec/support/resource_helpers.rb 42 def directory_attrs(opts = {}) 43 opts.tap do |o| 44 o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-dir-#{random_number}" 45 o[:description] = (!opts[:description].blank? && opts[:description]) || 'ruby desc' 46 end 47 end
enable_email_verification(directory)
click to toggle source
# File spec/support/resource_helpers.rb 64 def enable_email_verification(directory) 65 directory.account_creation_policy.verification_email_status = 'ENABLED' 66 directory.account_creation_policy.verification_success_email_status = 'ENABLED' 67 directory.account_creation_policy.welcome_email_status = 'ENABLED' 68 directory.account_creation_policy.save 69 end
group_attrs(opts = {})
click to toggle source
# File spec/support/resource_helpers.rb 57 def group_attrs(opts = {}) 58 opts.tap do |o| 59 o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-group-#{random_number}" 60 o[:description] = (!opts[:description].blank? && opts[:description]) || "ruby-group-desc-#{random_number}" 61 end 62 end
map_account_store(app, store, index, default_account_store, default_group_store)
click to toggle source
# File spec/support/resource_helpers.rb 71 def map_account_store(app, store, index, default_account_store, default_group_store) 72 test_api_client.account_store_mappings.create( 73 application: app, 74 account_store: store, 75 list_index: index, 76 is_default_account_store: default_account_store, 77 is_default_group_store: default_group_store 78 ) 79 end
map_organization_store(account_store, organization, default_account_store = false)
click to toggle source
# File spec/support/resource_helpers.rb 81 def map_organization_store(account_store, organization, default_account_store = false) 82 test_api_client.organization_account_store_mappings.create( 83 account_store: { href: account_store.href }, 84 organization: { href: organization.href }, 85 is_default_account_store: default_account_store 86 ) 87 end
organization_attrs(opts = {})
click to toggle source
# File spec/support/resource_helpers.rb 49 def organization_attrs(opts = {}) 50 opts.tap do |o| 51 o[:name] = (!opts[:name].blank? && opts[:name]) || "ruby-org-#{random_number}" 52 o[:description] = (!opts[:description].blank? && opts[:description]) || "ruby-org-#{random_number}" 53 o[:name_key] = (!opts[:name_key].blank? && opts[:name_key]) || "ruby-org-#{random_number}" 54 end 55 end
random_number()
click to toggle source
# File spec/support/resource_helpers.rb 89 def random_number 90 SecureRandom.hex(15) 91 end
test_host()
click to toggle source
# File spec/support/resource_helpers.rb 31 def test_host 32 Stormpath::DataStore::DEFAULT_SERVER_HOST 33 end