logstash-output-newrelic 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9339803f78539fb9240937234cc69240b289f8050c9ddfd37210f423570d828
4
- data.tar.gz: 14746a11f4c482bebe359504f9a66987bb6d500fb6e4b38f2d839a508aa4d62b
3
+ metadata.gz: d582474ed8258ecfade02da25a5a32b690d70efb9c12e5e34d51cb0bf229afd6
4
+ data.tar.gz: 8c2d60d8d9910f5f70286e3898e1e71f8cf7dfc428a0626943808a7b44fdba13
5
5
  SHA512:
6
- metadata.gz: 7cf438c882e3017df2597038d8812110d2fd8037c57c3d5e0440e1f11396143fa4aa52b1ad639d617cc32fb0c7ed05ac148bf70088d1e9dfab8b4170bf136f43
7
- data.tar.gz: b6c5a7c7acf89da4da50a1e675a9339ccc8f17cd5bce2b4e0662f7be1ee4211ecce1ad0b120036084938bdf388aee3224ab6fdf5b83625856cc0a8caa8dbc38a
6
+ metadata.gz: 7a4b6e04dfccb15df29ebd92429756d2c15a4c22ad470ec008f7e59d9506d0e9c560b86e7ef9ce9657e4952dd46dd8cb4d7f2167769e3eb61a16da002fe47cd6
7
+ data.tar.gz: e75fa1ff04550653a7e2fcfbda24af1550cb4df68c8ec1949ea0e9bfe56fbdcb6a765855100cf2d7d8842e2ee9711fabdd9363d9bf80e6e1d2546c8e485b8e29
@@ -163,10 +163,10 @@ class LogStash::Outputs::NewRelic < LogStash::Outputs::Base
163
163
  retry_duration = 1
164
164
 
165
165
  begin
166
- http = Net::HTTP.new(@end_point.host, 443)
166
+ http = Net::HTTP.new(@end_point.host, @end_point.port || 443)
167
167
  request = Net::HTTP::Post.new(@end_point.request_uri)
168
- http.use_ssl = true
169
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
168
+ http.use_ssl = (@end_point.scheme == 'https')
169
+ http.verify_mode = @end_point.scheme == 'https' ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
170
170
  if !@custom_ca_cert.nil?
171
171
  store = OpenSSL::X509::Store.new
172
172
  ca_cert = OpenSSL::X509::Certificate.new(File.read(@custom_ca_cert))
@@ -1,7 +1,7 @@
1
1
  module LogStash
2
2
  module Outputs
3
3
  module NewRelicVersion
4
- VERSION = "1.5.1"
4
+ VERSION = "1.5.2"
5
5
  end
6
6
  end
7
7
  end
@@ -7,6 +7,7 @@ require "logstash/event"
7
7
  require "thread"
8
8
  require "webmock/rspec"
9
9
  require "zlib"
10
+ require "rspec/wait"
10
11
 
11
12
  describe LogStash::Outputs::NewRelic do
12
13
  let (:base_uri) { "https://testing-example-collector.com" }
@@ -48,6 +49,50 @@ describe LogStash::Outputs::NewRelic do
48
49
  })).to have_been_made
49
50
  end
50
51
  end
52
+
53
+ context "check https connection scheme" do
54
+ it "uses https by default" do
55
+ stub_request(:any, base_uri).to_return(status: 200)
56
+
57
+ event = LogStash::Event.new({:message => "Test message" })
58
+ @newrelic_output.multi_receive([event])
59
+
60
+ wait_for(a_request(:post, base_uri)
61
+ .with(headers: {
62
+ "X-License-Key" => license_key,
63
+ "X-Event-Source" => "logs",
64
+ "Content-Encoding" => "gzip",
65
+ })).to have_been_made
66
+
67
+ # Check if the requests were made using HTTPS
68
+ expect(WebMock).to have_requested(:post, base_uri).with { |req| req.uri.scheme == 'https' }
69
+ expect(WebMock).to have_requested(:post, base_uri).with { |req| req.uri.port == 443 }
70
+ end
71
+ end
72
+
73
+ context "check http connection scheme" do
74
+ it "uses http when http config is set" do
75
+ stub_request(:any, "http://localhost:5000/").to_return(status: 200)
76
+ @newrelic_output = LogStash::Plugin.lookup("output", "newrelic").new({
77
+ "base_uri" => "http://localhost:5000/",
78
+ "license_key" => license_key
79
+ })
80
+ @newrelic_output.register
81
+ event = LogStash::Event.new({:message => "Test message" })
82
+ @newrelic_output.multi_receive([event])
83
+
84
+ wait_for(a_request(:post, "http://localhost:5000/")
85
+ .with(headers: {
86
+ "X-License-Key" => license_key,
87
+ "X-Event-Source" => "logs",
88
+ "Content-Encoding" => "gzip",
89
+ })).to have_been_made
90
+
91
+ # Check if the requests were made using HTTP to this endpoint
92
+ expect(WebMock).to have_requested(:post, "http://localhost:5000/").with { |req| req.uri.scheme == 'http' }
93
+ expect(WebMock).to have_requested(:post, "http://localhost:5000/").with { |req| req.uri.port == 5000 }
94
+ end
95
+ end
51
96
  end
52
97
 
53
98
  describe LogStash::Outputs::NewRelic do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-newrelic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - New Relic Logging Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement