1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Remove unnecessary DIR constant

We have `__dir__` which is the same thing.

https://github.com/rubygems/rubygems/commit/f89776427f
This commit is contained in:
David Rodríguez 2020-04-10 22:09:41 +02:00 committed by Hiroshi SHIBATA
parent 1ede0c15a1
commit 427eb2b93f
Notes: git 2020-05-08 07:39:21 +09:00

View file

@ -78,8 +78,6 @@ gems:
PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, '0.4.2')
DIR = File.expand_path(File.dirname(__FILE__))
# Generated via:
# x = OpenSSL::PKey::DH.new(2048) # wait a while...
# x.to_s => pem
@ -890,7 +888,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_ssl_connection
ssl_server = start_ssl_server
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
end
@ -901,8 +899,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:SSLVerifyClient =>
OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_client_cert = File.join(DIR, 'client.pem')
temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
temp_client_cert = File.join(__dir__, 'client.pem')
with_configured_fetcher(
":ssl_ca_cert: #{temp_ca_cert}\n" +
@ -916,8 +914,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:SSLVerifyClient =>
OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_client_cert = File.join(DIR, 'invalid_client.pem')
temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
temp_client_cert = File.join(__dir__, 'invalid_client.pem')
with_configured_fetcher(
":ssl_ca_cert: #{temp_ca_cert}\n" +
@ -946,7 +944,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_do_not_follow_insecure_redirect
ssl_server = start_ssl_server
temp_ca_cert = File.join(DIR, 'ca_cert.pem')
temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
expected_error_message =
"redirecting to non-https resource: #{@server_uri} (https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri})"
@ -1055,8 +1053,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
@proxy_server[:server].config[:Port]
end
DIR = File.expand_path(File.dirname(__FILE__))
def start_ssl_server(config = {})
null_logger = NilLog.new
server = WEBrick::HTTPServer.new({
@ -1064,7 +1060,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
:Logger => null_logger,
:AccessLog => [],
:SSLEnable => true,
:SSLCACertificateFile => File.join(DIR, 'ca_cert.pem'),
:SSLCACertificateFile => File.join(__dir__, 'ca_cert.pem'),
:SSLCertificate => cert('ssl_cert.pem'),
:SSLPrivateKey => key('ssl_key.pem'),
:SSLVerifyClient => nil,
@ -1145,11 +1141,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def cert(filename)
OpenSSL::X509::Certificate.new(File.read(File.join(DIR, filename)))
OpenSSL::X509::Certificate.new(File.read(File.join(__dir__, filename)))
end
def key(filename)
OpenSSL::PKey::RSA.new(File.read(File.join(DIR, filename)))
OpenSSL::PKey::RSA.new(File.read(File.join(__dir__, filename)))
end
end if defined?(OpenSSL::SSL)