summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_commands_push_command.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-04 00:29:40 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-04 00:29:40 +0000
commit5a90f9e8f84533e7859232895fc4bbe6b31cc771 (patch)
treee15086587f691a1f5bd3c7ddbfa38e825828caf6 /test/rubygems/test_gem_commands_push_command.rb
parentf1321bd6e7c2d6b6a29a67074bad6f2742263921 (diff)
downloadruby-5a90f9e8f84533e7859232895fc4bbe6b31cc771.tar.gz
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.1.
Please see entries of 2.6.0 and 2.6.1 on https://github.com/rubygems/rubygems/blob/master/History.txt [fix GH-1270] Patch by @segiddins git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_push_command.rb')
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb58
1 files changed, 49 insertions, 9 deletions
diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb
index 729de46f9d..b888a741f0 100644
--- a/test/rubygems/test_gem_commands_push_command.rb
+++ b/test/rubygems/test_gem_commands_push_command.rb
@@ -118,7 +118,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
end
def test_sending_gem_to_metadata_host
- @host = "http://rubygems.engineyard.com"
+ @host = "http://privategemserver.example"
@spec, @path = util_gem "freebird", "1.0.1" do |spec|
spec.metadata['default_gem_server'] = @host
@@ -152,7 +152,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
end
def test_sending_gem_to_allowed_push_host
- @host = "http://privategemserver.com"
+ @host = "http://privategemserver.example"
@spec, @path = util_gem "freebird", "1.0.1" do |spec|
spec.metadata['allowed_push_host'] = @host
@@ -179,8 +179,8 @@ class TestGemCommandsPushCommand < Gem::TestCase
end
def test_sending_gem_to_allowed_push_host_with_basic_credentials
- @sanitized_host = "http://privategemserver.com"
- @host = "http://user:password@privategemserver.com"
+ @sanitized_host = "http://privategemserver.example"
+ @host = "http://user:password@privategemserver.example"
@spec, @path = util_gem "freebird", "1.0.1" do |spec|
spec.metadata['allowed_push_host'] = @sanitized_host
@@ -207,10 +207,10 @@ class TestGemCommandsPushCommand < Gem::TestCase
def test_sending_gem_to_disallowed_default_host
@spec, @path = util_gem "freebird", "1.0.1" do |spec|
- spec.metadata['allowed_push_host'] = "https://privategemserver.com"
+ spec.metadata['allowed_push_host'] = "https://privategemserver.example"
end
- response = %{ERROR: "#{@host}" is not allowed by the gemspec, which only allows "https://privategemserver.com"}
+ response = %{ERROR: "#{@host}" is not allowed by the gemspec, which only allows "https://privategemserver.example"}
assert_raises Gem::MockGemUi::TermError do
send_battery
@@ -220,10 +220,11 @@ class TestGemCommandsPushCommand < Gem::TestCase
end
def test_sending_gem_to_disallowed_push_host
- @host = "https://somebodyelse.com"
+ @host = "https://anotherprivategemserver.example"
+ push_host = "https://privategemserver.example"
@spec, @path = util_gem "freebird", "1.0.1" do |spec|
- spec.metadata['allowed_push_host'] = "https://privategemserver.com"
+ spec.metadata['allowed_push_host'] = push_host
end
@api_key = "PRIVKEY"
@@ -241,7 +242,7 @@ class TestGemCommandsPushCommand < Gem::TestCase
FileUtils.rm Gem.configuration.credentials_path
- response = 'ERROR: "https://somebodyelse.com" is not allowed by the gemspec, which only allows "https://privategemserver.com"'
+ response = "ERROR: \"#{@host}\" is not allowed by the gemspec, which only allows \"#{push_host}\""
assert_raises Gem::MockGemUi::TermError do
send_battery
@@ -250,6 +251,45 @@ class TestGemCommandsPushCommand < Gem::TestCase
assert_match response, @ui.error
end
+ def test_sending_gem_defaulting_to_allowed_push_host
+ host = "http://privategemserver.example"
+
+ @spec, @path = util_gem "freebird", "1.0.1" do |spec|
+ spec.metadata.delete('default_gem_server')
+ spec.metadata['allowed_push_host'] = host
+ end
+
+ api_key = "PRIVKEY"
+
+ keys = {
+ host => api_key
+ }
+
+ FileUtils.mkdir_p File.dirname Gem.configuration.credentials_path
+ open Gem.configuration.credentials_path, 'w' do |f|
+ f.write keys.to_yaml
+ end
+ Gem.configuration.load_api_keys
+
+ FileUtils.rm Gem.configuration.credentials_path
+
+ @response = "Successfully registered gem: freebird (1.0.1)"
+ @fetcher.data["#{host}/api/v1/gems"] = [@response, 200, 'OK']
+
+ # do not set @host
+ use_ui(@ui) { @cmd.send_gem(@path) }
+
+ assert_match %r{Pushing gem to #{host}...}, @ui.output
+
+ assert_equal Net::HTTP::Post, @fetcher.last_request.class
+ assert_equal Gem.read_binary(@path), @fetcher.last_request.body
+ assert_equal File.size(@path), @fetcher.last_request["Content-Length"].to_i
+ assert_equal "application/octet-stream", @fetcher.last_request["Content-Type"]
+ assert_equal api_key, @fetcher.last_request["Authorization"]
+
+ assert_match @response, @ui.output
+ end
+
def test_raises_error_with_no_arguments
def @cmd.sign_in(*); end
assert_raises Gem::CommandLineError do