diff options
| author | Antonio Terceiro <terceiro@debian.org> | 2025-01-29 15:23:05 +0100 |
|---|---|---|
| committer | git-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com> | 2025-01-29 22:41:35 +0000 |
| commit | 982c596c65f4199dbe886ddfda9fe121a8151cca (patch) | |
| tree | 153b2eabef1f243acbb1176da601aaf5abc707a8 | |
| parent | 2e987b859ef3eef3e13fb6e0296b6ddb90597e58 (diff) | |
| parent | 37b77a502cf05b224772abe39408b9ee730b392c (diff) | |
2.2.0-1 (patches applied)applied/2.2.0-1applied/ubuntu/resolute-develapplied/ubuntu/resoluteapplied/ubuntu/questing-develapplied/ubuntu/questingapplied/ubuntu/plucky-proposedapplied/ubuntu/plucky-develapplied/ubuntu/pluckyapplied/ubuntu/develapplied/debian/sid
Imported using git-ubuntu import.
| -rw-r--r-- | .document | 2 | ||||
| -rw-r--r-- | .github/workflows/ci.yml | 4 | ||||
| -rw-r--r-- | History.md | 14 | ||||
| -rw-r--r-- | Rakefile | 2 | ||||
| -rw-r--r-- | debian/changelog | 8 | ||||
| -rw-r--r-- | debian/control | 2 | ||||
| -rw-r--r-- | lib/rack/test/cookie_jar.rb | 19 | ||||
| -rw-r--r-- | lib/rack/test/uploaded_file.rb | 14 | ||||
| -rw-r--r-- | lib/rack/test/version.rb | 2 | ||||
| -rw-r--r-- | spec/all.rb | 2 | ||||
| -rw-r--r-- | spec/fixtures/fake_app.rb | 1 | ||||
| -rw-r--r-- | spec/rack/test/cookie_jar_spec.rb | 13 | ||||
| -rw-r--r-- | spec/rack/test/cookie_spec.rb | 22 | ||||
| -rw-r--r-- | spec/rack/test/uploaded_file_spec.rb | 36 | ||||
| -rw-r--r-- | spec/rack/test_spec.rb | 4 |
15 files changed, 88 insertions, 57 deletions
@@ -1,4 +1,4 @@ -README.rdoc +README.md lib/**/*.rb History.txt MIT-LICENSE.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 068654d..d6accca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-20.04 ] - ruby: [ 2.0.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, jruby-9.3, jruby-9.4 ] + ruby: [ 2.0.0, 2.1, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, jruby-9.3, jruby-9.4 ] gemfile: [ Gemfile, Gemfile.rack-1.x ] exclude: - ruby: 2.0.0 @@ -22,7 +22,7 @@ jobs: env: BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: @@ -1,3 +1,17 @@ +## 2.2.0 / 2024-12-23 + +* Bug fixes: + * `Rack::Test::Cookie` now parses cookie parameters using a + case-insensitive approach (Guillaume Malette #349) + +* Minor enhancements: + * Arrays of cookies containing a blank cookie are now handled + correctly when processing responses. (Martin Emde #343) + * `Rack::Test::UploadedFile` no longer uses a finalizer for named + paths to close and unlink the created Tempfile. Tempfile itself + uses a finalizer to close and unlink itself, so there is no + reason for `Rack::Test::UploadedFile` to do so (Jeremy Evans #338) + ## 2.1.0 / 2023-03-14 * Breaking changes: @@ -2,7 +2,7 @@ task default: :spec desc "Run specs" task "spec" do - sh "#{FileUtils::RUBY} -w spec/all.rb" + sh "#{FileUtils::RUBY} -w #{'-W:strict_unused_block' if RUBY_VERSION >= '3.4'} spec/all.rb" end desc "Run specs with coverage" diff --git a/debian/changelog b/debian/changelog index fa8d116..4857b4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +ruby-rack-test (2.2.0-1) unstable; urgency=medium + + * Team upload + * New upstream version 2.2.0 + * Drop deprecated X?-Ruby-Versions: fields + + -- Antonio Terceiro <terceiro@debian.org> Wed, 29 Jan 2025 15:23:05 +0100 + ruby-rack-test (2.1.0-1) unstable; urgency=medium * Team upload. diff --git a/debian/control b/debian/control index 97f8ff3..39efcf8 100644 --- a/debian/control +++ b/debian/control @@ -16,12 +16,10 @@ Vcs-Git: https://salsa.debian.org/ruby-team/ruby-rack-test.git Vcs-Browser: https://salsa.debian.org/ruby-team/ruby-rack-test Homepage: https://github.com/rack/rack-test Testsuite: autopkgtest-pkg-ruby -XS-Ruby-Versions: all Rules-Requires-Root: no Package: ruby-rack-test Architecture: all -XB-Ruby-Versions: ${ruby:Versions} Depends: ${misc:Depends}, ${ruby:Depends}, ${shlibs:Depends} diff --git a/lib/rack/test/cookie_jar.rb b/lib/rack/test/cookie_jar.rb index c6f617d..d09a5bb 100644 --- a/lib/rack/test/cookie_jar.rb +++ b/lib/rack/test/cookie_jar.rb @@ -12,7 +12,7 @@ module Rack # The name of the cookie, will be a string attr_reader :name - + # The value of the cookie, will be a string or nil if there is no value. attr_reader :value @@ -28,7 +28,7 @@ module Rack @raw, options = raw.split(/[;,] */n, 2) @name, @value = parse_query(@raw, ';').to_a.first - @options = parse_query(options, ';') + @options = Hash[parse_query(options, ';').map { |k, v| [k.downcase, v] }] if domain = @options['domain'] @exact_domain_match = false @@ -69,7 +69,7 @@ module Rack # Whether the cookie has the httponly flag, indicating it is not available via # a javascript API. def http_only? - @options.key?('HttpOnly') || @options.key?('httponly') + @options.key?('httponly') end # The explicit or implicit path for the cookie. @@ -93,9 +93,8 @@ module Rack uri.host = @default_host if uri.host.nil? - real_domain = domain =~ /^\./ ? domain[1..-1] : domain !!((!secure? || (secure? && uri.scheme == 'https')) && - uri.host =~ Regexp.new("#{'^' if @exact_domain_match}#{Regexp.escape(real_domain)}$", Regexp::IGNORECASE)) + uri.host =~ Regexp.new("#{'^' if @exact_domain_match}#{Regexp.escape(domain)}$", Regexp::IGNORECASE)) end # Cookies that do not match the URI will not be sent in requests to the URI. @@ -110,11 +109,13 @@ module Rack # A hash of cookie options, including the cookie value, but excluding the cookie name. def to_h - @options.merge( + hash = @options.merge( 'value' => @value, 'HttpOnly' => http_only?, 'secure' => secure? ) + hash.delete('httponly') + hash end alias to_hash to_h @@ -183,12 +184,10 @@ module Rack def merge(raw_cookies, uri = nil) return unless raw_cookies - if raw_cookies.is_a? String - raw_cookies = raw_cookies.split("\n") - raw_cookies.reject!(&:empty?) - end + raw_cookies = raw_cookies.split("\n") if raw_cookies.is_a? String raw_cookies.each do |raw_cookie| + next if raw_cookie.empty? cookie = Cookie.new(raw_cookie, uri, @default_host) self << cookie if cookie.valid?(uri) end diff --git a/lib/rack/test/uploaded_file.rb b/lib/rack/test/uploaded_file.rb index 39346e4..5be6dc7 100644 --- a/lib/rack/test/uploaded_file.rb +++ b/lib/rack/test/uploaded_file.rb @@ -72,18 +72,6 @@ module Rack tempfile.respond_to?(method_name, include_private) || super end - # A proc that can be used as a finalizer to close and unlink the tempfile. - def self.finalize(file) - proc { actually_finalize file } - end - - # Close and unlink the given file, used as a finalizer for the tempfile, - # if the tempfile is backed by a file in the filesystem. - def self.actually_finalize(file) - file.close - file.unlink - end - private # Use the StringIO as the tempfile. @@ -104,8 +92,6 @@ module Rack @tempfile = Tempfile.new([::File.basename(@original_filename, extension), extension]) @tempfile.set_encoding(Encoding::BINARY) - ObjectSpace.define_finalizer(self, self.class.finalize(@tempfile)) - FileUtils.copy_file(path, @tempfile.path) end end diff --git a/lib/rack/test/version.rb b/lib/rack/test/version.rb index 0868d46..f7e7462 100644 --- a/lib/rack/test/version.rb +++ b/lib/rack/test/version.rb @@ -1,5 +1,5 @@ module Rack module Test - VERSION = '2.1.0'.freeze + VERSION = '2.2.0'.freeze end end diff --git a/spec/all.rb b/spec/all.rb index 586a20f..4542947 100644 --- a/spec/all.rb +++ b/spec/all.rb @@ -1 +1 @@ -Dir['spec/**/*_spec.rb'].each{|f| require_relative f.sub('spec/', '')} +Dir.glob('spec/**/*_spec.rb') {|f| require_relative f.sub('spec/', '')} diff --git a/spec/fixtures/fake_app.rb b/spec/fixtures/fake_app.rb index 3cfeff2..befb4b6 100644 --- a/spec/fixtures/fake_app.rb +++ b/spec/fixtures/fake_app.rb @@ -143,6 +143,7 @@ module Rack if input input.rewind env['rack.input'] = input + env.delete('rack.request.form_hash') end end end diff --git a/spec/rack/test/cookie_jar_spec.rb b/spec/rack/test/cookie_jar_spec.rb index 68a9587..854c582 100644 --- a/spec/rack/test/cookie_jar_spec.rb +++ b/spec/rack/test/cookie_jar_spec.rb @@ -67,4 +67,17 @@ describe Rack::Test::CookieJar do jar.merge('c=d; domain=example.org; secure', URI.parse('/')) jar.to_hash.must_equal 'a' => 'b' end + + it '#merge ignores empty cookies in cookie strings' do + jar = Rack::Test::CookieJar.new + jar.merge('', URI.parse('/')) + jar.merge("\nc=d") + jar.to_hash.must_equal 'c' => 'd' + end + + it '#merge ignores empty cookies in cookie arrays' do + jar = Rack::Test::CookieJar.new + jar.merge(['', 'c=d'], URI.parse('/')) + jar.to_hash.must_equal 'c' => 'd' + end end diff --git a/spec/rack/test/cookie_spec.rb b/spec/rack/test/cookie_spec.rb index 08e18ba..c632e23 100644 --- a/spec/rack/test/cookie_spec.rb +++ b/spec/rack/test/cookie_spec.rb @@ -49,12 +49,28 @@ describe "Rack::Test::Session" do cookie_string = [ '/', 'csrf_id=ABC123', - 'path=/', - 'expires=Wed, 01 Jan 2020 08:00:00 GMT', + 'path=/cookie', 'HttpOnly' ].join(Rack::Test::CookieJar::DELIMITER) cookie = Rack::Test::Cookie.new(cookie_string) - cookie.path.must_equal '/' + cookie.path.must_equal '/cookie' + end + + it 'attribute names are case-insensitive' do + cookie_string = [ + '/', + 'csrf_id=ABC123', + 'Path=/cookie', + 'Expires=Wed, 01 Jan 2020 08:00:00 GMT', + 'HttpOnly', + 'Secure', + ].join(Rack::Test::CookieJar::DELIMITER) + cookie = Rack::Test::Cookie.new(cookie_string) + + cookie.path.must_equal '/cookie' + cookie.secure?.must_equal true + cookie.http_only?.must_equal true + cookie.expires.must_equal Time.parse('Wed, 01 Jan 2020 08:00:00 GMT') end it 'escapes cookie values' do diff --git a/spec/rack/test/uploaded_file_spec.rb b/spec/rack/test/uploaded_file_spec.rb index 67bfbc5..5c42dba 100644 --- a/spec/rack/test/uploaded_file_spec.rb +++ b/spec/rack/test/uploaded_file_spec.rb @@ -51,35 +51,31 @@ describe Rack::Test::UploadedFile do proc{Rack::Test::UploadedFile.new('does_not_exist')}.must_raise RuntimeError end - it 'finalizes on garbage collection' do - finalized = false - c = Class.new(Rack::Test::UploadedFile) do - define_singleton_method(:actually_finalize) do |file| - finalized = true - super(file) - end + def local_paths(n) + local_paths = n.times.map do + Rack::Test::UploadedFile.new(file_path) end + local_paths.map(&:local_path).all?{|f| File.exist?(f)}.must_equal true + local_paths.map!(&:local_path) + local_paths.uniq.size.must_equal n + local_paths + end + + it 'removes local paths on garbage collection' do if RUBY_PLATFORM == 'java' require 'java' java_import 'java.lang.System' - 50.times do |_i| - c.new(file_path) - System.gc - end + paths = local_paths(500) + System.gc else - 50.times do |_i| - c.new(file_path) - GC.start - end + paths = local_paths(50) + GC.start end - # Due to CRuby's conservative garbage collection, you can never guarantee - # an object will be garbage collected, so this is a source of potential - # nondeterministic failure - finalized.must_equal true - end if RUBY_VERSION >= '2.7' || RUBY_ENGINE != 'ruby' + paths.all?{|f| File.exist?(f)}.must_equal false + end it '#initialize with an IO object sets the specified filename' do original_filename = 'content.txt' diff --git a/spec/rack/test_spec.rb b/spec/rack/test_spec.rb index d71457a..4b07b50 100644 --- a/spec/rack/test_spec.rb +++ b/spec/rack/test_spec.rb @@ -451,14 +451,14 @@ describe 'Rack::Test::Session#follow_redirect!' do get '/redirect', {}, 'rack.session' => { 'foo' => 'bar' } follow_redirect! - last_response.body.must_include 'session {"foo"=>"bar"}' + last_response.body.must_match(/session \{"foo" ?=> ?"bar"\}/) end it 'includes session options when following the redirect' do get '/redirect', {}, 'rack.session.options' => { 'foo' => 'bar' } follow_redirect! - last_response.body.must_include 'session {} with options {"foo"=>"bar"}' + last_response.body.must_match(/session \{\} with options \{"foo" ?=> ?"bar"\}/) end it 'raises an error if the last_response is not set' do |
