Skip to content

Commit

Permalink
Correctly split client and server mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robbavey committed Dec 10, 2024
1 parent e719cb3 commit 07b94e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions lib/logstash/outputs/tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
41 changes: 13 additions & 28 deletions spec/outputs/tcp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07b94e5

Please sign in to comment.