Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #348 from smarterclayton/bug_928240_prevent_from_code

Merged by openshift-bot
  • Loading branch information...
commit 3f25ceaf246bbd78e62dd561ec0f786628fd1c78 2 parents df178c8 + 9c0930f
@openshift-bot openshift-bot authored
View
2  lib/rhc/rest.rb
@@ -113,6 +113,8 @@ class SSLVersionRejected < SSLConnectionFailed; end
class MultipleCartridgeCreationNotSupported < Exception; end
+ class InitialGitUrlNotSupported < Exception; end
+
class SslCertificatesNotSupported < Exception; end
class AuthorizationsNotSupported < Exception
View
6 lib/rhc/rest/domain.rb
@@ -16,13 +16,17 @@ def add_application(name, options)
options.each{ |key, value| payload[key.to_sym] = value }
cartridges = Array(payload.delete(:cartridge)).concat(Array(payload.delete(:cartridges))).compact.uniq
- if (client.api_version_negotiated >= 1.3)
+ if client.api_version_negotiated >= 1.3
payload[:cartridges] = cartridges
else
raise RHC::Rest::MultipleCartridgeCreationNotSupported, "The server only supports creating an application with a single web cartridge." if cartridges.length > 1
payload[:cartridge] = cartridges.first
end
+ if client.api_version_negotiated < 1.3 && payload[:initial_git_url]
+ raise RHC::Rest::InitialGitUrlNotSupported, "The server does not support creating applications from a source repository."
+ end
+
options = {:timeout => options[:scale] && 0 || nil}
rest_method "ADD_APPLICATION", payload, options
end
View
10 spec/rhc/rest_spec.rb
@@ -43,6 +43,7 @@ module MockRestResponse
it{ domain.add_application('foo', :cartridges => ['bar']).should be_true }
it{ expect{ domain.add_application('foo', :cartridges => ['bar', 'other']) }.to raise_error(RHC::Rest::MultipleCartridgeCreationNotSupported) }
+ it{ expect{ domain.add_application('foo', :initial_git_url => 'a_url') }.to raise_error(RHC::Rest::InitialGitUrlNotSupported) }
it{ domain.add_application('foo', :cartridges => 'bar').should be_true }
it{ domain.add_application('foo', :cartridge => 'bar').should be_true }
it{ domain.add_application('foo', :cartridge => ['bar']).should be_true }
@@ -66,6 +67,15 @@ module MockRestResponse
it{ domain.add_application('foo', :cartridges => cartridges).should be_true }
it{ domain.add_application('foo', :cartridge => cartridges).should be_true }
end
+
+ context "with a url" do
+ before do
+ stub_api_request(:post, 'broker/rest/domains/bar/applications', false).
+ with(:body => {:name => 'foo', :initial_git_url => 'a_url', :cartridges => []}.to_json).
+ to_return(:status => 201, :body => {:type => 'application', :data => {:id => '1'}}.to_json)
+ end
+ it{ domain.add_application('foo', :initial_git_url => 'a_url').should be_true }
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.