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,189 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe CFConsole do
|
4
|
+
before do
|
5
|
+
@app = double("app")
|
6
|
+
@console = CFConsole.new(nil, @app)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return connection info for apps that have a console ip and port" do
|
10
|
+
instance = double("instance")
|
11
|
+
@app.should_receive(:instances) { [instance] }
|
12
|
+
instance.should_receive(:console) { {:ip => "192.168.1.1", :port => 3344} }
|
13
|
+
|
14
|
+
@console.get_connection_info(nil).should == {
|
15
|
+
"hostname" => "192.168.1.1",
|
16
|
+
"port" => 3344
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should raise error when no app instances found" do
|
21
|
+
@app.should_receive(:instances) { [] }
|
22
|
+
|
23
|
+
expect {
|
24
|
+
@console.get_connection_info(nil)
|
25
|
+
}.to raise_error("App has no running instances; try starting it.")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should raise error when app does not have console access" do
|
29
|
+
instance = double("instance")
|
30
|
+
@app.should_receive(:instances) { [instance] }
|
31
|
+
instance.should_receive(:console) { nil }
|
32
|
+
|
33
|
+
expect {
|
34
|
+
@console.get_connection_info(nil)
|
35
|
+
}.to raise_error("App does not have console access; try restarting it.")
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "start_console" do
|
39
|
+
before do
|
40
|
+
@creds = {
|
41
|
+
:path => %w(app cf-rails-console .consoleaccess),
|
42
|
+
:yaml => "username: cfuser\npassword: testpw",
|
43
|
+
:telnet => {"Name" => "cfuser", "Password" => "testpw"}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when console credentials cannot be obtained" do
|
48
|
+
it "should raise error" do
|
49
|
+
@app.should_receive(:file).with(*@creds[:path]) { "username: cfuser" }
|
50
|
+
|
51
|
+
expect {
|
52
|
+
@console.start_console
|
53
|
+
}.to raise_error("Unable to verify console credentials.")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when console credentials can be obtained" do
|
58
|
+
before do
|
59
|
+
@app.should_receive(:file).with(*@creds[:path]) { @creds[:yaml] }
|
60
|
+
@telnet = Object.new
|
61
|
+
@console.should_receive(:telnet_client).and_return(@telnet)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should raise error if authentication fails" do
|
65
|
+
@telnet.should_receive(:login).with(@creds[:telnet]) { "Login failed" }
|
66
|
+
@telnet.should_receive(:close)
|
67
|
+
|
68
|
+
expect { @console.start_console }.to raise_error("Login failed")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should retry authentication on timeout" do
|
72
|
+
@telnet.should_receive(:login).with(@creds[:telnet]){ raise TimeoutError }
|
73
|
+
@telnet.should_receive(:login).with(@creds[:telnet]) { "Switch to inspect mode\nirb():001:0> " }
|
74
|
+
verify_console_exit("irb():001:0> ")
|
75
|
+
|
76
|
+
@console.start_console
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should retry authentication on EOF" do
|
80
|
+
@console.should_receive(:telnet_client).and_return(@telnet)
|
81
|
+
@telnet.should_receive(:login).with(@creds[:telnet]) { raise EOFError }
|
82
|
+
@telnet.should_receive(:close)
|
83
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
84
|
+
verify_console_exit("irb():001:0> ")
|
85
|
+
|
86
|
+
@console.start_console
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should operate console interactively" do
|
90
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
91
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
92
|
+
Readline::HISTORY.should_receive(:push).with("puts 'hi'")
|
93
|
+
@telnet.should_receive(:cmd).with("puts 'hi'").and_return("nil" + "\n" + "irb():002:0> ")
|
94
|
+
@console.should_receive(:puts).with("nil")
|
95
|
+
verify_console_exit("irb():002:0> ")
|
96
|
+
|
97
|
+
@console.start_console
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not crash if command times out" do
|
101
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
102
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
103
|
+
Readline::HISTORY.should_receive(:push).with("puts 'hi'")
|
104
|
+
@telnet.should_receive(:cmd).with("puts 'hi'") { raise TimeoutError }
|
105
|
+
@console.should_receive(:puts).with("Timed out sending command to server.")
|
106
|
+
verify_console_exit("irb():001:0> ")
|
107
|
+
|
108
|
+
@console.start_console
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should raise error if an EOF is received" do
|
112
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("Switch to inspect mode\nirb():001:0> ")
|
113
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
114
|
+
Readline::HISTORY.should_receive(:push).with("puts 'hi'")
|
115
|
+
@telnet.should_receive(:cmd).with("puts 'hi'") { raise EOFError }
|
116
|
+
|
117
|
+
expect {
|
118
|
+
@console.start_console
|
119
|
+
}.to raise_error("The console connection has been terminated. Perhaps the app was stopped or deleted?")
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should not keep blank lines in history" do
|
123
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
124
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "" }
|
125
|
+
Readline::HISTORY.should_not_receive(:push)
|
126
|
+
@telnet.should_receive(:cmd).and_return("irb():002:0*> ")
|
127
|
+
verify_console_exit("irb():002:0*> ")
|
128
|
+
|
129
|
+
@console.start_console
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should not keep identical commands in history" do
|
133
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
134
|
+
Readline.should_receive(:readline).with("irb():001:0> ") { "puts 'hi'" }
|
135
|
+
Readline::HISTORY.should_receive(:to_a).and_return(["puts 'hi'"])
|
136
|
+
Readline::HISTORY.should_not_receive(:push).with("puts 'hi'")
|
137
|
+
@telnet.should_receive(:cmd).with("puts 'hi'").and_return("nil" + "\n" + "irb():002:0> ")
|
138
|
+
@console.should_receive(:puts).with("nil")
|
139
|
+
verify_console_exit("irb():002:0> ")
|
140
|
+
|
141
|
+
@console.start_console
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should return tab completion data" do
|
145
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("Switch to inspect mode\nirb():001:0> ")
|
146
|
+
@telnet.should_receive(:cmd).with("String" => "app.\t", "Match" => /\S*\n$/, "Timeout" => 10) { "to_s,nil?\n" }
|
147
|
+
verify_console_exit("irb():001:0> ")
|
148
|
+
|
149
|
+
@console.start_console
|
150
|
+
Readline.completion_proc.call("app.").should == ["to_s","nil?"]
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should return tab completion data receiving empty completion string" do
|
154
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
155
|
+
@telnet.should_receive(:cmd).with("String" => "app.\t", "Match" => /\S*\n$/, "Timeout" => 10) { "\n" }
|
156
|
+
verify_console_exit("irb():001:0> ")
|
157
|
+
|
158
|
+
@console.start_console
|
159
|
+
Readline.completion_proc.call("app.").should == []
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should not crash on timeout of remote tab completion data" do
|
163
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("Switch to inspect mode\nirb():001:0> ")
|
164
|
+
@telnet.should_receive(:cmd).with("String" => "app.\t", "Match" => /\S*\n$/, "Timeout" => 10) { raise TimeoutError }
|
165
|
+
verify_console_exit("irb():001:0> ")
|
166
|
+
|
167
|
+
@console.start_console
|
168
|
+
Readline.completion_proc.call("app.").should == []
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should properly initialize Readline for tab completion" do
|
172
|
+
@telnet.should_receive(:login).with(@creds[:telnet]).and_return("irb():001:0> ")
|
173
|
+
Readline.should_receive(:respond_to?).with("basic_word_break_characters=") { true }
|
174
|
+
Readline.should_receive(:basic_word_break_characters=).with(" \t\n`><=;|&{(")
|
175
|
+
Readline.should_receive(:completion_append_character=).with(nil)
|
176
|
+
Readline.should_receive(:completion_proc=).with(anything)
|
177
|
+
verify_console_exit("irb():001:0> ")
|
178
|
+
|
179
|
+
@console.start_console
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def verify_console_exit(prompt)
|
185
|
+
Readline.should_receive(:readline).with(prompt) { "exit" }
|
186
|
+
@telnet.should_receive(:cmd).with("String" => "exit", "Timeout" => 1) { raise TimeoutError }
|
187
|
+
@telnet.should_receive(:close)
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :app, :class => CFoundry::V2::App do
|
3
|
+
sequence(:guid) { |n| "app-guid-#{n}" }
|
4
|
+
sequence(:name) { |n| "app-name-#{n}" }
|
5
|
+
|
6
|
+
ignore do
|
7
|
+
client { FactoryGirl.build(:client) }
|
8
|
+
end
|
9
|
+
|
10
|
+
initialize_with { new(guid, client) }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :managed_service_instance, :class => CFoundry::V2::ManagedServiceInstance do
|
3
|
+
sequence(:guid) { |n| "service-instance-guid-#{n}" }
|
4
|
+
sequence(:name) { |n| "service-instance-name-#{n}" }
|
5
|
+
service_plan { build(:service_plan) }
|
6
|
+
|
7
|
+
ignore do
|
8
|
+
client { FactoryGirl.build(:client) }
|
9
|
+
end
|
10
|
+
|
11
|
+
initialize_with { new(guid, client) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :organization, :class => CFoundry::V2::Organization do
|
3
|
+
sequence(:guid) { |n| "organization-guid-#{n}" }
|
4
|
+
sequence(:name) { |n| "organization-name-#{n}" }
|
5
|
+
users { [build(:user)] }
|
6
|
+
spaces { [build(:space)] }
|
7
|
+
|
8
|
+
ignore do
|
9
|
+
client { FactoryGirl.build(:client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
initialize_with { new(guid, client) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module CFoundry
|
2
|
+
FactoryGirl.define do
|
3
|
+
factory :quota_definition, class: CFoundry::V2::QuotaDefinition do
|
4
|
+
sequence(:guid) { |n| "quota-definition-guid-#{n}" }
|
5
|
+
|
6
|
+
ignore do
|
7
|
+
client { FactoryGirl.build(:client) }
|
8
|
+
end
|
9
|
+
|
10
|
+
initialize_with { new(guid, client) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :service_binding, :class => CFoundry::V2::ServiceBinding do
|
3
|
+
sequence(:guid) { |n| "service-binding-guid-#{n}" }
|
4
|
+
|
5
|
+
ignore do
|
6
|
+
client { FactoryGirl.build(:client) }
|
7
|
+
end
|
8
|
+
|
9
|
+
initialize_with { new(guid, client) }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :service_plan, :class => CFoundry::V2::ServicePlan do
|
3
|
+
sequence(:guid) { |n| "service-plan-guid-#{n}" }
|
4
|
+
sequence(:name) { |n| "service-plan-name-#{n}" }
|
5
|
+
extra { "{}" }
|
6
|
+
|
7
|
+
after(:build) do |service_plan|
|
8
|
+
service_plan.service ||= FactoryGirl.build(:service, service_plans: [service_plan])
|
9
|
+
end
|
10
|
+
|
11
|
+
ignore do
|
12
|
+
client { FactoryGirl.build(:client) }
|
13
|
+
end
|
14
|
+
|
15
|
+
initialize_with { new(guid, client) }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :service, :class => CFoundry::V2::Service do
|
3
|
+
sequence(:guid) { |n| "service-guid-#{n}" }
|
4
|
+
sequence(:label) { |n| "service-label-#{n}" }
|
5
|
+
service_plans { [build(:service_plan)] }
|
6
|
+
extra { "{}" }
|
7
|
+
|
8
|
+
ignore do
|
9
|
+
client { FactoryGirl.build(:client) }
|
10
|
+
end
|
11
|
+
|
12
|
+
initialize_with { new(guid, client) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :space, :class => CFoundry::V2::Space do
|
3
|
+
sequence(:guid) { |n| "space-guid-#{n}" }
|
4
|
+
sequence(:name) { |n| "space-name-#{n}" }
|
5
|
+
domains { [build(:domain)] }
|
6
|
+
|
7
|
+
ignore do
|
8
|
+
client { FactoryGirl.build(:client) }
|
9
|
+
end
|
10
|
+
|
11
|
+
initialize_with { new(guid, client) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :user_provided_service_instance, :class => CFoundry::V2::UserProvidedServiceInstance do
|
3
|
+
sequence(:guid) { |n| "user-provided-service-instance-guid-#{n}" }
|
4
|
+
sequence(:name) { |n| "user-provided-service-instance-name-#{n}" }
|
5
|
+
|
6
|
+
ignore do
|
7
|
+
client { FactoryGirl.build(:client) }
|
8
|
+
end
|
9
|
+
|
10
|
+
initialize_with { new(guid, client) }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "webmock/rspec"
|
3
|
+
|
4
|
+
if ENV['CF_V2_RUN_INTEGRATION']
|
5
|
+
describe "A user pushing a new sinatra app", :ruby19 => true do
|
6
|
+
let(:run_id) { TRAVIS_BUILD_ID.to_s + Time.new.to_f.to_s.gsub(".", "_") }
|
7
|
+
let(:app) { "hello-sinatra-#{run_id}" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
FileUtils.rm_rf File.expand_path(CF::CONFIG_DIR)
|
11
|
+
login
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
`#{cf_bin} delete #{app} -f --routes --no-script`
|
16
|
+
end
|
17
|
+
|
18
|
+
it "attempts to use the backspace key" do
|
19
|
+
Dir.chdir("#{SPEC_ROOT}/assets/hello-sinatra") do
|
20
|
+
FileUtils.rm("manifest.yml", force: true)
|
21
|
+
BlueShell::Runner.run("#{cf_bin} push #{app}") do |runner|
|
22
|
+
expect(runner).to say "Instances> 1"
|
23
|
+
runner.send_return
|
24
|
+
|
25
|
+
expect(runner).to say "Memory Limit>"
|
26
|
+
runner.send_keys "128M"
|
27
|
+
|
28
|
+
expect(runner).to say "Creating #{app}... OK"
|
29
|
+
|
30
|
+
expect(runner).to say "Subdomain> #{app}"
|
31
|
+
app.length.times { runner.send_right_arrow }
|
32
|
+
runner.send_backspace
|
33
|
+
runner.send_return
|
34
|
+
|
35
|
+
expect(runner).to say "Domain>"
|
36
|
+
runner.send_return
|
37
|
+
|
38
|
+
expect(runner).to say /Binding #{app[0..-2]}\..* to #{app}.*OK/, 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
else
|
44
|
+
$stderr.puts 'Skipping v2 integration specs; please provide environment variables'
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,74 @@
|
|
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(:target) { ENV['CF_V2_TEST_TARGET'] }
|
16
|
+
let(:username) { ENV['CF_V2_TEST_USER'] }
|
17
|
+
let(:password) { ENV['CF_V2_TEST_PASSWORD'] }
|
18
|
+
let(:organization) { ENV['CF_V2_TEST_ORGANIZATION'] }
|
19
|
+
|
20
|
+
let(:client) do
|
21
|
+
client = CFoundry::V2::Client.new("https://#{target}")
|
22
|
+
client.login(:username => username, :password => password)
|
23
|
+
client
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:new_user) { Faker::Internet.disposable_email("cf-test-user-#{Time.now.to_i}") }
|
27
|
+
|
28
|
+
before do
|
29
|
+
Interact::Progress::Dots.start!
|
30
|
+
login
|
31
|
+
end
|
32
|
+
|
33
|
+
after do
|
34
|
+
# TODO: do this when cf delete-user is implemented
|
35
|
+
#BlueShell::Runner.run("#{cf_bin} delete-user #{email}") do |runner|
|
36
|
+
# expect(runner).to say "Really delete user #{email}?>"
|
37
|
+
# runner.send_keys "y"
|
38
|
+
# expect(runner).to say "Deleting #{email}... OK"
|
39
|
+
#end
|
40
|
+
|
41
|
+
# TODO: not this.
|
42
|
+
client.login(:username => new_user, :password => password)
|
43
|
+
user = client.current_user
|
44
|
+
guid = user.guid
|
45
|
+
client.login(:username => username, :password => password)
|
46
|
+
user.delete!
|
47
|
+
|
48
|
+
logout
|
49
|
+
Interact::Progress::Dots.stop!
|
50
|
+
end
|
51
|
+
|
52
|
+
it "creates a new user" do
|
53
|
+
BlueShell::Runner.run("#{cf_bin} create-user") do |runner|
|
54
|
+
expect(runner).to say "Email>"
|
55
|
+
runner.send_keys new_user
|
56
|
+
|
57
|
+
expect(runner).to say "Password>"
|
58
|
+
runner.send_keys password
|
59
|
+
|
60
|
+
expect(runner).to say "Verify Password>"
|
61
|
+
runner.send_keys password
|
62
|
+
|
63
|
+
expect(runner).to say "Creating user... OK"
|
64
|
+
expect(runner).to say "Adding user to #{organization}... OK"
|
65
|
+
end
|
66
|
+
|
67
|
+
BlueShell::Runner.run("#{cf_bin} login #{new_user} --password #{password}") do |runner|
|
68
|
+
expect(runner).to say "Authenticating... OK"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
else
|
73
|
+
$stderr.puts 'Skipping v2 integration specs; please provide environment variables'
|
74
|
+
end
|