Module: Ey::Core::TestHelpers::AccountHelpers
- Included in:
- Ey::Core::TestHelpers
- Defined in:
- lib/ey-core/test_helpers/account_helpers.rb
Instance Method Summary collapse
- #create_account(options = {}) ⇒ Object
- #create_provider(options = {}) ⇒ Object
- #create_user(options = {}) ⇒ Object
Instance Method Details
#create_account(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ey-core/test_helpers/account_helpers.rb', line 5 def create_account(={}) client = [:client] creator = [:creator] || client || create_client attributes = [:account] || {} attributes[:type] ||= "beta" # get around awsm billing requirements for tests attributes[:name] ||= SecureRandom.hex(6) if client attributes[:owner] ||= begin client.users.current rescue Ey::Core::Response::NotFound end end attributes[:owner] ||= create_user(client: client) created_account = (client || creator).accounts.create!(attributes) if client client.accounts.get!(created_account.identity) else created_account end end |
#create_provider(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ey-core/test_helpers/account_helpers.rb', line 47 def create_provider(={}) account = [:account] || create_account() attributes = [:provider] || {} attributes[:type] ||= :aws attributes[:provisioned_id] ||= SecureRandom.hex(8) attributes[:credentials] ||= case attributes[:type] when :aws then { :instance_aws_secret_id => SecureRandom.hex(6), :instance_aws_secret_key => SecureRandom.hex(6), :aws_secret_id => SecureRandom.hex(6), :aws_secret_key => SecureRandom.hex(6), :aws_login => Faker::Internet.email, :aws_pass => SecureRandom.hex(6), } when :azure then { } end account.providers.create!(attributes).resource! end |
#create_user(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ey-core/test_helpers/account_helpers.rb', line 30 def create_user(={}) client = [:client] creator = [:creator] || client || create_client attributes = [:user] || {} attributes[:name] ||= Faker::Name.name attributes[:email] ||= Faker::Internet.email created_user = creator.users.create!(attributes) if client client.users.get!(created_user.identity) else created_user end end |