rhc 1.2.7 → 1.3.8
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.
- data/bin/rhc +6 -8
- data/bin/rhc-chk +23 -10
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper.rb +3 -2
- data/features/lib/rhc_helper/api.rb +7 -0
- data/features/lib/rhc_helper/app.rb +8 -10
- data/features/lib/rhc_helper/domain.rb +2 -1
- data/features/lib/rhc_helper/runnable.rb +2 -24
- data/features/sshkey.feature +3 -3
- data/features/step_definitions/cartridge_steps.rb +6 -6
- data/features/step_definitions/client_steps.rb +0 -1
- data/features/step_definitions/sshkey_steps.rb +2 -2
- data/features/support/before_hooks.rb +0 -1
- data/features/support/env.rb +5 -3
- data/lib/rhc-common.rb +1 -1
- data/lib/rhc.rb +9 -8
- data/lib/rhc/auth.rb +3 -0
- data/lib/rhc/auth/basic.rb +54 -0
- data/lib/rhc/cartridge_helpers.rb +11 -5
- data/lib/rhc/cli.rb +4 -2
- data/lib/rhc/command_runner.rb +35 -30
- data/lib/rhc/commands.rb +127 -18
- data/lib/rhc/commands/account.rb +24 -0
- data/lib/rhc/commands/alias.rb +1 -1
- data/lib/rhc/commands/app.rb +210 -209
- data/lib/rhc/commands/apps.rb +22 -0
- data/lib/rhc/commands/base.rb +10 -77
- data/lib/rhc/commands/cartridge.rb +35 -35
- data/lib/rhc/commands/domain.rb +20 -13
- data/lib/rhc/commands/git_clone.rb +30 -0
- data/lib/rhc/commands/{port-forward.rb → port_forward.rb} +3 -3
- data/lib/rhc/commands/server.rb +28 -16
- data/lib/rhc/commands/setup.rb +18 -1
- data/lib/rhc/commands/snapshot.rb +4 -4
- data/lib/rhc/commands/sshkey.rb +4 -18
- data/lib/rhc/commands/tail.rb +32 -9
- data/lib/rhc/config.rb +168 -99
- data/lib/rhc/context_helper.rb +22 -9
- data/lib/rhc/core_ext.rb +41 -1
- data/lib/rhc/exceptions.rb +21 -5
- data/lib/rhc/git_helpers.rb +81 -0
- data/lib/rhc/help_formatter.rb +21 -1
- data/lib/rhc/helpers.rb +222 -87
- data/lib/rhc/output_helpers.rb +94 -110
- data/lib/rhc/rest.rb +15 -198
- data/lib/rhc/rest/api.rb +88 -0
- data/lib/rhc/rest/application.rb +29 -30
- data/lib/rhc/rest/attributes.rb +27 -0
- data/lib/rhc/rest/base.rb +29 -33
- data/lib/rhc/rest/cartridge.rb +42 -20
- data/lib/rhc/rest/client.rb +351 -89
- data/lib/rhc/rest/domain.rb +7 -13
- data/lib/rhc/rest/gear_group.rb +1 -1
- data/lib/rhc/rest/key.rb +7 -2
- data/lib/rhc/rest/mock.rb +609 -0
- data/lib/rhc/rest/user.rb +6 -2
- data/lib/rhc/{ssh_key_helpers.rb → ssh_helpers.rb} +58 -28
- data/lib/rhc/{targz.rb → tar_gz.rb} +0 -0
- data/lib/rhc/usage_templates/command_help.erb +4 -1
- data/lib/rhc/usage_templates/help.erb +24 -11
- data/lib/rhc/usage_templates/options_help.erb +14 -0
- data/lib/rhc/wizard.rb +283 -213
- 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 +3 -371
- data/spec/rhc/auth_spec.rb +226 -0
- data/spec/rhc/cli_spec.rb +41 -14
- data/spec/rhc/command_spec.rb +44 -15
- data/spec/rhc/commands/account_spec.rb +41 -0
- data/spec/rhc/commands/alias_spec.rb +16 -15
- data/spec/rhc/commands/app_spec.rb +115 -92
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/cartridge_spec.rb +134 -112
- data/spec/rhc/commands/domain_spec.rb +31 -86
- data/spec/rhc/commands/git_clone_spec.rb +56 -0
- data/spec/rhc/commands/{port-forward_spec.rb → port_forward_spec.rb} +27 -32
- data/spec/rhc/commands/server_spec.rb +28 -3
- data/spec/rhc/commands/setup_spec.rb +29 -11
- data/spec/rhc/commands/snapshot_spec.rb +4 -3
- data/spec/rhc/commands/sshkey_spec.rb +24 -56
- data/spec/rhc/commands/tail_spec.rb +26 -9
- data/spec/rhc/commands/threaddump_spec.rb +12 -11
- data/spec/rhc/config_spec.rb +211 -164
- data/spec/rhc/context_spec.rb +2 -0
- data/spec/rhc/helpers_spec.rb +242 -46
- data/spec/rhc/rest_application_spec.rb +42 -28
- data/spec/rhc/rest_client_spec.rb +110 -93
- data/spec/rhc/rest_spec.rb +220 -131
- data/spec/rhc/targz_spec.rb +1 -1
- data/spec/rhc/wizard_spec.rb +435 -624
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +140 -6
- data/spec/wizard_spec_helper.rb +326 -0
- metadata +163 -143
- data/lib/rhc/client.rb +0 -17
- data/lib/rhc/git_helper.rb +0 -59
data/spec/spec.opts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--color
|
1
|
+
--color
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,27 @@ require 'webmock/rspec'
|
|
3
3
|
require 'fakefs/safe'
|
4
4
|
require 'rbconfig'
|
5
5
|
|
6
|
+
require 'pry' if ENV['PRY']
|
7
|
+
|
8
|
+
# Environment reset
|
9
|
+
ENV['http_proxy'] = nil
|
10
|
+
ENV['HTTP_PROXY'] = nil
|
11
|
+
|
12
|
+
class FakeFS::Mode
|
13
|
+
def initialize(mode_s)
|
14
|
+
@s = mode_s
|
15
|
+
end
|
16
|
+
def to_s(*args)
|
17
|
+
@s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
class FakeFS::Stat
|
21
|
+
attr_reader :mode
|
22
|
+
def initialize(mode_s)
|
23
|
+
@mode = FakeFS::Mode.new(mode_s)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
6
27
|
# chmod isn't implemented in the released fakefs gem
|
7
28
|
# but is in git. Once the git version is released we
|
8
29
|
# should remove this and actively check permissions
|
@@ -11,8 +32,21 @@ class FakeFS::File
|
|
11
32
|
# noop
|
12
33
|
end
|
13
34
|
|
14
|
-
|
15
|
-
|
35
|
+
def self.stat(path)
|
36
|
+
FakeFS::Stat.new(mode(path))
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.mode(path)
|
40
|
+
@modes && @modes[path] || '664'
|
41
|
+
end
|
42
|
+
def self.expect_mode(path, mode)
|
43
|
+
(@modes ||= {})[path] = mode
|
44
|
+
end
|
45
|
+
|
46
|
+
# FakeFS incorrectly assigns this to '/'
|
47
|
+
remove_const(:PATH_SEPARATOR) rescue nil
|
48
|
+
const_set(:PATH_SEPARATOR, ":")
|
49
|
+
const_set(:ALT_SEPARATOR, '') rescue nil
|
16
50
|
|
17
51
|
def self.executable?(path)
|
18
52
|
# if the file exists we will assume it is executable
|
@@ -50,6 +84,19 @@ module ClassSpecHelpers
|
|
50
84
|
"#{description}".split(" ").map{|word| word.capitalize}.join.gsub(/[^\w]/, '')
|
51
85
|
end
|
52
86
|
end
|
87
|
+
|
88
|
+
def with_constants(constants, base=Object, &block)
|
89
|
+
constants.each do |constant, val|
|
90
|
+
base.const_set(constant, val)
|
91
|
+
end
|
92
|
+
|
93
|
+
block.call
|
94
|
+
ensure
|
95
|
+
constants.each do |constant, val|
|
96
|
+
base.send(:remove_const, constant)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
53
100
|
def new_command_runner *args, &block
|
54
101
|
Commander::Runner.instance_variable_set :"@singleton", RHC::CommandRunner.new(args)
|
55
102
|
program :name, 'test'
|
@@ -65,7 +112,7 @@ module ClassSpecHelpers
|
|
65
112
|
#
|
66
113
|
#
|
67
114
|
#
|
68
|
-
def expects_running
|
115
|
+
def expects_running(*args, &block)
|
69
116
|
mock_terminal
|
70
117
|
r = new_command_runner *args do
|
71
118
|
instance #ensure instance is created before subject :new is mocked
|
@@ -74,6 +121,18 @@ module ClassSpecHelpers
|
|
74
121
|
end
|
75
122
|
lambda { r.run! }
|
76
123
|
end
|
124
|
+
def command_for(*args)
|
125
|
+
mock_terminal
|
126
|
+
r = new_command_runner *args do
|
127
|
+
instance #ensure instance is created before subject :new is mocked
|
128
|
+
subject.should_receive(:new).any_number_of_times.and_return(instance)
|
129
|
+
RHC::Commands.to_commander
|
130
|
+
end
|
131
|
+
command = nil
|
132
|
+
RHC::Commands.stub(:execute){ |cmd, method, args| command = cmd; 0 }
|
133
|
+
r.run!
|
134
|
+
command
|
135
|
+
end
|
77
136
|
|
78
137
|
class MockHighLineTerminal < HighLine
|
79
138
|
def initialize(input, output)
|
@@ -110,6 +169,9 @@ module ClassSpecHelpers
|
|
110
169
|
@input.seek(reset_pos)
|
111
170
|
result
|
112
171
|
end
|
172
|
+
def close_write
|
173
|
+
@input.close_write
|
174
|
+
end
|
113
175
|
end
|
114
176
|
|
115
177
|
def mock_terminal
|
@@ -118,28 +180,60 @@ module ClassSpecHelpers
|
|
118
180
|
$stderr = (@error = StringIO.new)
|
119
181
|
$terminal = MockHighLineTerminal.new @input, @output
|
120
182
|
end
|
183
|
+
def input_line(s)
|
184
|
+
$terminal.write_line s
|
185
|
+
end
|
186
|
+
def last_output(&block)
|
187
|
+
if block_given?
|
188
|
+
yield $terminal.read
|
189
|
+
else
|
190
|
+
$terminal.read
|
191
|
+
end
|
192
|
+
end
|
121
193
|
|
122
194
|
def capture(&block)
|
195
|
+
old_stdout = $stdout
|
123
196
|
old_stderr = $stderr
|
124
197
|
old_terminal = $terminal
|
125
198
|
@input = StringIO.new
|
126
199
|
@output = StringIO.new
|
200
|
+
$stdout = @output
|
127
201
|
$stderr = (@error = StringIO.new)
|
128
202
|
$terminal = MockHighLineTerminal.new @input, @output
|
129
203
|
yield
|
204
|
+
@output.string
|
130
205
|
ensure
|
206
|
+
$stdout = old_stdout
|
207
|
+
$stderr = old_stderr
|
208
|
+
$terminal = old_terminal
|
209
|
+
end
|
210
|
+
|
211
|
+
def capture_all(&block)
|
212
|
+
old_stdout = $stdout
|
213
|
+
old_stderr = $stderr
|
214
|
+
old_terminal = $terminal
|
215
|
+
@input = StringIO.new
|
216
|
+
@output = StringIO.new
|
217
|
+
$stdout = @output
|
218
|
+
$stderr = @output
|
219
|
+
$terminal = MockHighLineTerminal.new @input, @output
|
220
|
+
yield
|
221
|
+
@output.string
|
222
|
+
ensure
|
223
|
+
$stdout = old_stdout
|
131
224
|
$stderr = old_stderr
|
132
225
|
$terminal = old_terminal
|
133
|
-
@output.to_s
|
134
226
|
end
|
135
227
|
|
136
228
|
def run(input=[])
|
137
229
|
#Commander::Runner.instance_variable_set :"@singleton", nil
|
138
230
|
mock_terminal
|
139
231
|
input.each { |i| $terminal.write_line(i) }
|
232
|
+
$terminal.close_write
|
233
|
+
#"#{@output.string}\n#{$stderr.string}"
|
140
234
|
RHC::CLI.start(arguments)
|
141
|
-
"#{@output.string}\n#{$stderr.string}"
|
142
235
|
end
|
236
|
+
|
143
237
|
def run_output(input=[])
|
144
238
|
run(input)
|
145
239
|
rescue SystemExit => e
|
@@ -153,7 +247,36 @@ module ClassSpecHelpers
|
|
153
247
|
#
|
154
248
|
def user_agent_header
|
155
249
|
lambda do |request|
|
156
|
-
|
250
|
+
#User-Agent is not sent to mock by httpclient
|
251
|
+
#request.headers['User-Agent'] =~ %r{\Arhc/\d+\.\d+.\d+ \(.*?ruby.*?\)}
|
252
|
+
true
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def base_config(&block)
|
257
|
+
config = RHC::Config.new
|
258
|
+
config.stub(:load_config_files)
|
259
|
+
defaults = config.instance_variable_get(:@defaults)
|
260
|
+
yield config, defaults if block_given?
|
261
|
+
RHC::Config.stub(:default).and_return(config)
|
262
|
+
RHC::Config.stub(:new).and_return(config)
|
263
|
+
config
|
264
|
+
end
|
265
|
+
|
266
|
+
def user_config
|
267
|
+
user = respond_to?(:username) ? self.username : 'test_user'
|
268
|
+
password = respond_to?(:password) ? self.password : 'test pass'
|
269
|
+
server = respond_to?(:server) ? self.server : nil
|
270
|
+
|
271
|
+
base_config do |config, defaults|
|
272
|
+
defaults.add 'default_rhlogin', user
|
273
|
+
defaults.add 'password', password
|
274
|
+
defaults.add 'libra_server', server if server
|
275
|
+
end.tap do |c|
|
276
|
+
opts = c.to_options
|
277
|
+
opts[:rhlogin].should == user
|
278
|
+
opts[:password].should == password
|
279
|
+
opts[:server].should == server if server
|
157
280
|
end
|
158
281
|
end
|
159
282
|
end
|
@@ -216,3 +339,14 @@ Spec::Runner.configure do |config|
|
|
216
339
|
config.include(CommanderInvocationMatchers)
|
217
340
|
config.include(ClassSpecHelpers)
|
218
341
|
end
|
342
|
+
|
343
|
+
module TestEnv
|
344
|
+
extend ClassSpecHelpers
|
345
|
+
class << self
|
346
|
+
attr_accessor :instance, :subject
|
347
|
+
def instance=(i)
|
348
|
+
self.subject = i.class
|
349
|
+
@instance = i
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
@@ -0,0 +1,326 @@
|
|
1
|
+
|
2
|
+
module WizardStepsHelper
|
3
|
+
def should_greet_user
|
4
|
+
next_stage.should_not be_nil
|
5
|
+
|
6
|
+
last_output do |s|
|
7
|
+
s.count("\n").should >= 3
|
8
|
+
s.should match(/OpenShift Client Tools \(RHC\) Setup Wizard/)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def should_challenge_for(username, password)
|
13
|
+
input_line username.to_s if username
|
14
|
+
input_line password.to_s if password
|
15
|
+
next_stage.should_not be_nil
|
16
|
+
|
17
|
+
last_output do |s|
|
18
|
+
s.send(username ? :should : :should_not, match("Login to "))
|
19
|
+
s.send(password ? :should : :should_not, match(/Password: [\*]{8}$/))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def should_write_config
|
24
|
+
test_config_file(false)
|
25
|
+
end
|
26
|
+
def should_overwrite_config
|
27
|
+
test_config_file(true)
|
28
|
+
end
|
29
|
+
def test_config_file(present)
|
30
|
+
File.exists?(current_config_path).should be present
|
31
|
+
|
32
|
+
next_stage.should_not be_nil
|
33
|
+
|
34
|
+
last_output.should match("Saving configuration to #{current_config_path}")
|
35
|
+
|
36
|
+
File.readable?(current_config_path).should be true
|
37
|
+
RHC::Vendor::ParseConfig.new(current_config_path).tap do |cp|
|
38
|
+
cp["default_rhlogin"].should == username
|
39
|
+
cp["libra_server"].should == mock_uri
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def should_create_an_ssh_keypair
|
44
|
+
setup_mock_ssh
|
45
|
+
keys_should_not_exist
|
46
|
+
|
47
|
+
next_stage.should_not be_nil
|
48
|
+
|
49
|
+
keys_should_exist
|
50
|
+
last_output.should match('No SSH keys were found. We will generate a pair of keys')
|
51
|
+
end
|
52
|
+
|
53
|
+
def should_not_create_an_ssh_keypair
|
54
|
+
next_stage.should_not be_nil
|
55
|
+
|
56
|
+
last_output.should == ''
|
57
|
+
end
|
58
|
+
|
59
|
+
def should_upload_default_key
|
60
|
+
input_line 'yes'
|
61
|
+
|
62
|
+
next_stage.should_not be_nil
|
63
|
+
|
64
|
+
last_output do |s|
|
65
|
+
s.should match('Since you do not have any keys associated')
|
66
|
+
s.should match(/Fingerprint\: (?:[a-f0-9]{2}\:){15}/)
|
67
|
+
s.should match("Uploading key 'default' from #{current_ssh_dir}/id_rsa.pub ... ")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def should_skip_uploading_key
|
72
|
+
input_line 'no'
|
73
|
+
|
74
|
+
next_stage.should_not be_nil
|
75
|
+
|
76
|
+
last_output.should match('You can upload your SSH key at a later time using ')
|
77
|
+
end
|
78
|
+
|
79
|
+
def should_find_matching_server_key
|
80
|
+
next_stage.should_not be_nil
|
81
|
+
|
82
|
+
last_output.should == ""
|
83
|
+
end
|
84
|
+
|
85
|
+
def should_find_git
|
86
|
+
setup_mock_has_git(true)
|
87
|
+
|
88
|
+
next_stage.should_not be_nil
|
89
|
+
|
90
|
+
last_output.should match(/Checking for git .*found/)
|
91
|
+
end
|
92
|
+
|
93
|
+
def should_display_windows_info
|
94
|
+
next_stage.should_not be_nil
|
95
|
+
|
96
|
+
last_output do |s|
|
97
|
+
s.should match('Git for Windows')
|
98
|
+
s.should match('In order to fully interact with OpenShift you will need to install and configure a git client')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def should_not_find_git
|
103
|
+
setup_mock_has_git(false)
|
104
|
+
|
105
|
+
next_stage.should_not be_nil
|
106
|
+
|
107
|
+
last_output do |s|
|
108
|
+
s.should match(/Checking for git .*needs to be installed/)
|
109
|
+
s.should match("Automated installation of client tools is not supported for your platform")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def should_not_find_problems
|
114
|
+
FakeFS::File.expect_mode(RHC::Config.ssh_priv_key_file_path, '600')
|
115
|
+
|
116
|
+
next_stage.should_not be_nil
|
117
|
+
last_output do |s|
|
118
|
+
s.should match(/Checking common problems \.+.+?done/)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def should_check_remote_server
|
123
|
+
FakeFS::File.expect_mode(RHC::Config.ssh_priv_key_file_path, '600')
|
124
|
+
|
125
|
+
ssh = Object.new
|
126
|
+
ssh.should_receive(:close)
|
127
|
+
Net::SSH.should_receive(:start).once.and_return(ssh)
|
128
|
+
subject.should_receive(:ssh_key_uploaded?).and_return(true)
|
129
|
+
|
130
|
+
next_stage.should_not be_nil
|
131
|
+
last_output do |s|
|
132
|
+
s.should match(/Checking common problems \.+.+?done/)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def should_find_ssh_keys
|
137
|
+
next_stage.should_not be_nil
|
138
|
+
|
139
|
+
last_output do |s|
|
140
|
+
s.should_not match(/Remote server does not have the corresponding SSH key/)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def should_not_find_ssh_keys
|
145
|
+
next_stage.should_not be_nil
|
146
|
+
|
147
|
+
last_output do |s|
|
148
|
+
s.should match(/Remote server does not have the corresponding SSH key/)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def should_create_a_namespace
|
153
|
+
input_line "thisnamespaceistoobigandhastoomanycharacterstobevalid"
|
154
|
+
input_line "invalidnamespace"
|
155
|
+
input_line "testnamespace"
|
156
|
+
|
157
|
+
next_stage.should_not be_nil
|
158
|
+
|
159
|
+
last_output do |s|
|
160
|
+
s.should match(/Checking your namespace .*none/)
|
161
|
+
s.should match(/(?:Too long.*?){2}/m)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def should_skip_creating_namespace
|
166
|
+
input_line ""
|
167
|
+
|
168
|
+
next_stage.should_not be_nil
|
169
|
+
|
170
|
+
last_output do |s|
|
171
|
+
s.should match(/Checking your namespace .*none/)
|
172
|
+
s.should match("You will not be able to create applications without first creating a namespace")
|
173
|
+
s.should match("You may create a namespace later through 'rhc domain create'")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def should_find_a_namespace(namespace)
|
178
|
+
next_stage.should_not be_nil
|
179
|
+
|
180
|
+
last_output.should match(/Checking your namespace .*#{namespace}/)
|
181
|
+
end
|
182
|
+
|
183
|
+
def should_list_types_of_apps_to_create
|
184
|
+
next_stage.should_not be_nil
|
185
|
+
|
186
|
+
last_output do |s|
|
187
|
+
s.should match('rhc app create <app name> mock_standalone_cart-1')
|
188
|
+
s.should match('rhc app create <app name> mock_standalone_cart-2')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def should_find_apps(*args)
|
193
|
+
next_stage.should_not be_nil
|
194
|
+
|
195
|
+
last_output do |s|
|
196
|
+
s.should match("found #{args.length}")
|
197
|
+
args.each do |(name, domain_name)|
|
198
|
+
s.should match("#{name} http://#{name}-#{domain_name}.rhcloud.com")
|
199
|
+
end
|
200
|
+
s.should match("You are using ")
|
201
|
+
s.should match("The following gear sizes are available to you")
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def should_be_done
|
206
|
+
next_stage.should be_true
|
207
|
+
|
208
|
+
last_output.should match("Your client tools are now configured.")
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
module WizardHelper
|
214
|
+
def next_stage
|
215
|
+
@stages ||= subject.stages
|
216
|
+
@stage ||= -1
|
217
|
+
@current_stage = @stages[@stage+=1]
|
218
|
+
subject.send(@current_stage)
|
219
|
+
end
|
220
|
+
|
221
|
+
def current_config_path
|
222
|
+
subject.send(:config).config_path
|
223
|
+
end
|
224
|
+
|
225
|
+
def setup_mock_has_git(bool)
|
226
|
+
subject.stub(:"has_git?") { bool }
|
227
|
+
end
|
228
|
+
|
229
|
+
def current_ssh_dir
|
230
|
+
subject.send(:config).ssh_dir
|
231
|
+
end
|
232
|
+
def setup_mock_ssh(add_ssh_key=false)
|
233
|
+
FileUtils.mkdir_p current_ssh_dir
|
234
|
+
if add_ssh_key
|
235
|
+
setup_mock_ssh_keys
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def keys_should_exist
|
240
|
+
File.exists?(File.join(current_ssh_dir, "id_rsa")).should be true
|
241
|
+
File.exists?(File.join(current_ssh_dir, "id_rsa.pub")).should be true
|
242
|
+
end
|
243
|
+
def keys_should_not_exist
|
244
|
+
File.exists?(File.join(current_ssh_dir, "id_rsa")).should be false
|
245
|
+
File.exists?(File.join(current_ssh_dir, "id_rsa.pub")).should be false
|
246
|
+
end
|
247
|
+
|
248
|
+
def priv_key
|
249
|
+
<<EOF
|
250
|
+
-----BEGIN RSA PRIVATE KEY-----
|
251
|
+
MIICWwIBAAKBgQDIXpBBs7g93z/5JqW5IJNJR8bG6DWhpL2vR2ROEfzGqDHLZ+Xb
|
252
|
+
saS/Ogc3nZNSav3juHWdiBFIc0unPpLdwmXtcL3tjN52CJqPgU/W0q061fL/tk77
|
253
|
+
fFqW2upluo0ZRZQdPc3vTI3tWWZcpyE2LPHHUOI3KN+lRqxgw0Y6z/3SfwIDAQAB
|
254
|
+
AoGAbMC+xZp5TsPEokOywWeH6cdWgZF5wpF7Dw7Nx34F2AFkfYWYAgVKaSxizHHv
|
255
|
+
i1VdFmOBGw7Gaq+BiXXyGwEvdpmgDoZDwvJrShZef5LwYnJ/NCqjZ8Xbb9z4VxCL
|
256
|
+
pkqMFFpEeNQcIDLZRF8Z1prRQnOL+Z498P6d3G/UWkR5NXkCQQDsGlpJzJwAPpwr
|
257
|
+
YZ98LgKT0n2WHeCrMQ9ZyJQl3Dz40qasQmIotB+mdIh87EFex7vvyiuzRC5rfcoX
|
258
|
+
CBHEkQpVAkEA2UFNBKgI1v5+16K0/CXPakQ25AlGODDv2VXlHwRPOayUG/Tn2joj
|
259
|
+
fj0T4/pu9AGhz0oVXFlz7iO8PEwFU+plgwJAKD2tmdp31ErXj0VKS34EDnHX2dgp
|
260
|
+
zMPF3AWlynYpJjexFLcTx+A7bMF76d7SnXbpf0sz+4/pYYTFBvvnG1ulKQJACJsR
|
261
|
+
lfGiCAIkvB3x1VsaEDeLhRTo9yjZF17TqJrfGIXBiCn3VSmgZku9EfbFllzKMA/b
|
262
|
+
MMFKWlCIEEtimqRaSQJAPVA1E7AiEvfUv0kRT73tDf4p/BRJ7p2YwjxrGpDBQhG1
|
263
|
+
YI+4NOhWtAG3Uips++8RhvmLjv8y+TNKU31J1EJmYA==
|
264
|
+
-----END RSA PRIVATE KEY-----
|
265
|
+
EOF
|
266
|
+
end
|
267
|
+
|
268
|
+
def pub_key
|
269
|
+
<<EOF
|
270
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDIXpBBs7g93z/5JqW5IJNJR8bG6DWhpL2vR2ROEfzGqDHLZ+XbsaS/Ogc3nZNSav3juHWdiBFIc0unPpLdwmXtcL3tjN52CJqPgU/W0q061fL/tk77fFqW2upluo0ZRZQdPc3vTI3tWWZcpyE2LPHHUOI3KN+lRqxgw0Y6z/3Sfw== OpenShift-Key
|
271
|
+
EOF
|
272
|
+
end
|
273
|
+
|
274
|
+
def rsa_key_content_public
|
275
|
+
'AAAAB3NzaC1yc2EAAAADAQABAAABAQDJ54a/MlApilkfv7VCQS3lyUL5tHkJbuKNHOk6BtREsdrATZOpB3En3bRlgDMeGR0tAuRanvBai8TQG2kZluwdqAuTER0hiuZrAimrUHWbkQGZlwGWHBzNw/98gliZJYkZchAJjyzdQULbzq9xhcXzfYhUbZH1SGq6sThmR63tiYZHlbqQ+a56vpyFQsVEzvq5uqkvcJpSX74gDo0xqAAxSdNYZTBpLgFMB9Xzk/1UNlZ9C1SNDxEwFQZgzNriVyrGsJWaXfZdJRBa0PwScPEpJ4VlDFEgdtynjE1LabUAdMBoBXlr8QZgNHCuc3hUq/IVm3NShx+J3hVO3mP8HcLJ'
|
276
|
+
end
|
277
|
+
def rsa_key_fingerprint_public
|
278
|
+
'18:2a:99:6c:9b:65:6f:a5:13:57:c9:41:c7:b4:24:36'
|
279
|
+
end
|
280
|
+
|
281
|
+
class Sshkey < OpenStruct
|
282
|
+
def type
|
283
|
+
@table[:type]
|
284
|
+
end
|
285
|
+
def type=(type)
|
286
|
+
@table[:type] = type
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def mock_key_objects
|
291
|
+
[
|
292
|
+
Sshkey.new(:name => 'default', :type => 'ssh-rsa', :fingerprint => "0f:97:4b:82:87:bb:c6:dc:40:a3:c1:bc:bb:55:1e:fa"),
|
293
|
+
Sshkey.new(:name => 'cb490595', :type => 'ssh-rsa', :fingerprint => "cb:49:05:95:b4:42:1c:95:74:f7:2d:41:0d:f0:37:3b"),
|
294
|
+
Sshkey.new(:name => '96d90241', :type => 'ssh-rsa', :fingerprint => "96:d9:02:41:e1:cb:0d:ce:e5:3b:fc:da:13:65:3e:32"),
|
295
|
+
Sshkey.new(:name => '73ce2cc1', :type => 'ssh-rsa', :fingerprint => "73:ce:2c:c1:01:ea:79:cc:f6:be:86:45:67:96:7f:e3")
|
296
|
+
]
|
297
|
+
end
|
298
|
+
|
299
|
+
def setup_mock_ssh_keys(dir=current_ssh_dir)
|
300
|
+
private_key_file = File.join(dir, "id_rsa")
|
301
|
+
public_key_file = File.join(dir, "id_rsa.pub")
|
302
|
+
File.open(private_key_file, 'w') { |f| f.write priv_key }
|
303
|
+
|
304
|
+
File.open(public_key_file, 'w') { |f| f.write pub_key }
|
305
|
+
end
|
306
|
+
|
307
|
+
def setup_different_config
|
308
|
+
path = File.join(File.join(home_dir, '.openshift'), 'express.conf')
|
309
|
+
FileUtils.mkdir_p File.dirname(path)
|
310
|
+
File.open(path, "w") do |file|
|
311
|
+
file.puts <<EOF
|
312
|
+
# Default user login
|
313
|
+
default_rhlogin='a_different_user'
|
314
|
+
|
315
|
+
# Server API
|
316
|
+
libra_server = 'a_different_server.com'
|
317
|
+
EOF
|
318
|
+
end
|
319
|
+
path
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
Spec::Runner.configure do |config|
|
324
|
+
config.include(WizardHelper)
|
325
|
+
config.include(WizardStepsHelper)
|
326
|
+
end
|