trucker-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +1277 -0
- data/Rakefile +13 -0
- data/bin/truck +18 -0
- data/lib/admin/README.md +30 -0
- data/lib/admin/curl.rb +59 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +8 -0
- data/lib/admin/service_auth_token.rb +93 -0
- data/lib/admin/service_broker/add.rb +54 -0
- data/lib/admin/service_broker/remove.rb +33 -0
- data/lib/admin/service_broker/service_brokers.rb +29 -0
- data/lib/admin/service_broker/update.rb +60 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/cf.rb +14 -0
- data/lib/cf/cli.rb +495 -0
- data/lib/cf/cli/app/app.rb +43 -0
- data/lib/cf/cli/app/apps.rb +87 -0
- data/lib/cf/cli/app/base.rb +72 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +99 -0
- data/lib/cf/cli/app/events.rb +45 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +104 -0
- data/lib/cf/cli/app/push/create.rb +108 -0
- data/lib/cf/cli/app/push/interactions.rb +90 -0
- data/lib/cf/cli/app/push/sync.rb +57 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +31 -0
- data/lib/cf/cli/app/scale.rb +63 -0
- data/lib/cf/cli/app/start.rb +175 -0
- data/lib/cf/cli/app/stats.rb +66 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +9 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +104 -0
- data/lib/cf/cli/login_requirements.rb +13 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +36 -0
- data/lib/cf/cli/organization/delete.rb +61 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +30 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/populators/base.rb +16 -0
- data/lib/cf/cli/populators/organization.rb +32 -0
- data/lib/cf/cli/populators/populator_methods.rb +64 -0
- data/lib/cf/cli/populators/space.rb +33 -0
- data/lib/cf/cli/populators/target.rb +14 -0
- data/lib/cf/cli/route/base.rb +9 -0
- data/lib/cf/cli/route/delete.rb +28 -0
- data/lib/cf/cli/route/map.rb +68 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +56 -0
- data/lib/cf/cli/service/base.rb +9 -0
- data/lib/cf/cli/service/bind.rb +43 -0
- data/lib/cf/cli/service/create.rb +158 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/service_helper.rb +25 -0
- data/lib/cf/cli/service/service_instance_helper.rb +100 -0
- data/lib/cf/cli/service/services.rb +110 -0
- data/lib/cf/cli/service/unbind.rb +36 -0
- data/lib/cf/cli/space/base.rb +27 -0
- data/lib/cf/cli/space/create.rb +66 -0
- data/lib/cf/cli/space/delete.rb +55 -0
- data/lib/cf/cli/space/rename.rb +38 -0
- data/lib/cf/cli/space/space.rb +66 -0
- data/lib/cf/cli/space/spaces.rb +57 -0
- data/lib/cf/cli/space/switch.rb +18 -0
- data/lib/cf/cli/start/base.rb +35 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/login.rb +104 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +50 -0
- data/lib/cf/cli/start/target_prettifier.rb +35 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +51 -0
- data/lib/cf/cli/user/passwd.rb +36 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -0
- data/lib/cf/errors.rb +19 -0
- data/lib/cf/plugin.rb +56 -0
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +3 -0
- data/lib/console/README.md +16 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +32 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +343 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +25 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/micro/micro.rb +56 -0
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/micro/switcher/darwin.rb +21 -0
- data/lib/micro/switcher/dummy.rb +15 -0
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/micro/switcher/windows.rb +31 -0
- data/lib/micro/vmrun.rb +175 -0
- data/lib/tasks/gem_release.rake +56 -0
- data/lib/tasks/windows_build.rake +14 -0
- data/lib/tunnel/README.md +29 -0
- data/lib/tunnel/config/clients.yml +17 -0
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/lib/tunnel/helper-app/server.rb +43 -0
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- data/spec/admin/curl_spec.rb +52 -0
- data/spec/admin/guid_spec.rb +85 -0
- data/spec/admin/service_broker/add_spec.rb +64 -0
- data/spec/admin/service_broker/remove_spec.rb +46 -0
- data/spec/admin/service_broker/service_brokers_spec.rb +34 -0
- data/spec/admin/service_broker/update_spec.rb +51 -0
- data/spec/admin/set_quota_spec.rb +89 -0
- data/spec/assets/env/Gemfile +4 -0
- data/spec/assets/env/Gemfile.lock +20 -0
- data/spec/assets/env/env_test.rb +58 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +8 -0
- data/spec/assets/rails328_ruby187_app/Gemfile +39 -0
- data/spec/assets/rails328_ruby187_app/README.rdoc +261 -0
- data/spec/assets/rails328_ruby187_app/Rakefile +7 -0
- data/spec/assets/rails328_ruby187_app/app/assets/images/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js +15 -0
- data/spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css +13 -0
- data/spec/assets/rails328_ruby187_app/app/controllers/application_controller.rb +3 -0
- data/spec/assets/rails328_ruby187_app/app/helpers/application_helper.rb +2 -0
- data/spec/assets/rails328_ruby187_app/app/views/layouts/application.html.erb +14 -0
- data/spec/assets/rails328_ruby187_app/config.ru +4 -0
- data/spec/assets/rails328_ruby187_app/config/application.rb +62 -0
- data/spec/assets/rails328_ruby187_app/config/boot.rb +6 -0
- data/spec/assets/rails328_ruby187_app/config/database.yml +25 -0
- data/spec/assets/rails328_ruby187_app/config/environment.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/environments/development.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/environments/production.rb +67 -0
- data/spec/assets/rails328_ruby187_app/config/environments/test.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/inflections.rb +15 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/mime_types.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/secret_token.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/session_store.rb +8 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/assets/rails328_ruby187_app/config/locales/en.yml +5 -0
- data/spec/assets/rails328_ruby187_app/config/routes.rb +58 -0
- data/spec/assets/rails328_ruby187_app/db/seeds.rb +7 -0
- data/spec/assets/rails328_ruby187_app/doc/README_FOR_APP +2 -0
- data/spec/assets/rails328_ruby187_app/manifest.yml +7 -0
- data/spec/assets/rails328_ruby187_app/public/404.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/422.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/500.html +25 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/manifest.yml +4 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/favicon.ico +0 -0
- data/spec/assets/rails328_ruby187_app/public/index.html +241 -0
- data/spec/assets/rails328_ruby187_app/public/robots.txt +5 -0
- data/spec/assets/rails328_ruby187_app/script/rails +6 -0
- data/spec/assets/rails328_ruby187_app/test/performance/browsing_test.rb +12 -0
- data/spec/assets/rails328_ruby187_app/test/test_helper.rb +13 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +197 -0
- data/spec/cf/cli/app/env_spec.rb +261 -0
- data/spec/cf/cli/app/events_spec.rb +72 -0
- data/spec/cf/cli/app/help_spec.rb +39 -0
- data/spec/cf/cli/app/instances_spec.rb +69 -0
- data/spec/cf/cli/app/push/create_spec.rb +444 -0
- data/spec/cf/cli/app/push/interactions_spec.rb +32 -0
- data/spec/cf/cli/app/push_spec.rb +332 -0
- data/spec/cf/cli/app/rename_spec.rb +108 -0
- data/spec/cf/cli/app/restart_spec.rb +47 -0
- data/spec/cf/cli/app/scale_spec.rb +63 -0
- data/spec/cf/cli/app/start_spec.rb +255 -0
- data/spec/cf/cli/app/stats_spec.rb +66 -0
- data/spec/cf/cli/domain/help_spec.rb +39 -0
- data/spec/cf/cli/domain/map_spec.rb +140 -0
- data/spec/cf/cli/domain/unmap_spec.rb +77 -0
- data/spec/cf/cli/help_spec.rb +21 -0
- data/spec/cf/cli/organization/create_spec.rb +121 -0
- data/spec/cf/cli/organization/delete_spec.rb +105 -0
- data/spec/cf/cli/organization/help_spec.rb +39 -0
- data/spec/cf/cli/organization/orgs_spec.rb +116 -0
- data/spec/cf/cli/organization/rename_spec.rb +116 -0
- data/spec/cf/cli/populators/organization_spec.rb +179 -0
- data/spec/cf/cli/populators/space_spec.rb +156 -0
- data/spec/cf/cli/populators/target_spec.rb +39 -0
- data/spec/cf/cli/route/delete_spec.rb +92 -0
- data/spec/cf/cli/route/help_spec.rb +32 -0
- data/spec/cf/cli/route/map_spec.rb +148 -0
- data/spec/cf/cli/route/unmap_spec.rb +114 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/create_spec.rb +147 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/help_spec.rb +39 -0
- data/spec/cf/cli/service/rename_spec.rb +103 -0
- data/spec/cf/cli/service/service_helper_spec.rb +66 -0
- data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/services_spec.rb +156 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/base_spec.rb +49 -0
- data/spec/cf/cli/space/create_spec.rb +144 -0
- data/spec/cf/cli/space/delete_spec.rb +109 -0
- data/spec/cf/cli/space/help_spec.rb +39 -0
- data/spec/cf/cli/space/rename_spec.rb +110 -0
- data/spec/cf/cli/space/space_spec.rb +80 -0
- data/spec/cf/cli/space/spaces_spec.rb +107 -0
- data/spec/cf/cli/space/switch_space_spec.rb +57 -0
- data/spec/cf/cli/start/help_spec.rb +39 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +49 -0
- data/spec/cf/cli/start/target_prettifier_spec.rb +78 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +98 -0
- data/spec/cf/cli/user/help_spec.rb +32 -0
- data/spec/cf/cli/user/passwd_spec.rb +94 -0
- data/spec/cf/cli/user/register_spec.rb +145 -0
- data/spec/cf/cli_spec.rb +474 -0
- data/spec/console/console_spec.rb +189 -0
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +7 -0
- data/spec/factories/cfoundry/v2/domains_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/managed_service_instances_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/quota_definitions.rb +13 -0
- data/spec/factories/cfoundry/v2/routes_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_brokers_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +17 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/users_factory.rb +7 -0
- data/spec/features/backspace_spec.rb +46 -0
- data/spec/features/create_user_spec.rb +74 -0
- data/spec/features/delete_orphaned_service_spec.rb +64 -0
- data/spec/features/login_spec.rb +65 -0
- data/spec/features/manifests_spec.rb +86 -0
- data/spec/features/org_spec.rb +50 -0
- data/spec/features/push_flow_spec.rb +169 -0
- data/spec/features/service_brokers_spec.rb +173 -0
- data/spec/features/services_spec.rb +122 -0
- data/spec/features/space_spec.rb +107 -0
- data/spec/features/switching_targets_spec.rb +70 -0
- data/spec/manifests/errors_spec.rb +43 -0
- data/spec/manifests/loader/builder_spec.rb +80 -0
- data/spec/manifests/loader/normalizer_spec.rb +158 -0
- data/spec/manifests/manifests_spec.rb +335 -0
- data/spec/manifests/plugin_spec.rb +410 -0
- data/spec/micro/plugin_spec.rb +64 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/cli_helper.rb +87 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/features_helper.rb +99 -0
- data/spec/support/interact_helper.rb +27 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/mock_commands/mock_restart.rb +16 -0
- data/spec/support/mock_commands/mock_start.rb +17 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/tunnel/plugin_spec.rb +31 -0
- data/spec/tunnel/tunnel_spec.rb +54 -0
- metadata +814 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
if ENV['CF_V2_RUN_INTEGRATION']
|
4
|
+
describe "Services" do
|
5
|
+
before do
|
6
|
+
login
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "listing services" do
|
10
|
+
let(:service1) { "some-provided-instance-#{Time.now.to_i}" }
|
11
|
+
let(:service2) { "cf-managed-instance-#{Time.now.to_i}" }
|
12
|
+
|
13
|
+
it "shows all service instances in the space" do
|
14
|
+
create_service_instance("user-provided", service1, credentials: { hostname: "myservice.com"} )
|
15
|
+
create_service_instance("dummy-dev", service2, plan: "small")
|
16
|
+
|
17
|
+
BlueShell::Runner.run("#{cf_bin} services") do |runner|
|
18
|
+
expect(runner).to say /#{service1}\s+user-provided\s+n\/a\s+n\/a\s+n\/a\s+.*/
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
delete_service(service1)
|
24
|
+
delete_service(service2)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "creating a service" do
|
29
|
+
describe "when the user leaves the line blank for a plan" do
|
30
|
+
it "re-prompts for the plan" do
|
31
|
+
BlueShell::Runner.run("#{cf_bin} create-service") do |runner|
|
32
|
+
expect(runner).to say "What kind?"
|
33
|
+
runner.send_keys "1"
|
34
|
+
expect(runner).to say "Name?"
|
35
|
+
runner.send_return
|
36
|
+
expect(runner).to say "Which plan?"
|
37
|
+
runner.send_return
|
38
|
+
expect(runner).to say "Which plan?"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "when the service is a user-provided instance" do
|
44
|
+
let(:service_name) { "my-private-db-#{Random.rand(1000) + 1000}"}
|
45
|
+
|
46
|
+
it "can create a service instance" do
|
47
|
+
BlueShell::Runner.run("#{cf_bin} create-service") do |runner|
|
48
|
+
expect(runner).to say "What kind?"
|
49
|
+
runner.send_keys "user-provided"
|
50
|
+
|
51
|
+
expect(runner).to say "Name?"
|
52
|
+
runner.send_keys service_name
|
53
|
+
|
54
|
+
expect(runner).to say "What credential parameters should applications use to connect to this service instance?\n(e.g. hostname, port, password)"
|
55
|
+
runner.send_keys "hostname"
|
56
|
+
expect(runner).to say "hostname"
|
57
|
+
runner.send_keys "myserviceinstance.com"
|
58
|
+
|
59
|
+
expect(runner).to say /Creating service #{service_name}.+ OK/
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
after do
|
64
|
+
delete_service(service_name)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "binding to a service" do
|
70
|
+
let(:app_folder) { "env" }
|
71
|
+
let(:app_name) { "services_env_test_app-#{Time.now.to_i}" }
|
72
|
+
|
73
|
+
let(:service_name) { "some-provided-instance-#{Time.now.to_i}" }
|
74
|
+
|
75
|
+
it "can bind and unbind user-provided services to apps" do
|
76
|
+
push_app(app_folder, app_name, start_command: "'bundle exec ruby env_test.rb -p $PORT'", timeout: 90)
|
77
|
+
create_service_instance("user-provided", service_name, credentials: { hostname: "myservice.com"} )
|
78
|
+
|
79
|
+
BlueShell::Runner.run("#{cf_bin} bind-service") do |runner|
|
80
|
+
expect(runner).to say "Which application?>"
|
81
|
+
runner.send_keys app_name
|
82
|
+
|
83
|
+
expect(runner).to say "Which service?>"
|
84
|
+
runner.send_keys service_name
|
85
|
+
|
86
|
+
expect(runner).to say "Binding #{service_name} to #{app_name}... OK"
|
87
|
+
end
|
88
|
+
|
89
|
+
BlueShell::Runner.run("#{cf_bin} unbind-service") do |runner|
|
90
|
+
expect(runner).to say "Which application?"
|
91
|
+
runner.send_keys app_name
|
92
|
+
|
93
|
+
expect(runner).to say "Which service?>"
|
94
|
+
runner.send_keys service_name
|
95
|
+
|
96
|
+
expect(runner).to say "Unbinding #{service_name} from #{app_name}... OK"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
after do
|
101
|
+
delete_app(app_name)
|
102
|
+
delete_service(service_name)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def delete_service(service_name)
|
107
|
+
BlueShell::Runner.run("#{cf_bin} delete-service --service #{service_name} --force") do |runner|
|
108
|
+
expect(runner).to say "Deleting #{service_name}... OK"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def delete_app(app_name, routes=true)
|
113
|
+
delete_cmd = "#{cf_bin} delete #{app_name}"
|
114
|
+
delete_cmd + " --routes" if routes
|
115
|
+
BlueShell::Runner.run(delete_cmd) do |runner|
|
116
|
+
expect(runner).to say "Really delete #{app_name}?"
|
117
|
+
runner.send_keys "y"
|
118
|
+
expect(runner).to say "Deleting #{app_name}... OK"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "webmock/rspec"
|
3
|
+
require "ffaker"
|
4
|
+
|
5
|
+
if ENV['CF_V2_RUN_INTEGRATION']
|
6
|
+
describe 'A new user tries to use CF against v2 production', :ruby19 => true do
|
7
|
+
before(:all) do
|
8
|
+
WebMock.allow_net_connect!
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
WebMock.disable_net_connect!
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:organization) { ENV['CF_V2_TEST_ORGANIZATION'] }
|
16
|
+
let(:space) { ENV['CF_V2_TEST_SPACE'] }
|
17
|
+
|
18
|
+
before do
|
19
|
+
Interact::Progress::Dots.start!
|
20
|
+
login
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
logout
|
25
|
+
Interact::Progress::Dots.stop!
|
26
|
+
end
|
27
|
+
|
28
|
+
it "can get space info" do
|
29
|
+
BlueShell::Runner.run("#{cf_bin} space #{space} --no-quiet") do |runner|
|
30
|
+
expect(runner).to say("#{space}:\n")
|
31
|
+
expect(runner).to say("organization: #{organization}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "needs cleanup after specs" do
|
36
|
+
let(:run_id) { TRAVIS_BUILD_ID.to_s + Time.new.to_f.to_s.gsub(".", "_") }
|
37
|
+
let(:app) { "hello-sinatra-recursive-#{run_id}" }
|
38
|
+
let(:new_space) { "test-space-#{rand(10000)}" }
|
39
|
+
let(:new_space_two) { "test-space-renamed-#{rand(10000)}" }
|
40
|
+
|
41
|
+
after do
|
42
|
+
begin
|
43
|
+
BlueShell::Runner.run("#{cf_bin} delete-space #{new_space} -r -f")
|
44
|
+
rescue
|
45
|
+
end
|
46
|
+
begin
|
47
|
+
BlueShell::Runner.run("#{cf_bin} delete-space #{new_space_two} -r -f")
|
48
|
+
rescue
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can create, switch, rename, and delete spaces" do
|
53
|
+
BlueShell::Runner.run("#{cf_bin} create-space #{new_space}") do |runner|
|
54
|
+
expect(runner).to say("Creating space #{new_space}... OK")
|
55
|
+
end
|
56
|
+
|
57
|
+
BlueShell::Runner.run("#{cf_bin} switch-space #{new_space}") do |runner|
|
58
|
+
expect(runner).to say("Switching to space #{new_space}... OK")
|
59
|
+
end
|
60
|
+
|
61
|
+
BlueShell::Runner.run("#{cf_bin} rename-space #{new_space} #{new_space_two}") do |runner|
|
62
|
+
expect(runner).to say("Renaming to #{new_space_two}... OK")
|
63
|
+
end
|
64
|
+
|
65
|
+
BlueShell::Runner.run("#{cf_bin} delete-space #{new_space_two}") do |runner|
|
66
|
+
expect(runner).to say("Really delete")
|
67
|
+
runner.send_keys "y"
|
68
|
+
|
69
|
+
expect(runner).to say("Deleting space #{new_space_two}... OK")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "can create an app in a space, then delete it recursively" do
|
74
|
+
BlueShell::Runner.run("#{cf_bin} create-space #{new_space}") { |runner| runner.wait_for_exit(30) }
|
75
|
+
BlueShell::Runner.run("#{cf_bin} switch-space #{new_space}") { |runner| runner.wait_for_exit(30) }
|
76
|
+
|
77
|
+
push_app("hello-sinatra", app)
|
78
|
+
|
79
|
+
BlueShell::Runner.run("#{cf_bin} delete-space #{new_space} --force") do |runner|
|
80
|
+
expect(runner).to say("If you want to delete the space along with all dependent objects, rerun the command with the '--recursive' flag.")
|
81
|
+
runner.wait_for_exit(30)
|
82
|
+
end.should_not be_successful
|
83
|
+
|
84
|
+
BlueShell::Runner.run("#{cf_bin} spaces") do |runner|
|
85
|
+
expect(runner).to say(new_space)
|
86
|
+
expect(runner).to say(app)
|
87
|
+
end
|
88
|
+
|
89
|
+
BlueShell::Runner.run("#{cf_bin} delete-space #{new_space} --recursive --force") do |runner|
|
90
|
+
expect(runner).to say("Deleting space #{new_space}... OK")
|
91
|
+
end
|
92
|
+
|
93
|
+
BlueShell::Runner.run("#{cf_bin} spaces") do |runner|
|
94
|
+
expect(runner).to_not say(new_space)
|
95
|
+
expect(runner).to_not say(app)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "shows all the spaces in the org" do
|
101
|
+
BlueShell::Runner.run("#{cf_bin} spaces") do |runner|
|
102
|
+
expect(runner).to say(space)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
if ENV['CF_V2_RUN_INTEGRATION']
|
4
|
+
describe 'A new user tries to use CF against v2 production', ruby19: true do
|
5
|
+
|
6
|
+
let(:target) { ENV['CF_V2_TEST_TARGET'] }
|
7
|
+
let(:space) { ENV['CF_V2_TEST_SPACE'] }
|
8
|
+
let(:space_2) { "#{ENV['CF_V2_TEST_SPACE']}-2"}
|
9
|
+
let(:organization_2) { ENV['CF_V2_TEST_ORGANIZATION_TWO'] }
|
10
|
+
|
11
|
+
let(:created_space_1) { "space-#{rand(10000)}"}
|
12
|
+
let(:created_space_2) { "space-#{rand(10000)}"}
|
13
|
+
|
14
|
+
before do
|
15
|
+
target_file = File.expand_path("~/.truck/target")
|
16
|
+
FileUtils.rm(target_file) if File.exists? target_file
|
17
|
+
Interact::Progress::Dots.start!
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
logout
|
22
|
+
Interact::Progress::Dots.stop!
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can switch targets, even if a target is invalid" do
|
26
|
+
BlueShell::Runner.run("#{cf_bin} target") do |runner|
|
27
|
+
expect(runner).to say " CF instance: N/A"
|
28
|
+
end
|
29
|
+
|
30
|
+
BlueShell::Runner.run("#{cf_bin} target invalid-target") do |runner|
|
31
|
+
expect(runner).to say "Target refused"
|
32
|
+
runner.wait_for_exit
|
33
|
+
end
|
34
|
+
|
35
|
+
BlueShell::Runner.run("#{cf_bin} target #{target}") do |runner|
|
36
|
+
expect(runner).to say "Setting target"
|
37
|
+
expect(runner).to say target
|
38
|
+
runner.wait_for_exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "with created spaces in the second org" do
|
43
|
+
it "can switch organizations and spaces" do
|
44
|
+
login
|
45
|
+
|
46
|
+
BlueShell::Runner.run("#{cf_bin} target -o #{organization_2}") do |runner|
|
47
|
+
expect(runner).to say "Switching to organization #{organization_2}"
|
48
|
+
expect(runner).to say "Space>"
|
49
|
+
runner.send_keys space_2
|
50
|
+
|
51
|
+
expect(runner).to say(/Switching to space #{space_2}/)
|
52
|
+
|
53
|
+
runner.wait_for_exit 15
|
54
|
+
end
|
55
|
+
|
56
|
+
BlueShell::Runner.run("#{cf_bin} target -s #{space}") do |runner|
|
57
|
+
expect(runner).to say("Switching to space #{space}")
|
58
|
+
runner.wait_for_exit 15
|
59
|
+
end
|
60
|
+
|
61
|
+
BlueShell::Runner.run("#{cf_bin} target -s #{space_2}") do |runner|
|
62
|
+
expect(runner).to say("Switching to space #{space_2}")
|
63
|
+
runner.wait_for_exit 15
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
else
|
69
|
+
$stderr.puts 'Skipping v2 integration specs; please provide necessary environment variables'
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFManifests::InvalidManifest do
|
4
|
+
let(:file) { "/path/to/file" }
|
5
|
+
|
6
|
+
subject { described_class.new(file) }
|
7
|
+
|
8
|
+
it { should be_kind_of CF::UserFriendlyError }
|
9
|
+
|
10
|
+
describe "#initialize" do
|
11
|
+
it "is initialized with a file" do
|
12
|
+
described_class.new(file)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#to_s" do
|
17
|
+
it "says the file is malformed" do
|
18
|
+
expect(subject.to_s).to eq(
|
19
|
+
"Manifest file '#{file}' is malformed.")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#file" do
|
24
|
+
it "returns the file it was initialized with" do
|
25
|
+
expect(subject.file).to eq(file)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe CFManifests::CircularDependency do
|
31
|
+
let(:app) { "app" }
|
32
|
+
subject { described_class.new(app) }
|
33
|
+
|
34
|
+
it { should be_kind_of CF::UserFriendlyError }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe CFManifests::UnknownSymbol do
|
38
|
+
let(:symbol) { "symbol" }
|
39
|
+
subject { described_class.new(symbol) }
|
40
|
+
|
41
|
+
it { should be_kind_of CF::UserFriendlyError }
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFManifests::Builder do
|
4
|
+
subject { CFManifests::Loader.new(nil, nil) }
|
5
|
+
|
6
|
+
describe "#build" do
|
7
|
+
let(:file) { "manifest.yml" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
FakeFS.activate!
|
11
|
+
|
12
|
+
File.open(file, "w") do |io|
|
13
|
+
io.write manifest
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
FakeFS.deactivate!
|
19
|
+
FakeFS::FileSystem.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with a simple manifest" do
|
23
|
+
let(:manifest) do
|
24
|
+
<<EOF
|
25
|
+
---
|
26
|
+
foo: bar
|
27
|
+
EOF
|
28
|
+
end
|
29
|
+
|
30
|
+
it "loads the manifest YAML" do
|
31
|
+
expect(subject.build(file)).to eq("foo" => "bar")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with a manifest that inherits another" do
|
36
|
+
let(:manifest) do
|
37
|
+
<<EOF
|
38
|
+
---
|
39
|
+
inherit: other-manifest.yml
|
40
|
+
foo:
|
41
|
+
baz: c
|
42
|
+
EOF
|
43
|
+
end
|
44
|
+
|
45
|
+
before do
|
46
|
+
FakeFS.activate!
|
47
|
+
|
48
|
+
File.open("other-manifest.yml", "w") do |io|
|
49
|
+
io.write <<OTHER
|
50
|
+
---
|
51
|
+
foo:
|
52
|
+
bar: a
|
53
|
+
baz: b
|
54
|
+
OTHER
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "merges itself into the parent, by depth" do
|
59
|
+
manifest = subject.build(file)
|
60
|
+
expect(manifest).to include(
|
61
|
+
"foo" => { "bar" => "a", "baz" => "c" })
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does not include the 'inherit' attribute" do
|
65
|
+
manifest = subject.build(file)
|
66
|
+
expect(manifest).to_not include("inherit")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with an invalid manifest" do
|
71
|
+
let(:manifest) { "" }
|
72
|
+
|
73
|
+
it "raises an error" do
|
74
|
+
expect {
|
75
|
+
subject.build(file)
|
76
|
+
}.to raise_error(CFManifests::InvalidManifest)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFManifests::Normalizer do
|
4
|
+
let(:manifest) { {} }
|
5
|
+
let(:loader) { CFManifests::Loader.new(nil, nil) }
|
6
|
+
|
7
|
+
describe '#normalize!' do
|
8
|
+
subject do
|
9
|
+
loader.normalize!(manifest)
|
10
|
+
manifest
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with a manifest where the applications have no path set' do
|
14
|
+
let(:manifest) { { "applications" => { "." => { "name" => "foo" } } } }
|
15
|
+
|
16
|
+
it "sets the path to their tag, assuming it's a path" do
|
17
|
+
expect(subject).to eq(
|
18
|
+
:applications => [{ :name => "foo", :path => "." }])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with a manifest where the url is nil' do
|
23
|
+
let(:manifest) { { "applications" => { "." => { "url" => nil } } } }
|
24
|
+
|
25
|
+
it "sets it to none" do
|
26
|
+
expect(subject).to eq(
|
27
|
+
:applications => [{ :path => ".", :url => "none" }]
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with a manifest with a subdomain attribute' do
|
33
|
+
let(:manifest) { { "applications" => { "." => { "subdomain" => "use-this-for-host" } } } }
|
34
|
+
|
35
|
+
it "sets the subdomain key to be host" do
|
36
|
+
expect(subject).to eq(
|
37
|
+
:applications => [{ :path => ".", :host => "use-this-for-host" }]
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when the host attribute is also set" do
|
42
|
+
let(:manifest) { { "applications" => { "." => { "subdomain" => "dont-use-this-for-host", "host" => "canonical-attribute" } } } }
|
43
|
+
|
44
|
+
it 'does not overwrite an explicit host attribute' do
|
45
|
+
expect(subject).to eq(
|
46
|
+
:applications => [{ :path => ".", :host => "canonical-attribute" }]
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'with a manifest with toplevel attributes' do
|
53
|
+
context 'and properties' do
|
54
|
+
let(:manifest) {
|
55
|
+
{ "name" => "foo", "properties" => { "fizz" => "buzz" } }
|
56
|
+
}
|
57
|
+
|
58
|
+
it 'keeps the properties at the toplevel' do
|
59
|
+
expect(subject).to eq(
|
60
|
+
:applications => [{ :name => "foo", :path => "." }],
|
61
|
+
:properties => { :fizz => "buzz" })
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'and no applications' do
|
66
|
+
context 'and no path' do
|
67
|
+
let(:manifest) { { "name" => "foo" } }
|
68
|
+
|
69
|
+
it 'adds it as an application with path .' do
|
70
|
+
expect(subject).to eq(
|
71
|
+
:applications => [{ :name => "foo", :path => "." }])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'and a path' do
|
76
|
+
let(:manifest) { { "name" => "foo", "path" => "./foo" } }
|
77
|
+
|
78
|
+
it 'adds it as an application with the proper tag and path' do
|
79
|
+
expect(subject).to eq(
|
80
|
+
:applications => [{ :name => "foo", :path => "./foo" }])
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'and applications' do
|
86
|
+
let(:manifest) {
|
87
|
+
{ "applications" => {
|
88
|
+
"./foo" => { "name" => "foo" },
|
89
|
+
"./bar" => { "name" => "bar" },
|
90
|
+
"./baz" => { "name" => "baz" }
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
it "merges the toplevel attributes into the applications" do
|
96
|
+
expect(subject[:applications]).to match_array [
|
97
|
+
{ :name => "foo", :path => "./foo" },
|
98
|
+
{ :name => "bar", :path => "./bar" },
|
99
|
+
{ :name => "baz", :path => "./baz" }
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'with a manifest where applications is a hash' do
|
106
|
+
let(:manifest) { { "applications" => { "foo" => { "name" => "foo" } } } }
|
107
|
+
|
108
|
+
it 'converts the array to a hash, with the path as the key' do
|
109
|
+
expect(subject).to eq(
|
110
|
+
:applications => [{ :name => "foo", :path => "foo" }])
|
111
|
+
end
|
112
|
+
|
113
|
+
context "and the applications had dependencies" do
|
114
|
+
let(:manifest) do
|
115
|
+
{ "applications" => {
|
116
|
+
"bar" => { "name" => "bar", "depends-on" => "foo" },
|
117
|
+
"foo" => { "name" => "foo" }
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
it "converts using dependency order" do
|
123
|
+
expect(subject).to eq(
|
124
|
+
:applications => [{ :name => "foo", :path => "foo" }, { :name => "bar", :path => "bar" }])
|
125
|
+
end
|
126
|
+
|
127
|
+
context "and there's a circular dependency" do
|
128
|
+
let(:manifest) do
|
129
|
+
{ "applications" => {
|
130
|
+
"bar" => { "name" => "bar", "depends-on" => "foo" },
|
131
|
+
"foo" => { "name" => "foo", "depends-on" => "bar" }
|
132
|
+
}
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
it "doesn't blow up" do
|
137
|
+
expect(subject).to be_true
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#normalize_app!' do
|
145
|
+
subject do
|
146
|
+
loader.send(:normalize_app!, manifest)
|
147
|
+
manifest
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'with mem instead of memory' do
|
151
|
+
let(:manifest) { { "name" => "foo", "mem" => "128M" } }
|
152
|
+
|
153
|
+
it 'renames mem to memory' do
|
154
|
+
expect(subject).to eq("name" => "foo", "memory" => "128M")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|