rsolr 2.5.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: f44e7e34b8e615204b49052907e322c46387d858f147b7e34bd4c53edf6b336e
4
- data.tar.gz: b5ad262ba4b5777f18b817c529f9cb8768843972f394420a4798191f92a11b17
3
+ metadata.gz: 2b7e170dd7fcd0bfd504562297b93a6fb504da5e95df0d356cd0d1c70a7515c8
4
+ data.tar.gz: b4d04a24455588c421f72d29b8e9e7ab255fb4bfde9457bc6ab5f64bb64c76a4
5
5
  SHA512:
6
- metadata.gz: c230788c63b34623fa05608af73c25c5c7bd6fbab106afc62c63b1347a688bf302d0b03323204b0efd047f01ddc2d957722cd5ed0f98553ec3974b7ed2653c79
7
- data.tar.gz: 606324146e3acb8cb86c726a528550fefd0bd57fdebce977fc260c5a38caf4b1c5aeca7c3f23637dcf4bf04e8fbc196e60e4cc63f9827ee7e88af01e816ce3a4
6
+ metadata.gz: cd27dcd3369b5d1e4cd99604426927bf83a3a4c3ef7d8a06fb3cfc45676b33c920ce256ecb7fc577dedbbe910b6d50a45fdaa7dd0324516529c5705df8698385
7
+ data.tar.gz: 5a488c3aa5e5ca93e8fe2647baf313d8b5a94229e99d6a49820a3bf80b65fe9c19fd8ab05678ee402d3674d7a043ded6110acdf4ada5a2a1752b96f4080ceec1
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby: [jruby-9.3.3.0, 2.7, '3.0', '3.1']
14
+ ruby: [jruby-9.3.3.0, '3.0', '3.1', '3.2', '3.3']
15
15
  faraday: ['~> 0.17', '~> 1', '~>2']
16
16
  steps:
17
17
  - uses: actions/checkout@v2
@@ -27,18 +27,3 @@ jobs:
27
27
  run: bundle exec rake
28
28
  env:
29
29
  FARADAY_VERSION: ${{ matrix.faraday}}
30
- legacy_tests:
31
- runs-on: ubuntu-latest
32
- strategy:
33
- matrix:
34
- ruby: [jruby-9.2.20.0, 2.4, 2.5, 2.6, 2.7]
35
- steps:
36
- - uses: actions/checkout@v2
37
- - name: Set up Ruby
38
- uses: ruby/setup-ruby@v1
39
- with:
40
- ruby-version: ${{ matrix.ruby }}
41
- - name: Install dependencies
42
- run: bundle install
43
- - name: Run tests
44
- run: bundle exec rake
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/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
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.5.0"
2
+ VERSION = "2.6.0"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -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.5.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: 2022-02-11 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
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  requirements:
239
239
  - Apache Solr
240
- rubygems_version: 3.3.3
240
+ rubygems_version: 3.4.10
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: A Ruby client for Apache Solr