diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rubygems/test_bundled_ca.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_owner_command.rb | 6 | ||||
-rw-r--r-- | test/rubygems/test_gem_commands_push_command.rb | 10 | ||||
-rw-r--r-- | test/rubygems/test_gem_dependency_installer.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_remote_fetcher.rb | 14 | ||||
-rw-r--r-- | test/rubygems/test_gem_request.rb | 16 | ||||
-rw-r--r-- | test/rubygems/test_gem_requirement.rb | 6 | ||||
-rw-r--r-- | test/rubygems/test_gem_source.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_gem_source_subpath_problem.rb | 2 | ||||
-rw-r--r-- | test/rubygems/test_webauthn_listener.rb | 16 | ||||
-rw-r--r-- | test/rubygems/utilities.rb | 18 |
11 files changed, 48 insertions, 48 deletions
diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb index ca8e328eb5..616b18ee83 100644 --- a/test/rubygems/test_bundled_ca.rb +++ b/test/rubygems/test_bundled_ca.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require_relative "helper" -require "net/http" +require "rubygems/net/http" require "rubygems/openssl" unless Gem::HAVE_OPENSSL @@ -28,7 +28,7 @@ class TestGemBundledCA < Gem::TestCase def assert_https(host) assert true - http = Net::HTTP.new(host, 443) + http = Gem::Net::HTTP.new(host, 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.cert_store = bundled_certificate_store diff --git a/test/rubygems/test_gem_commands_owner_command.rb b/test/rubygems/test_gem_commands_owner_command.rb index d35232df7e..18558819f4 100644 --- a/test/rubygems/test_gem_commands_owner_command.rb +++ b/test/rubygems/test_gem_commands_owner_command.rb @@ -44,7 +44,7 @@ EOF @cmd.show_owners("freewill") end - assert_equal Net::HTTP::Get, @stub_fetcher.last_request.class + assert_equal Gem::Net::HTTP::Get, @stub_fetcher.last_request.class assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"] assert_match(/Owners for gem: freewill/, @stub_ui.output) @@ -165,7 +165,7 @@ EOF @cmd.add_owners("freewill", ["[email protected]"]) end - assert_equal Net::HTTP::Post, @stub_fetcher.last_request.class + assert_equal Gem::Net::HTTP::Post, @stub_fetcher.last_request.class assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"] assert_equal "email=user-new1%40example.com", @stub_fetcher.last_request.body @@ -244,7 +244,7 @@ EOF @cmd.remove_owners("freewill", ["[email protected]"]) end - assert_equal Net::HTTP::Delete, @stub_fetcher.last_request.class + assert_equal Gem::Net::HTTP::Delete, @stub_fetcher.last_request.class assert_equal Gem.configuration.rubygems_api_key, @stub_fetcher.last_request["Authorization"] assert_equal "email=user-remove1%40example.com", @stub_fetcher.last_request.body diff --git a/test/rubygems/test_gem_commands_push_command.rb b/test/rubygems/test_gem_commands_push_command.rb index d4f0794a98..66cc2303de 100644 --- a/test/rubygems/test_gem_commands_push_command.rb +++ b/test/rubygems/test_gem_commands_push_command.rb @@ -60,7 +60,7 @@ class TestGemCommandsPushCommand < Gem::TestCase assert_match(/Pushing gem to #{@host}.../, @ui.output) - assert_equal Net::HTTP::Post, @fetcher.last_request.class + assert_equal Gem::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"] @@ -77,7 +77,7 @@ class TestGemCommandsPushCommand < Gem::TestCase @cmd.execute - assert_equal Net::HTTP::Post, @fetcher.last_request.class + assert_equal Gem::Net::HTTP::Post, @fetcher.last_request.class assert_equal Gem.read_binary(@path), @fetcher.last_request.body assert_equal "application/octet-stream", @fetcher.last_request["Content-Type"] @@ -96,7 +96,7 @@ class TestGemCommandsPushCommand < Gem::TestCase @cmd.execute - assert_equal Net::HTTP::Post, @fetcher.last_request.class + assert_equal Gem::Net::HTTP::Post, @fetcher.last_request.class assert_equal Gem.read_binary(@path), @fetcher.last_request.body assert_equal "application/octet-stream", @fetcher.last_request["Content-Type"] @@ -116,7 +116,7 @@ class TestGemCommandsPushCommand < Gem::TestCase @cmd.execute - assert_equal Net::HTTP::Post, @fetcher.last_request.class + assert_equal Gem::Net::HTTP::Post, @fetcher.last_request.class assert_equal Gem.read_binary(@path), @fetcher.last_request.body assert_equal "application/octet-stream", @fetcher.last_request["Content-Type"] @@ -319,7 +319,7 @@ class TestGemCommandsPushCommand < Gem::TestCase assert_match(/Pushing gem to #{host}.../, @ui.output) - assert_equal Net::HTTP::Post, @fetcher.last_request.class + assert_equal Gem::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"] diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index f08274eac8..ac84a589e5 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -488,7 +488,7 @@ class TestGemDependencyInstaller < Gem::TestCase @fetcher.data["http://gems.example.com/gems/a-1.gem"] = a1_data # compact index is available - compact_index_response = Net::HTTPResponse.new "1.1", 200, "OK" + compact_index_response = Gem::Net::HTTPResponse.new "1.1", 200, "OK" compact_index_response.uri = URI("http://gems.example.com") @fetcher.data["http://gems.example.com/"] = compact_index_response diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index e6971015c4..9c879ed428 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -659,13 +659,13 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== def fetcher.request(uri, request_class, last_modified = nil) url = "http://gems.example.com/redirect" if defined? @requested - res = Net::HTTPOK.new nil, 200, nil + res = Gem::Net::HTTPOK.new nil, 200, nil def res.body "real_path" end else @requested = true - res = Net::HTTPMovedPermanently.new nil, 301, nil + res = Gem::Net::HTTPMovedPermanently.new nil, 301, nil res.add_field "Location", url end res @@ -683,7 +683,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== def fetcher.request(uri, request_class, last_modified = nil) url = "http://gems.example.com/redirect" - res = Net::HTTPMovedPermanently.new nil, 301, nil + res = Gem::Net::HTTPMovedPermanently.new nil, 301, nil res.add_field "Location", url res end @@ -701,7 +701,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== url = "http://gems.example.com/redirect" def fetcher.request(uri, request_class, last_modified = nil) - res = Net::HTTPMovedPermanently.new nil, 301, nil + res = Gem::Net::HTTPMovedPermanently.new nil, 301, nil res end @@ -728,7 +728,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== def fetcher.request(uri, request_class, last_modified = nil) $fetched_uri = uri - res = Net::HTTPOK.new nil, 200, nil + res = Gem::Net::HTTPOK.new nil, 200, nil def res.body "success" end @@ -958,8 +958,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== @fetcher = fetcher assert_throws :block_called do - fetcher.request URI("http://example"), Net::HTTP::Get do |req| - assert_kind_of Net::HTTPGenericRequest, req + fetcher.request URI("http://example"), Gem::Net::HTTP::Get do |req| + assert_kind_of Gem::Net::HTTPGenericRequest, req throw :block_called end end diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb index d39ea02543..d5eb245352 100644 --- a/test/rubygems/test_gem_request.rb +++ b/test/rubygems/test_gem_request.rb @@ -96,7 +96,7 @@ class TestGemRequest < Gem::TestCase end def test_configure_connection_for_https - connection = Net::HTTP.new "localhost", 443 + connection = Gem::Net::HTTP.new "localhost", 443 request = Class.new(Gem::Request) do def self.get_cert_files @@ -115,7 +115,7 @@ class TestGemRequest < Gem::TestCase ssl_ca_cert = Gem.configuration.ssl_ca_cert Gem.configuration.ssl_ca_cert = CA_CERT_FILE - connection = Net::HTTP.new "localhost", 443 + connection = Gem::Net::HTTP.new "localhost", 443 request = Class.new(Gem::Request) do def self.get_cert_files @@ -193,7 +193,7 @@ class TestGemRequest < Gem::TestCase def test_fetch uri = Gem::Uri.new(URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}")) response = util_stub_net_http(body: :junk, code: 200) do - @request = make_request(uri, Net::HTTP::Get, nil, nil) + @request = make_request(uri, Gem::Net::HTTP::Get, nil, nil) @request.fetch end @@ -207,7 +207,7 @@ class TestGemRequest < Gem::TestCase uri = Gem::Uri.new(URI.parse("https://user:[email protected]/specs.#{Gem.marshal_version}")) conn = util_stub_net_http(body: :junk, code: 200) do |c| use_ui @ui do - @request = make_request(uri, Net::HTTP::Get, nil, nil) + @request = make_request(uri, Gem::Net::HTTP::Get, nil, nil) @request.fetch end c @@ -224,7 +224,7 @@ class TestGemRequest < Gem::TestCase conn = util_stub_net_http(body: :junk, code: 200) do |c| use_ui @ui do - @request = make_request(uri, Net::HTTP::Get, nil, nil) + @request = make_request(uri, Gem::Net::HTTP::Get, nil, nil) @request.fetch end c @@ -241,7 +241,7 @@ class TestGemRequest < Gem::TestCase conn = util_stub_net_http(body: :junk, code: 200) do |c| use_ui @ui do - @request = make_request(uri, Net::HTTP::Get, nil, nil) + @request = make_request(uri, Gem::Net::HTTP::Get, nil, nil) @request.fetch end c @@ -255,7 +255,7 @@ class TestGemRequest < Gem::TestCase def test_fetch_head uri = Gem::Uri.new(URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}")) response = util_stub_net_http(body: "", code: 200) do |_conn| - @request = make_request(uri, Net::HTTP::Get, nil, nil) + @request = make_request(uri, Gem::Net::HTTP::Get, nil, nil) @request.fetch end @@ -267,7 +267,7 @@ class TestGemRequest < Gem::TestCase uri = Gem::Uri.new(URI.parse("#{@gem_repo}/specs.#{Gem.marshal_version}")) t = Time.utc(2013, 1, 2, 3, 4, 5) conn, response = util_stub_net_http(body: "", code: 304) do |c| - @request = make_request(uri, Net::HTTP::Get, t, nil) + @request = make_request(uri, Gem::Net::HTTP::Get, t, nil) [c, @request.fetch] end diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb index 05931d651d..57d143180f 100644 --- a/test/rubygems/test_gem_requirement.rb +++ b/test/rubygems/test_gem_requirement.rb @@ -437,19 +437,19 @@ class TestGemRequirement < Gem::TestCase end def test_marshal_load_attack - wa = Net::WriteAdapter.allocate + wa = Gem::Net::WriteAdapter.allocate wa.instance_variable_set(:@socket, self.class) wa.instance_variable_set(:@method_id, :exploit) request_set = Gem::RequestSet.allocate request_set.instance_variable_set(:@git_set, "id") request_set.instance_variable_set(:@sets, wa) - wa = Net::WriteAdapter.allocate + wa = Gem::Net::WriteAdapter.allocate wa.instance_variable_set(:@socket, request_set) wa.instance_variable_set(:@method_id, :resolve) ent = Gem::Package::TarReader::Entry.allocate ent.instance_variable_set(:@read, 0) ent.instance_variable_set(:@header, "aaa") - io = Net::BufferedIO.allocate + io = Gem::Net::BufferedIO.allocate io.instance_variable_set(:@io, ent) io.instance_variable_set(:@debug_output, wa) reader = Gem::Package::TarReader.allocate diff --git a/test/rubygems/test_gem_source.rb b/test/rubygems/test_gem_source.rb index 55cc50a5b2..096ac36a66 100644 --- a/test/rubygems/test_gem_source.rb +++ b/test/rubygems/test_gem_source.rb @@ -43,7 +43,7 @@ class TestGemSource < Gem::TestCase end def test_dependency_resolver_set_bundler_api - response = Net::HTTPResponse.new "1.1", 200, "OK" + response = Gem::Net::HTTPResponse.new "1.1", 200, "OK" response.uri = URI("http://example") @fetcher.data[@gem_repo] = response diff --git a/test/rubygems/test_gem_source_subpath_problem.rb b/test/rubygems/test_gem_source_subpath_problem.rb index 0aa2085b3c..1ca9b67159 100644 --- a/test/rubygems/test_gem_source_subpath_problem.rb +++ b/test/rubygems/test_gem_source_subpath_problem.rb @@ -21,7 +21,7 @@ class TestGemSourceSubpathProblem < Gem::TestCase end def test_dependency_resolver_set - response = Net::HTTPResponse.new "1.1", 200, "OK" + response = Gem::Net::HTTPResponse.new "1.1", 200, "OK" response.uri = URI("http://example") @fetcher.data["#{@gem_repo}/"] = response diff --git a/test/rubygems/test_webauthn_listener.rb b/test/rubygems/test_webauthn_listener.rb index 5e91064b49..e3f7c8c395 100644 --- a/test/rubygems/test_webauthn_listener.rb +++ b/test/rubygems/test_webauthn_listener.rb @@ -35,15 +35,15 @@ class WebauthnListenerTest < Gem::TestCase def test_wait_for_otp_code_get_follows_options wait_for_otp_code - assert Gem::MockBrowser.options(URI("http://localhost:#{@port}?code=xyz")).is_a? Net::HTTPNoContent - assert Gem::MockBrowser.get(URI("http://localhost:#{@port}?code=xyz")).is_a? Net::HTTPOK + assert Gem::MockBrowser.options(URI("http://localhost:#{@port}?code=xyz")).is_a? Gem::Net::HTTPNoContent + assert Gem::MockBrowser.get(URI("http://localhost:#{@port}?code=xyz")).is_a? Gem::Net::HTTPOK end def test_wait_for_otp_code_options_request wait_for_otp_code response = Gem::MockBrowser.options URI("http://localhost:#{@port}?code=xyz") - assert response.is_a? Net::HTTPNoContent + assert response.is_a? Gem::Net::HTTPNoContent assert_equal Gem.host, response["access-control-allow-origin"] assert_equal "POST", response["access-control-allow-methods"] assert_equal "Content-Type, Authorization, x-csrf-token", response["access-control-allow-headers"] @@ -54,7 +54,7 @@ class WebauthnListenerTest < Gem::TestCase wait_for_otp_code response = Gem::MockBrowser.get URI("http://localhost:#{@port}?code=xyz") - assert response.is_a? Net::HTTPOK + assert response.is_a? Gem::Net::HTTPOK assert_equal "text/plain; charset=utf-8", response["Content-Type"] assert_equal "7", response["Content-Length"] assert_equal Gem.host, response["access-control-allow-origin"] @@ -72,7 +72,7 @@ class WebauthnListenerTest < Gem::TestCase response = Gem::MockBrowser.post URI("http://localhost:#{@port}?code=xyz") assert response - assert response.is_a? Net::HTTPMethodNotAllowed + assert response.is_a? Gem::Net::HTTPMethodNotAllowed assert_equal "GET, OPTIONS", response["allow"] assert_equal "close", response["Connection"] @@ -84,7 +84,7 @@ class WebauthnListenerTest < Gem::TestCase wait_for_otp_code_expect_error_with_message("Security device verification failed: Page at /path not found.") response = Gem::MockBrowser.post URI("http://localhost:#{@port}/path?code=xyz") - assert response.is_a? Net::HTTPNotFound + assert response.is_a? Gem::Net::HTTPNotFound assert_equal "close", response["Connection"] @thread.join @@ -95,7 +95,7 @@ class WebauthnListenerTest < Gem::TestCase wait_for_otp_code_expect_error_with_message("Security device verification failed: Did not receive OTP from https://rubygems.org.") response = Gem::MockBrowser.get URI("http://localhost:#{@port}") - assert response.is_a? Net::HTTPBadRequest + assert response.is_a? Gem::Net::HTTPBadRequest assert_equal "text/plain; charset=utf-8", response["Content-Type"] assert_equal "22", response["Content-Length"] assert_equal "close", response["Connection"] @@ -109,7 +109,7 @@ class WebauthnListenerTest < Gem::TestCase wait_for_otp_code_expect_error_with_message("Security device verification failed: Did not receive OTP from https://rubygems.org.") response = Gem::MockBrowser.get URI("http://localhost:#{@port}?param=xyz") - assert response.is_a? Net::HTTPBadRequest + assert response.is_a? Gem::Net::HTTPBadRequest assert_equal "text/plain; charset=utf-8", response["Content-Type"] assert_equal "22", response["Content-Length"] assert_equal "close", response["Connection"] diff --git a/test/rubygems/utilities.rb b/test/rubygems/utilities.rb index 63075e0e9c..996b1f3440 100644 --- a/test/rubygems/utilities.rb +++ b/test/rubygems/utilities.rb @@ -65,7 +65,7 @@ class Gem::FakeFetcher def create_response(uri) data = find_data(uri) response = data.respond_to?(:call) ? data.call : data - raise TypeError, "#{response.class} is not a type of Net::HTTPResponse" unless response.is_a?(Net::HTTPResponse) + raise TypeError, "#{response.class} is not a type of Gem::Net::HTTPResponse" unless response.is_a?(Gem::Net::HTTPResponse) response end @@ -164,7 +164,7 @@ class Gem::FakeFetcher end ## -# The HTTPResponseFactory allows easy creation of Net::HTTPResponse instances in RubyGems tests: +# The HTTPResponseFactory allows easy creation of Gem::Net::HTTPResponse instances in RubyGems tests: # # Example: # @@ -178,7 +178,7 @@ end class Gem::HTTPResponseFactory def self.create(body:, code:, msg:, headers: {}) - response = Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg) + response = Gem::Net::HTTPResponse.send(:response_class, code.to_s).new("1.0", code.to_s, msg) response.instance_variable_set(:@body, body) response.instance_variable_set(:@read, true) headers.each {|name, value| response[name] = value } @@ -201,23 +201,23 @@ end class Gem::MockBrowser def self.options(uri) - options = Net::HTTP::Options.new(uri) - Net::HTTP.start(uri.hostname, uri.port) do |http| + options = Gem::Net::HTTP::Options.new(uri) + Gem::Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(options) end end def self.get(uri) - get = Net::HTTP::Get.new(uri) - Net::HTTP.start(uri.hostname, uri.port) do |http| + get = Gem::Net::HTTP::Get.new(uri) + Gem::Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(get) end end def self.post(uri, content_type: "application/x-www-form-urlencoded") headers = { "content-type" => content_type } if content_type - post = Net::HTTP::Post.new(uri, headers) - Net::HTTP.start(uri.hostname, uri.port) do |http| + post = Gem::Net::HTTP::Post.new(uri, headers) + Gem::Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(post) end end |