From de6fed2db1305c58e772cb66e70711bb8e03bc17 Mon Sep 17 00:00:00 2001 From: Daniel Gadd Date: Wed, 11 Feb 2015 12:28:34 +1300 Subject: [PATCH] Added tests for interfaces and ssl_interfaces parameters Added spec tests for new interfaces and ssl_interfaces parameters to ensure they are configured properly and generate the expected output. --- spec/classes/rabbitmq_spec.rb | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/spec/classes/rabbitmq_spec.rb b/spec/classes/rabbitmq_spec.rb index 8429c98c4..56f632e38 100644 --- a/spec/classes/rabbitmq_spec.rb +++ b/spec/classes/rabbitmq_spec.rb @@ -459,6 +459,16 @@ end end + describe 'interfaces option with no ssl' do + let(:params) { + { :interface => '0.0.0.0', + } } + + it 'should set ssl options to specified values' do + should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\{"0.0.0.0", 5672\}\]}) + end + end + describe 'ssl options' do let(:params) { { :ssl => true, @@ -484,6 +494,27 @@ end end + + describe 'ssl options with ssl_interfaces' do + let(:params) { + { :ssl => true, + :ssl_port => 3141, + :ssl_interface => '0.0.0.0', + :ssl_cacert => '/path/to/cacert', + :ssl_cert => '/path/to/cert', + :ssl_key => '/path/to/key' + } } + + it 'should set ssl options to specified values' do + should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]}) + should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"}) + should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"}) + should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key}) + end + end + + + describe 'ssl options with ssl_only' do let(:params) { { :ssl => true, @@ -503,6 +534,26 @@ end end + describe 'ssl options with ssl_only and ssl_interfaces' do + let(:params) { + { :ssl => true, + :ssl_only => true, + :ssl_port => 3141, + :ssl_interface => '0.0.0.0', + :ssl_cacert => '/path/to/cacert', + :ssl_cert => '/path/to/cert', + :ssl_key => '/path/to/key' + } } + + it 'should set ssl options to specified values' do + should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]}) + should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]}) + should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"}) + should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"}) + should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key}) + end + end + describe 'ssl options with specific ssl versions' do let(:params) { { :ssl => true,