startapp 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/COPYRIGHT +1 -0
- data/LICENSE +11 -0
- data/README.md +95 -0
- data/Rakefile +6 -0
- data/autocomplete/rhc_bash +1672 -0
- data/bin/app +37 -0
- data/conf/express.conf +8 -0
- data/features/assets/deploy.tar.gz +0 -0
- data/features/core_feature.rb +191 -0
- data/features/deployments_feature.rb +129 -0
- data/features/domains_feature.rb +58 -0
- data/features/keys_feature.rb +37 -0
- data/features/members_feature.rb +166 -0
- data/lib/rhc/auth/basic.rb +64 -0
- data/lib/rhc/auth/token.rb +102 -0
- data/lib/rhc/auth/token_store.rb +53 -0
- data/lib/rhc/auth.rb +5 -0
- data/lib/rhc/autocomplete.rb +66 -0
- data/lib/rhc/autocomplete_templates/bash.erb +39 -0
- data/lib/rhc/cartridge_helpers.rb +118 -0
- data/lib/rhc/cli.rb +40 -0
- data/lib/rhc/command_runner.rb +185 -0
- data/lib/rhc/commands/account.rb +25 -0
- data/lib/rhc/commands/alias.rb +124 -0
- data/lib/rhc/commands/app.rb +726 -0
- data/lib/rhc/commands/apps.rb +20 -0
- data/lib/rhc/commands/authorization.rb +115 -0
- data/lib/rhc/commands/base.rb +174 -0
- data/lib/rhc/commands/cartridge.rb +329 -0
- data/lib/rhc/commands/clone.rb +66 -0
- data/lib/rhc/commands/configure.rb +20 -0
- data/lib/rhc/commands/create.rb +100 -0
- data/lib/rhc/commands/delete.rb +19 -0
- data/lib/rhc/commands/deploy.rb +32 -0
- data/lib/rhc/commands/deployment.rb +82 -0
- data/lib/rhc/commands/domain.rb +172 -0
- data/lib/rhc/commands/env.rb +142 -0
- data/lib/rhc/commands/force_stop.rb +17 -0
- data/lib/rhc/commands/git_clone.rb +34 -0
- data/lib/rhc/commands/logout.rb +51 -0
- data/lib/rhc/commands/logs.rb +21 -0
- data/lib/rhc/commands/member.rb +148 -0
- data/lib/rhc/commands/port_forward.rb +197 -0
- data/lib/rhc/commands/reload.rb +17 -0
- data/lib/rhc/commands/restart.rb +17 -0
- data/lib/rhc/commands/scp.rb +54 -0
- data/lib/rhc/commands/server.rb +40 -0
- data/lib/rhc/commands/setup.rb +60 -0
- data/lib/rhc/commands/show.rb +43 -0
- data/lib/rhc/commands/snapshot.rb +137 -0
- data/lib/rhc/commands/ssh.rb +51 -0
- data/lib/rhc/commands/sshkey.rb +97 -0
- data/lib/rhc/commands/start.rb +17 -0
- data/lib/rhc/commands/stop.rb +17 -0
- data/lib/rhc/commands/tail.rb +47 -0
- data/lib/rhc/commands/threaddump.rb +14 -0
- data/lib/rhc/commands/tidy.rb +17 -0
- data/lib/rhc/commands.rb +396 -0
- data/lib/rhc/config.rb +321 -0
- data/lib/rhc/context_helper.rb +121 -0
- data/lib/rhc/core_ext.rb +202 -0
- data/lib/rhc/coverage_helper.rb +33 -0
- data/lib/rhc/deployment_helpers.rb +111 -0
- data/lib/rhc/exceptions.rb +256 -0
- data/lib/rhc/git_helpers.rb +106 -0
- data/lib/rhc/help_formatter.rb +55 -0
- data/lib/rhc/helpers.rb +481 -0
- data/lib/rhc/highline_extensions.rb +479 -0
- data/lib/rhc/json.rb +51 -0
- data/lib/rhc/output_helpers.rb +260 -0
- data/lib/rhc/rest/activation.rb +11 -0
- data/lib/rhc/rest/alias.rb +42 -0
- data/lib/rhc/rest/api.rb +87 -0
- data/lib/rhc/rest/application.rb +348 -0
- data/lib/rhc/rest/attributes.rb +36 -0
- data/lib/rhc/rest/authorization.rb +8 -0
- data/lib/rhc/rest/base.rb +79 -0
- data/lib/rhc/rest/cartridge.rb +162 -0
- data/lib/rhc/rest/client.rb +650 -0
- data/lib/rhc/rest/deployment.rb +18 -0
- data/lib/rhc/rest/domain.rb +98 -0
- data/lib/rhc/rest/environment_variable.rb +15 -0
- data/lib/rhc/rest/gear_group.rb +16 -0
- data/lib/rhc/rest/httpclient.rb +145 -0
- data/lib/rhc/rest/key.rb +44 -0
- data/lib/rhc/rest/membership.rb +105 -0
- data/lib/rhc/rest/mock.rb +1042 -0
- data/lib/rhc/rest/user.rb +32 -0
- data/lib/rhc/rest.rb +148 -0
- data/lib/rhc/scp_helpers.rb +27 -0
- data/lib/rhc/ssh_helpers.rb +380 -0
- data/lib/rhc/tar_gz.rb +51 -0
- data/lib/rhc/usage_templates/command_help.erb +51 -0
- data/lib/rhc/usage_templates/command_syntax_help.erb +11 -0
- data/lib/rhc/usage_templates/help.erb +61 -0
- data/lib/rhc/usage_templates/missing_help.erb +1 -0
- data/lib/rhc/usage_templates/options_help.erb +12 -0
- data/lib/rhc/vendor/okjson.rb +600 -0
- data/lib/rhc/vendor/parseconfig.rb +178 -0
- data/lib/rhc/vendor/sshkey.rb +253 -0
- data/lib/rhc/vendor/zliby.rb +628 -0
- data/lib/rhc/version.rb +5 -0
- data/lib/rhc/wizard.rb +637 -0
- data/lib/rhc.rb +34 -0
- data/spec/coverage_helper.rb +82 -0
- data/spec/direct_execution_helper.rb +339 -0
- data/spec/keys/example.pem +23 -0
- data/spec/keys/example_private.pem +27 -0
- data/spec/keys/server.pem +19 -0
- data/spec/rest_spec_helper.rb +31 -0
- data/spec/rhc/assets/cert.crt +22 -0
- data/spec/rhc/assets/cert_key_rsa +27 -0
- data/spec/rhc/assets/empty.txt +0 -0
- data/spec/rhc/assets/env_vars.txt +7 -0
- data/spec/rhc/assets/env_vars_2.txt +1 -0
- data/spec/rhc/assets/foo.txt +1 -0
- data/spec/rhc/assets/targz_corrupted.tar.gz +1 -0
- data/spec/rhc/assets/targz_sample.tar.gz +0 -0
- data/spec/rhc/auth_spec.rb +442 -0
- data/spec/rhc/cli_spec.rb +186 -0
- data/spec/rhc/command_spec.rb +435 -0
- data/spec/rhc/commands/account_spec.rb +42 -0
- data/spec/rhc/commands/alias_spec.rb +333 -0
- data/spec/rhc/commands/app_spec.rb +777 -0
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/authorization_spec.rb +157 -0
- data/spec/rhc/commands/cartridge_spec.rb +665 -0
- data/spec/rhc/commands/clone_spec.rb +41 -0
- data/spec/rhc/commands/deployment_spec.rb +327 -0
- data/spec/rhc/commands/domain_spec.rb +401 -0
- data/spec/rhc/commands/env_spec.rb +493 -0
- data/spec/rhc/commands/git_clone_spec.rb +102 -0
- data/spec/rhc/commands/logout_spec.rb +86 -0
- data/spec/rhc/commands/member_spec.rb +247 -0
- data/spec/rhc/commands/port_forward_spec.rb +217 -0
- data/spec/rhc/commands/scp_spec.rb +77 -0
- data/spec/rhc/commands/server_spec.rb +69 -0
- data/spec/rhc/commands/setup_spec.rb +118 -0
- data/spec/rhc/commands/snapshot_spec.rb +179 -0
- data/spec/rhc/commands/ssh_spec.rb +163 -0
- data/spec/rhc/commands/sshkey_spec.rb +188 -0
- data/spec/rhc/commands/tail_spec.rb +81 -0
- data/spec/rhc/commands/threaddump_spec.rb +84 -0
- data/spec/rhc/config_spec.rb +407 -0
- data/spec/rhc/helpers_spec.rb +531 -0
- data/spec/rhc/highline_extensions_spec.rb +314 -0
- data/spec/rhc/json_spec.rb +30 -0
- data/spec/rhc/rest_application_spec.rb +258 -0
- data/spec/rhc/rest_client_spec.rb +752 -0
- data/spec/rhc/rest_spec.rb +740 -0
- data/spec/rhc/targz_spec.rb +55 -0
- data/spec/rhc/wizard_spec.rb +756 -0
- data/spec/spec_helper.rb +575 -0
- data/spec/wizard_spec_helper.rb +330 -0
- metadata +469 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rest_spec_helper'
|
|
3
|
+
require 'rhc/commands/apps'
|
|
4
|
+
|
|
5
|
+
describe RHC::Commands::Apps do
|
|
6
|
+
before{ user_config }
|
|
7
|
+
let!(:rest_client){ MockRestClient.new }
|
|
8
|
+
|
|
9
|
+
describe 'run' do
|
|
10
|
+
context 'when no domains' do
|
|
11
|
+
let(:arguments) { ['apps'] }
|
|
12
|
+
|
|
13
|
+
it { expect { run }.to exit_with_code(1) }
|
|
14
|
+
it { run_output.should match(/In order to deploy applications.*app create-domain/) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context 'with a domain' do
|
|
18
|
+
let(:arguments){ ['apps'] }
|
|
19
|
+
let!(:domain){ rest_client.add_domain("first") }
|
|
20
|
+
|
|
21
|
+
it { expect { run }.to exit_with_code(1) }
|
|
22
|
+
it { run_output.should match(/No applications.*app create-app/) }
|
|
23
|
+
|
|
24
|
+
context 'with apps' do
|
|
25
|
+
let(:arguments) { ['apps'] }
|
|
26
|
+
before{ domain.add_application('scaled', 'php', true) }
|
|
27
|
+
|
|
28
|
+
it { expect { run }.to exit_with_code(0) }
|
|
29
|
+
it { run_output.should match(/scaled.*\-\-.*php.*Scaling:.*x2 \(minimum/m) }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'when help is shown' do
|
|
34
|
+
let(:arguments) { ['apps', '--help'] }
|
|
35
|
+
it { expect { run }.to exit_with_code(0) }
|
|
36
|
+
it { run_output.should match(/app apps.*Display the list of applications/m) }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'rest_spec_helper'
|
|
3
|
+
require 'rhc'
|
|
4
|
+
require 'rhc/commands/authorization'
|
|
5
|
+
|
|
6
|
+
describe RHC::Commands::Authorization do
|
|
7
|
+
|
|
8
|
+
def self.with_authorization
|
|
9
|
+
let(:username) { 'foo' }
|
|
10
|
+
let(:password) { 'pass' }
|
|
11
|
+
let(:server) { mock_uri }
|
|
12
|
+
before{ user_config }
|
|
13
|
+
before{ stub_api(false, true) }
|
|
14
|
+
end
|
|
15
|
+
def self.without_authorization
|
|
16
|
+
let(:username) { 'foo' }
|
|
17
|
+
let(:password) { 'pass' }
|
|
18
|
+
let(:server) { mock_uri }
|
|
19
|
+
before{ user_config }
|
|
20
|
+
before{ stub_api(false, false) }
|
|
21
|
+
end
|
|
22
|
+
def self.expect_an_unsupported_message
|
|
23
|
+
context "without authorizations" do
|
|
24
|
+
without_authorization
|
|
25
|
+
it('should warn that the server doesn\'t support auth'){ run_output.should =~ /The server does not support setting, retrieving, or authenticating with authorization tokens/ }
|
|
26
|
+
it{ expect{ run }.to exit_with_code(1) }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#run' do
|
|
31
|
+
let(:arguments) { ['authorizations'] }
|
|
32
|
+
context "with authorizations" do
|
|
33
|
+
with_authorization
|
|
34
|
+
before{ challenge{ stub_authorizations } }
|
|
35
|
+
it('should display the note') { run_output.should =~ /an_authorization/ }
|
|
36
|
+
it('should display the token') { run_output.should =~ /Token:\s+a_token_value/ }
|
|
37
|
+
it('should display the expiration') { run_output.should =~ /Expires In:\s+1 minute/ }
|
|
38
|
+
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date('2013-02-21T01:00:01Z')}/ }
|
|
39
|
+
it('should display the scopes') { run_output.should =~ /Scopes:\s+session read/ }
|
|
40
|
+
it{ expect{ run }.to exit_with_code(0) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
expect_an_unsupported_message
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#run' do
|
|
47
|
+
let(:arguments) { ['authorization']}
|
|
48
|
+
context 'given no arguments' do
|
|
49
|
+
it('should display help'){ run_output.should =~ /An authorization token grants access to the StartApp REST API.*To see all your authorizations/m }
|
|
50
|
+
it 'should ask for an argument' do
|
|
51
|
+
expect{ run }.to exit_with_code(1)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#list' do
|
|
57
|
+
let(:arguments) { ['authorization', 'list'] }
|
|
58
|
+
context "with authorizations" do
|
|
59
|
+
with_authorization
|
|
60
|
+
before{ challenge{ stub_authorizations } }
|
|
61
|
+
it('should display the note') { run_output.should =~ /an_authorization/ }
|
|
62
|
+
it('should display the token') { run_output.should =~ /Token:\s+a_token_value/ }
|
|
63
|
+
it('should display the expiration') { run_output.should =~ /Expires In:\s+1 minute/ }
|
|
64
|
+
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date('2013-02-21T01:00:01Z')}/ }
|
|
65
|
+
it('should display the scopes') { run_output.should =~ /Scopes:\s+session read/ }
|
|
66
|
+
it{ expect{ run }.to exit_with_code(0) }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
expect_an_unsupported_message
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe "#delete" do
|
|
73
|
+
let(:arguments) { ['authorization', 'delete', 'foo', 'bar'] }
|
|
74
|
+
|
|
75
|
+
context "with authorizations" do
|
|
76
|
+
with_authorization
|
|
77
|
+
before{ challenge{ stub_delete_authorization('foo') } }
|
|
78
|
+
before{ challenge{ stub_delete_authorization('bar') } }
|
|
79
|
+
it('should display success') { run_output.should =~ /Deleting auth.*done/ }
|
|
80
|
+
it{ expect{ run }.to exit_with_code(0) }
|
|
81
|
+
after{ a_request(:delete, mock_href('broker/rest/user/authorizations/foo', true)).should have_been_made }
|
|
82
|
+
after{ a_request(:delete, mock_href('broker/rest/user/authorizations/bar', true)).should have_been_made }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "without a token in the command line" do
|
|
86
|
+
let(:arguments) { ['authorization', 'delete'] }
|
|
87
|
+
it('should display success') { run_output.should =~ /You must specify one or more tokens to delete/ }
|
|
88
|
+
it{ expect{ run }.to exit_with_code(1) }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
expect_an_unsupported_message
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "#delete_all" do
|
|
95
|
+
let(:arguments) { ['authorization', 'delete-all'] }
|
|
96
|
+
|
|
97
|
+
context "with authorizations" do
|
|
98
|
+
with_authorization
|
|
99
|
+
before{ challenge{ stub_delete_authorizations } }
|
|
100
|
+
it('should display success') { run_output.should =~ /Deleting all auth.*done/ }
|
|
101
|
+
it{ expect{ run }.to exit_with_code(0) }
|
|
102
|
+
after{ a_request(:delete, mock_href('broker/rest/user/authorizations', true)).should have_been_made }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
expect_an_unsupported_message
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe "#scope_help" do
|
|
109
|
+
let(:rest_client){ double(:authorization_scope_list => [['scope_1', 'A description'], ['scope_2', 'Another description']]) }
|
|
110
|
+
before{ subject.should_receive(:rest_client).and_return(rest_client) }
|
|
111
|
+
it{ capture{ subject.send(:scope_help) }.should =~ /scope_1.*A description/ }
|
|
112
|
+
it{ capture{ subject.send(:scope_help) }.should =~ /scope_2.*Another description/ }
|
|
113
|
+
it{ capture{ subject.send(:scope_help) }.should =~ /You may pass multiple scopes/ }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe "#add" do
|
|
117
|
+
let(:arguments) { ['authorization', 'add'] }
|
|
118
|
+
|
|
119
|
+
context "with authorizations" do
|
|
120
|
+
using_command_instance
|
|
121
|
+
with_authorization
|
|
122
|
+
before{ instance.should_receive(:scope_help) }
|
|
123
|
+
|
|
124
|
+
it('should display the scope help') { command_output.should =~ /When adding an authorization.*to see more options/m }
|
|
125
|
+
it{ expect{ run_command }.to exit_with_code(0) }
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
expect_an_unsupported_message
|
|
129
|
+
|
|
130
|
+
context "with empty scope options" do
|
|
131
|
+
let(:arguments) { ['authorization', 'add', '--scopes', ' ', '--note', 'a_note', '--expires-in', '300'] }
|
|
132
|
+
using_command_instance
|
|
133
|
+
with_authorization
|
|
134
|
+
before{ instance.should_receive(:scope_help) }
|
|
135
|
+
|
|
136
|
+
it('should display the scope help') { command_output.should =~ /When adding an authorization.*to see more options/m }
|
|
137
|
+
it{ expect{ run_command }.to exit_with_code(0) }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
context "with options" do
|
|
142
|
+
let(:arguments) { ['authorization', 'add', '--scope', 'foo,bar', '--note', 'a_note', '--expires-in', '300'] }
|
|
143
|
+
with_authorization
|
|
144
|
+
before{ challenge{ stub_add_authorization(:note => 'a_note', :scope => 'foo,bar', :expires_in => '300') } }
|
|
145
|
+
|
|
146
|
+
it('should display success') { run_output.should =~ /Adding authorization.*done/ }
|
|
147
|
+
it('should display the note') { run_output.should =~ /a_note/ }
|
|
148
|
+
it('should display the token') { run_output.should =~ /Token:\s+a_token_value/ }
|
|
149
|
+
it('should display the expiration') { run_output.should =~ /Expires In:\s+5 minutes/ }
|
|
150
|
+
it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date(mock_date_1)}/ }
|
|
151
|
+
it('should display the scopes') { run_output.should =~ /Scopes:\s+foo bar/ }
|
|
152
|
+
it{ expect{ run }.to exit_with_code(0) }
|
|
153
|
+
|
|
154
|
+
expect_an_unsupported_message
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|