Loading spec/defines/attr_spec.rb +19 −41 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::attr' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { :source => 'place_value_here', #:ensure => present, #:key => "User-Name", #:prefix => "filter", :source => 'puppet:///modules/test/path/to/file', } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$fr_version ? { 2 => $fr_basepath, 3 => $fr_moduleconfigpath/attr_filter, default => $fr_moduleconfigpath }/XXreplace_meXX') .with( 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0640', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[Package[$fr_package], Group[$fr_group]]', 'source' => '' ) is_expected.to contain_file('/etc/raddb/mods-config/attr_filter/test') .that_notifies('Service[radiusd]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .with_source('puppet:///modules/test/path/to/file') end it do is_expected.to contain_concat__fragment('attr-XXreplace_meXX') .with( 'content' => 'template(freeradius/attr.fr$fr_version.erb)', 'order' => '20', 'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/$fr_version ? { 2 => modules, 3 => mods-enabled, default => modules }/attr_filter' ) is_expected.to contain_concat__fragment('attr-test') .with_content(%r{^attr_filter filter.test {\n\s+key = "\%{User-Name}"\n\s+filename = \${modconfdir}/\${\.:name}/test\n}}) .with_order('20') .with_target('/etc/raddb/mods-available/attr_filter') end end spec/defines/blank_spec.rb +14 −34 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::blank' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } let(:params) { {} } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/XXreplace_meXX') .with( 'content' => '# This file is intentionally left blank to reduce complexity. Blanking it but leaving it present is safer than deleting it, since the package manager will replace some files if they are deleted, leading to unexpected behaviour!', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0644', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[File[$fr_basepath], Package[$fr_package], Group[$fr_group]]' ) is_expected.to contain_file('/etc/raddb/test') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_content(%r{^# This file is intentionally left blank .*}) .with_group('radiusd') .with_mode('0644') .with_owner('root') end end spec/defines/cert_spec.rb +49 −41 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::cert' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} context 'with type set to key' do let(:params) do { type: 'key', content: 'test data', } end it do is_expected.to contain_file('/etc/raddb/certs/test') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb/certs]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_content(%r{test data}) .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .with_show_diff('false') .with_source(nil) end end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value context 'with type set to cert and with source' do let(:params) do { #:source => undef, #:content => undef, #:type => "key", #:ensure => present, type: 'cert', source: 'puppet:///modules/test/path/to/cert', content: :undef, } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/certs/XXreplace_meXX') .with( 'content' => 'undef', 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '$type ? { key => 0640, cert => 0644, default => 0644 }', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[File[$fr_basepath/certs], Package[$fr_package], Group[$fr_group]]', 'show_diff' => 'false', 'source' => 'undef' ) is_expected.to contain_file('/etc/raddb/certs/test') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb/certs]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_content(nil) .with_ensure('present') .with_group('radiusd') .with_mode('0644') .with_owner('root') .with_show_diff('false') .with_source('puppet:///modules/test/path/to/cert') end end end spec/defines/client_spec.rb +16 −43 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::client' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { :shortname => 'place_value_here', :secret => 'place_value_here', #:ip => undef, #:ip6 => undef, #:virtual_server => undef, #:nastype => undef, #:netmask => undef, #:redirect => undef, #:port => undef, #:srcip => undef, #:firewall => false, #:ensure => present, :shortname => 'test_short', :secret => 'secret_value', :ip => '1.2.3.4', } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/clients.d/.conf') .with( 'content' => 'template(freeradius/client.conf.fr$fr_version.erb)', 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0640', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[File[$fr_basepath/clients.d], Group[$fr_group]]' ) is_expected.to contain_file('/etc/raddb/clients.d/test_short.conf') .with_content(%r{^client test_short {\n\s+ipaddr = 1.2.3.4\n\s+proto = \*\n\s+shortname = test_short\n\s+secret = "secret_value"\n\s+require_message_authenticator = no\n}\n}) .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb/clients.d]') .that_requires('Group[radiusd]') end end spec/defines/config_spec.rb +15 −35 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::config' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { #:source => undef, #:content => undef, #:ensure => present, :content => 'test content', } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/$fr_version ? { 2 => conf.d, 3 => mods-config, default => conf.d }/XXreplace_meXX') .with( 'content' => 'undef', 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0640', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[Package[$fr_package], Group[$fr_group]]', 'source' => 'undef' ) is_expected.to contain_file('/etc/raddb/mods-config/test') .with_content('test content') .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .with_source(nil) .that_notifies('Service[radiusd]') .that_requires('Package[freeradius]') .that_requires('Group[radiusd]') end end Loading
spec/defines/attr_spec.rb +19 −41 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::attr' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { :source => 'place_value_here', #:ensure => present, #:key => "User-Name", #:prefix => "filter", :source => 'puppet:///modules/test/path/to/file', } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$fr_version ? { 2 => $fr_basepath, 3 => $fr_moduleconfigpath/attr_filter, default => $fr_moduleconfigpath }/XXreplace_meXX') .with( 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0640', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[Package[$fr_package], Group[$fr_group]]', 'source' => '' ) is_expected.to contain_file('/etc/raddb/mods-config/attr_filter/test') .that_notifies('Service[radiusd]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .with_source('puppet:///modules/test/path/to/file') end it do is_expected.to contain_concat__fragment('attr-XXreplace_meXX') .with( 'content' => 'template(freeradius/attr.fr$fr_version.erb)', 'order' => '20', 'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/$fr_version ? { 2 => modules, 3 => mods-enabled, default => modules }/attr_filter' ) is_expected.to contain_concat__fragment('attr-test') .with_content(%r{^attr_filter filter.test {\n\s+key = "\%{User-Name}"\n\s+filename = \${modconfdir}/\${\.:name}/test\n}}) .with_order('20') .with_target('/etc/raddb/mods-available/attr_filter') end end
spec/defines/blank_spec.rb +14 −34 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::blank' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } let(:params) { {} } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/XXreplace_meXX') .with( 'content' => '# This file is intentionally left blank to reduce complexity. Blanking it but leaving it present is safer than deleting it, since the package manager will replace some files if they are deleted, leading to unexpected behaviour!', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0644', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[File[$fr_basepath], Package[$fr_package], Group[$fr_group]]' ) is_expected.to contain_file('/etc/raddb/test') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_content(%r{^# This file is intentionally left blank .*}) .with_group('radiusd') .with_mode('0644') .with_owner('root') end end
spec/defines/cert_spec.rb +49 −41 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::cert' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} context 'with type set to key' do let(:params) do { type: 'key', content: 'test data', } end it do is_expected.to contain_file('/etc/raddb/certs/test') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb/certs]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_content(%r{test data}) .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .with_show_diff('false') .with_source(nil) end end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value context 'with type set to cert and with source' do let(:params) do { #:source => undef, #:content => undef, #:type => "key", #:ensure => present, type: 'cert', source: 'puppet:///modules/test/path/to/cert', content: :undef, } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/certs/XXreplace_meXX') .with( 'content' => 'undef', 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '$type ? { key => 0640, cert => 0644, default => 0644 }', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[File[$fr_basepath/certs], Package[$fr_package], Group[$fr_group]]', 'show_diff' => 'false', 'source' => 'undef' ) is_expected.to contain_file('/etc/raddb/certs/test') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb/certs]') .that_requires('Group[radiusd]') .that_requires('Package[freeradius]') .with_content(nil) .with_ensure('present') .with_group('radiusd') .with_mode('0644') .with_owner('root') .with_show_diff('false') .with_source('puppet:///modules/test/path/to/cert') end end end
spec/defines/client_spec.rb +16 −43 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::client' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { :shortname => 'place_value_here', :secret => 'place_value_here', #:ip => undef, #:ip6 => undef, #:virtual_server => undef, #:nastype => undef, #:netmask => undef, #:redirect => undef, #:port => undef, #:srcip => undef, #:firewall => false, #:ensure => present, :shortname => 'test_short', :secret => 'secret_value', :ip => '1.2.3.4', } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/clients.d/.conf') .with( 'content' => 'template(freeradius/client.conf.fr$fr_version.erb)', 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0640', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[File[$fr_basepath/clients.d], Group[$fr_group]]' ) is_expected.to contain_file('/etc/raddb/clients.d/test_short.conf') .with_content(%r{^client test_short {\n\s+ipaddr = 1.2.3.4\n\s+proto = \*\n\s+shortname = test_short\n\s+secret = "secret_value"\n\s+require_message_authenticator = no\n}\n}) .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .that_notifies('Service[radiusd]') .that_requires('File[/etc/raddb/clients.d]') .that_requires('Group[radiusd]') end end
spec/defines/config_spec.rb +15 −35 Original line number Diff line number Diff line require 'spec_helper' require 'shared_contexts' describe 'freeradius::config' do # by default the hiera integration uses hiera data from the shared_contexts.rb file # but basically to mock hiera you first need to add a key/value pair # to the specific context in the spec/shared_contexts.rb file # Note: you can only use a single hiera context per describe/context block # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera include_context 'redhat_common_dependencies' let(:title) { 'XXreplace_meXX' } let(:title) { 'test' } # below is the facts hash that gives you the ability to mock # facts on a per describe/context block. If you use a fact in your # manifest you should mock the facts below. let(:facts) do {} end # below is a list of the resource parameters that you can override. # By default all non-required parameters are commented out, # while all required parameters will require you to add a value let(:params) do { #:source => undef, #:content => undef, #:ensure => present, :content => 'test content', } end # add these two lines in a single test block to enable puppet and hiera debug mode # Puppet::Util::Log.level = :debug # Puppet::Util::Log.newdestination(:console) it do is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/$fr_version ? { 2 => conf.d, 3 => mods-config, default => conf.d }/XXreplace_meXX') .with( 'content' => 'undef', 'ensure' => 'present', 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', 'mode' => '0640', 'notify' => 'Service[$fr_service]', 'owner' => 'root', 'require' => '[Package[$fr_package], Group[$fr_group]]', 'source' => 'undef' ) is_expected.to contain_file('/etc/raddb/mods-config/test') .with_content('test content') .with_ensure('present') .with_group('radiusd') .with_mode('0640') .with_owner('root') .with_source(nil) .that_notifies('Service[radiusd]') .that_requires('Package[freeradius]') .that_requires('Group[radiusd]') end end