rhc 0.95.14 → 0.96.9
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/README.md +9 -8
- data/bin/rhc-chk +7 -4
- data/features/support/env.rb +2 -3
- data/lib/rhc-common.rb +50 -62
- data/lib/rhc-rest.rb +5 -4
- data/lib/rhc-rest/application.rb +6 -6
- data/lib/rhc-rest/cartridge.rb +5 -5
- data/lib/rhc-rest/client.rb +6 -5
- data/lib/rhc-rest/domain.rb +4 -4
- data/lib/rhc-rest/exceptions/exceptions.rb +3 -1
- data/lib/rhc-rest/key.rb +2 -2
- data/lib/rhc-rest/user.rb +2 -2
- data/lib/rhc.rb +1 -0
- data/lib/rhc/cli.rb +2 -2
- data/lib/rhc/commands/server.rb +1 -1
- data/lib/rhc/commands/setup.rb +2 -5
- data/lib/rhc/core_ext.rb +16 -0
- data/lib/rhc/helpers.rb +14 -2
- data/lib/rhc/version.rb +9 -0
- data/spec/coverage_helper.rb +1 -0
- data/spec/rest_spec_helper.rb +27 -0
- data/spec/rhc/commands/server_spec.rb +2 -2
- data/spec/rhc/commands/setup_spec.rb +48 -0
- data/spec/rhc/helpers_spec.rb +7 -0
- data/spec/rhc/rest_application_spec.rb +130 -0
- data/spec/rhc/rest_client_spec.rb +18 -17
- data/spec/rhc/rest_spec.rb +16 -16
- data/spec/rhc/wizard_spec.rb +5 -5
- data/spec/spec_helper.rb +9 -0
- metadata +314 -306
- data/lib/rhc-rest/version.rb +0 -5
@@ -66,8 +66,10 @@ module Rhc
|
|
66
66
|
#that authorization has been refused for those credentials.
|
67
67
|
class UnAuthorizedException < Rhc::Rest::ClientErrorException; end
|
68
68
|
|
69
|
-
#
|
69
|
+
# Unreachable host, SSL Exception
|
70
70
|
class ResourceAccessException < Rhc::Rest::BaseException; end
|
71
|
+
#I/O Exceptions Connection timeouts, etc
|
72
|
+
class ConnectionException < Rhc::Rest::BaseException; end
|
71
73
|
|
72
74
|
end
|
73
75
|
end
|
data/lib/rhc-rest/key.rb
CHANGED
@@ -17,7 +17,7 @@ module Rhc
|
|
17
17
|
method = @links['UPDATE']['method']
|
18
18
|
payload = {:type => type, :content => content}
|
19
19
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
20
|
-
return
|
20
|
+
return request(request)
|
21
21
|
end
|
22
22
|
|
23
23
|
#Delete Key
|
@@ -26,7 +26,7 @@ module Rhc
|
|
26
26
|
url = @links['DELETE']['href']
|
27
27
|
method = @links['DELETE']['method']
|
28
28
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
29
|
-
return
|
29
|
+
return request(request)
|
30
30
|
end
|
31
31
|
alias :delete :destroy
|
32
32
|
end
|
data/lib/rhc-rest/user.rb
CHANGED
@@ -14,7 +14,7 @@ module Rhc
|
|
14
14
|
method = @links['ADD_KEY']['method']
|
15
15
|
payload = {:name => name, :type => type, :content => content}
|
16
16
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload)
|
17
|
-
return
|
17
|
+
return request(request)
|
18
18
|
end
|
19
19
|
|
20
20
|
#Get all Key for this user
|
@@ -22,7 +22,7 @@ module Rhc
|
|
22
22
|
url = @links['LIST_KEYS']['href']
|
23
23
|
method = @links['LIST_KEYS']['method']
|
24
24
|
request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers)
|
25
|
-
return
|
25
|
+
return request(request)
|
26
26
|
end
|
27
27
|
|
28
28
|
#Find Key by name
|
data/lib/rhc.rb
CHANGED
data/lib/rhc/cli.rb
CHANGED
@@ -30,9 +30,9 @@ module RHC
|
|
30
30
|
Commander::Runner.instance_variable_set :@singleton, runner
|
31
31
|
|
32
32
|
program :name, 'rhc'
|
33
|
-
program :version,
|
33
|
+
program :version, RHC::VERSION::STRING
|
34
34
|
program :description, 'Command line interface for OpenShift.'
|
35
|
-
program :help_formatter,
|
35
|
+
program :help_formatter, :compact
|
36
36
|
|
37
37
|
RHC::Commands.load.to_commander
|
38
38
|
exit(run! || 0)
|
data/lib/rhc/commands/server.rb
CHANGED
@@ -6,7 +6,7 @@ module RHC::Commands
|
|
6
6
|
summary "Display information about the status of the OpenShift service."
|
7
7
|
description "Retrieves any open issues or notices about the operation of the OpenShift service and displays them in the order they were opened."
|
8
8
|
def run
|
9
|
-
status = decode_json(
|
9
|
+
status = decode_json(get("#{openshift_url}/app/status/status.json").body)
|
10
10
|
open = status['open']
|
11
11
|
|
12
12
|
(success 'All systems running fine' and return 0) if open.blank?
|
data/lib/rhc/commands/setup.rb
CHANGED
@@ -4,21 +4,18 @@ require 'rhc/config'
|
|
4
4
|
|
5
5
|
module RHC::Commands
|
6
6
|
class Setup < Base
|
7
|
-
|
8
7
|
summary "Runs the setup wizard to configure your OpenShift account."
|
9
8
|
|
10
9
|
def run
|
11
10
|
# TODO: make help subcommand global
|
12
|
-
if
|
11
|
+
if args[0] == 'help'
|
13
12
|
say Commander::Runner.instance.help_formatter.render_command(@command)
|
14
13
|
return 0
|
15
14
|
end
|
16
15
|
|
17
16
|
w = RHC::RerunWizard.new(config.config_path)
|
18
|
-
s = w.run
|
19
|
-
|
20
17
|
# exit 0 on success 1 otherwise
|
21
|
-
|
18
|
+
w.run ? 0 : 1
|
22
19
|
end
|
23
20
|
end
|
24
21
|
end
|
data/lib/rhc/core_ext.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# From Rails core_ext/object.rb
|
2
2
|
require 'rhc/json'
|
3
|
+
require 'open-uri'
|
3
4
|
|
4
5
|
class Object
|
5
6
|
def present?
|
@@ -22,3 +23,18 @@ class File
|
|
22
23
|
yield read(chunk_size) until eof?
|
23
24
|
end
|
24
25
|
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# Allow http => https redirection, see
|
29
|
+
# http://bugs.ruby-lang.org/issues/859 to 1.8.7 for rough
|
30
|
+
# outline of change.
|
31
|
+
#
|
32
|
+
module OpenURI
|
33
|
+
def self.redirectable?(uri1, uri2) # :nodoc:
|
34
|
+
# This test is intended to forbid a redirection from http://... to
|
35
|
+
# file:///etc/passwd.
|
36
|
+
# However this is ad hoc. It should be extensible/configurable.
|
37
|
+
uri1.scheme.downcase == uri2.scheme.downcase ||
|
38
|
+
(/\A(?:http|ftp)\z/i =~ uri1.scheme && /\A(?:https?|ftp)\z/i =~ uri2.scheme)
|
39
|
+
end
|
40
|
+
end
|
data/lib/rhc/helpers.rb
CHANGED
@@ -39,6 +39,18 @@ module RHC
|
|
39
39
|
# Replace with d = DateTime.rfc3339(s)
|
40
40
|
end
|
41
41
|
|
42
|
+
#
|
43
|
+
# Web related requests
|
44
|
+
#
|
45
|
+
|
46
|
+
def user_agent
|
47
|
+
"rhc/#{RHC::VERSION::STRING} (ruby #{RUBY_VERSION}; #{RUBY_PLATFORM})#{" (API #{Rhc::Rest::API_VERSION})" rescue ''}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def get(uri, opts=nil, *args)
|
51
|
+
opts = {'User-Agent' => user_agent}.merge(opts || {})
|
52
|
+
RestClient.get(uri, opts, *args)
|
53
|
+
end
|
42
54
|
|
43
55
|
#
|
44
56
|
# Global config
|
@@ -49,8 +61,8 @@ module RHC
|
|
49
61
|
raise "Operations requiring configuration must define a config accessor"
|
50
62
|
end
|
51
63
|
|
52
|
-
global_option '-l', '--rhlogin login', "Red Hat login (
|
53
|
-
global_option '-p', '--password password', "
|
64
|
+
global_option '-l', '--rhlogin login', "Red Hat login (RedHat Network or OpenShift)"
|
65
|
+
global_option '-p', '--password password', "Red Hat password"
|
54
66
|
|
55
67
|
def openshift_server
|
56
68
|
config.get_value('libra_server')
|
data/lib/rhc/version.rb
ADDED
data/spec/coverage_helper.rb
CHANGED
@@ -35,6 +35,7 @@ unless RUBY_VERSION < '1.9'
|
|
35
35
|
add_filter 'features/' # Don't report on the files that run the cucumber tests
|
36
36
|
add_filter 'lib/rhc-feature-coverage-helper.rb'
|
37
37
|
add_filter 'spec/' # Don't report on the files that run the spec tests
|
38
|
+
add_filter 'lib/rhc/help_formatter.rb'
|
38
39
|
|
39
40
|
# Groups - general categories of test areas
|
40
41
|
add_group('Commands') { |src_file| src_file.filename.include?(File.join(%w[lib rhc commands])) }
|
data/spec/rest_spec_helper.rb
CHANGED
@@ -13,6 +13,11 @@ module RestSpecHelper
|
|
13
13
|
"test_user"
|
14
14
|
end
|
15
15
|
|
16
|
+
def stub_api_request(method, uri, with_auth=true)
|
17
|
+
stub_request(method, mock_href(uri, with_auth)).
|
18
|
+
with(&user_agent_header)
|
19
|
+
end
|
20
|
+
|
16
21
|
def mock_pass
|
17
22
|
"test pass"
|
18
23
|
end
|
@@ -83,4 +88,26 @@ module RestSpecHelper
|
|
83
88
|
[['ADD_KEY', 'user/keys/add', 'post'],
|
84
89
|
['LIST_KEYS', 'user/keys/', 'get' ]]
|
85
90
|
end
|
91
|
+
|
92
|
+
def mock_cartridge_response(cart_count=1)
|
93
|
+
carts = []
|
94
|
+
while carts.length < cart_count
|
95
|
+
carts << {
|
96
|
+
:name => "mock_cart_#{carts.length}",
|
97
|
+
:type => "mock_cart_#{carts.length}_type",
|
98
|
+
:links => mock_response_links(mock_cart_links('mock_domain','mock_app',"mock_cart_#{carts.length}"))
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
carts = carts[0] if cart_count == 1
|
103
|
+
type = cart_count == 1 ? 'cartridge' : 'cartridges'
|
104
|
+
|
105
|
+
return {
|
106
|
+
:body => {
|
107
|
+
:type => type,
|
108
|
+
:data => carts
|
109
|
+
}.to_json,
|
110
|
+
:status => 200
|
111
|
+
}
|
112
|
+
end
|
86
113
|
end
|
@@ -11,14 +11,14 @@ describe RHC::Commands::Server do
|
|
11
11
|
let(:arguments) { ['server'] }
|
12
12
|
|
13
13
|
context 'when no issues' do
|
14
|
-
before { stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').to_return(:body => {'issues' => []}.to_json) }
|
14
|
+
before { stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').with(&user_agent_header).to_return(:body => {'issues' => []}.to_json) }
|
15
15
|
it('should output success') { run_output.should =~ /All systems running fine/ }
|
16
16
|
it { expect { run }.should exit_with_code(0) }
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'when 1 issue' do
|
20
20
|
before do
|
21
|
-
stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').to_return(:body =>
|
21
|
+
stub_request(:get, 'https://openshift.redhat.com/app/status/status.json').with(&user_agent_header).to_return(:body =>
|
22
22
|
{'open' => [
|
23
23
|
{'issue' => {
|
24
24
|
'created_at' => '2011-05-22T17:31:32-04:00',
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rhc/wizard'
|
3
|
+
require 'rhc/config'
|
4
|
+
require 'rhc/commands/setup'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
|
7
|
+
# just test the command runner as we already have extensive wizard tests
|
8
|
+
describe RHC::Commands::Setup do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
RHC::Config.set_defaults
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'run' do
|
15
|
+
let(:arguments) { ['setup', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
@wizard = mock('wizard')
|
19
|
+
@wizard.stub!(:run).and_return(true)
|
20
|
+
RHC::RerunWizard.stub!(:new) { @wizard }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when no issues' do
|
24
|
+
it "should exit 0" do
|
25
|
+
expect { run }.should exit_with_code(0)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when there is an issue' do
|
30
|
+
it "should exit 1" do
|
31
|
+
@wizard.stub!(:run).and_return(false)
|
32
|
+
expect { run }.should exit_with_code(1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'help' do
|
38
|
+
let(:arguments) { ['setup', 'help'] }
|
39
|
+
|
40
|
+
context 'help is run' do
|
41
|
+
it "should display help" do
|
42
|
+
@wizard.stub!(:run).and_return(true)
|
43
|
+
expect { run }.should exit_with_code(0)
|
44
|
+
end
|
45
|
+
it('should output usage') { run_output.should match("Runs the setup wizard") }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/rhc/helpers_spec.rb
CHANGED
@@ -242,3 +242,10 @@ describe Object do
|
|
242
242
|
specify('empty string') { ''.blank?.should be_true }
|
243
243
|
end
|
244
244
|
end
|
245
|
+
|
246
|
+
describe OpenURI do
|
247
|
+
context 'redirectable?' do
|
248
|
+
specify('http to https') { OpenURI.redirectable?(URI.parse('http://foo.com'), URI.parse('https://foo.com')).should be_true }
|
249
|
+
specify('https to http') { OpenURI.redirectable?(URI.parse('https://foo.com'), URI.parse('http://foo.com')).should be_false }
|
250
|
+
end
|
251
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc-rest/client'
|
4
|
+
|
5
|
+
Spec::Runner.configure do |configuration|
|
6
|
+
include(RestSpecHelper)
|
7
|
+
end
|
8
|
+
|
9
|
+
module Rhc
|
10
|
+
module Rest
|
11
|
+
describe Application do
|
12
|
+
let (:app_links) { mock_response_links(mock_app_links('mock_domain','mock_app')) }
|
13
|
+
let (:app_obj) {
|
14
|
+
Rhc::Rest::Application.new({ 'domain_id' => 'mock_domain',
|
15
|
+
'name' => 'mock_app',
|
16
|
+
'creation_time' => Time.now.to_s,
|
17
|
+
'uuid' => 1234,
|
18
|
+
'aliases' => ['alias1','alias2'],
|
19
|
+
'server_identity' => mock_uri,
|
20
|
+
'links' => app_links
|
21
|
+
})
|
22
|
+
}
|
23
|
+
context "#new" do
|
24
|
+
it "returns an application object" do
|
25
|
+
app = app_obj
|
26
|
+
app.should be_an_instance_of Rhc::Rest::Application
|
27
|
+
app.instance_variable_get(:@links).length.should equal(app_links.length)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "#add_cartridge" do
|
32
|
+
before do
|
33
|
+
stub_api_request(:any, app_links['ADD_CARTRIDGE']['relative']).
|
34
|
+
to_return(mock_cartridge_response)
|
35
|
+
end
|
36
|
+
it "returns a new cartridge object" do
|
37
|
+
app = app_obj
|
38
|
+
cart = app.add_cartridge('mock_cart_0')
|
39
|
+
cart.should be_an_instance_of Rhc::Rest::Cartridge
|
40
|
+
cart.instance_variable_get(:@name).should == 'mock_cart_0'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#cartridges" do
|
45
|
+
before(:each) do
|
46
|
+
stub_api_request(:any, app_links['LIST_CARTRIDGES']['relative']).
|
47
|
+
to_return(mock_cartridge_response(2)).
|
48
|
+
to_return(mock_cartridge_response(0))
|
49
|
+
end
|
50
|
+
it "returns a list of all cartridges in the current application" do
|
51
|
+
app = app_obj
|
52
|
+
carts = app.cartridges
|
53
|
+
carts.length.should equal(2)
|
54
|
+
(0..1).each do |idx|
|
55
|
+
carts[idx].should be_an_instance_of Rhc::Rest::Cartridge
|
56
|
+
carts[idx].instance_variable_get(:@name).should == "mock_cart_#{idx}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
it "returns an empty list if the current app has no cartridges" do
|
60
|
+
app = app_obj
|
61
|
+
carts = app.cartridges # Disregard the first request;
|
62
|
+
carts = app.cartridges # 2nd request simulates empty response.
|
63
|
+
carts.length.should equal(0)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# These application control tests are subtle; the key lies in making sure the
|
68
|
+
# webmock specifies the expected body that is sent in the request.
|
69
|
+
# This is currently of the form "event=foo"
|
70
|
+
shared_examples_for "a control method" do
|
71
|
+
before do
|
72
|
+
@control_method = control_data[:method]
|
73
|
+
@control_call = [@control_method]
|
74
|
+
if control_data.has_key?(:arg)
|
75
|
+
@control_call << control_data[:arg]
|
76
|
+
end
|
77
|
+
@control_event = control_data.has_key?(:event) ? control_data[:event] : @control_method.to_s
|
78
|
+
@control_link = control_data.has_key?(:link) ? control_data[:link].upcase : @control_method.to_s.upcase
|
79
|
+
@control_output = control_data.has_key?(:result) ? control_data[:result] : @control_event
|
80
|
+
@with_payload = control_data.has_key?(:payload) ? control_data[:payload] : true
|
81
|
+
if @with_payload
|
82
|
+
stub_api_request(:any, app_links[@control_link]['relative']).
|
83
|
+
with(:body => { 'event' => @control_event }). # This is the critical part
|
84
|
+
to_return({ :body => { :data => @control_event }.to_json, :status => 200 })
|
85
|
+
else
|
86
|
+
stub_api_request(:any, app_links[@control_link]['relative']).
|
87
|
+
to_return({ :body => { :data => @control_event }.to_json, :status => 200 })
|
88
|
+
end
|
89
|
+
end
|
90
|
+
it "sends the control request to the server" do
|
91
|
+
app = app_obj
|
92
|
+
expect { app.send(*@control_call) }.to_not raise_error
|
93
|
+
app.send(*@control_call).should == @control_output
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "#start" do
|
98
|
+
let(:control_data) { { :method => :start } }
|
99
|
+
it_should_behave_like "a control method"
|
100
|
+
end
|
101
|
+
|
102
|
+
context "#stop" do
|
103
|
+
context " and the request is not forced (force == false)" do
|
104
|
+
let(:control_data) { { :method => :stop } }
|
105
|
+
it_should_behave_like "a control method"
|
106
|
+
end
|
107
|
+
context " and the request is forced (force == true)" do
|
108
|
+
let(:control_data) { { :method => :stop, :arg => true, :event => 'force-stop', :link => 'stop' } }
|
109
|
+
it_should_behave_like "a control method"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "#restart" do
|
114
|
+
let(:control_data) { { :method => :restart } }
|
115
|
+
it_should_behave_like "a control method"
|
116
|
+
end
|
117
|
+
|
118
|
+
context "#delete" do
|
119
|
+
let(:control_data) { { :method => :delete, :payload => false } }
|
120
|
+
it_should_behave_like "a control method"
|
121
|
+
end
|
122
|
+
|
123
|
+
context "#destroy" do
|
124
|
+
let(:control_data) { { :method => :destroy, :event => 'delete', :link => 'delete', :payload => false } }
|
125
|
+
it_should_behave_like "a control method"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
@@ -29,18 +29,19 @@ module Rhc
|
|
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
|
-
|
32
|
+
|
33
33
|
context "#new" do
|
34
34
|
before do
|
35
|
-
|
35
|
+
stub_api_request(:get, '').
|
36
36
|
to_return({ :body => { :data => client_links }.to_json,
|
37
37
|
:status => 200
|
38
38
|
})
|
39
|
-
|
39
|
+
stub_api_request(:get, 'api_error').
|
40
40
|
to_raise(RestClient::ExceptionWithResponse.new('API Error'))
|
41
|
-
|
41
|
+
stub_api_request(:get, 'other_error').
|
42
42
|
to_raise(Exception.new('Other Error'))
|
43
43
|
end
|
44
|
+
|
44
45
|
it "returns a client object from the required arguments" do
|
45
46
|
credentials = Base64.encode64(mock_user + ":" + mock_pass)
|
46
47
|
client = Rhc::Rest::Client.new(mock_href, mock_user, mock_pass)
|
@@ -59,7 +60,7 @@ module Rhc
|
|
59
60
|
|
60
61
|
context "with an instantiated client " do
|
61
62
|
before(:each) do
|
62
|
-
|
63
|
+
stub_api_request(:get, '').
|
63
64
|
to_return({ :body => { :data => client_links }.to_json,
|
64
65
|
:status => 200
|
65
66
|
})
|
@@ -68,7 +69,7 @@ module Rhc
|
|
68
69
|
|
69
70
|
context "#add_domain" do
|
70
71
|
before do
|
71
|
-
|
72
|
+
stub_api_request(:any, client_links['ADD_DOMAIN']['relative']).
|
72
73
|
to_return({ :body => {
|
73
74
|
:type => 'domain',
|
74
75
|
:data => {
|
@@ -90,7 +91,7 @@ module Rhc
|
|
90
91
|
|
91
92
|
context "#domains" do
|
92
93
|
before(:each) do
|
93
|
-
|
94
|
+
stub_api_request(:any, client_links['LIST_DOMAINS']['relative']).
|
94
95
|
to_return({ :body => {
|
95
96
|
:type => 'domains',
|
96
97
|
:data =>
|
@@ -130,7 +131,7 @@ module Rhc
|
|
130
131
|
|
131
132
|
context "#find_domain" do
|
132
133
|
before(:each) do
|
133
|
-
|
134
|
+
stub_api_request(:any, client_links['LIST_DOMAINS']['relative']).
|
134
135
|
to_return({ :body => {
|
135
136
|
:type => 'domains',
|
136
137
|
:data =>
|
@@ -157,7 +158,7 @@ module Rhc
|
|
157
158
|
|
158
159
|
context "#find_application" do
|
159
160
|
before(:each) do
|
160
|
-
|
161
|
+
stub_api_request(:any, client_links['LIST_DOMAINS']['relative']).
|
161
162
|
to_return({ :body => {
|
162
163
|
:type => 'domains',
|
163
164
|
:data =>
|
@@ -170,7 +171,7 @@ module Rhc
|
|
170
171
|
}.to_json,
|
171
172
|
:status => 200
|
172
173
|
})
|
173
|
-
|
174
|
+
stub_api_request(:any, domain_0_links['LIST_APPLICATIONS']['relative']).
|
174
175
|
to_return({ :body => {
|
175
176
|
:type => 'applications',
|
176
177
|
:data =>
|
@@ -185,7 +186,7 @@ module Rhc
|
|
185
186
|
}.to_json,
|
186
187
|
:status => 200
|
187
188
|
})
|
188
|
-
|
189
|
+
stub_api_request(:any, domain_1_links['LIST_APPLICATIONS']['relative']).
|
189
190
|
to_return({ :body => {
|
190
191
|
:type => 'applications',
|
191
192
|
:data =>
|
@@ -220,7 +221,7 @@ module Rhc
|
|
220
221
|
|
221
222
|
context "#cartridges" do
|
222
223
|
before(:each) do
|
223
|
-
|
224
|
+
stub_api_request(:any, client_links['LIST_CARTRIDGES']['relative']).
|
224
225
|
to_return({ :body => {
|
225
226
|
:type => 'cartridges',
|
226
227
|
:data =>
|
@@ -263,7 +264,7 @@ module Rhc
|
|
263
264
|
|
264
265
|
context "#find_cartridge" do
|
265
266
|
before(:each) do
|
266
|
-
|
267
|
+
stub_api_request(:any, client_links['LIST_CARTRIDGES']['relative']).
|
267
268
|
to_return({ :body => {
|
268
269
|
:type => 'cartridges',
|
269
270
|
:data =>
|
@@ -296,7 +297,7 @@ module Rhc
|
|
296
297
|
|
297
298
|
context "#user" do
|
298
299
|
before(:each) do
|
299
|
-
|
300
|
+
stub_api_request(:any, client_links['GET_USER']['relative']).
|
300
301
|
to_return({ :body => {
|
301
302
|
:type => 'user',
|
302
303
|
:data =>
|
@@ -317,7 +318,7 @@ module Rhc
|
|
317
318
|
|
318
319
|
context "#find_key" do
|
319
320
|
before(:each) do
|
320
|
-
|
321
|
+
stub_api_request(:any, client_links['GET_USER']['relative']).
|
321
322
|
to_return({ :body => {
|
322
323
|
:type => 'user',
|
323
324
|
:data =>
|
@@ -327,7 +328,7 @@ module Rhc
|
|
327
328
|
}.to_json,
|
328
329
|
:status => 200
|
329
330
|
})
|
330
|
-
|
331
|
+
stub_api_request(:any, user_links['LIST_KEYS']['relative']).
|
331
332
|
to_return({ :body => {
|
332
333
|
:type => 'keys',
|
333
334
|
:data =>
|
@@ -363,7 +364,7 @@ module Rhc
|
|
363
364
|
|
364
365
|
shared_examples_for "a logout method" do
|
365
366
|
before(:each) do
|
366
|
-
|
367
|
+
stub_api_request(:get, '').
|
367
368
|
to_return({ :body => { :data => client_links }.to_json,
|
368
369
|
:status => 200
|
369
370
|
})
|