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,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::Curl do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_admin_dir" }
|
5
|
+
|
6
|
+
stub_home_dir_with { fake_home_dir }
|
7
|
+
|
8
|
+
let(:client) { fake_client }
|
9
|
+
|
10
|
+
context "when the response is JSON" do
|
11
|
+
it "pretty-prints the response" do
|
12
|
+
stub_request(:get, "https://api.some-target-for-cf-curl.com/foo").to_return(
|
13
|
+
:headers => {
|
14
|
+
"content-type" => "application/json; charset=utf8"
|
15
|
+
},
|
16
|
+
:status => 200,
|
17
|
+
:body => '{"foo":"bar"}'
|
18
|
+
)
|
19
|
+
|
20
|
+
cf %W[curl GET /foo]
|
21
|
+
expect(output).to say(<<OUT)
|
22
|
+
{
|
23
|
+
"foo": "bar"
|
24
|
+
}
|
25
|
+
OUT
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with an implicit target" do
|
30
|
+
it "makes a request to the current target" do
|
31
|
+
stub_request(:get, "https://api.some-target-for-cf-curl.com/apps/5/instances").to_return(
|
32
|
+
:status => 200,
|
33
|
+
:body => 'some-body'
|
34
|
+
)
|
35
|
+
|
36
|
+
cf %W[curl GET /apps/5/instances]
|
37
|
+
expect(output).to say("some-body")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with an explicit target" do
|
42
|
+
it "makes a request to the given target" do
|
43
|
+
stub_request(:get, "https://some-other-domain.com/apps/5/instances").to_return(
|
44
|
+
:status => 200,
|
45
|
+
:body => 'some-other-body'
|
46
|
+
)
|
47
|
+
|
48
|
+
cf %W[curl GET https://some-other-domain.com/apps/5/instances]
|
49
|
+
expect(output).to say("some-other-body")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::Guid do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_admin_dir" }
|
5
|
+
stub_home_dir_with { fake_home_dir }
|
6
|
+
|
7
|
+
before do
|
8
|
+
CFoundry::Client.any_instance.stub(:info) { { :version => 2 } }
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:api_response) {{
|
12
|
+
:total_results => 1,
|
13
|
+
:total_pages => 1,
|
14
|
+
:resources => [
|
15
|
+
:metadata => {
|
16
|
+
:guid => "guid",
|
17
|
+
},
|
18
|
+
:entity => {
|
19
|
+
:name => "name",
|
20
|
+
},
|
21
|
+
]
|
22
|
+
}}
|
23
|
+
|
24
|
+
def stub_api(path, response, opts={})
|
25
|
+
stub = stub_request(:get, "https://api.some-target-for-cf-curl.com#{path}")
|
26
|
+
response = MultiJson.dump(response) unless opts[:not_json]
|
27
|
+
stub.to_return(:status => 200, :body => response)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when api returns >0 resources" do
|
31
|
+
context "with known type" do
|
32
|
+
let(:args) { ["guid", "--type", "organizations"] }
|
33
|
+
|
34
|
+
it "shows results" do
|
35
|
+
stub_api("/v2/organizations?", api_response)
|
36
|
+
cf(args)
|
37
|
+
expect(stdout.string).to match(/name.*guid/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with short known type" do
|
42
|
+
let(:args) { ["guid", "--type", "or"] }
|
43
|
+
|
44
|
+
it "shows results" do
|
45
|
+
stub_api("/v2/organizations?", api_response)
|
46
|
+
cf(args)
|
47
|
+
expect(stdout.string).to match(/name.*guid/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "with unknown type" do
|
52
|
+
let(:args) { ["guid", "--type", "some-unknown-type"] }
|
53
|
+
|
54
|
+
it "makes a request with unknown type" do
|
55
|
+
stub_api("/v2/some-unknown-type?", api_response)
|
56
|
+
cf(args)
|
57
|
+
expect(stdout.string).to match(/name.*guid/)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when api returns 0 resources" do
|
63
|
+
before do
|
64
|
+
api_response[:total_results] = 0
|
65
|
+
api_response[:total_pages] = 0
|
66
|
+
api_response[:resources] = []
|
67
|
+
end
|
68
|
+
|
69
|
+
it "shows 0 results" do
|
70
|
+
stub_api("/v2/organizations?", api_response)
|
71
|
+
cf(["guid", "--type", "organizations"])
|
72
|
+
expect(stdout.string).to match(/No results/)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when api does not return resources (errors, etc.)" do
|
77
|
+
["", "not-json"].each do |response|
|
78
|
+
it "shows unexpected response for api resonse '#{response}'" do
|
79
|
+
stub_api("/v2/organizations?", response, :not_json => true)
|
80
|
+
cf(["guid", "--type", "organizations"])
|
81
|
+
expect(stdout.string).to match(/Unexpected response/)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::ServiceBroker::Add do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_admin_dir" }
|
5
|
+
|
6
|
+
stub_home_dir_with { fake_home_dir }
|
7
|
+
|
8
|
+
let(:client) { build(:client) }
|
9
|
+
|
10
|
+
let(:service_broker) { CFoundry::V2::ServiceBroker.new(nil, client) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
CFAdmin::ServiceBroker::Add.client = client
|
14
|
+
client.stub(:service_broker).and_return(service_broker)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "creates a service broker when arguments are provided on the command line" do
|
18
|
+
service_broker.stub(:create!)
|
19
|
+
|
20
|
+
cf %W[add-service-broker --name cf-mysql --url http://cf-mysql.cfapp.io --username cfmysqlusername --password cfmysqlsecret]
|
21
|
+
|
22
|
+
service_broker.name.should == 'cf-mysql'
|
23
|
+
service_broker.broker_url.should == 'http://cf-mysql.cfapp.io'
|
24
|
+
service_broker.auth_username.should == 'cfmysqlusername'
|
25
|
+
service_broker.auth_password.should == 'cfmysqlsecret'
|
26
|
+
|
27
|
+
service_broker.should have_received(:create!)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "creates a service broker when only the name is provided" do
|
31
|
+
service_broker.stub(:create!)
|
32
|
+
|
33
|
+
stub_ask("URL").and_return("http://example.com")
|
34
|
+
stub_ask("Username").and_return("username")
|
35
|
+
stub_ask("Password").and_return("password")
|
36
|
+
|
37
|
+
cf %W[add-service-broker cf-mysql]
|
38
|
+
|
39
|
+
service_broker.name.should == 'cf-mysql'
|
40
|
+
service_broker.broker_url.should == 'http://example.com'
|
41
|
+
service_broker.auth_username.should == 'username'
|
42
|
+
service_broker.auth_password.should == 'password'
|
43
|
+
|
44
|
+
service_broker.should have_received(:create!)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "creates a service broker when no arguments are provided" do
|
48
|
+
service_broker.stub(:create!)
|
49
|
+
|
50
|
+
stub_ask("Name").and_return("cf-mysql")
|
51
|
+
stub_ask("URL").and_return("http://example.com")
|
52
|
+
stub_ask("Username").and_return("username")
|
53
|
+
stub_ask("Password").and_return("password")
|
54
|
+
|
55
|
+
cf %W[add-service-broker]
|
56
|
+
|
57
|
+
service_broker.name.should == 'cf-mysql'
|
58
|
+
service_broker.broker_url.should == 'http://example.com'
|
59
|
+
service_broker.auth_username.should == 'username'
|
60
|
+
service_broker.auth_password.should == 'password'
|
61
|
+
|
62
|
+
service_broker.should have_received(:create!)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CFAdmin::ServiceBroker::Remove do
|
4
|
+
|
5
|
+
describe 'command metadata' do
|
6
|
+
let(:command) { Mothership.commands[:remove_service_broker] }
|
7
|
+
subject { command }
|
8
|
+
its(:description) { should eq 'Remove a service broker' }
|
9
|
+
it { expect(Mothership::Help.group(:admin)).to include(subject) }
|
10
|
+
|
11
|
+
include_examples 'inputs must have descriptions'
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'running the command' do
|
15
|
+
let(:client) { build(:client) }
|
16
|
+
before do
|
17
|
+
CFAdmin::ServiceBroker::Remove.client = client
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'successful behavior' do
|
21
|
+
let(:service_broker) { build(:service_broker, :name => 'somebroker') }
|
22
|
+
before do
|
23
|
+
client.stub(:service_broker_by_name).with('somebroker').and_return(service_broker)
|
24
|
+
service_broker.should_receive(:delete!)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'removes the service broker' do
|
28
|
+
should_ask('Really remove somebroker?', {:default => false}) { true }
|
29
|
+
|
30
|
+
capture_output { cf %W[remove-service-broker somebroker] }
|
31
|
+
expect(output).to say("Removing service broker #{service_broker.name}... OK")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'error conditions' do
|
36
|
+
context 'when the service broker does not exist' do
|
37
|
+
it 'provides a helpful error message' do
|
38
|
+
client.stub(:service_broker_by_name).with('doesnotexist').and_return(nil)
|
39
|
+
|
40
|
+
capture_output { cf %W[remove-service-broker doesnotexist] }
|
41
|
+
expect(error_output).to say("Unknown service_broker 'doesnotexist'.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::ServiceBroker::ServiceBrokers do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_admin_dir" }
|
5
|
+
|
6
|
+
stub_home_dir_with { fake_home_dir }
|
7
|
+
|
8
|
+
let(:client) { build(:client) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
CFAdmin::ServiceBroker::ServiceBrokers.client = client
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when there are no brokers registered" do
|
15
|
+
let(:brokers_data) { [] }
|
16
|
+
it "says there are no brokers" do
|
17
|
+
client.should_receive(:service_brokers).and_return(brokers_data)
|
18
|
+
mock_with_progress("Getting service brokers")
|
19
|
+
cf %W[service-brokers]
|
20
|
+
expect(stdout.string).to eq("\nName URL\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when there are brokers registered" do
|
25
|
+
let(:brokers_data) { [ double(guid: 'guiddy', name: 'mysql', broker_url: 'http://mysql.example.com/') ] }
|
26
|
+
|
27
|
+
it "lists the brokers" do
|
28
|
+
client.should_receive(:service_brokers).and_return(brokers_data)
|
29
|
+
mock_with_progress("Getting service brokers")
|
30
|
+
cf %W[service-brokers]
|
31
|
+
expect(stdout.string).to match(/\nName.*URL.*\nmysql.*mysql.example.com/)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::ServiceBroker::Update do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_admin_dir" }
|
5
|
+
stub_home_dir_with { fake_home_dir }
|
6
|
+
|
7
|
+
let(:client) { build(:client) }
|
8
|
+
|
9
|
+
let(:service_broker) { CFoundry::V2::ServiceBroker.new(nil, client) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
service_broker.name = 'formername'
|
13
|
+
service_broker.broker_url = 'http://former.example.com'
|
14
|
+
service_broker.auth_username = 'formerusername'
|
15
|
+
service_broker.auth_password = 'formerpassword'
|
16
|
+
|
17
|
+
CFAdmin::ServiceBroker::Update.client = client
|
18
|
+
client.stub(:service_broker_by_name).with('formername').and_return(service_broker)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "updates a service broker when arguments are provided on the command line" do
|
22
|
+
service_broker.stub(:update!)
|
23
|
+
|
24
|
+
cf %W[update-service-broker --broker formername --name cf-othersql --url http://other.cfapp.io --username username --password secret2]
|
25
|
+
|
26
|
+
service_broker.name.should == 'cf-othersql'
|
27
|
+
service_broker.broker_url.should == 'http://other.cfapp.io'
|
28
|
+
service_broker.auth_username.should == 'username'
|
29
|
+
service_broker.auth_password.should == 'secret2'
|
30
|
+
|
31
|
+
service_broker.should have_received(:update!)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "updates a service broker when no change arguments are provided" do
|
35
|
+
service_broker.stub(:update!)
|
36
|
+
|
37
|
+
stub_ask("Name", :default => 'formername').and_return("cf-othersql")
|
38
|
+
stub_ask("URL", :default => 'http://former.example.com').and_return("http://other.example.com")
|
39
|
+
stub_ask("Username", :default => 'formerusername').and_return("username2")
|
40
|
+
stub_ask("Password", :default => 'formerpassword').and_return("password2")
|
41
|
+
|
42
|
+
cf %W[update-service-broker formername]
|
43
|
+
|
44
|
+
service_broker.name.should == 'cf-othersql'
|
45
|
+
service_broker.broker_url.should == 'http://other.example.com'
|
46
|
+
service_broker.auth_username.should == 'username2'
|
47
|
+
service_broker.auth_password.should == 'password2'
|
48
|
+
|
49
|
+
service_broker.should have_received(:update!)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFAdmin::SetQuota do
|
4
|
+
let(:fake_home_dir) { "#{SPEC_ROOT}/fixtures/fake_admin_dir" }
|
5
|
+
|
6
|
+
stub_home_dir_with { fake_home_dir }
|
7
|
+
|
8
|
+
let(:paid_quota) { build :quota_definition, :name => "paid" }
|
9
|
+
let(:free_quota) { build :quota_definition, :name => "free" }
|
10
|
+
|
11
|
+
let(:organization) do
|
12
|
+
build :organization, :name => "some-org-name",
|
13
|
+
:quota_definition => free_quota
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:client) do
|
17
|
+
build(:client).tap do |client|
|
18
|
+
client.stub(
|
19
|
+
:organizations => [organization],
|
20
|
+
:quota_definitions => [paid_quota, free_quota])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
CF::CLI.any_instance.stub(:client) { client }
|
26
|
+
organization.stub(:update!)
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when given an organization and a quota definition" do
|
30
|
+
it "promotes the organization to the given quota definition" do
|
31
|
+
expect {
|
32
|
+
cf %W[set-quota paid some-org-name]
|
33
|
+
}.to change {
|
34
|
+
organization.quota_definition
|
35
|
+
}.from(free_quota).to(paid_quota)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "shows progress to the user" do
|
39
|
+
cf %W[set-quota paid some-org-name]
|
40
|
+
expect(output).to say("Setting quota of some-org-name to paid... OK")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "saves the changes made to the organization" do
|
44
|
+
organization.should_receive(:update!)
|
45
|
+
cf %W[set-quota paid some-org-name]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when NOT given a quota definition" do
|
50
|
+
it "prompts for the quota definition" do
|
51
|
+
should_ask("Quota", hash_including(:choices => client.quota_definitions)) do
|
52
|
+
paid_quota
|
53
|
+
end
|
54
|
+
|
55
|
+
cf %W[set-quota --organization some-org-name]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when NOT given an organization" do
|
60
|
+
context "and the user has a current organization" do
|
61
|
+
before { client.current_organization = organization }
|
62
|
+
|
63
|
+
it "promotes the current to the given quota definition" do
|
64
|
+
expect {
|
65
|
+
cf %W[set-quota paid]
|
66
|
+
}.to change {
|
67
|
+
organization.quota_definition
|
68
|
+
}.from(free_quota).to(paid_quota)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "saves the changes made to the organization" do
|
72
|
+
organization.should_receive(:update!)
|
73
|
+
cf %W[set-quota paid]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "and the user does NOT have a current organization" do
|
78
|
+
before { client.current_organization = nil }
|
79
|
+
|
80
|
+
it "prompts for the organization" do
|
81
|
+
should_ask("Organization", hash_including(:choices => client.organizations)) do
|
82
|
+
organization
|
83
|
+
end
|
84
|
+
|
85
|
+
cf %W[set-quota paid]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
json (1.8.0)
|
5
|
+
rack (1.5.2)
|
6
|
+
rack-protection (1.5.0)
|
7
|
+
rack
|
8
|
+
sinatra (1.4.3)
|
9
|
+
rack (~> 1.4)
|
10
|
+
rack-protection (~> 1.4)
|
11
|
+
tilt (~> 1.3, >= 1.3.4)
|
12
|
+
tilt (1.4.1)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler
|
19
|
+
json
|
20
|
+
sinatra
|