From dc2798cfdc07852d7f184f98f1aca343a301c0c7 Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Wed, 15 May 2024 10:52:38 +0300 Subject: [PATCH] Fixed cacert.pem file location (#8) --- Rakefile | 4 ++-- lib/tebako-runtime/version.rb | 2 +- spec/runtime_spec.rb | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 12156eb..0834bca 100644 --- a/Rakefile +++ b/Rakefile @@ -36,11 +36,11 @@ namespace :build do desc "Download cacert.pem" task :download_cacert do url = URI("https://curl.se/ca/cacert.pem") - FileUtils.mkdir_p("cert") + FileUtils.mkdir_p("lib/cert") Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == "https") do |http| request = Net::HTTP::Get.new url http.request request do |response| - open "cert/cacert.pem.mozilla", "w" do |io| + open "lib/cert/cacert.pem.mozilla", "w" do |io| response.read_body do |chunk| io.write chunk end diff --git a/lib/tebako-runtime/version.rb b/lib/tebako-runtime/version.rb index 15d39f5..d2a8a25 100644 --- a/lib/tebako-runtime/version.rb +++ b/lib/tebako-runtime/version.rb @@ -26,5 +26,5 @@ # POSSIBILITY OF SUCH DAMAGE. module TebakoRuntime - VERSION = "0.4.0" + VERSION = "0.4.1" end diff --git a/spec/runtime_spec.rb b/spec/runtime_spec.rb index e307416..e84ef52 100644 --- a/spec/runtime_spec.rb +++ b/spec/runtime_spec.rb @@ -151,6 +151,9 @@ def tmpdir_name end it "provides an adapter for net/http gem" do + TebakoRuntime.send(:remove_const, :COMPILER_MEMFS) + TebakoRuntime::COMPILER_MEMFS = File.join(TebakoRuntime.full_gem_path("tebako-runtime"), "lib") + tfile = File.join(TebakoRuntime.full_gem_path("tebako-runtime"), "lib", "cert", "cacert.pem.mozilla") expect(TebakoRuntime).to receive(:extract_memfs).with(tfile).and_call_original require "net/http" @@ -162,7 +165,7 @@ def tmpdir_name http.use_ssl = true - expect(http.ca_file).to eq(tfile) + expect(http.ca_file).to eq(File.join(TebakoRuntime::COMPILER_MEMFS_LIB_CACHE, "cacert.pem.mozilla")) expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_PEER) end