pbox 1.17.2

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.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/COPYRIGHT +1 -0
  3. data/LICENSE +11 -0
  4. data/README.md +40 -0
  5. data/Rakefile +6 -0
  6. data/autocomplete/pbox_bash +1639 -0
  7. data/bin/pbox +37 -0
  8. data/conf/protonbox.conf +8 -0
  9. data/features/assets/deploy.tar.gz +0 -0
  10. data/features/core_feature.rb +178 -0
  11. data/features/deployments_feature.rb +127 -0
  12. data/features/domains_feature.rb +49 -0
  13. data/features/keys_feature.rb +37 -0
  14. data/features/members_feature.rb +166 -0
  15. data/lib/rhc/auth/basic.rb +64 -0
  16. data/lib/rhc/auth/token.rb +102 -0
  17. data/lib/rhc/auth/token_store.rb +53 -0
  18. data/lib/rhc/auth.rb +5 -0
  19. data/lib/rhc/autocomplete.rb +66 -0
  20. data/lib/rhc/autocomplete_templates/bash.erb +39 -0
  21. data/lib/rhc/cartridge_helpers.rb +118 -0
  22. data/lib/rhc/cli.rb +40 -0
  23. data/lib/rhc/command_runner.rb +186 -0
  24. data/lib/rhc/commands/account.rb +25 -0
  25. data/lib/rhc/commands/alias.rb +124 -0
  26. data/lib/rhc/commands/app.rb +701 -0
  27. data/lib/rhc/commands/apps.rb +20 -0
  28. data/lib/rhc/commands/authorization.rb +96 -0
  29. data/lib/rhc/commands/base.rb +174 -0
  30. data/lib/rhc/commands/cartridge.rb +326 -0
  31. data/lib/rhc/commands/deployment.rb +82 -0
  32. data/lib/rhc/commands/domain.rb +167 -0
  33. data/lib/rhc/commands/env.rb +142 -0
  34. data/lib/rhc/commands/git_clone.rb +29 -0
  35. data/lib/rhc/commands/logout.rb +51 -0
  36. data/lib/rhc/commands/member.rb +148 -0
  37. data/lib/rhc/commands/port_forward.rb +197 -0
  38. data/lib/rhc/commands/server.rb +40 -0
  39. data/lib/rhc/commands/setup.rb +60 -0
  40. data/lib/rhc/commands/snapshot.rb +137 -0
  41. data/lib/rhc/commands/ssh.rb +51 -0
  42. data/lib/rhc/commands/sshkey.rb +97 -0
  43. data/lib/rhc/commands/tail.rb +47 -0
  44. data/lib/rhc/commands/threaddump.rb +14 -0
  45. data/lib/rhc/commands.rb +396 -0
  46. data/lib/rhc/config.rb +320 -0
  47. data/lib/rhc/context_helper.rb +121 -0
  48. data/lib/rhc/core_ext.rb +202 -0
  49. data/lib/rhc/coverage_helper.rb +33 -0
  50. data/lib/rhc/deployment_helpers.rb +88 -0
  51. data/lib/rhc/exceptions.rb +232 -0
  52. data/lib/rhc/git_helpers.rb +91 -0
  53. data/lib/rhc/help_formatter.rb +55 -0
  54. data/lib/rhc/helpers.rb +477 -0
  55. data/lib/rhc/highline_extensions.rb +479 -0
  56. data/lib/rhc/json.rb +51 -0
  57. data/lib/rhc/output_helpers.rb +260 -0
  58. data/lib/rhc/rest/activation.rb +11 -0
  59. data/lib/rhc/rest/alias.rb +42 -0
  60. data/lib/rhc/rest/api.rb +87 -0
  61. data/lib/rhc/rest/application.rb +332 -0
  62. data/lib/rhc/rest/attributes.rb +36 -0
  63. data/lib/rhc/rest/authorization.rb +8 -0
  64. data/lib/rhc/rest/base.rb +79 -0
  65. data/lib/rhc/rest/cartridge.rb +154 -0
  66. data/lib/rhc/rest/client.rb +650 -0
  67. data/lib/rhc/rest/deployment.rb +18 -0
  68. data/lib/rhc/rest/domain.rb +98 -0
  69. data/lib/rhc/rest/environment_variable.rb +15 -0
  70. data/lib/rhc/rest/gear_group.rb +16 -0
  71. data/lib/rhc/rest/httpclient.rb +145 -0
  72. data/lib/rhc/rest/key.rb +44 -0
  73. data/lib/rhc/rest/membership.rb +105 -0
  74. data/lib/rhc/rest/mock.rb +1024 -0
  75. data/lib/rhc/rest/user.rb +32 -0
  76. data/lib/rhc/rest.rb +148 -0
  77. data/lib/rhc/ssh_helpers.rb +378 -0
  78. data/lib/rhc/tar_gz.rb +51 -0
  79. data/lib/rhc/usage_templates/command_help.erb +51 -0
  80. data/lib/rhc/usage_templates/command_syntax_help.erb +11 -0
  81. data/lib/rhc/usage_templates/help.erb +35 -0
  82. data/lib/rhc/usage_templates/missing_help.erb +1 -0
  83. data/lib/rhc/usage_templates/options_help.erb +12 -0
  84. data/lib/rhc/vendor/okjson.rb +600 -0
  85. data/lib/rhc/vendor/parseconfig.rb +178 -0
  86. data/lib/rhc/vendor/sshkey.rb +253 -0
  87. data/lib/rhc/vendor/zliby.rb +628 -0
  88. data/lib/rhc/version.rb +5 -0
  89. data/lib/rhc/wizard.rb +633 -0
  90. data/lib/rhc.rb +34 -0
  91. data/spec/coverage_helper.rb +89 -0
  92. data/spec/direct_execution_helper.rb +338 -0
  93. data/spec/keys/example.pem +23 -0
  94. data/spec/keys/example_private.pem +27 -0
  95. data/spec/keys/server.pem +19 -0
  96. data/spec/rest_spec_helper.rb +31 -0
  97. data/spec/rhc/assets/cert.crt +22 -0
  98. data/spec/rhc/assets/cert_key_rsa +27 -0
  99. data/spec/rhc/assets/empty.txt +0 -0
  100. data/spec/rhc/assets/env_vars.txt +7 -0
  101. data/spec/rhc/assets/env_vars_2.txt +1 -0
  102. data/spec/rhc/assets/foo.txt +1 -0
  103. data/spec/rhc/assets/targz_corrupted.tar.gz +1 -0
  104. data/spec/rhc/assets/targz_sample.tar.gz +0 -0
  105. data/spec/rhc/auth_spec.rb +442 -0
  106. data/spec/rhc/cli_spec.rb +188 -0
  107. data/spec/rhc/command_spec.rb +435 -0
  108. data/spec/rhc/commands/account_spec.rb +42 -0
  109. data/spec/rhc/commands/alias_spec.rb +333 -0
  110. data/spec/rhc/commands/app_spec.rb +754 -0
  111. data/spec/rhc/commands/apps_spec.rb +39 -0
  112. data/spec/rhc/commands/authorization_spec.rb +145 -0
  113. data/spec/rhc/commands/cartridge_spec.rb +641 -0
  114. data/spec/rhc/commands/deployment_spec.rb +286 -0
  115. data/spec/rhc/commands/domain_spec.rb +383 -0
  116. data/spec/rhc/commands/env_spec.rb +493 -0
  117. data/spec/rhc/commands/git_clone_spec.rb +80 -0
  118. data/spec/rhc/commands/logout_spec.rb +86 -0
  119. data/spec/rhc/commands/member_spec.rb +228 -0
  120. data/spec/rhc/commands/port_forward_spec.rb +217 -0
  121. data/spec/rhc/commands/server_spec.rb +69 -0
  122. data/spec/rhc/commands/setup_spec.rb +118 -0
  123. data/spec/rhc/commands/snapshot_spec.rb +179 -0
  124. data/spec/rhc/commands/ssh_spec.rb +163 -0
  125. data/spec/rhc/commands/sshkey_spec.rb +188 -0
  126. data/spec/rhc/commands/tail_spec.rb +81 -0
  127. data/spec/rhc/commands/threaddump_spec.rb +84 -0
  128. data/spec/rhc/config_spec.rb +407 -0
  129. data/spec/rhc/helpers_spec.rb +524 -0
  130. data/spec/rhc/highline_extensions_spec.rb +314 -0
  131. data/spec/rhc/json_spec.rb +30 -0
  132. data/spec/rhc/rest_application_spec.rb +248 -0
  133. data/spec/rhc/rest_client_spec.rb +752 -0
  134. data/spec/rhc/rest_spec.rb +740 -0
  135. data/spec/rhc/targz_spec.rb +55 -0
  136. data/spec/rhc/wizard_spec.rb +756 -0
  137. data/spec/spec_helper.rb +575 -0
  138. data/spec/wizard_spec_helper.rb +330 -0
  139. metadata +435 -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.*pbox 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.*pbox 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(/pbox apps.*Display the list of applications/m) }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,145 @@
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) { ['authorization'] }
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', '--h']}
48
+ context 'given --h' do
49
+ it 'should not raise' do
50
+ expect{ run }.to_not raise_error
51
+ end
52
+ end
53
+ end
54
+
55
+ describe '#list' do
56
+ let(:arguments) { ['authorization', 'list'] }
57
+ context "with authorizations" do
58
+ with_authorization
59
+ before{ challenge{ stub_authorizations } }
60
+ it('should display the note') { run_output.should =~ /an_authorization/ }
61
+ it('should display the token') { run_output.should =~ /Token:\s+a_token_value/ }
62
+ it('should display the expiration') { run_output.should =~ /Expires In:\s+1 minute/ }
63
+ it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date('2013-02-21T01:00:01Z')}/ }
64
+ it('should display the scopes') { run_output.should =~ /Scopes:\s+session read/ }
65
+ it{ expect{ run }.to exit_with_code(0) }
66
+ end
67
+
68
+ expect_an_unsupported_message
69
+ end
70
+
71
+ describe "#delete" do
72
+ let(:arguments) { ['authorization', 'delete', 'foo', 'bar'] }
73
+
74
+ context "with authorizations" do
75
+ with_authorization
76
+ before{ challenge{ stub_delete_authorization('foo') } }
77
+ before{ challenge{ stub_delete_authorization('bar') } }
78
+ it('should display success') { run_output.should =~ /Deleting auth.*done/ }
79
+ it{ expect{ run }.to exit_with_code(0) }
80
+ after{ a_request(:delete, mock_href('broker/rest/user/authorizations/foo', true)).should have_been_made }
81
+ after{ a_request(:delete, mock_href('broker/rest/user/authorizations/bar', true)).should have_been_made }
82
+ end
83
+
84
+ context "without a token in the command line" do
85
+ let(:arguments) { ['authorization', 'delete'] }
86
+ it('should display success') { run_output.should =~ /You must specify one or more tokens to delete/ }
87
+ it{ expect{ run }.to exit_with_code(1) }
88
+ end
89
+
90
+ expect_an_unsupported_message
91
+ end
92
+
93
+ describe "#delete_all" do
94
+ let(:arguments) { ['authorization', 'delete-all'] }
95
+
96
+ context "with authorizations" do
97
+ with_authorization
98
+ before{ challenge{ stub_delete_authorizations } }
99
+ it('should display success') { run_output.should =~ /Deleting all auth.*done/ }
100
+ it{ expect{ run }.to exit_with_code(0) }
101
+ after{ a_request(:delete, mock_href('broker/rest/user/authorizations', true)).should have_been_made }
102
+ end
103
+
104
+ expect_an_unsupported_message
105
+ end
106
+
107
+ describe "#scope_help" do
108
+ let(:rest_client){ double(:authorization_scope_list => [['scope_1', 'A description'], ['scope_2', 'Another description']]) }
109
+ before{ subject.should_receive(:rest_client).and_return(rest_client) }
110
+ it{ capture{ subject.send(:scope_help) }.should =~ /scope_1.*A description/ }
111
+ it{ capture{ subject.send(:scope_help) }.should =~ /scope_2.*Another description/ }
112
+ it{ capture{ subject.send(:scope_help) }.should =~ /You may pass multiple scopes/ }
113
+ end
114
+
115
+ describe "#add" do
116
+ let(:arguments) { ['authorization', 'add'] }
117
+
118
+ context "with authorizations" do
119
+ using_command_instance
120
+ with_authorization
121
+ before{ instance.should_receive(:scope_help) }
122
+
123
+ it('should display the scope help') { command_output.should =~ /When adding an authorization.*to see more options/m }
124
+ it{ expect{ run_command }.to exit_with_code(0) }
125
+ end
126
+
127
+ expect_an_unsupported_message
128
+
129
+ context "with options" do
130
+ let(:arguments) { ['authorization', 'add', '--scope', 'foo,bar', '--note', 'a_note', '--expires-in', '300'] }
131
+ with_authorization
132
+ before{ challenge{ stub_add_authorization(:note => 'a_note', :scope => 'foo,bar', :expires_in => '300') } }
133
+
134
+ it('should display success') { run_output.should =~ /Adding authorization.*done/ }
135
+ it('should display the note') { run_output.should =~ /a_note/ }
136
+ it('should display the token') { run_output.should =~ /Token:\s+a_token_value/ }
137
+ it('should display the expiration') { run_output.should =~ /Expires In:\s+5 minutes/ }
138
+ it('should display the creation date') { run_output.should =~ /Created:\s+#{RHC::Helpers.date(mock_date_1)}/ }
139
+ it('should display the scopes') { run_output.should =~ /Scopes:\s+foo bar/ }
140
+ it{ expect{ run }.to exit_with_code(0) }
141
+
142
+ expect_an_unsupported_message
143
+ end
144
+ end
145
+ end