rhc 0.97.17 → 0.98.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/bin/rhc +9 -9
  2. data/bin/rhc-port-forward +3 -0
  3. data/bin/rhc-sshkey +3 -0
  4. data/features/README.md +163 -35
  5. data/features/application.feature +24 -0
  6. data/features/cartridge.feature +24 -0
  7. data/features/client.feature +11 -0
  8. data/features/domain.feature +29 -0
  9. data/features/lib/rhc_helper.rb +14 -0
  10. data/features/lib/rhc_helper/app.rb +2 -8
  11. data/features/lib/rhc_helper/cartridge.rb +1 -7
  12. data/features/lib/rhc_helper/commandify.rb +37 -6
  13. data/features/lib/rhc_helper/domain.rb +5 -1
  14. data/features/lib/rhc_helper/httpify.rb +124 -60
  15. data/features/lib/rhc_helper/loggable.rb +0 -2
  16. data/features/lib/rhc_helper/persistable.rb +12 -2
  17. data/features/lib/rhc_helper/sshkey.rb +29 -0
  18. data/features/multiple_cartridge.feature +17 -0
  19. data/features/sshkey.feature +58 -0
  20. data/features/step_definitions/application_steps.rb +60 -52
  21. data/features/step_definitions/cartridge_steps.rb +22 -24
  22. data/features/step_definitions/client_steps.rb +9 -2
  23. data/features/step_definitions/domain_steps.rb +4 -0
  24. data/features/step_definitions/sshkey_steps.rb +56 -0
  25. data/features/support/assumptions.rb +37 -0
  26. data/features/support/before_hooks.rb +25 -0
  27. data/features/support/env.rb +84 -39
  28. data/features/support/key1 +27 -0
  29. data/features/support/key1.pub +1 -0
  30. data/features/support/key2 +27 -0
  31. data/features/support/key2.pub +1 -0
  32. data/features/support/key3.pub +1 -0
  33. data/features/support/ssh.sh +2 -0
  34. data/features/verify.feature +18 -159
  35. data/lib/rhc-common.rb +8 -21
  36. data/lib/rhc.rb +9 -5
  37. data/lib/rhc/autocomplete.rb +68 -0
  38. data/lib/rhc/autocomplete_templates/rhc.erb +33 -0
  39. data/lib/rhc/cli.rb +9 -6
  40. data/lib/rhc/command_runner.rb +108 -0
  41. data/lib/rhc/commands.rb +66 -132
  42. data/lib/rhc/commands/base.rb +95 -24
  43. data/lib/rhc/commands/domain.rb +33 -50
  44. data/lib/rhc/commands/port-forward.rb +81 -0
  45. data/lib/rhc/commands/setup.rb +1 -1
  46. data/lib/rhc/commands/sshkey.rb +95 -0
  47. data/lib/rhc/config.rb +108 -103
  48. data/lib/rhc/context_helper.rb +19 -0
  49. data/lib/rhc/coverage_helper.rb +1 -1
  50. data/lib/rhc/exceptions.rb +55 -4
  51. data/lib/rhc/help_formatter.rb +2 -3
  52. data/lib/rhc/helpers.rb +31 -23
  53. data/lib/{rhc-rest.rb → rhc/rest.rb} +95 -23
  54. data/lib/{rhc-rest → rhc/rest}/application.rb +1 -1
  55. data/lib/{rhc-rest → rhc/rest}/cartridge.rb +1 -1
  56. data/lib/{rhc-rest → rhc/rest}/client.rb +40 -9
  57. data/lib/{rhc-rest → rhc/rest}/domain.rb +1 -1
  58. data/lib/{rhc-rest → rhc/rest}/key.rb +11 -1
  59. data/lib/{rhc-rest → rhc/rest}/user.rb +1 -1
  60. data/lib/rhc/ssh_key_helpers.rb +10 -1
  61. data/lib/rhc/targz.rb +7 -8
  62. data/lib/rhc/usage_templates/command_help.erb +7 -6
  63. data/lib/rhc/usage_templates/help.erb +6 -9
  64. data/lib/rhc/usage_templates/missing_help.erb +1 -0
  65. data/lib/rhc/version.rb +2 -2
  66. data/lib/rhc/wizard.rb +4 -9
  67. data/spec/coverage_helper.rb +2 -2
  68. data/spec/rest_spec_helper.rb +66 -16
  69. data/spec/rhc/cli_spec.rb +16 -5
  70. data/spec/rhc/command_spec.rb +61 -6
  71. data/spec/rhc/commands/domain_spec.rb +50 -27
  72. data/spec/rhc/commands/port-forward_spec.rb +133 -0
  73. data/spec/rhc/commands/setup_spec.rb +2 -2
  74. data/spec/rhc/commands/sshkey_spec.rb +141 -0
  75. data/spec/rhc/common_spec.rb +1 -1
  76. data/spec/rhc/config_spec.rb +6 -4
  77. data/spec/rhc/helpers_spec.rb +0 -21
  78. data/spec/rhc/rest_application_spec.rb +7 -7
  79. data/spec/rhc/rest_client_spec.rb +87 -24
  80. data/spec/rhc/rest_spec.rb +36 -36
  81. data/spec/rhc/wizard_spec.rb +3 -3
  82. data/spec/spec.opts +1 -0
  83. data/spec/spec_helper.rb +3 -3
  84. metadata +61 -31
  85. data/lib/rhc-rest/exceptions/exceptions.rb +0 -75
  86. data/test/functional/application_test.rb +0 -71
  87. data/test/functional/domain_test.rb +0 -123
  88. data/test/functional/test_credentials.rb +0 -5
  89. data/test/sample-usage.rb +0 -122
  90. data/test/support/server.rb +0 -14
  91. data/test/support/testcase.rb +0 -3
  92. data/test/test_helper.rb +0 -4
  93. data/test/unit/command_test.rb +0 -19
@@ -31,7 +31,7 @@ describe RHC do
31
31
  :status => 200
32
32
  })
33
33
  stub_request(:any, mock_href(domain_links['ADD_APPLICATION']['relative'], true)).
34
- to_raise(Rhc::Rest::ServerErrorException.new("Mock server error"))
34
+ to_raise(RHC::Rest::ServerErrorException.new("Mock server error"))
35
35
  RHC.stub!(:print_response_err) { |output| @test_output = output; exit 1 }
36
36
  end
37
37
  it "posts an error message if the Rest API encounters a server error" do
@@ -15,6 +15,12 @@ describe RHC::Config do
15
15
  FakeFS.deactivate!
16
16
  end
17
17
 
18
+ describe "class" do
19
+ subject{ RHC::Config }
20
+ it("should raise when foo is invoked") { expect{ RHC::Config.method_missing(:foo) }.to raise_error(NoMethodError) }
21
+ it("should invoke a method on default") { RHC::Config.username.should be RHC::Config.default.username }
22
+ end
23
+
18
24
  context "Config default values with no files" do
19
25
  before(:each) do
20
26
  RHC::Config.initialize
@@ -26,10 +32,6 @@ describe RHC::Config do
26
32
  RHC::Config.has_opts_config?.should be_false
27
33
  end
28
34
 
29
- it "should suggest I run the wizard" do
30
- RHC::Config.should_run_wizard?.should be_true
31
- end
32
-
33
35
  it "should return openshift.redhat.com for the server" do
34
36
  RHC::Config['libra_server'].should == "openshift.redhat.com"
35
37
  RHC::Config.default_rhlogin.should be_nil
@@ -154,27 +154,6 @@ describe RHC::Helpers do
154
154
  end
155
155
  end
156
156
 
157
- context "Rest Client helper" do
158
- before do
159
- FakeFS.activate!
160
- Rhc::Rest::Client.stub!(:new) { |openshift_rest_node, username, password, debug| @username = username; @password = password; nil}
161
- end
162
-
163
- it "should ask for username" do
164
- $terminal.write_line("testuser@foo.bar")
165
- $terminal.write_line("password")
166
- @tests.rest_client
167
- @username.should == "testuser@foo.bar"
168
- @tests.config["default_rhlogin"].should == @username
169
- @password.should == "password"
170
- end
171
-
172
- after do
173
- FakeFS::FileSystem.clear
174
- FakeFS.deactivate!
175
- end
176
- end
177
-
178
157
  class HelperTests
179
158
  include RHC::Helpers
180
159
  include RHC::SSHKeyHelpers
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
  require 'rest_spec_helper'
3
- require 'rhc-rest/client'
4
3
  require 'base64'
5
4
 
6
5
  Spec::Runner.configure do |configuration|
7
6
  include(RestSpecHelper)
8
7
  end
9
8
 
10
- module Rhc
9
+ module RHC
11
10
  module Rest
12
11
  describe Application do
13
12
  # make sure auth is set up for the Application object since we are not
14
13
  # calling it from RHC::Rest::Client
15
- credentials = Base64.encode64("#{mock_user}:#{mock_pass}")
14
+ credentials = Base64.strict_encode64("#{mock_user}:#{mock_pass}")
16
15
  @@headers["Authorization"] = "Basic #{credentials}"
16
+ @@headers["User-Agent"] = RHC::Helpers.user_agent
17
17
 
18
18
  let (:app_links) { mock_response_links(mock_app_links('mock_domain','mock_app')) }
19
19
  let (:app_obj) {
20
- Rhc::Rest::Application.new({ 'domain_id' => 'mock_domain',
20
+ RHC::Rest::Application.new({ 'domain_id' => 'mock_domain',
21
21
  'name' => 'mock_app',
22
22
  'creation_time' => Time.now.to_s,
23
23
  'uuid' => 1234,
@@ -29,7 +29,7 @@ module Rhc
29
29
  context "#new" do
30
30
  it "returns an application object" do
31
31
  app = app_obj
32
- app.should be_an_instance_of Rhc::Rest::Application
32
+ app.should be_an_instance_of RHC::Rest::Application
33
33
  app.instance_variable_get(:@links).length.should equal(app_links.length)
34
34
  end
35
35
  end
@@ -42,7 +42,7 @@ module Rhc
42
42
  it "returns a new cartridge object" do
43
43
  app = app_obj
44
44
  cart = app.add_cartridge('mock_cart_0')
45
- cart.should be_an_instance_of Rhc::Rest::Cartridge
45
+ cart.should be_an_instance_of RHC::Rest::Cartridge
46
46
  cart.instance_variable_get(:@name).should == 'mock_cart_0'
47
47
  end
48
48
  end
@@ -58,7 +58,7 @@ module Rhc
58
58
  carts = app.cartridges
59
59
  carts.length.should equal(2)
60
60
  (0..1).each do |idx|
61
- carts[idx].should be_an_instance_of Rhc::Rest::Cartridge
61
+ carts[idx].should be_an_instance_of RHC::Rest::Cartridge
62
62
  carts[idx].instance_variable_get(:@name).should == "mock_cart_#{idx}"
63
63
  end
64
64
  end
@@ -2,7 +2,7 @@ require 'base64'
2
2
  require 'spec_helper'
3
3
  require 'stringio'
4
4
  require 'rest_spec_helper'
5
- require 'rhc-rest/client'
5
+ require 'rhc/rest/client'
6
6
 
7
7
  Spec::Runner.configure do |configuration|
8
8
  include(RestSpecHelper)
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  # This object is used in a few cases where we need to inspect
12
12
  # the logged output.
13
- class MockClient < Rhc::Rest::Client
13
+ class MockClient < RHC::Rest::Client
14
14
  def logger
15
15
  Logger.new((@output = StringIO.new))
16
16
  end
@@ -22,13 +22,14 @@ class MockClient < Rhc::Rest::Client
22
22
  end
23
23
  end
24
24
 
25
- module Rhc
25
+ module RHC
26
26
  module Rest
27
27
  describe Client do
28
28
  let(:client_links) { mock_response_links(mock_client_links) }
29
29
  let(:domain_0_links) { mock_response_links(mock_domain_links('mock_domain_0')) }
30
30
  let(:domain_1_links) { mock_response_links(mock_domain_links('mock_domain_1')) }
31
31
  let(:user_links) { mock_response_links(mock_user_links) }
32
+ let(:key_links) { mock_response_links(mock_key_links) }
32
33
 
33
34
  context "#new" do
34
35
  before do
@@ -43,17 +44,22 @@ module Rhc
43
44
  end
44
45
 
45
46
  it "returns a client object from the required arguments" do
46
- credentials = Base64.encode64(mock_user + ":" + mock_pass)
47
- client = Rhc::Rest::Client.new(mock_href, mock_user, mock_pass)
47
+ credentials = Base64.strict_encode64(mock_user + ":" + mock_pass)
48
+ client = RHC::Rest::Client.new(mock_href, mock_user, mock_pass)
48
49
  @@headers['Authorization'].should == "Basic #{credentials}"
49
50
  client.instance_variable_get(:@links).should == client_links
50
51
  end
51
- it "logs an error message if the API cannot be connected" do
52
- client = MockClient.new(mock_href('api_error'), mock_user, mock_pass)
53
- client.logged.should =~ /API Error$/
52
+ it "does not add newlines to username and password > 60 characters" do
53
+ username = "a" * 45
54
+ password = "p" * 45
55
+ client = RHC::Rest::Client.new(mock_href, mock_user, mock_pass)
56
+ @@headers['Authorization'].should_not match("\n")
57
+ end
58
+ it "raises an error message if the API cannot be connected" do
59
+ expect { MockClient.new(mock_href('api_error'), mock_user, mock_pass) }.should raise_error
54
60
  end
55
61
  it "raises a generic error for any other error condition" do
56
- lambda{ Rhc::Rest::Client.new(mock_href('other_error'), mock_user, mock_pass) }.
62
+ lambda{ RHC::Rest::Client.new(mock_href('other_error'), mock_user, mock_pass) }.
57
63
  should raise_error("Resource could not be accessed:Other Error")
58
64
  end
59
65
  end
@@ -64,7 +70,7 @@ module Rhc
64
70
  to_return({ :body => { :data => client_links }.to_json,
65
71
  :status => 200
66
72
  })
67
- @client = Rhc::Rest::Client.new(mock_href, mock_user, mock_pass)
73
+ @client = RHC::Rest::Client.new(mock_href, mock_user, mock_pass)
68
74
  end
69
75
 
70
76
  context "#add_domain" do
@@ -82,7 +88,7 @@ module Rhc
82
88
  end
83
89
  it "returns a domain object" do
84
90
  domain = @client.add_domain('mock_domain')
85
- domain.class.should == Rhc::Rest::Domain
91
+ domain.class.should == RHC::Rest::Domain
86
92
  domain.instance_variable_get(:@id).should == 'mock_domain'
87
93
  domain.instance_variable_get(:@links).should ==
88
94
  mock_response_links(mock_domain_links('mock_domain'))
@@ -115,7 +121,7 @@ module Rhc
115
121
  domains = @client.domains
116
122
  domains.length.should equal(2)
117
123
  (0..1).each do |idx|
118
- domains[idx].class.should == Rhc::Rest::Domain
124
+ domains[idx].class.should == RHC::Rest::Domain
119
125
  domains[idx].instance_variable_get(:@id).should == "mock_domain_#{idx}"
120
126
  domains[idx].instance_variable_get(:@links).should ==
121
127
  mock_response_links(mock_domain_links("mock_domain_#{idx}"))
@@ -150,7 +156,7 @@ module Rhc
150
156
  expect { match = @client.find_domain('mock_domain_0') }.should_not raise_error
151
157
 
152
158
  match.id.should == 'mock_domain_0'
153
- match.class.should == Rhc::Rest::Domain
159
+ match.class.should == RHC::Rest::Domain
154
160
  end
155
161
  it "raise an error when no matching domain IDs can be found" do
156
162
  expect { @client.find_domain('mock_domain_2') }.should raise_error(RHC::DomainNotFoundException)
@@ -207,7 +213,7 @@ module Rhc
207
213
  domain = @client.domains[0]
208
214
  domain.applications.each do |app|
209
215
  match = domain.find_application(app.name)
210
- match.class.should == Rhc::Rest::Application
216
+ match.class.should == RHC::Rest::Application
211
217
  match.instance_variable_get(:@name).should == 'mock_app'
212
218
  match.instance_variable_get(:@domain_id).should == "#{domain.id}"
213
219
  match.instance_variable_get(:@links).should ==
@@ -247,12 +253,12 @@ module Rhc
247
253
  carts = @client.cartridges
248
254
  carts.length.should equal(2)
249
255
  (0..1).each do |idx|
250
- carts[idx].class.should == Rhc::Rest::Cartridge
256
+ carts[idx].class.should == RHC::Rest::Cartridge
251
257
  carts[idx].instance_variable_get(:@name).should == "mock_cart_#{idx}"
252
258
  carts[idx].instance_variable_get(:@type).should == "mock_cart_#{idx}_type"
253
259
  carts[idx].instance_variable_get(:@links).should ==
254
260
  mock_response_links(mock_cart_links("mock_cart_#{idx}"))
255
- end
261
+ end
256
262
  end
257
263
  it "returns an empty list when no cartridges exist" do
258
264
  # Disregard the first response; this is for the previous expectiation.
@@ -261,8 +267,8 @@ module Rhc
261
267
  carts.length.should equal(0)
262
268
  end
263
269
  end
264
-
265
- context "#find_cartridge" do
270
+
271
+ context "#find_cartridges" do
266
272
  before(:each) do
267
273
  stub_api_request(:any, client_links['LIST_CARTRIDGES']['relative']).
268
274
  to_return({ :body => {
@@ -275,24 +281,33 @@ module Rhc
275
281
  { :name => 'mock_cart_1',
276
282
  :type => 'mock_cart_1_type',
277
283
  :links => mock_response_links(mock_cart_links('mock_cart_1')),
278
- }]
284
+ },
285
+ { :name => 'mock_nomatch_cart_0',
286
+ :type => 'mock_nomatch_cart_0_type',
287
+ :links => mock_response_links(mock_cart_links('mock_nomatch_cart_0')),
288
+ }
289
+ ]
279
290
  }.to_json,
280
291
  :status => 200
281
292
  })
282
293
  end
283
294
  it "returns a list of cartridge objects for matching cartridges" do
284
- matches = @client.find_cartridge('mock_cart_0')
295
+ matches = @client.find_cartridges('mock_cart_0')
285
296
  matches.length.should equal(1)
286
- matches[0].class.should == Rhc::Rest::Cartridge
297
+ matches[0].class.should == RHC::Rest::Cartridge
287
298
  matches[0].instance_variable_get(:@name).should == 'mock_cart_0'
288
299
  matches[0].instance_variable_get(:@type).should == 'mock_cart_0_type'
289
300
  matches[0].instance_variable_get(:@links).should ==
290
301
  mock_response_links(mock_cart_links('mock_cart_0'))
291
302
  end
292
303
  it "returns an empty list when no matching cartridges can be found" do
293
- matches = @client.find_cartridge('no_match')
304
+ matches = @client.find_cartridges('no_match')
294
305
  matches.length.should equal(0)
295
306
  end
307
+ it "returns multiple cartridge matches" do
308
+ matches = @client.find_cartridges :regex => "mock_cart_[0-9]"
309
+ matches.length.should equal(2)
310
+ end
296
311
  end
297
312
 
298
313
  context "#user" do
@@ -310,7 +325,7 @@ module Rhc
310
325
  end
311
326
  it "returns the user object associated with this client connection" do
312
327
  user = @client.user
313
- user.class.should == Rhc::Rest::User
328
+ user.class.should == RHC::Rest::User
314
329
  user.instance_variable_get(:@login).should == mock_user
315
330
  user.instance_variable_get(:@links).should == mock_response_links(mock_user_links)
316
331
  end
@@ -350,7 +365,7 @@ module Rhc
350
365
  key = nil
351
366
  expect { key = @client.find_key('mock_key_0') }.should_not raise_error
352
367
 
353
- key.class.should == Rhc::Rest::Key
368
+ key.class.should == RHC::Rest::Key
354
369
  key.instance_variable_get(:@name).should == 'mock_key_0'
355
370
  key.instance_variable_get(:@type).should == 'mock_key_0_type'
356
371
  key.instance_variable_get(:@content).should == '123456789:0'
@@ -388,6 +403,54 @@ module Rhc
388
403
  end
389
404
  end
390
405
 
406
+ context "#delete_key" do
407
+ before(:each) do
408
+ stub_api_request(:any, client_links['GET_USER']['relative']).
409
+ to_return({ :body => {
410
+ :type => 'user',
411
+ :data =>
412
+ { :login => mock_user,
413
+ :links => mock_response_links(mock_user_links)
414
+ }
415
+ }.to_json,
416
+ :status => 200
417
+ })
418
+ stub_api_request(:any, user_links['LIST_KEYS']['relative']).
419
+ to_return({ :body => {
420
+ :type => 'keys',
421
+ :data =>
422
+ [{ :name => 'mock_key_0',
423
+ :type => 'mock_key_0_type',
424
+ :content => '123456789:0',
425
+ :links => mock_response_links(mock_key_links('mock_key_0'))
426
+ },
427
+ { :name => 'mock_key_1',
428
+ :type => 'mock_key_1_type',
429
+ :content => '123456789:1',
430
+ :links => mock_response_links(mock_key_links('mock_key_1'))
431
+ }]
432
+ }.to_json,
433
+ :status => 200
434
+ })
435
+
436
+ stub_api_request(:post, key_links['DELETE']['relative']).
437
+ to_return({ :body => {}.to_json,
438
+ :status => 200
439
+ })
440
+
441
+ @client = MockClient.new(mock_href, mock_user, mock_pass)
442
+ end
443
+
444
+ it "should delete keys" do
445
+ expect { @client.delete_key('mock_key_0') }.should be_true
446
+ end
447
+
448
+ it 'raises an error if nonexistent key is requested' do
449
+ expect { @client.find_key('no_match') }.
450
+ should raise_error(RHC::KeyNotFoundException)
451
+ end
452
+ end
453
+
391
454
  context "#logout" do
392
455
  let(:logout_method) { :logout }
393
456
  it_should_behave_like "a logout method"
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
  require 'rest_spec_helper'
3
- require 'rhc-rest'
3
+ require 'rhc/rest'
4
4
 
5
5
  Spec::Runner.configure do |configuration|
6
6
  include(RestSpecHelper)
7
7
  end
8
8
 
9
- # We have to make an object to test the Rhc::Rest module
10
- class RhcRest
11
- include Rhc::Rest
9
+ # We have to make an object to test the RHC::Rest module
10
+ class RHCRest
11
+ include RHC::Rest
12
12
  end
13
13
 
14
14
  module MockRestResponse
@@ -20,11 +20,11 @@ module MockRestResponse
20
20
  end
21
21
  end
22
22
 
23
- module Rhc
23
+ module RHC
24
24
  include RestSpecHelper
25
25
 
26
26
  describe Rest do
27
- subject{ RhcRest.new }
27
+ subject{ RHCRest.new }
28
28
 
29
29
  # logger function
30
30
  describe "#logger" do
@@ -56,7 +56,7 @@ module Rhc
56
56
  }}
57
57
  it "deserializes to an application" do
58
58
  json_response = { :type => 'application', :data => object }.to_json
59
- app_obj = Rhc::Rest::Application.new(object)
59
+ app_obj = RHC::Rest::Application.new(object)
60
60
  subject.parse_response(json_response).should have_same_attributes_as(app_obj)
61
61
  end
62
62
  end
@@ -81,8 +81,8 @@ module Rhc
81
81
  }
82
82
  it "deserializes to a list of applications" do
83
83
  json_response = { :type => 'applications', :data => object }.to_json
84
- app_obj_1 = Rhc::Rest::Application.new(object[0])
85
- app_obj_2 = Rhc::Rest::Application.new(object[1])
84
+ app_obj_1 = RHC::Rest::Application.new(object[0])
85
+ app_obj_2 = RHC::Rest::Application.new(object[1])
86
86
  subject.parse_response(json_response).length.should equal(2)
87
87
  subject.parse_response(json_response)[0].should have_same_attributes_as(app_obj_1)
88
88
  subject.parse_response(json_response)[1].should have_same_attributes_as(app_obj_2)
@@ -98,7 +98,7 @@ module Rhc
98
98
 
99
99
  it "deserializes to a cartridge" do
100
100
  json_response = { :type => 'cartridge', :data => object }.to_json
101
- cart_obj = Rhc::Rest::Cartridge.new(object)
101
+ cart_obj = RHC::Rest::Cartridge.new(object)
102
102
  subject.parse_response(json_response).should have_same_attributes_as(cart_obj)
103
103
  end
104
104
  end
@@ -116,8 +116,8 @@ module Rhc
116
116
 
117
117
  it "deserializes to a list of cartridges" do
118
118
  json_response = { :type => 'cartridges', :data => object }.to_json
119
- cart_obj_1 = Rhc::Rest::Cartridge.new(object[0])
120
- cart_obj_2 = Rhc::Rest::Cartridge.new(object[1])
119
+ cart_obj_1 = RHC::Rest::Cartridge.new(object[0])
120
+ cart_obj_2 = RHC::Rest::Cartridge.new(object[1])
121
121
  subject.parse_response(json_response).length.should equal(2)
122
122
  subject.parse_response(json_response)[0].should have_same_attributes_as(cart_obj_1)
123
123
  subject.parse_response(json_response)[1].should have_same_attributes_as(cart_obj_2)
@@ -132,7 +132,7 @@ module Rhc
132
132
 
133
133
  it "deserializes to a domain" do
134
134
  json_response = { :type => 'domain', :data => object }.to_json
135
- dom_obj = Rhc::Rest::Domain.new(object)
135
+ dom_obj = RHC::Rest::Domain.new(object)
136
136
  subject.parse_response(json_response).should have_same_attributes_as(dom_obj)
137
137
  end
138
138
  end
@@ -148,8 +148,8 @@ module Rhc
148
148
 
149
149
  it "deserializes to a list of domains" do
150
150
  json_response = { :type => 'domains', :data => object }.to_json
151
- dom_obj_1 = Rhc::Rest::Domain.new(object[0])
152
- dom_obj_2 = Rhc::Rest::Domain.new(object[1])
151
+ dom_obj_1 = RHC::Rest::Domain.new(object[0])
152
+ dom_obj_2 = RHC::Rest::Domain.new(object[1])
153
153
  subject.parse_response(json_response).length.should equal(2)
154
154
  subject.parse_response(json_response)[0].should have_same_attributes_as(dom_obj_1)
155
155
  subject.parse_response(json_response)[1].should have_same_attributes_as(dom_obj_2)
@@ -166,7 +166,7 @@ module Rhc
166
166
 
167
167
  it "deserializes to a key" do
168
168
  json_response = { :type => 'key', :data => object }.to_json
169
- key_obj = Rhc::Rest::Key.new(object)
169
+ key_obj = RHC::Rest::Key.new(object)
170
170
  subject.parse_response(json_response).should have_same_attributes_as(key_obj)
171
171
  end
172
172
  end
@@ -186,8 +186,8 @@ module Rhc
186
186
 
187
187
  it "deserializes to a list of keys" do
188
188
  json_response = { :type => 'keys', :data => object }.to_json
189
- key_obj_1 = Rhc::Rest::Key.new(object[0])
190
- key_obj_2 = Rhc::Rest::Key.new(object[1])
189
+ key_obj_1 = RHC::Rest::Key.new(object[0])
190
+ key_obj_2 = RHC::Rest::Key.new(object[1])
191
191
  subject.parse_response(json_response).length.should equal(2)
192
192
  subject.parse_response(json_response)[0].should have_same_attributes_as(key_obj_1)
193
193
  subject.parse_response(json_response)[1].should have_same_attributes_as(key_obj_2)
@@ -202,7 +202,7 @@ module Rhc
202
202
 
203
203
  it "deserializes to a user" do
204
204
  json_response = { :type => 'user', :data => object }.to_json
205
- user_obj = Rhc::Rest::User.new(object)
205
+ user_obj = RHC::Rest::User.new(object)
206
206
  subject.parse_response(json_response).should have_same_attributes_as(user_obj)
207
207
  end
208
208
  end
@@ -227,7 +227,7 @@ module Rhc
227
227
  end
228
228
 
229
229
  it "sends the response to be deserialized" do
230
- dom_obj = Rhc::Rest::Domain.new(object)
230
+ dom_obj = RHC::Rest::Domain.new(object)
231
231
  request = RestClient::Request.new(:url => mock_href,
232
232
  :method => 'get',
233
233
  :headers => { :accept => :json },
@@ -252,7 +252,7 @@ module Rhc
252
252
  :method => 'get',
253
253
  :headers => {:accept => :json}
254
254
  )
255
- lambda { subject.request(request) }.should raise_error(Rhc::Rest::ResourceAccessException, 'Failed to access resource: unexpected nil')
255
+ lambda { subject.request(request) }.should raise_error(RHC::Rest::ResourceAccessException, 'Failed to access resource: unexpected nil')
256
256
  end
257
257
  end
258
258
 
@@ -283,7 +283,7 @@ module Rhc
283
283
  :method => 'get',
284
284
  :headers => {:accept => :json}
285
285
  )
286
- lambda { subject.request(request) }.should raise_error(Rhc::Rest::TimeoutException, "Connection to server timed out. It is possible the operation finished without being able to report success. Use 'rhc domain show' or 'rhc app status' to check the status of your applications.")
286
+ lambda { subject.request(request) }.should raise_error(RHC::Rest::TimeoutException, "Connection to server timed out. It is possible the operation finished without being able to report success. Use 'rhc domain show' or 'rhc app status' to check the status of your applications.")
287
287
  end
288
288
  end
289
289
 
@@ -296,7 +296,7 @@ module Rhc
296
296
  :method => 'get',
297
297
  :headers => {:accept => :json}
298
298
  )
299
- lambda { subject.request(request) }.should raise_error(Rhc::Rest::ConnectionException, 'Connection to server got interrupted: Lost Server Connection')
299
+ lambda { subject.request(request) }.should raise_error(RHC::Rest::ConnectionException, 'Connection to server got interrupted: Lost Server Connection')
300
300
  end
301
301
  end
302
302
 
@@ -309,7 +309,7 @@ module Rhc
309
309
  :method => 'get',
310
310
  :headers => {:accept => :json}
311
311
  )
312
- lambda { subject.request(request) }.should raise_error(Rhc::Rest::ResourceAccessException, 'Failed to access resource: Unverified SSL Certificate')
312
+ lambda { subject.request(request) }.should raise_error(RHC::Rest::ResourceAccessException, 'Failed to access resource: Unverified SSL Certificate')
313
313
  end
314
314
  end
315
315
 
@@ -323,7 +323,7 @@ module Rhc
323
323
  :method => 'get',
324
324
  :headers => {:accept => :json}
325
325
  )
326
- lambda { subject.request(request) }.should raise_error(Rhc::Rest::ResourceAccessException, 'Failed to access resource: Generic Error')
326
+ lambda { subject.request(request) }.should raise_error(RHC::Rest::ResourceAccessException, 'Failed to access resource: Generic Error')
327
327
  end
328
328
  end
329
329
 
@@ -342,7 +342,7 @@ module Rhc
342
342
  :method => 'get',
343
343
  :headers => {:accept => :json}
344
344
  )
345
- lambda { subject.request(request) }.should raise_error(Rhc::Rest::UnAuthorizedException, 'Not authenticated')
345
+ lambda { subject.request(request) }.should raise_error(RHC::Rest::UnAuthorizedException, 'Not authenticated')
346
346
  end
347
347
  end
348
348
  end
@@ -355,7 +355,7 @@ module Rhc
355
355
  json_data = RHC::Json.encode(mock_resp)
356
356
  json_data.extend(MockRestResponse)
357
357
  json_data.set_code(400)
358
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ClientErrorException, 'mock error message')
358
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ClientErrorException, 'mock error message')
359
359
  end
360
360
  end
361
361
 
@@ -365,7 +365,7 @@ module Rhc
365
365
  json_data.extend(MockRestResponse)
366
366
  json_data.set_code(401)
367
367
 
368
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::UnAuthorizedException, 'Not authenticated')
368
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::UnAuthorizedException, 'Not authenticated')
369
369
  end
370
370
  end
371
371
 
@@ -375,7 +375,7 @@ module Rhc
375
375
  json_data = RHC::Json.encode(mock_resp)
376
376
  json_data.extend(MockRestResponse)
377
377
  json_data.set_code(403)
378
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::RequestDeniedException, 'mock error message')
378
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::RequestDeniedException, 'mock error message')
379
379
  end
380
380
  end
381
381
 
@@ -385,7 +385,7 @@ module Rhc
385
385
  json_data = RHC::Json.encode(mock_resp)
386
386
  json_data.extend(MockRestResponse)
387
387
  json_data.set_code(404)
388
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ResourceNotFoundException, 'mock error message')
388
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ResourceNotFoundException, 'mock error message')
389
389
  end
390
390
  end
391
391
 
@@ -395,7 +395,7 @@ module Rhc
395
395
  json_data = RHC::Json.encode(mock_resp)
396
396
  json_data.extend(MockRestResponse)
397
397
  json_data.set_code(409)
398
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ValidationException, 'mock error message')
398
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ValidationException, 'mock error message')
399
399
  end
400
400
  end
401
401
 
@@ -405,7 +405,7 @@ module Rhc
405
405
  json_data = RHC::Json.encode(mock_resp)
406
406
  json_data.extend(MockRestResponse)
407
407
  json_data.set_code(422)
408
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ValidationException, 'mock error message')
408
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ValidationException, 'mock error message')
409
409
  end
410
410
  end
411
411
 
@@ -416,7 +416,7 @@ module Rhc
416
416
  json_data = RHC::Json.encode(mock_resp)
417
417
  json_data.extend(MockRestResponse)
418
418
  json_data.set_code(422)
419
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ValidationException, 'mock error message 1 mock error message 2')
419
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ValidationException, 'mock error message 1 mock error message 2')
420
420
  end
421
421
  end
422
422
 
@@ -426,7 +426,7 @@ module Rhc
426
426
  json_data = RHC::Json.encode(mock_resp)
427
427
  json_data.extend(MockRestResponse)
428
428
  json_data.set_code(500)
429
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ServerErrorException, 'mock error message')
429
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ServerErrorException, 'mock error message')
430
430
  end
431
431
  end
432
432
 
@@ -436,7 +436,7 @@ module Rhc
436
436
  json_data = RHC::Json.encode(mock_resp)
437
437
  json_data.extend(MockRestResponse)
438
438
  json_data.set_code(503)
439
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ServiceUnavailableException, 'mock error message')
439
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ServiceUnavailableException, 'mock error message')
440
440
  end
441
441
  end
442
442
 
@@ -446,7 +446,7 @@ module Rhc
446
446
  json_data = RHC::Json.encode(mock_resp)
447
447
  json_data.extend(MockRestResponse)
448
448
  json_data.set_code(999)
449
- lambda { subject.process_error_response(json_data) }.should raise_error(Rhc::Rest::ResourceAccessException, 'Server returned error code with no output: 999')
449
+ lambda { subject.process_error_response(json_data) }.should raise_error(RHC::Rest::ResourceAccessException, 'Server returned error code with no output: 999')
450
450
  end
451
451
  end
452
452
  end