Commit d2d902dc authored by Nathan Ward's avatar Nathan Ward
Browse files

Update tests for all defines as part of testing rework

parent 7f90367f
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) { 'test' }
let(:title) { 'XXreplace_meXX' }
# 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
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) { 'test' }
let(:params) { {} }
let(:title) { 'XXreplace_meXX' }
# 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
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' }
# 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,
#:type => "key",
#:ensure => present,
}
let(:title) { 'test' }
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
# 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'
)
context 'with type set to cert and with source' do
let(:params) do
{
type: 'cert',
source: 'puppet:///modules/test/path/to/cert',
content: :undef,
}
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(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
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) { 'test' }
let(:title) { 'XXreplace_meXX' }
# 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
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) { 'test' }
let(:title) { 'XXreplace_meXX' }
# 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
require 'spec_helper'
require 'shared_contexts'
describe 'freeradius::dictionary' 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) { 'test' }
let(:title) { 'XXreplace_meXX' }
# 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',
#:order => 50,
#:ensure => present,
:source => 'puppet:///modules/test/path/to/dict',
}
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 }/dictionary.d/dictionary.XXreplace_meXX')
.with(
'ensure' => 'present',
'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }',
'mode' => '0644',
'notify' => 'Service[$fr_service]',
'owner' => 'root',
'require' => '[File[$fr_basepath/dictionary.d], Package[$fr_package], Group[$fr_group]]',
'source' => ''
)
is_expected.to contain_file('/etc/raddb/dictionary.d/dictionary.test')
.with_ensure('present')
.with_group('radiusd')
.with_mode('0644')
.with_owner('root')
.with_source('puppet:///modules/test/path/to/dict')
.that_notifies('Service[radiusd]')
.that_requires('File[/etc/raddb/dictionary.d]')
.that_requires('Package[freeradius]')
.that_requires('Group[radiusd]')
end
it do
is_expected.to contain_concat__fragment('dictionary.XXreplace_meXX')
.with(
'content' => '$INCLUDE $::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/dictionary.d/dictionary.XXreplace_meXX\\n',
'order' => '50',
'require' => 'File[$fr_basepath/dictionary.d/dictionary.$name]',
'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/dictionary'
)
is_expected.to contain_concat__fragment('dictionary.test')
.with_content(%r{^\$INCLUDE /etc/raddb/dictionary\.d/dictionary\.test$})
.with_order('50')
.with_target('/etc/raddb/dictionary')
.that_requires('File[/etc/raddb/dictionary.d/dictionary.test]')
end
end
require 'spec_helper'
require 'shared_contexts'
describe 'freeradius::home_server_pool' 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) { 'test' }
let(:title) { 'XXreplace_meXX' }
# 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
{
:home_server => 'place_value_here',
#:type => "fail-over",
#:virtual_server => "",
#:fallback => "",
:home_server => [
'test_home_server_1',
'test_home_server_2',
],
}
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_concat__fragment('homeserverpool-XXreplace_meXX')
.with(
'content' => 'template(freeradius/home_server_pool.erb)',
'order' => '20',
'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/proxy.conf'
)
is_expected.to contain_concat__fragment('homeserverpool-test')
.with_content(%r{home_server_pool test {\n\s+type = fail-over\n\s+home_server = test_home_server_1\n\s+home_server = test_home_server_2\n}\n})
.with_order('20')
.with_target('/etc/raddb/proxy.conf')
end
end
require 'spec_helper'
require 'shared_contexts'
describe 'freeradius::home_server' 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) { 'test' }
let(:title) { 'XXreplace_meXX' }
# 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
{
:secret => 'place_value_here',
#:type => "auth",
#:ipaddr => "",
#:ipv6addr => "",
#:virtual_server => "",
#:port => 1812,
#:proto => "udp",
:secret => 'test_secret',
:ipaddr => '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_concat__fragment('homeserver-XXreplace_meXX')
.with(
'content' => 'template(freeradius/home_server.erb)',
'order' => '10',
'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/proxy.conf'
)
is_expected.to contain_concat__fragment('homeserver-test')
.with_content(%r{home_server test {\n\s+type = auth\n\s+ipaddr = 1.2.3.4\n\s+port = 1812\n\s+proto = udp\n\s+secret = test_secret\n\s+status_check = none\n}\n})
.with_order('10')
.with_target('/etc/raddb/proxy.conf')
end
end
require 'spec_helper'
require 'shared_contexts'
describe 'freeradius::instantiate' 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) { 'test' }
let(:params) { {} }
let(:title) { 'XXreplace_meXX' }
# 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
{
#:ensure => present,
}
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 }/instantiate/XXreplace_meXX')
.with(
'content' => 'XXreplace_meXX',
'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]]'
)
is_expected.to contain_file('/etc/raddb/instantiate/test')
.with_content('test')
.with_ensure('present')
.with_group('radiusd')
.with_mode('0640')
.with_owner('root')
.that_notifies('Service[radiusd]')
.that_requires('Package[freeradius]')
.that_requires('Group[radiusd]')
end
end
require 'spec_helper'
require 'shared_contexts'
describe 'freeradius::krb5' do
# by default the hiera integration uses hiera data from the shared_contexts.rb file