Update rabbitmq module
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / acceptance / user_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'rabbitmq user:' do
4   context 'create user resource' do
5     it 'runs successfully' do
6       pp = <<-EOS
7       if $facts['os']['family'] == 'RedHat' {
8         class { 'erlang': epel_enable => true }
9         Class['erlang'] -> Class['rabbitmq']
10       }
11       class { 'rabbitmq':
12         service_manage    => true,
13         port              => 5672,
14         delete_guest_user => true,
15         admin_enable      => true,
16       } ->
17
18       rabbitmq_user { 'dan':
19         admin    => true,
20         password => 'bar',
21       }
22       EOS
23
24       apply_manifest(pp, catch_failures: true)
25       apply_manifest(pp, catch_changes: true)
26     end
27
28     # rubocop:disable RSpec/MultipleExpectations
29     it 'has the user' do
30       shell('rabbitmqctl list_users -q') do |r|
31         expect(r.stdout).to match(%r{dan.*administrator})
32         expect(r.exit_code).to be_zero
33       end
34     end
35     # rubocop:enable RSpec/MultipleExpectations
36   end
37
38   context 'destroy user resource' do
39     it 'runs successfully' do
40       pp = <<-EOS
41       rabbitmq_user { 'dan':
42         ensure => absent,
43       }
44       EOS
45
46       apply_manifest(pp, catch_failures: true)
47       apply_manifest(pp, catch_changes: true)
48     end
49
50     it 'does not have the user' do
51       shell('rabbitmqctl list_users -q') do |r|
52         expect(r.stdout).not_to match(%r{dan\s+})
53       end
54     end
55   end
56 end