Skip to content

Commit

Permalink
Test against Ruby 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Mar 6, 2021
1 parent f7cbd43 commit c672ff2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -9,6 +9,7 @@ rvm:
- ruby-2.5
- ruby-2.6
- ruby-2.7
- ruby-3.0
- ruby-head
script:
- bundle exec bundler-audit
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -19,7 +19,7 @@ This gem provides a safe and easy way to fetch content from user-submitted urls.
- handles URIs/IPv4/IPv6, redirects, DNS, etc, correctly
- has 0 runtime dependencies
- has a comprehensive test suite (100% code coverage)
- is tested against ruby `2.0`, `2.1`, `2.2`, `2.3`, `2.4`, `2.5`, `2.6`, `2.7`, and `ruby-head`
- is tested against ruby `2.0`, `2.1`, `2.2`, `2.3`, `2.4`, `2.5`, `2.6`, `2.7`, `3.0`, and `ruby-head`

### Quick start

Expand Down
5 changes: 3 additions & 2 deletions spec/lib/ssrf_filter_spec.rb
Expand Up @@ -172,7 +172,7 @@
it 'should disallow header values with newlines and carriage returns' do
# Starting in ruby 2.5, assigning a header value with newlines throws an ArgumentError
major, minor = RUBY_VERSION.scan(/\A(\d+)\.(\d+)\.\d+\Z/).first.map(&:to_i)
exception = major >= 2 && minor >= 5 ? ArgumentError : SsrfFilter::CRLFInjection
exception = major >= 3 || (major >= 2 && minor >= 5) ? ArgumentError : SsrfFilter::CRLFInjection

expect do
SsrfFilter.get("https://#{public_ipv4}", headers: {'name' => "val\nue"})
Expand Down Expand Up @@ -417,9 +417,10 @@ def inject_custom_trust_store(*certificates)
end

it 'should follow redirects and succeed on a public hostname' do
major = RUBY_VERSION.scan(/\A(\d+)\.\d+\.\d+\Z/).first.map(&:to_i).first
stub_request(:post, "https://#{public_ipv4}/path?key=value").with(headers: {host: 'www.example.com'})
.to_return(status: 301, headers: {location: 'https://www.example2.com/path2?key2=value2'})
stub_request(:post, "https://#{public_ipv6}/path2?key2=value2")
stub_request(:post, "https://#{major >= 3 ? "[#{public_ipv6}]" : public_ipv6}/path2?key2=value2")
.with(headers: {host: 'www.example2.com'}).to_return(status: 200, body: 'response body')
resolver = proc do |hostname|
[{
Expand Down
5 changes: 2 additions & 3 deletions ssrf_filter.gemspec
Expand Up @@ -20,9 +20,8 @@ Gem::Specification.new do |gem|
gem.add_development_dependency('bundler-audit', '~> 0.6.1')
gem.add_development_dependency('coveralls', '~> 0.8.22')
gem.add_development_dependency('rspec', '~> 3.8.0')
gem.add_development_dependency('webmock', '~> 3.5.1')

raise 'Unsupported version of ruby' unless major == 2
gem.add_development_dependency('webmock', '>= 3.5.1')
gem.add_development_dependency('webrick') if major >= 3

if minor > 1
gem.add_development_dependency('rubocop', '~> 0.65.0')
Expand Down

0 comments on commit c672ff2

Please sign in to comment.