+ ' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
+ ' {servers, ["ldap.example.com"]},',
+ ' {user_dn_pattern, "ou=users,dc=example,dc=com"},', ' {use_ssl, false},',
+ ' {port, 389},', ' {foo, bar},', ' {log, true}'])
+ end
+ end
+
+ describe 'configuring ldap authentication' do
+ let :params do
+ { config_stomp: false,
+ ldap_auth: true,
+ ldap_server: 'ldap.example.com',
+ ldap_other_bind: 'as_user',
+ ldap_use_ssl: false,
+ ldap_port: 389,
+ ldap_log: true,
+ ldap_config_variables: { 'foo' => 'bar' } }
+ end
+
+ it { is_expected.to contain_rabbitmq_plugin('rabbitmq_auth_backend_ldap') }
+
+ it 'does not set user_dn_pattern when none is specified' do
+ verify_contents(catalogue, 'rabbitmq.config',
+ ['[', ' {rabbit, [', ' {auth_backends, [rabbit_auth_backend_internal, rabbit_auth_backend_ldap]},', ' ]}',
+ ' {rabbitmq_auth_backend_ldap, [', ' {other_bind, as_user},',
+ ' {servers, ["ldap.example.com"]},',
+ ' {use_ssl, false},',
+ ' {port, 389},', ' {foo, bar},', ' {log, true}'])
+ content = catalogue.resource('file', 'rabbitmq.config').send(:parameters)[:content]
+ expect(content).not_to include 'user_dn_pattern'
+ end
+ end
+
+ describe 'configuring auth_backends' do
+ let :params do
+ { auth_backends: ['{baz, foo}', 'bar'] }
+ end
+
+ it 'contains auth_backends' do
+ verify_contents(catalogue, 'rabbitmq.config',
+ [' {auth_backends, [{baz, foo}, bar]},'])
+ end
+ end
+
+ describe 'auth_backends overrides ldap_auth' do
+ let :params do
+ { auth_backends: ['{baz, foo}', 'bar'],
+ ldap_auth: true }
+ end
+
+ it 'contains auth_backends' do
+ verify_contents(catalogue, 'rabbitmq.config',
+ [' {auth_backends, [{baz, foo}, bar]},'])
+ end
+ end
+
+ describe 'configuring shovel plugin' do
+ let :params do
+ {
+ config_shovel: true
+ }
+ end
+
+ it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel') }
+
+ it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
+
+ describe 'with admin_enable false' do
+ let :params do
+ {
+ config_shovel: true,
+ admin_enable: false
+ }
+ end
+
+ it { is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
+ end
+
+ describe 'with static shovels' do
+ let :params do
+ {
+ config_shovel: true,
+ config_shovel_statics: {
+ 'shovel_first' => '{sources,[{broker,"amqp://"}]},
+ {destinations,[{broker,"amqp://site1.example.com"}]},
+ {queue,<<"source_one">>}',
+ 'shovel_second' => '{sources,[{broker,"amqp://"}]},
+ {destinations,[{broker,"amqp://site2.example.com"}]},
+ {queue,<<"source_two">>}'
+ }
+ }
+ end
+
+ it 'generates correct configuration' do
+ verify_contents(catalogue, 'rabbitmq.config', [
+ ' {rabbitmq_shovel,',
+ ' [{shovels,[',
+ ' {shovel_first,[{sources,[{broker,"amqp://"}]},',
+ ' {destinations,[{broker,"amqp://site1.example.com"}]},',
+ ' {queue,<<"source_one">>}]},',
+ ' {shovel_second,[{sources,[{broker,"amqp://"}]},',
+ ' {destinations,[{broker,"amqp://site2.example.com"}]},',
+ ' {queue,<<"source_two">>}]}',
+ ' ]}]}'
+ ])
+ end
+ end
+ end
+
+ describe 'configuring shovel plugin' do
+ let :params do
+ {
+ config_shovel: true
+ }
+ end
+
+ it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel') }
+
+ it { is_expected.to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
+
+ describe 'with admin_enable false' do
+ let :params do
+ {
+ config_shovel: true,
+ admin_enable: false
+ }
+ end
+
+ it { is_expected.not_to contain_rabbitmq_plugin('rabbitmq_shovel_management') }
+ end
+
+ describe 'with static shovels' do
+ let :params do
+ {
+ config_shovel: true,
+ config_shovel_statics: {
+ 'shovel_first' => '{sources,[{broker,"amqp://"}]},
+ {destinations,[{broker,"amqp://site1.example.com"}]},
+ {queue,<<"source_one">>}',
+ 'shovel_second' => '{sources,[{broker,"amqp://"}]},
+ {destinations,[{broker,"amqp://site2.example.com"}]},
+ {queue,<<"source_two">>}'
+ }
+ }
+ end
+
+ it 'generates correct configuration' do
+ verify_contents(catalogue, 'rabbitmq.config', [
+ ' {rabbitmq_shovel,',
+ ' [{shovels,[',
+ ' {shovel_first,[{sources,[{broker,"amqp://"}]},',
+ ' {destinations,[{broker,"amqp://site1.example.com"}]},',
+ ' {queue,<<"source_one">>}]},',
+ ' {shovel_second,[{sources,[{broker,"amqp://"}]},',
+ ' {destinations,[{broker,"amqp://site2.example.com"}]},',
+ ' {queue,<<"source_two">>}]}',
+ ' ]}]}'
+ ])
+ end