Skip to content

Commit de6fed2

Browse files
committed
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.
1 parent a8e4ec6 commit de6fed2

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

spec/classes/rabbitmq_spec.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,16 @@
459459
end
460460
end
461461

462+
describe 'interfaces option with no ssl' do
463+
let(:params) {
464+
{ :interface => '0.0.0.0',
465+
} }
466+
467+
it 'should set ssl options to specified values' do
468+
should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\{"0.0.0.0", 5672\}\]})
469+
end
470+
end
471+
462472
describe 'ssl options' do
463473
let(:params) {
464474
{ :ssl => true,
@@ -484,6 +494,27 @@
484494
end
485495
end
486496

497+
498+
describe 'ssl options with ssl_interfaces' do
499+
let(:params) {
500+
{ :ssl => true,
501+
:ssl_port => 3141,
502+
:ssl_interface => '0.0.0.0',
503+
:ssl_cacert => '/path/to/cacert',
504+
:ssl_cert => '/path/to/cert',
505+
:ssl_key => '/path/to/key'
506+
} }
507+
508+
it 'should set ssl options to specified values' do
509+
should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
510+
should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"})
511+
should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
512+
should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
513+
end
514+
end
515+
516+
517+
487518
describe 'ssl options with ssl_only' do
488519
let(:params) {
489520
{ :ssl => true,
@@ -503,6 +534,26 @@
503534
end
504535
end
505536

537+
describe 'ssl options with ssl_only and ssl_interfaces' do
538+
let(:params) {
539+
{ :ssl => true,
540+
:ssl_only => true,
541+
:ssl_port => 3141,
542+
:ssl_interface => '0.0.0.0',
543+
:ssl_cacert => '/path/to/cacert',
544+
:ssl_cert => '/path/to/cert',
545+
:ssl_key => '/path/to/key'
546+
} }
547+
548+
it 'should set ssl options to specified values' do
549+
should contain_file('rabbitmq.config').with_content(%r{tcp_listeners, \[\]})
550+
should contain_file('rabbitmq.config').with_content(%r{ssl_listeners, \[\{"0.0.0.0", 3141\}\]})
551+
should contain_file('rabbitmq.config').with_content(%r{ssl_options, \[\{cacertfile,"/path/to/cacert"})
552+
should contain_file('rabbitmq.config').with_content(%r{certfile,"/path/to/cert"})
553+
should contain_file('rabbitmq.config').with_content(%r{keyfile,"/path/to/key})
554+
end
555+
end
556+
506557
describe 'ssl options with specific ssl versions' do
507558
let(:params) {
508559
{ :ssl => true,

0 commit comments

Comments
 (0)