From 07b94e558cb159f129fb1f890e3efadc924b5a4a Mon Sep 17 00:00:00 2001 From: Rob Bavey Date: Tue, 10 Dec 2024 15:00:15 -0500 Subject: [PATCH] Correctly split client and server mode tests --- CHANGELOG.md | 2 +- lib/logstash/outputs/tcp.rb | 5 ----- spec/outputs/tcp_spec.rb | 41 ++++++++++++------------------------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5dee2d..0db0ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - `ssl_cacert`, which should be replaced by `ssl_certificate_authorities` - `ssl_enable`, which should be replaced by `ssl_enabled` - `ssl_verify`, which should be replaced by `ssl_client_authentication` when `mode` is `server` or `ssl_verification_mode`when mode is `client` - - [xxx](https://github.com/logstash-plugins/logstash-output-tcp/pull/xxx) + - [58](https://github.com/logstash-plugins/logstash-output-tcp/pull/58) ## 6.2.1 - Document correct default plugin codec [#54](https://github.com/logstash-plugins/logstash-output-tcp/pull/54) diff --git a/lib/logstash/outputs/tcp.rb b/lib/logstash/outputs/tcp.rb index bd4f0be..c15eddf 100644 --- a/lib/logstash/outputs/tcp.rb +++ b/lib/logstash/outputs/tcp.rb @@ -179,11 +179,6 @@ def load_cert_store end private :load_cert_store - def initialize(*args) - super(*args) - # setup_ssl_params! - end - # @overload Base#register def register require "socket" diff --git a/spec/outputs/tcp_spec.rb b/spec/outputs/tcp_spec.rb index dc53600..718ab5b 100644 --- a/spec/outputs/tcp_spec.rb +++ b/spec/outputs/tcp_spec.rb @@ -24,35 +24,20 @@ let(:event) { LogStash::Event.new('message' => 'foo bar') } - describe 'handling obsolete settings for client mode' do - [{:name => 'ssl_cert', :replacement => 'ssl_certificate', :sample_value => "certificate_path"}, - {:name => 'ssl_cacert', :replacement => 'ssl_certificate_authorities', :sample_value => "certificate_path"}, - {:name => 'ssl_enable', :replacement => 'ssl_enabled', :sample_value => true}, - {:name => 'ssl_verify', :replacement => 'ssl_client_authentication', :sample_value => 'peer'}].each do | obsolete_setting | - context "with obsolete #{obsolete_setting[:name]}" do - let (:deprecated_config) do - config.merge({obsolete_setting[:name] => obsolete_setting[:sample_value]}) - end - - it "should raise a config error with the appropriate message" do - expect { LogStash::Outputs::Tcp.new(deprecated_config).register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `tcp` is obsolete and is no longer available. Use '#{obsolete_setting[:replacement]}'/i - end - end - end - end - - describe 'handling obsolete settings for server mode' do - [{:name => 'ssl_cert', :replacement => 'ssl_certificate', :sample_value => "certificate_path"}, - {:name => 'ssl_cacert', :replacement => 'ssl_certificate_authorities', :sample_value => "certificate_path"}, - {:name => 'ssl_enable', :replacement => 'ssl_enabled', :sample_value => true}, - {:name => 'ssl_verify', :replacement => 'ssl_client_authentication', :sample_value => 'peer'}].each do | obsolete_setting | - context "with obsolete #{obsolete_setting[:name]}" do - let (:deprecated_config) do - config.merge({obsolete_setting[:name] => obsolete_setting[:sample_value]}) - end + ['server', 'client'].each do |mode| + describe "handling obsolete settings for #{mode} mode" do + [{:name => 'ssl_cert', :replacement => 'ssl_certificate', :sample_value => "certificate_path"}, + {:name => 'ssl_cacert', :replacement => 'ssl_certificate_authorities', :sample_value => "certificate_path"}, + {:name => 'ssl_enable', :replacement => 'ssl_enabled', :sample_value => true}, + {:name => 'ssl_verify', :replacement => 'ssl_client_authentication', :sample_value => 'peer'}].each do | obsolete_setting | + context "with obsolete #{obsolete_setting[:name]}" do + let (:deprecated_config) do + config.merge({'mode' => mode, obsolete_setting[:name] => obsolete_setting[:sample_value]}) + end - it "should raise a config error with the appropriate message" do - expect { LogStash::Outputs::Tcp.new(deprecated_config).register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `tcp` is obsolete and is no longer available. Use '#{obsolete_setting[:replacement]}'/i + it "should raise a config error with the appropriate message" do + expect { LogStash::Outputs::Tcp.new(deprecated_config).register }.to raise_error LogStash::ConfigurationError, /The setting `#{obsolete_setting[:name]}` in plugin `tcp` is obsolete and is no longer available. Use '#{obsolete_setting[:replacement]}'/i + end end end end