rsolr 2.4.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: def877722611e3004a0264d334d6807aade91d4af710c3b0846a9023cf44e620
4
- data.tar.gz: 9a5b3e5c1252fe6cb78669286f0a90449fbe923b9a6385a211f70ff6462b2a43
3
+ metadata.gz: 2b7e170dd7fcd0bfd504562297b93a6fb504da5e95df0d356cd0d1c70a7515c8
4
+ data.tar.gz: b4d04a24455588c421f72d29b8e9e7ab255fb4bfde9457bc6ab5f64bb64c76a4
5
5
  SHA512:
6
- metadata.gz: a7d50dddb8b4408965f3c09b16a05f3306de7cde2f89f668a3e847f1e842b44f4e6372f43e7c2fa26ab4287d64c183a969721701ea54ce51716f8afc71126755
7
- data.tar.gz: 0137a6861afffa2cdd51effc56805997641943037bc65ef9170a9feef35c1675d14f80d318fb97b3b9e1c45971b71b69ebdc2ced1976c000296829580b9642f8
6
+ metadata.gz: cd27dcd3369b5d1e4cd99604426927bf83a3a4c3ef7d8a06fb3cfc45676b33c920ce256ecb7fc577dedbbe910b6d50a45fdaa7dd0324516529c5705df8698385
7
+ data.tar.gz: 5a488c3aa5e5ca93e8fe2647baf313d8b5a94229e99d6a49820a3bf80b65fe9c19fd8ab05678ee402d3674d7a043ded6110acdf4ada5a2a1752b96f4080ceec1
@@ -11,7 +11,8 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby: [jruby-9.2.20.0, 2.4, 2.5, 2.6, 2.7, 3.0]
14
+ ruby: [jruby-9.3.3.0, '3.0', '3.1', '3.2', '3.3']
15
+ faraday: ['~> 0.17', '~> 1', '~>2']
15
16
  steps:
16
17
  - uses: actions/checkout@v2
17
18
  - name: Set up Ruby
@@ -20,5 +21,9 @@ jobs:
20
21
  ruby-version: ${{ matrix.ruby }}
21
22
  - name: Install dependencies
22
23
  run: bundle install
24
+ env:
25
+ FARADAY_VERSION: ${{ matrix.faraday}}
23
26
  - name: Run tests
24
27
  run: bundle exec rake
28
+ env:
29
+ FARADAY_VERSION: ${{ matrix.faraday}}
data/CHANGES.txt CHANGED
@@ -1,3 +1,15 @@
1
+ 2.6.0
2
+
3
+ - Stop testing on Ruby 2. https://github.com/rsolr/rsolr/pull/237
4
+ - Set solr version to 8.11.3. https://github.com/rsolr/rsolr/pull/238
5
+ - Add newer rubies to the test matrix. https://github.com/rsolr/rsolr/pull/239
6
+ - Sanitizing URIs displayed in error messages. https://github.com/rsolr/rsolr/pull/236
7
+
8
+ 2.5.0
9
+
10
+ - Sorry, not human-edited: https://github.com/rsolr/rsolr/compare/v2.4.0...v2.5.0
11
+
12
+
1
13
  2.4.0
2
14
 
3
15
  - Raise specific timeout error for solr timeouts. https://github.com/rsolr/rsolr/pull/214
data/Gemfile CHANGED
@@ -4,6 +4,10 @@ gemspec
4
4
 
5
5
  gem "builder", ">= 2.1.2"
6
6
 
7
- # HTTP.rb (used by solr_wrapper to download solr for integration testing) fails
8
- # to download the full contents of files (under jruby)?
9
- gem "http", '< 5', platforms: :jruby
7
+ if defined? JRUBY_VERSION
8
+ # HTTP.rb (used by solr_wrapper to download solr for integration testing) fails
9
+ # to download the full contents of files (under jruby)?
10
+ gem "http", '< 5', platforms: :jruby
11
+ end
12
+
13
+ gem 'faraday', ENV['FARADAY_VERSION'] if ENV['FARADAY_VERSION']
data/lib/rsolr/client.rb CHANGED
@@ -215,7 +215,7 @@ class RSolr::Client
215
215
  rescue Faraday::TimeoutError => e
216
216
  raise RSolr::Error::Timeout.new(request_context, e.response)
217
217
  rescue Errno::ECONNREFUSED, defined?(Faraday::ConnectionFailed) ? Faraday::ConnectionFailed : Faraday::Error::ConnectionFailed
218
- raise RSolr::Error::ConnectionRefused, request_context.inspect
218
+ raise RSolr::Error::ConnectionRefused.new(request_context)
219
219
  rescue Faraday::Error => e
220
220
  raise RSolr::Error::Http.new(request_context, e.response)
221
221
  end
@@ -314,12 +314,22 @@ class RSolr::Client
314
314
  conn_opts[:request][:params_encoder] = Faraday::FlatParamsEncoder
315
315
 
316
316
  Faraday.new(conn_opts) do |conn|
317
- conn.basic_auth(uri.user, uri.password) if uri.user && uri.password
317
+ if uri.user && uri.password
318
+ case Faraday::VERSION
319
+ when /^0/
320
+ conn.basic_auth uri.user, uri.password
321
+ when /^1/
322
+ conn.request :basic_auth, uri.user, uri.password
323
+ else
324
+ conn.request :authorization, :basic_auth, uri.user, uri.password
325
+ end
326
+ end
327
+
318
328
  conn.response :raise_error
319
329
  conn.request :retry, max: options[:retry_after_limit], interval: 0.05,
320
330
  interval_randomness: 0.5, backoff_factor: 2,
321
331
  exceptions: ['Faraday::Error', 'Timeout::Error'] if options[:retry_503]
322
- conn.adapter options[:adapter] || Faraday.default_adapter
332
+ conn.adapter options[:adapter] || Faraday.default_adapter || :net_http
323
333
  end
324
334
  end
325
335
  end
data/lib/rsolr/error.rb CHANGED
@@ -2,7 +2,18 @@ require 'json'
2
2
 
3
3
  module RSolr::Error
4
4
 
5
+ module URICleanup
6
+ # Removes username and password from URI object.
7
+ def clean_uri(uri)
8
+ uri = uri.dup
9
+ uri.password = "REDACTED" if uri.password
10
+ uri.user = "REDACTED" if uri.user
11
+ uri
12
+ end
13
+ end
14
+
5
15
  module SolrContext
16
+ include URICleanup
6
17
 
7
18
  attr_accessor :request, :response
8
19
 
@@ -13,7 +24,7 @@ module RSolr::Error
13
24
  details = parse_solr_error_response response[:body]
14
25
  m << "\nError: #{details}\n" if details
15
26
  end
16
- p = "\nURI: #{request[:uri].to_s}"
27
+ p = "\nURI: #{clean_uri(request[:uri]).to_s}"
17
28
  p << "\nRequest Headers: #{request[:headers].inspect}" if request[:headers]
18
29
  p << "\nRequest Data: #{request[:data].inspect}" if request[:data]
19
30
  p << "\n"
@@ -52,11 +63,16 @@ module RSolr::Error
52
63
  nil
53
64
  end
54
65
  end
55
-
56
-
57
66
  end
58
67
 
59
68
  class ConnectionRefused < ::Errno::ECONNREFUSED
69
+ include URICleanup
70
+
71
+ def initialize(request)
72
+ request[:uri] = clean_uri(request[:uri])
73
+
74
+ super(request.inspect)
75
+ end
60
76
  end
61
77
 
62
78
  class Http < RuntimeError
data/lib/rsolr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module RSolr
2
- VERSION = "2.4.0"
2
+ VERSION = "2.6.0"
3
3
 
4
4
  def self.version
5
5
  VERSION
data/rsolr.gemspec CHANGED
@@ -27,13 +27,13 @@ Gem::Specification.new do |s|
27
27
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
28
28
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
29
29
  s.require_paths = ["lib"]
30
-
30
+
31
31
  s.required_ruby_version = '>= 1.9.3'
32
-
32
+
33
33
  s.requirements << 'Apache Solr'
34
34
 
35
35
  s.add_dependency 'builder', '>= 2.1.2'
36
- s.add_dependency 'faraday', '>= 0.9.0'
36
+ s.add_dependency 'faraday', '>= 0.9', '!= 2.0.0', '< 3'
37
37
 
38
38
  s.add_development_dependency 'activesupport'
39
39
  s.add_development_dependency 'nokogiri', '>= 1.4.0'
@@ -77,6 +77,24 @@ RSpec.describe RSolr::Client do
77
77
 
78
78
  expect{ client.execute({}) }.to raise_error RSolr::Error::Timeout
79
79
  end
80
+
81
+ context 'when an Errno::ECONNREFUSED error is raised' do
82
+ let(:uri) { URI.parse('http://admin:secret@hostname.local:8983/solr/admin/update?wt=json&q=test') }
83
+
84
+ before do
85
+ allow(client.connection).to receive(:send).and_raise(Errno::ECONNREFUSED)
86
+ end
87
+
88
+ it "maps error to RSolr::Error:ConnectionRefused" do
89
+ expect { client.execute({ uri: uri }) }.to raise_error RSolr::Error::ConnectionRefused
90
+ end
91
+
92
+ it "removes credentials from uri" do
93
+ expect {
94
+ client.execute({ uri: uri })
95
+ }.to raise_error(RSolr::Error::ConnectionRefused, /http:\/\/REDACTED:REDACTED@hostname\.local:8983/)
96
+ end
97
+ end
80
98
  end
81
99
 
82
100
  context "post" do
@@ -7,7 +7,7 @@ RSpec.describe RSolr::Error do
7
7
  exception
8
8
  end
9
9
  let (:response_lines) { (1..15).to_a.map { |i| "line #{i}" } }
10
- let(:request) { double :[] => "mocked" }
10
+ let(:request) { { uri: URI.parse('http://hostname.local:8983/solr/admin/update?wt=json&q=test') } }
11
11
  let(:response_body) { response_lines.join("\n") }
12
12
  let(:response) {{
13
13
  :body => response_body,
@@ -89,7 +89,7 @@ RSpec.describe RSolr::Error do
89
89
  "code":500
90
90
  }
91
91
  }
92
- EOS
92
+ EOS
93
93
  }
94
94
  it {
95
95
  should include msg
@@ -116,7 +116,7 @@ RSpec.describe RSolr::Error do
116
116
  "facet_fields":{}
117
117
  },
118
118
  }
119
- EOS
119
+ EOS
120
120
  }
121
121
  it "shows the first eleven lines of the response" do
122
122
  expect(subject).to include(response_body.split("\n")[0..10].join("\n"))
@@ -146,4 +146,13 @@ RSpec.describe RSolr::Error do
146
146
  expect(subject).not_to include(response_body.split("\n")[11])
147
147
  end
148
148
  end
149
+
150
+ context "when request uri contains credentials" do
151
+ let(:request) { { uri: URI.parse('http://admin:admin@hostname.local:8983/solr/admin/update?wt=json&q=test') } }
152
+
153
+
154
+ it 'includes redacted url' do
155
+ expect(subject).to include 'http://REDACTED:REDACTED@hostname.local:8983/solr/admin/update?wt=json&q=test'
156
+ end
157
+ end
149
158
  end
@@ -2,6 +2,10 @@ require 'spec_helper'
2
2
  require 'solr_wrapper'
3
3
 
4
4
  RSpec.describe "Solr basic_configs" do
5
+ SolrWrapper.default_instance_options = {
6
+ port: SolrWrapper.default_solr_port,
7
+ version: '8.11.3'
8
+ }
5
9
  SOLR_INSTANCE = SolrWrapper.default_instance({})
6
10
  before(:all) { SOLR_INSTANCE.start }
7
11
  after(:all) { SOLR_INSTANCE.stop }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Latter
@@ -29,7 +29,7 @@ authors:
29
29
  autorequire:
30
30
  bindir: bin
31
31
  cert_chain: []
32
- date: 2021-12-15 00:00:00.000000000 Z
32
+ date: 2024-03-25 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: builder
@@ -51,14 +51,26 @@ dependencies:
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.0
54
+ version: '0.9'
55
+ - - "!="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.0.0
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '3'
55
61
  type: :runtime
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: 0.9.0
67
+ version: '0.9'
68
+ - - "!="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.0.0
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '3'
62
74
  - !ruby/object:Gem::Dependency
63
75
  name: activesupport
64
76
  requirement: !ruby/object:Gem::Requirement
@@ -225,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
237
  version: '0'
226
238
  requirements:
227
239
  - Apache Solr
228
- rubygems_version: 3.1.6
240
+ rubygems_version: 3.4.10
229
241
  signing_key:
230
242
  specification_version: 4
231
243
  summary: A Ruby client for Apache Solr