ey-core 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.ruby-version +1 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +167 -0
- data/Gemfile +28 -0
- data/Guardfile +15 -0
- data/LICENSE.txt +19 -0
- data/README.md +82 -0
- data/Rakefile +15 -0
- data/bin/ey-core +4 -0
- data/ey-core.gemspec +28 -0
- data/lib/ey-core.rb +59 -0
- data/lib/ey-core/associations.rb +155 -0
- data/lib/ey-core/cli.rb +118 -0
- data/lib/ey-core/client.rb +402 -0
- data/lib/ey-core/client/mock.rb +288 -0
- data/lib/ey-core/client/real.rb +93 -0
- data/lib/ey-core/collection.rb +131 -0
- data/lib/ey-core/collections/account_cancellations.rb +6 -0
- data/lib/ey-core/collections/account_referrals.rb +10 -0
- data/lib/ey-core/collections/accounts.rb +8 -0
- data/lib/ey-core/collections/addons.rb +16 -0
- data/lib/ey-core/collections/addresses.rb +9 -0
- data/lib/ey-core/collections/alerts.rb +9 -0
- data/lib/ey-core/collections/application_archives.rb +9 -0
- data/lib/ey-core/collections/application_deployments.rb +9 -0
- data/lib/ey-core/collections/applications.rb +9 -0
- data/lib/ey-core/collections/backup_files.rb +9 -0
- data/lib/ey-core/collections/components.rb +9 -0
- data/lib/ey-core/collections/contacts.rb +9 -0
- data/lib/ey-core/collections/costs.rb +8 -0
- data/lib/ey-core/collections/database_plan_usages.rb +7 -0
- data/lib/ey-core/collections/database_server_revisions.rb +7 -0
- data/lib/ey-core/collections/database_server_snapshots.rb +17 -0
- data/lib/ey-core/collections/database_server_usages.rb +7 -0
- data/lib/ey-core/collections/database_servers.rb +9 -0
- data/lib/ey-core/collections/database_services.rb +9 -0
- data/lib/ey-core/collections/environment_plan_usages.rb +7 -0
- data/lib/ey-core/collections/environments.rb +15 -0
- data/lib/ey-core/collections/features.rb +9 -0
- data/lib/ey-core/collections/firewall_rules.rb +9 -0
- data/lib/ey-core/collections/firewalls.rb +9 -0
- data/lib/ey-core/collections/gems.rb +6 -0
- data/lib/ey-core/collections/keypair_deployments.rb +9 -0
- data/lib/ey-core/collections/keypairs.rb +9 -0
- data/lib/ey-core/collections/legacy_alerts.rb +9 -0
- data/lib/ey-core/collections/load_balancer_nodes.rb +9 -0
- data/lib/ey-core/collections/load_balancer_services.rb +9 -0
- data/lib/ey-core/collections/load_balancers.rb +16 -0
- data/lib/ey-core/collections/logical_databases.rb +16 -0
- data/lib/ey-core/collections/logs.rb +9 -0
- data/lib/ey-core/collections/memberships.rb +9 -0
- data/lib/ey-core/collections/messages.rb +9 -0
- data/lib/ey-core/collections/plan_usages.rb +7 -0
- data/lib/ey-core/collections/provider_locations.rb +13 -0
- data/lib/ey-core/collections/providers.rb +15 -0
- data/lib/ey-core/collections/requests.rb +10 -0
- data/lib/ey-core/collections/server_events.rb +9 -0
- data/lib/ey-core/collections/server_usages.rb +7 -0
- data/lib/ey-core/collections/servers.rb +9 -0
- data/lib/ey-core/collections/services.rb +14 -0
- data/lib/ey-core/collections/ssl_certificates.rb +9 -0
- data/lib/ey-core/collections/storage_users.rb +10 -0
- data/lib/ey-core/collections/storages.rb +9 -0
- data/lib/ey-core/collections/tasks.rb +9 -0
- data/lib/ey-core/collections/tokens.rb +8 -0
- data/lib/ey-core/collections/untracked_addresses.rb +4 -0
- data/lib/ey-core/collections/untracked_servers.rb +9 -0
- data/lib/ey-core/collections/users.rb +12 -0
- data/lib/ey-core/collections/volumes.rb +9 -0
- data/lib/ey-core/logger.rb +31 -0
- data/lib/ey-core/memory_cache.rb +17 -0
- data/lib/ey-core/mock/helper.rb +104 -0
- data/lib/ey-core/mock/params.rb +31 -0
- data/lib/ey-core/mock/resources.rb +92 -0
- data/lib/ey-core/mock/searching.rb +111 -0
- data/lib/ey-core/mock/util.rb +23 -0
- data/lib/ey-core/model.rb +39 -0
- data/lib/ey-core/models/account.rb +65 -0
- data/lib/ey-core/models/account_cancellation.rb +6 -0
- data/lib/ey-core/models/account_referral.rb +8 -0
- data/lib/ey-core/models/account_trial.rb +15 -0
- data/lib/ey-core/models/addon.rb +37 -0
- data/lib/ey-core/models/address.rb +57 -0
- data/lib/ey-core/models/alert.rb +94 -0
- data/lib/ey-core/models/application.rb +32 -0
- data/lib/ey-core/models/application_archive.rb +67 -0
- data/lib/ey-core/models/application_deployment.rb +18 -0
- data/lib/ey-core/models/backup_file.rb +52 -0
- data/lib/ey-core/models/billing.rb +27 -0
- data/lib/ey-core/models/component.rb +11 -0
- data/lib/ey-core/models/contact.rb +14 -0
- data/lib/ey-core/models/cost.rb +16 -0
- data/lib/ey-core/models/database_plan_usage.rb +10 -0
- data/lib/ey-core/models/database_server.rb +56 -0
- data/lib/ey-core/models/database_server_revision.rb +10 -0
- data/lib/ey-core/models/database_server_snapshot.rb +43 -0
- data/lib/ey-core/models/database_server_usage.rb +15 -0
- data/lib/ey-core/models/database_service.rb +52 -0
- data/lib/ey-core/models/environment.rb +143 -0
- data/lib/ey-core/models/environment_plan_usage.rb +10 -0
- data/lib/ey-core/models/feature.rb +33 -0
- data/lib/ey-core/models/firewall.rb +46 -0
- data/lib/ey-core/models/firewall_rule.rb +41 -0
- data/lib/ey-core/models/gem.rb +5 -0
- data/lib/ey-core/models/keypair.rb +38 -0
- data/lib/ey-core/models/keypair_deployment.rb +26 -0
- data/lib/ey-core/models/legacy_alert.rb +12 -0
- data/lib/ey-core/models/load_balancer.rb +43 -0
- data/lib/ey-core/models/load_balancer_node.rb +17 -0
- data/lib/ey-core/models/load_balancer_service.rb +22 -0
- data/lib/ey-core/models/log.rb +33 -0
- data/lib/ey-core/models/logical_database.rb +40 -0
- data/lib/ey-core/models/membership.rb +49 -0
- data/lib/ey-core/models/message.rb +27 -0
- data/lib/ey-core/models/plan_usage.rb +14 -0
- data/lib/ey-core/models/provider.rb +59 -0
- data/lib/ey-core/models/provider_location.rb +11 -0
- data/lib/ey-core/models/request.rb +93 -0
- data/lib/ey-core/models/server.rb +76 -0
- data/lib/ey-core/models/server_event.rb +11 -0
- data/lib/ey-core/models/server_usage.rb +15 -0
- data/lib/ey-core/models/service.rb +10 -0
- data/lib/ey-core/models/ssl_certificate.rb +44 -0
- data/lib/ey-core/models/storage.rb +38 -0
- data/lib/ey-core/models/storage_user.rb +44 -0
- data/lib/ey-core/models/support_trial.rb +10 -0
- data/lib/ey-core/models/task.rb +35 -0
- data/lib/ey-core/models/token.rb +20 -0
- data/lib/ey-core/models/untracked_address.rb +24 -0
- data/lib/ey-core/models/untracked_server.rb +45 -0
- data/lib/ey-core/models/user.rb +35 -0
- data/lib/ey-core/models/volume.rb +20 -0
- data/lib/ey-core/request.rb +21 -0
- data/lib/ey-core/request_failure.rb +11 -0
- data/lib/ey-core/requests/attach_address.rb +53 -0
- data/lib/ey-core/requests/authorized_channel.rb +22 -0
- data/lib/ey-core/requests/boot_environment.rb +131 -0
- data/lib/ey-core/requests/bootstrap_logical_database.rb +80 -0
- data/lib/ey-core/requests/cancel_account.rb +33 -0
- data/lib/ey-core/requests/create_account.rb +33 -0
- data/lib/ey-core/requests/create_addon.rb +35 -0
- data/lib/ey-core/requests/create_address.rb +53 -0
- data/lib/ey-core/requests/create_alert.rb +63 -0
- data/lib/ey-core/requests/create_application.rb +72 -0
- data/lib/ey-core/requests/create_application_archive.rb +44 -0
- data/lib/ey-core/requests/create_backup_file.rb +52 -0
- data/lib/ey-core/requests/create_database_server.rb +72 -0
- data/lib/ey-core/requests/create_database_service.rb +57 -0
- data/lib/ey-core/requests/create_database_service_snapshot.rb +69 -0
- data/lib/ey-core/requests/create_environment.rb +69 -0
- data/lib/ey-core/requests/create_firewall.rb +62 -0
- data/lib/ey-core/requests/create_firewall_rule.rb +60 -0
- data/lib/ey-core/requests/create_keypair.rb +42 -0
- data/lib/ey-core/requests/create_keypair_deployment.rb +36 -0
- data/lib/ey-core/requests/create_load_balancer.rb +62 -0
- data/lib/ey-core/requests/create_log.rb +53 -0
- data/lib/ey-core/requests/create_logical_database.rb +56 -0
- data/lib/ey-core/requests/create_membership.rb +47 -0
- data/lib/ey-core/requests/create_message.rb +35 -0
- data/lib/ey-core/requests/create_password_reset.rb +38 -0
- data/lib/ey-core/requests/create_provider.rb +90 -0
- data/lib/ey-core/requests/create_ssl_certificate.rb +83 -0
- data/lib/ey-core/requests/create_storage.rb +64 -0
- data/lib/ey-core/requests/create_storage_user.rb +64 -0
- data/lib/ey-core/requests/create_task.rb +55 -0
- data/lib/ey-core/requests/create_token.rb +24 -0
- data/lib/ey-core/requests/create_untracked_address.rb +48 -0
- data/lib/ey-core/requests/create_untracked_server.rb +39 -0
- data/lib/ey-core/requests/create_user.rb +43 -0
- data/lib/ey-core/requests/deploy_environment_application.rb +43 -0
- data/lib/ey-core/requests/deprovision_environment.rb +17 -0
- data/lib/ey-core/requests/destroy_addon.rb +24 -0
- data/lib/ey-core/requests/destroy_database_server.rb +41 -0
- data/lib/ey-core/requests/destroy_database_server_snapshot.rb +42 -0
- data/lib/ey-core/requests/destroy_database_service.rb +57 -0
- data/lib/ey-core/requests/destroy_environment.rb +43 -0
- data/lib/ey-core/requests/destroy_firewall.rb +41 -0
- data/lib/ey-core/requests/destroy_firewall_rule.rb +41 -0
- data/lib/ey-core/requests/destroy_load_balancer.rb +30 -0
- data/lib/ey-core/requests/destroy_logical_database.rb +41 -0
- data/lib/ey-core/requests/destroy_provider.rb +34 -0
- data/lib/ey-core/requests/destroy_server.rb +46 -0
- data/lib/ey-core/requests/destroy_ssl_certificate.rb +28 -0
- data/lib/ey-core/requests/destroy_storage.rb +33 -0
- data/lib/ey-core/requests/destroy_storage_user.rb +38 -0
- data/lib/ey-core/requests/destroy_user.rb +29 -0
- data/lib/ey-core/requests/detach_address.rb +48 -0
- data/lib/ey-core/requests/disable_feature.rb +30 -0
- data/lib/ey-core/requests/discover_database_server.rb +66 -0
- data/lib/ey-core/requests/discover_database_server_snapshots.rb +69 -0
- data/lib/ey-core/requests/discover_provider_location.rb +57 -0
- data/lib/ey-core/requests/download_file.rb +25 -0
- data/lib/ey-core/requests/enable_feature.rb +35 -0
- data/lib/ey-core/requests/get_account.rb +29 -0
- data/lib/ey-core/requests/get_account_cancellation.rb +21 -0
- data/lib/ey-core/requests/get_account_referrals.rb +28 -0
- data/lib/ey-core/requests/get_account_trial.rb +31 -0
- data/lib/ey-core/requests/get_accounts.rb +42 -0
- data/lib/ey-core/requests/get_addon.rb +25 -0
- data/lib/ey-core/requests/get_addons.rb +24 -0
- data/lib/ey-core/requests/get_address.rb +25 -0
- data/lib/ey-core/requests/get_addresses.rb +27 -0
- data/lib/ey-core/requests/get_alert.rb +21 -0
- data/lib/ey-core/requests/get_alerting_environments.rb +37 -0
- data/lib/ey-core/requests/get_alerts.rb +44 -0
- data/lib/ey-core/requests/get_api_token.rb +19 -0
- data/lib/ey-core/requests/get_application.rb +21 -0
- data/lib/ey-core/requests/get_application_archive.rb +32 -0
- data/lib/ey-core/requests/get_application_archives.rb +29 -0
- data/lib/ey-core/requests/get_application_deployment.rb +21 -0
- data/lib/ey-core/requests/get_application_deployments.rb +28 -0
- data/lib/ey-core/requests/get_applications.rb +28 -0
- data/lib/ey-core/requests/get_backup_file.rb +21 -0
- data/lib/ey-core/requests/get_backup_files.rb +28 -0
- data/lib/ey-core/requests/get_billing.rb +24 -0
- data/lib/ey-core/requests/get_component.rb +21 -0
- data/lib/ey-core/requests/get_components.rb +29 -0
- data/lib/ey-core/requests/get_contacts.rb +34 -0
- data/lib/ey-core/requests/get_costs.rb +25 -0
- data/lib/ey-core/requests/get_current_user.rb +19 -0
- data/lib/ey-core/requests/get_database_plan_usages.rb +24 -0
- data/lib/ey-core/requests/get_database_server.rb +21 -0
- data/lib/ey-core/requests/get_database_server_revisions.rb +27 -0
- data/lib/ey-core/requests/get_database_server_snapshot.rb +20 -0
- data/lib/ey-core/requests/get_database_server_snapshots.rb +39 -0
- data/lib/ey-core/requests/get_database_server_usages.rb +24 -0
- data/lib/ey-core/requests/get_database_servers.rb +30 -0
- data/lib/ey-core/requests/get_database_servers_firewalls.rb +30 -0
- data/lib/ey-core/requests/get_database_service.rb +20 -0
- data/lib/ey-core/requests/get_database_services.rb +55 -0
- data/lib/ey-core/requests/get_environment.rb +21 -0
- data/lib/ey-core/requests/get_environment_database_services.rb +21 -0
- data/lib/ey-core/requests/get_environment_logical_databases.rb +20 -0
- data/lib/ey-core/requests/get_environment_plan_usages.rb +24 -0
- data/lib/ey-core/requests/get_environments.rb +29 -0
- data/lib/ey-core/requests/get_feature.rb +21 -0
- data/lib/ey-core/requests/get_features.rb +28 -0
- data/lib/ey-core/requests/get_firewall.rb +21 -0
- data/lib/ey-core/requests/get_firewall_rule.rb +21 -0
- data/lib/ey-core/requests/get_firewall_rules.rb +29 -0
- data/lib/ey-core/requests/get_firewalls.rb +45 -0
- data/lib/ey-core/requests/get_gem.rb +24 -0
- data/lib/ey-core/requests/get_keypair.rb +21 -0
- data/lib/ey-core/requests/get_keypair_deployment.rb +21 -0
- data/lib/ey-core/requests/get_keypair_deployments.rb +29 -0
- data/lib/ey-core/requests/get_keypairs.rb +34 -0
- data/lib/ey-core/requests/get_legacy_alert.rb +21 -0
- data/lib/ey-core/requests/get_legacy_alerts.rb +29 -0
- data/lib/ey-core/requests/get_load_balancer.rb +21 -0
- data/lib/ey-core/requests/get_load_balancer_node.rb +21 -0
- data/lib/ey-core/requests/get_load_balancer_nodes.rb +30 -0
- data/lib/ey-core/requests/get_load_balancer_service.rb +21 -0
- data/lib/ey-core/requests/get_load_balancer_services.rb +30 -0
- data/lib/ey-core/requests/get_load_balancers.rb +29 -0
- data/lib/ey-core/requests/get_log.rb +21 -0
- data/lib/ey-core/requests/get_logical_database.rb +23 -0
- data/lib/ey-core/requests/get_logical_databases.rb +36 -0
- data/lib/ey-core/requests/get_logs.rb +37 -0
- data/lib/ey-core/requests/get_membership.rb +21 -0
- data/lib/ey-core/requests/get_memberships.rb +29 -0
- data/lib/ey-core/requests/get_message.rb +28 -0
- data/lib/ey-core/requests/get_messages.rb +27 -0
- data/lib/ey-core/requests/get_metadata.rb +22 -0
- data/lib/ey-core/requests/get_operational_contact.rb +21 -0
- data/lib/ey-core/requests/get_operational_contacts.rb +20 -0
- data/lib/ey-core/requests/get_plan_usages.rb +24 -0
- data/lib/ey-core/requests/get_possible_provider_locations.rb +19 -0
- data/lib/ey-core/requests/get_provider.rb +21 -0
- data/lib/ey-core/requests/get_provider_location.rb +29 -0
- data/lib/ey-core/requests/get_provider_locations.rb +28 -0
- data/lib/ey-core/requests/get_providers.rb +28 -0
- data/lib/ey-core/requests/get_request.rb +71 -0
- data/lib/ey-core/requests/get_requests.rb +29 -0
- data/lib/ey-core/requests/get_server.rb +34 -0
- data/lib/ey-core/requests/get_server_event.rb +20 -0
- data/lib/ey-core/requests/get_server_events.rb +28 -0
- data/lib/ey-core/requests/get_server_usages.rb +24 -0
- data/lib/ey-core/requests/get_servers.rb +25 -0
- data/lib/ey-core/requests/get_ssl_certificate.rb +23 -0
- data/lib/ey-core/requests/get_ssl_certificates.rb +28 -0
- data/lib/ey-core/requests/get_storage.rb +21 -0
- data/lib/ey-core/requests/get_storage_user.rb +21 -0
- data/lib/ey-core/requests/get_storage_users.rb +28 -0
- data/lib/ey-core/requests/get_storages.rb +28 -0
- data/lib/ey-core/requests/get_support_trial.rb +51 -0
- data/lib/ey-core/requests/get_task.rb +21 -0
- data/lib/ey-core/requests/get_tasks.rb +28 -0
- data/lib/ey-core/requests/get_untracked_server.rb +18 -0
- data/lib/ey-core/requests/get_untracked_servers.rb +24 -0
- data/lib/ey-core/requests/get_user.rb +21 -0
- data/lib/ey-core/requests/get_users.rb +42 -0
- data/lib/ey-core/requests/get_volume.rb +21 -0
- data/lib/ey-core/requests/get_volumes.rb +28 -0
- data/lib/ey-core/requests/reboot_server.rb +39 -0
- data/lib/ey-core/requests/request_callback.rb +26 -0
- data/lib/ey-core/requests/reset_password.rb +31 -0
- data/lib/ey-core/requests/run_cluster_application_action.rb +28 -0
- data/lib/ey-core/requests/run_environment_application_action.rb +29 -0
- data/lib/ey-core/requests/signup.rb +56 -0
- data/lib/ey-core/requests/update_addon.rb +28 -0
- data/lib/ey-core/requests/update_address.rb +29 -0
- data/lib/ey-core/requests/update_alert.rb +32 -0
- data/lib/ey-core/requests/update_application_archive.rb +23 -0
- data/lib/ey-core/requests/update_billing.rb +26 -0
- data/lib/ey-core/requests/update_connector.rb +32 -0
- data/lib/ey-core/requests/update_membership.rb +29 -0
- data/lib/ey-core/requests/update_server.rb +29 -0
- data/lib/ey-core/requests/update_ssl_certificate.rb +25 -0
- data/lib/ey-core/requests/update_untracked_server.rb +24 -0
- data/lib/ey-core/requests/upload_file.rb +44 -0
- data/lib/ey-core/response.rb +55 -0
- data/lib/ey-core/response_cache.rb +29 -0
- data/lib/ey-core/subscribable.rb +49 -0
- data/lib/ey-core/token_authentication.rb +13 -0
- data/lib/ey-core/version.rb +5 -0
- data/spec/account_trial_spec.rb +17 -0
- data/spec/accounts_referrals_spec.rb +20 -0
- data/spec/accounts_spec.rb +113 -0
- data/spec/addons_and_vars_spec.rb +62 -0
- data/spec/addresses_spec.rb +56 -0
- data/spec/alerts_spec.rb +148 -0
- data/spec/application_archives_spec.rb +39 -0
- data/spec/applications_spec.rb +65 -0
- data/spec/billing_spec.rb +31 -0
- data/spec/client_spec.rb +16 -0
- data/spec/collection_spec.rb +43 -0
- data/spec/costs_spec.rb +22 -0
- data/spec/database_plan_usage_spec.rb +39 -0
- data/spec/database_server_snapshots_spec.rb +41 -0
- data/spec/database_server_usage_spec.rb +49 -0
- data/spec/database_servers_spec.rb +61 -0
- data/spec/database_services_spec.rb +76 -0
- data/spec/environment_plan_usage_spec.rb +38 -0
- data/spec/environments_spec.rb +106 -0
- data/spec/features_spec.rb +79 -0
- data/spec/firewalls_spec.rb +84 -0
- data/spec/gems_spec.rb +11 -0
- data/spec/keypair_deployments_spec.rb +33 -0
- data/spec/keypairs_spec.rb +51 -0
- data/spec/legacy_alerts_spec.rb +44 -0
- data/spec/load_balancers_spec.rb +31 -0
- data/spec/logical_databases_spec.rb +38 -0
- data/spec/logs_spec.rb +44 -0
- data/spec/memberships_spec.rb +70 -0
- data/spec/messages_spec.rb +27 -0
- data/spec/metadata_spec.rb +11 -0
- data/spec/plan_usage_spec.rb +65 -0
- data/spec/provider_locations_spec.rb +64 -0
- data/spec/providers_spec.rb +105 -0
- data/spec/requests/upload_file_spec.rb +25 -0
- data/spec/requests_spec.rb +23 -0
- data/spec/reset_password_spec.rb +22 -0
- data/spec/server_events_spec.rb +31 -0
- data/spec/server_usage_spec.rb +70 -0
- data/spec/servers_spec.rb +55 -0
- data/spec/services_spec.rb +9 -0
- data/spec/signups_spec.rb +45 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/ssl_certificates_spec.rb +94 -0
- data/spec/storages_spec.rb +57 -0
- data/spec/support/account_helper.rb +71 -0
- data/spec/support/alert_helper.rb +14 -0
- data/spec/support/client_helper.rb +38 -0
- data/spec/support/core.rb +23 -0
- data/spec/support/coverage.rb +43 -0
- data/spec/support/resource_helper.rb +190 -0
- data/spec/support/timecop.rb +8 -0
- data/spec/support_trial_spec.rb +33 -0
- data/spec/tokens_spec.rb +19 -0
- data/spec/untracked_servers_spec.rb +59 -0
- data/spec/users_spec.rb +82 -0
- metadata +574 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'signups' do
|
4
|
+
context "with a hmac client" do
|
5
|
+
let!(:client) { create_client }
|
6
|
+
|
7
|
+
let!(:public_feature) do
|
8
|
+
if Ey::Core::Client.mocking?
|
9
|
+
client.create_feature(
|
10
|
+
:id => "public_feature",
|
11
|
+
:privacy => "public",
|
12
|
+
:name => "A Public Feature",
|
13
|
+
)
|
14
|
+
else
|
15
|
+
client.features.all.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create a user and account" do
|
20
|
+
user_params = {
|
21
|
+
:name => Faker::Name.name,
|
22
|
+
:email => Faker::Internet.email,
|
23
|
+
:password => SecureRandom.hex(8),
|
24
|
+
}
|
25
|
+
account_params = {
|
26
|
+
:account_name => SecureRandom.hex(6),
|
27
|
+
}
|
28
|
+
features = [ public_feature.id ]
|
29
|
+
|
30
|
+
signup = client.signup(user: user_params, account: account_params, features: features, redirect_url: "http://redirect.example.com").body["signup"]
|
31
|
+
user = client.users.get(signup["user_id"])
|
32
|
+
account = client.accounts.get(signup["account_id"])
|
33
|
+
|
34
|
+
expect(user.name).to eq(user_params[:name])
|
35
|
+
expect(user.email).to eq(user_params[:email])
|
36
|
+
|
37
|
+
expect(account.name).to eq(account_params[:name])
|
38
|
+
|
39
|
+
expect(user.accounts).to contain_exactly(account)
|
40
|
+
expect(account.features.map(&:id)).to include(*features)
|
41
|
+
|
42
|
+
expect(signup["upgrade_url"]).not_to be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
ENV['MOCK_CORE'] ||= 'true'
|
2
|
+
ENV['CORE_URL'] ||= "http://api-development.localdev.engineyard.com:9292"
|
3
|
+
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
Bundler.require(:default, :test)
|
7
|
+
|
8
|
+
require File.expand_path("../../lib/ey-core", __FILE__)
|
9
|
+
Dir[File.expand_path("../{shared,support}/*.rb", __FILE__)].each{|f| require(f)}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.order = "random"
|
13
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'as a user' do
|
4
|
+
let!(:client) { create_client }
|
5
|
+
let!(:user) { client.users.create!(name: Faker::Name.name, email: Faker::Internet.email) }
|
6
|
+
let(:client) { create_client }
|
7
|
+
let(:account) { client.accounts.create!(owner: user, name: Faker::Name.first_name) }
|
8
|
+
|
9
|
+
let(:random_cert) do
|
10
|
+
key = OpenSSL::PKey::RSA.new(1024)
|
11
|
+
name = OpenSSL::X509::Name.parse("/CN=example.org")
|
12
|
+
|
13
|
+
# NB: the order in which these attributes are set seems to be
|
14
|
+
# important in making it self-signed and not just a certificate
|
15
|
+
# with a mystery issuer. It's not clear which attributes have
|
16
|
+
# the ordering requirement.
|
17
|
+
cert = OpenSSL::X509::Certificate.new
|
18
|
+
cert.version = 2
|
19
|
+
cert.serial = Time.now.tv_sec # monotonically increasing
|
20
|
+
cert.not_before = Time.now - (7 * 24 * 60 * 60) # allow for plenty of clock skew
|
21
|
+
cert.not_after = Time.now + (10 * 356 * 24 * 60 * 60) # allow for plenty of clock skew
|
22
|
+
cert.subject = name
|
23
|
+
cert.public_key = key.public_key
|
24
|
+
cert.issuer = name
|
25
|
+
|
26
|
+
cert.sign(key, OpenSSL::Digest::SHA1.new)
|
27
|
+
|
28
|
+
{ cert: cert.to_pem, key: key.to_pem }
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_ssl_certificate(params={})
|
32
|
+
params = {
|
33
|
+
account: account,
|
34
|
+
name: "#{Faker::Name.first_name}_cert",
|
35
|
+
}.merge!(params)
|
36
|
+
|
37
|
+
unless params[:self_sign]
|
38
|
+
params[:public_certificate] = random_cert[:cert]
|
39
|
+
params[:private_key] = random_cert[:key]
|
40
|
+
end
|
41
|
+
|
42
|
+
client.ssl_certificates.create!(params).resource!
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can create an ssl certificate" do
|
46
|
+
ssl_certificate = create_ssl_certificate
|
47
|
+
expect(ssl_certificate.id).to be
|
48
|
+
expect(ssl_certificate.public_certificate.strip).to eq(random_cert[:cert].strip)
|
49
|
+
expect(ssl_certificate.private_key.strip).to eq(random_cert[:key].strip)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "create a self signed certificate" do
|
53
|
+
ssl_certificate = create_ssl_certificate(name: "self-signed", self_sign: true)
|
54
|
+
|
55
|
+
expect(ssl_certificate.certificate_chain).to eq(nil)
|
56
|
+
expect(ssl_certificate.id).to be
|
57
|
+
expect(ssl_certificate.name).to eq("self-signed")
|
58
|
+
expect(ssl_certificate.self_signed).to eq(true)
|
59
|
+
expect(ssl_certificate.private_key.strip).not_to eq(random_cert[:key].strip)
|
60
|
+
expect(ssl_certificate.public_certificate.strip).not_to eq(random_cert[:cert].strip)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can get a created ssl certificate" do
|
64
|
+
ssl_certificate = create_ssl_certificate
|
65
|
+
ssl_certificate = client.ssl_certificates.get(ssl_certificate.id)
|
66
|
+
expect(ssl_certificate).to be
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can update an ssl certificate", focus: true do
|
70
|
+
ssl_certificate = create_ssl_certificate
|
71
|
+
ssl_certificate.name = "changed"
|
72
|
+
ssl_certificate.save!
|
73
|
+
|
74
|
+
ssl_certificate = client.ssl_certificates.get(ssl_certificate.id)
|
75
|
+
expect(ssl_certificate.name).to eq("changed")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "can destroy a ssl certificate" do
|
79
|
+
ssl_certificate = create_ssl_certificate
|
80
|
+
expect { ssl_certificate.destroy }.to change { client.ssl_certificates.all.size }.by(-1)
|
81
|
+
expect(client.ssl_certificates.get(ssl_certificate.id).deleted_at).to_not be(nil)
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "from account" do
|
85
|
+
it "can get a list of ssl certificates for an account" do
|
86
|
+
create_ssl_certificate
|
87
|
+
|
88
|
+
other_account = client.accounts.create!(owner: user, name: Faker::Name.first_name)
|
89
|
+
create_ssl_certificate(account: other_account, name: "other")
|
90
|
+
|
91
|
+
expect(account.ssl_certificates.size).to eq(1)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'storages' do
|
4
|
+
let!(:client) { create_client }
|
5
|
+
let!(:account) { create_account(client: client) }
|
6
|
+
let!(:provider) { create_provider(account: account) }
|
7
|
+
|
8
|
+
it "should create a storage" do
|
9
|
+
storage_request = provider.storages.create!(name: SecureRandom.hex(6), location: "us-east-1", provider: provider)
|
10
|
+
storage_request.ready!
|
11
|
+
expect(storage_request.successful).to be_truthy
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "with a storage" do
|
15
|
+
let!(:storage) { provider.storages.create!(name: SecureRandom.hex(6), location: "us-east-1", provider: provider).resource! }
|
16
|
+
|
17
|
+
it "should list storages" do
|
18
|
+
expect(client.storages).to include(storage)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should get a storage" do
|
22
|
+
expect(client.storages.get(storage.identity)).to eq(storage)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should destroy a storage" do
|
26
|
+
destroy_request = storage.destroy!
|
27
|
+
destroy_request.ready!
|
28
|
+
expect(destroy_request.successful).to be(true)
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "users" do
|
32
|
+
it "should create a new storage user" do
|
33
|
+
request = storage.storage_users.create!(username: SecureRandom.hex(6), storage: storage, permissions: "admin")
|
34
|
+
request.ready!
|
35
|
+
expect(request.successful).to be(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "with a user" do
|
39
|
+
let!(:user) { storage.storage_users.create!(username: SecureRandom.hex(6), storage: storage, permissions: "admin").resource! }
|
40
|
+
|
41
|
+
it "should list storage users" do
|
42
|
+
expect(storage.storage_users).to include(user)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should get a storage user" do
|
46
|
+
expect(storage.storage_users.get(user.id)).to eq(user)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should destroy a storage user" do
|
50
|
+
request = user.destroy!
|
51
|
+
request.ready!
|
52
|
+
expect(request.successful).to be(true)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module AccountHelper
|
2
|
+
def create_account(options={})
|
3
|
+
creator = options[:creator] || create_client
|
4
|
+
client = options[:client]
|
5
|
+
|
6
|
+
attributes = options[:account] || {}
|
7
|
+
attributes[:type] ||= "beta" # get around awsm billing requirements for tests
|
8
|
+
attributes[:name] ||= SecureRandom.hex(6)
|
9
|
+
|
10
|
+
if client
|
11
|
+
attributes[:owner] ||= begin
|
12
|
+
client.users.current
|
13
|
+
rescue Ey::Core::Response::NotFound
|
14
|
+
end
|
15
|
+
end
|
16
|
+
attributes[:owner] ||= create_user(client: client)
|
17
|
+
|
18
|
+
created_account = (client || creator).accounts.create!(attributes)
|
19
|
+
|
20
|
+
if client
|
21
|
+
client.accounts.get!(created_account.identity)
|
22
|
+
else
|
23
|
+
created_account
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_user(options={})
|
28
|
+
creator = options[:creator] || create_client
|
29
|
+
client = options[:client]
|
30
|
+
|
31
|
+
attributes = options[:user] || {}
|
32
|
+
attributes[:name] ||= Faker::Name.name
|
33
|
+
attributes[:email] ||= Faker::Internet.email
|
34
|
+
|
35
|
+
created_user = creator.users.create!(attributes)
|
36
|
+
|
37
|
+
if client
|
38
|
+
client.users.get!(created_user.identity)
|
39
|
+
else
|
40
|
+
created_user
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_provider(options={})
|
45
|
+
account = options[:account] || create_account(options)
|
46
|
+
|
47
|
+
attributes = options[:provider] || {}
|
48
|
+
attributes[:type] ||= :aws
|
49
|
+
attributes[:provisioned_id] ||= SecureRandom.hex(8)
|
50
|
+
attributes[:credentials] ||= case attributes[:type]
|
51
|
+
when :aws then
|
52
|
+
{
|
53
|
+
:instance_aws_secret_id => SecureRandom.hex(6),
|
54
|
+
:instance_aws_secret_key => SecureRandom.hex(6),
|
55
|
+
:aws_secret_id => SecureRandom.hex(6),
|
56
|
+
:aws_secret_key => SecureRandom.hex(6),
|
57
|
+
:aws_login => Faker::Internet.email,
|
58
|
+
:aws_pass => SecureRandom.hex(6),
|
59
|
+
}
|
60
|
+
when :azure then
|
61
|
+
{
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
account.providers.create!(attributes).resource!
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
RSpec.configure do |config|
|
70
|
+
config.include(AccountHelper)
|
71
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module LegacyAlertHelper
|
2
|
+
def create_legacy_alert(client, attributes={})
|
3
|
+
attributes = Cistern::Hash.stringify_keys(attributes)
|
4
|
+
|
5
|
+
if server = attributes.delete("server")
|
6
|
+
attributes["server"] = client.url_for("/servers/#{server.id}")
|
7
|
+
end
|
8
|
+
client.data[:legacy_alerts][attributes["id"]] = attributes
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.include(LegacyAlertHelper)
|
14
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ClientHelper
|
2
|
+
def create_client(attributes={})
|
3
|
+
token = if (user = attributes.delete(:user)) && Ey::Core::Client.mocking?
|
4
|
+
core = Ey::Core::Client::Mock.data.values.find { |c| c[:users][user.identity] }
|
5
|
+
core[:users][user.identity]["token"]
|
6
|
+
end
|
7
|
+
token ||= begin
|
8
|
+
token_dotfile = YAML.load_file(File.expand_path("/../../../.token"), __FILE__) rescue {}
|
9
|
+
ENV["CORE_TOKEN"] || token_dotfile[ENV["CORE_URL"]] || "a4bf6558da8c1051536d1596b8931ebd346aff0b"
|
10
|
+
end
|
11
|
+
|
12
|
+
merged_attributes = attributes.merge(token: token, cache: true)
|
13
|
+
merged_attributes.merge!(logger: Logger.new(STDOUT)) if ENV['VERBOSE']
|
14
|
+
|
15
|
+
Ey::Core::Client.new(merged_attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_server_client(server, attributes={})
|
19
|
+
unless core = Ey::Core::Client::Mock.data.values.find { |data| data[:servers][server.identity] }
|
20
|
+
raise "Failed to find server in mock data: #{server}"
|
21
|
+
end
|
22
|
+
|
23
|
+
token = core[:servers][server.identity]["token"]
|
24
|
+
|
25
|
+
merged_attributes = attributes.merge(token: token, cache: true)
|
26
|
+
merged_attributes.merge!(logger: Logger.new(STDOUT)) if ENV['VERBOSE']
|
27
|
+
|
28
|
+
Ey::Core::Client.new(merged_attributes)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_unauthenticated_client
|
32
|
+
Ey::Core::Client.new(token: nil)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
RSpec.configure do |config|
|
37
|
+
config.include(ClientHelper)
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Cistern.formatter = Cistern::Formatter::AwesomePrint
|
2
|
+
|
3
|
+
if ENV['MOCK_CORE'] == 'true'
|
4
|
+
Ey::Core::Client.mock!
|
5
|
+
end
|
6
|
+
|
7
|
+
Ey::Core::Client::Mock.timeout = 0.1
|
8
|
+
Ey::Core::Client::Mock.poll_interval = 0
|
9
|
+
|
10
|
+
Ey::Core::Client::Real.timeout = 3
|
11
|
+
Ey::Core::Client::Real.poll_interval = 0
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.before(:each) do
|
15
|
+
if Ey::Core::Client.mocking?
|
16
|
+
Ey::Core::Client::Mock.reset!
|
17
|
+
elsif defined?(client) && client
|
18
|
+
client.reset! unless ENV["RESET"] == "false"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.filter_run_excluding(Ey::Core::Client.mocking? ? {real_only: true} : { mock_only: true })
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
if ENV['COVERAGE'] and Kernel.respond_to? :caller_locations
|
2
|
+
require 'cistern/coverage'
|
3
|
+
|
4
|
+
SimpleCov.at_exit do
|
5
|
+
puts "Adding cistern coverage data"
|
6
|
+
|
7
|
+
result = SimpleCov.result
|
8
|
+
|
9
|
+
models = Ey::Core::Client.constants.map {|c| Ey::Core::Client.const_get c }.select {|c| c.is_a? Class}.select {|c| c.superclass == Ey::Core::Model }
|
10
|
+
|
11
|
+
models.each do |m|
|
12
|
+
coverage_details = []
|
13
|
+
|
14
|
+
coverage_details += m.attributes.values.select {|opts| opts[:coverage_hits] } rescue []
|
15
|
+
coverage_details += m.associations.values.select {|opts| opts[:coverage_hits] } rescue []
|
16
|
+
|
17
|
+
coverage_details.each do |options|
|
18
|
+
unless result_file = result.files.find {|f| f.filename == options[:coverage_file] }
|
19
|
+
raise "Coverage failed, couldn't find file '#{file}' in the coverage report"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Use the actual calls to the attribute reader as the coverage metric
|
23
|
+
result_file.line(options[:coverage_line]).instance_variable_set(:@coverage, options[:coverage_hits])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
result.format!
|
28
|
+
end
|
29
|
+
|
30
|
+
CodeClimate::TestReporter.start
|
31
|
+
SimpleCov.start do
|
32
|
+
add_filter 'spec'
|
33
|
+
|
34
|
+
add_group 'Collections', 'lib/ey-core/collections'
|
35
|
+
add_group 'Models', 'lib/ey-core/models'
|
36
|
+
add_group 'Requests', 'lib/ey-core/requests'
|
37
|
+
end
|
38
|
+
elsif ENV['COVERAGE']
|
39
|
+
warn <<-WARN
|
40
|
+
Coverage reporting skipped.
|
41
|
+
This ruby version lacks necessary method Kernel.caller_locations"
|
42
|
+
WARN
|
43
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module ResourceHelper
|
2
|
+
def load_blueprint(options={})
|
3
|
+
application = create_application(account: account)
|
4
|
+
database_service = create_database_service(provider: account.providers.first)
|
5
|
+
environment = create_environment(account: account, application: application, database_service: database_service, environment: {name: "environment#{SecureRandom.hex(4)}"})
|
6
|
+
|
7
|
+
[database_service, environment]
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_application(options={})
|
11
|
+
account = options.delete(:account) || create_account(options)
|
12
|
+
options = Cistern::Hash.stringify_keys(options)
|
13
|
+
|
14
|
+
options["name"] ||= "application#{SecureRandom.hex(4)}"
|
15
|
+
options["repository"] ||= "git://github.com/engineyard/todo.git"
|
16
|
+
options["type"] ||= "rails4"
|
17
|
+
|
18
|
+
account.applications.create!(options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_server(client, options={})
|
22
|
+
options = Cistern::Hash.stringify_keys(options)
|
23
|
+
|
24
|
+
request = environment.servers.create(
|
25
|
+
"flavor" => "m3.medium",
|
26
|
+
"role" => "util",
|
27
|
+
)
|
28
|
+
|
29
|
+
request.resource!
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_cost(client, options={})
|
33
|
+
account = options[:account] || create_account(client: client)
|
34
|
+
level = options[:level] || "summarized"
|
35
|
+
finality = options[:finality] || "estimated"
|
36
|
+
related_resource_type = options[:related_resource_type] || "account"
|
37
|
+
category = options[:category] || "non-server"
|
38
|
+
description = options[:description] || "AWS Other Services"
|
39
|
+
value = options[:value] || "1763"
|
40
|
+
environment = options[:environment] || nil
|
41
|
+
|
42
|
+
client.data[:costs] << {
|
43
|
+
billing_month: "2015-07",
|
44
|
+
data_type: "cost",
|
45
|
+
level: level,
|
46
|
+
finality: finality,
|
47
|
+
related_resource_type: related_resource_type,
|
48
|
+
category: category,
|
49
|
+
units: "USD cents",
|
50
|
+
description: description,
|
51
|
+
value: value,
|
52
|
+
account: client.url_for("accounts/#{account.identity}"),
|
53
|
+
environment: environment
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_account_referral(client, options={})
|
58
|
+
referred = options.delete(:referred) || create_account(client: client)
|
59
|
+
referrer = options.delete(:referrer) || create_account(client: client)
|
60
|
+
|
61
|
+
account_referral_id = SecureRandom.uuid
|
62
|
+
referral = client.data[:account_referrals][account_referral_id] = {
|
63
|
+
"id" => account_referral_id,
|
64
|
+
"referrer" => client.url_for("accounts/#{referrer.identity}"),
|
65
|
+
"referred" => client.url_for("accounts/#{referred.identity}"),
|
66
|
+
}
|
67
|
+
|
68
|
+
client.account_referrals.new(referral)
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_firewall(client, options={})
|
72
|
+
provider = options.fetch(:provider) { create_provider(client: client) }
|
73
|
+
|
74
|
+
firewall_params = options[:firewall] || {}
|
75
|
+
name = firewall_params.delete(:name) || SecureRandom.hex(6)
|
76
|
+
location = firewall_params.delete(:location) || "us-west-2"
|
77
|
+
|
78
|
+
client.firewalls.create!(
|
79
|
+
:name => name,
|
80
|
+
:location => location,
|
81
|
+
:provider => provider,
|
82
|
+
).resource!
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_database_service(options={})
|
86
|
+
provider = options[:provider] || create_provider(options.merge(client: client))
|
87
|
+
|
88
|
+
database_service_params = Hashie::Mash.new(
|
89
|
+
:name => Faker::Name.first_name,
|
90
|
+
:provider => provider,
|
91
|
+
).merge(options.fetch(:database_service, {}))
|
92
|
+
|
93
|
+
database_server_params = Hashie::Mash.new(
|
94
|
+
:location => "us-west-2c",
|
95
|
+
:flavor => "db.m3.large",
|
96
|
+
:engine => "postgres",
|
97
|
+
:version => "9.3.5",
|
98
|
+
).merge(options.fetch(:database_server, {}))
|
99
|
+
|
100
|
+
client.database_services.create!(database_service_params.merge(database_server: database_server_params)).resource!
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_environment(options={})
|
104
|
+
account = options[:account] || create_account(options)
|
105
|
+
|
106
|
+
unless account.providers.first || options[:provider]
|
107
|
+
create_provider(account: account)
|
108
|
+
end
|
109
|
+
|
110
|
+
environment = options[:environment] || {}
|
111
|
+
application = options[:application] || create_application(account: account)
|
112
|
+
database_service = options[:database_service]
|
113
|
+
configuration = Cistern::Hash.stringify_keys(options[:configuration] || {})
|
114
|
+
configuration["type"] ||= "solo"
|
115
|
+
environment[:name] ||= options.fetch(:name, SecureRandom.hex(3))
|
116
|
+
environment[:region] ||= "us-west-2"
|
117
|
+
|
118
|
+
environment.merge!(application_id: application.id, account: account)
|
119
|
+
environment.merge!(database_service: database_service) if database_service
|
120
|
+
environment = client.environments.create!(environment)
|
121
|
+
|
122
|
+
unless options[:boot] == false
|
123
|
+
request = environment.boot(configuration: configuration, application_id: application.id)
|
124
|
+
request.ready!
|
125
|
+
end
|
126
|
+
environment
|
127
|
+
end
|
128
|
+
|
129
|
+
def create_provider_location(client, attributes={})
|
130
|
+
attributes = Cistern::Hash.stringify_keys(attributes)
|
131
|
+
|
132
|
+
if provider = attributes.delete("provider")
|
133
|
+
attributes["provider"] = client.url_for("/providers/#{provider.id}")
|
134
|
+
end
|
135
|
+
|
136
|
+
attributes["id"] ||= client.uuid
|
137
|
+
client.data[:provider_locations][attributes["id"]] = attributes
|
138
|
+
|
139
|
+
client.provider_locations.new(attributes)
|
140
|
+
end
|
141
|
+
|
142
|
+
def create_server_event(client, attributes={})
|
143
|
+
attributes = Cistern::Hash.stringify_keys(attributes)
|
144
|
+
|
145
|
+
attributes.fetch("type")
|
146
|
+
|
147
|
+
if server = attributes.delete("server")
|
148
|
+
attributes["server"] = client.url_for("/servers/#{server.id}")
|
149
|
+
end
|
150
|
+
|
151
|
+
event_id = attributes["id"] ||= SecureRandom.uuid
|
152
|
+
|
153
|
+
client.server_events.new(
|
154
|
+
client.data[:server_events][event_id] = attributes
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
def create_logical_database(options={})
|
159
|
+
database_service = options.fetch(:database_service) { create_database_service(options) }
|
160
|
+
|
161
|
+
database_service.databases.create!(
|
162
|
+
:name => SecureRandom.hex(6),
|
163
|
+
:username => "ey#{SecureRandom.hex(6)}",
|
164
|
+
:password => SecureRandom.hex(8),
|
165
|
+
).resource!
|
166
|
+
end
|
167
|
+
|
168
|
+
def create_untracked_server(options={})
|
169
|
+
provider = options.fetch(:provider) { create_provider(options) }
|
170
|
+
|
171
|
+
untracked_server = options[:untracked_server] || {}
|
172
|
+
|
173
|
+
provisioner_id = untracked_server[:provisioner_id] || SecureRandom.uuid
|
174
|
+
location = untracked_server[:location] || "us-west-2b"
|
175
|
+
provisioned_id = untracked_server[:provisioned_id] || "i-#{SecureRandom.hex(4)}"
|
176
|
+
state = untracked_server[:state] || "found"
|
177
|
+
|
178
|
+
client.untracked_servers.create(
|
179
|
+
:location => location,
|
180
|
+
:provider => provider,
|
181
|
+
:provisioned_id => provisioned_id,
|
182
|
+
:provisioner_id => provisioner_id,
|
183
|
+
:state => state,
|
184
|
+
)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
RSpec.configure do |config|
|
189
|
+
config.include(ResourceHelper)
|
190
|
+
end
|