diff --git a/.fixtures.yml b/.fixtures.yml index d9e7c4936961c43eca7865ae018e5780530f2852..0dd95a29e21b0477d0ef7cfa603435a2084f51ef 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,6 @@ fixtures: symlinks: - freeradius: "#{source_dir}" + puppet-freeradius: "#{source_dir}" repositories: stdlib: repo: https://github.com/puppetlabs/puppetlabs-stdlib.git diff --git a/.gitignore b/.gitignore index 846ab72a20f6b1d35ca0d6772f8ce841a2baee30..daa07517f8670d2c51f50654aa4af0bd48793f25 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ -*.swp -pkg/ -spec/fixures/ -.gemfile.lock +.*.sw? +pkg +spec/fixtures +.rspec_system +.vagrant +.bundle +vendor +.idea +.project +.DS_Store + diff --git a/.puppet-lint.rc b/.puppet-lint.rc index a37b48e66f16e6f520973765eab7e6e1c0f3712a..dc3a48fae39b7cc69aec01c9fe94aa9e47ebc3a6 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -3,6 +3,53 @@ # refer to <http://puppet-lint.com/checks/>. # Examples (uncomment before use): + +# spacing, indentation and whitespace +#--no-2sp_soft_tabs-check +#--no-hard_tabs-check +#--no-trailing_whitespace-check #--no-80chars-check +#--no-arrow_alignment-check + +# comments +#--no-slash_comments-check +#--no-star_comments-check + +# quoting +#--no-double_quoted_strings-check +#--no-variables_not_enclosed-check +#--no-only_variable_string-check +#--no-single_quote_string_with_variables-check +#--no-quoted_booleans-check +#--no-puppet_url_without_modules-check + +# resources +#--no-unquoted_resource_title-check +#--no-ensure_first_param-check +#--no-ensure_not_symlink_target-check +#--no-file_mode-check +#--no-unquoted_file_mode-check +#--no-duplicate_params-check + +# conditionals +#--no-selector_inside_resource-check +#--no-case_without_default-check + +# classes #--no-class_inherits_from_params_class-check +#--no-autoloader_layout-check +#--no-right_to_left_relationship-check +#--no-nested_classes_or_defines-check #--no-inherits_across_namespaces-check +#--no-variable_scope-check +#--no-variable_contains_dash-check +#--no-parameter_order-check +#--no-names_containing_dash-check + +# documentation +#--no-documentation-check + +# nodes +#--no-unquoted_node_name-check + +# For more controls please see http://puppet-lint.com/plugins/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0cd1a18d10324716a737ffd53e8fa0b3cff9a1..c8aed7d6140da3c3085b4168f8115f70b8a3c0be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,247 +1,18 @@ -## Changelog +## Release 0.0.1 +### Summary -### 3.6.0 - * Add support for Debian 9 (thanks @its-not-a-bug-its-a-feature) +Adds several new features and updates -### 3.5.0 - * Add support for huntgroups (thanks @sts and @phaer) +### Features +- Deprecation function X in favor of Y. +- Updated Gemfile to deal with parallel_tests Ruby dependancy -### 3.4.3 - * Fix missing notify that caused problems when adding a new virtual server in `sites_available` +### Bugfixes +- README typo fixes. +- Updates deprecation tests to include future parser. -### 3.4.1 - * Fix calling syntax for logrotate - * Add param `package_ensure` - -### 3.4.0 - * Fix bug with modules that have ensure => absent - * Fix bug with module::files where content and source - * Fix bug with path of krb5 module - * Manage parameter `allow_expired_crl` - * Clean up comments in templates to reduce the size - -### 3.3.0 - * Deploy modules to `mods_available` and symlink to `mods_enabled` - * Deploy modules to `sites_available` and symlink to `sites_enabled` - -### 3.2.0 - * Warn instead of failing if the FR version is not 3.x - * Update logrotate module dependency - * Add PostgreSQL support - * Fix bug with templating home servers in Puppet 4 - * Fix bug with logrotate postrotate on non Red Hat distros - -### 3.1.0 - * Provide facility to enable/disable specific EAP types in `freeradius::module::eap` - -### 3.0.0 - * More parameters available for `freeradius::client` - * Allow management of `freeradius::dictionary` with `source` or `content` - * Enable status checks for `freeradius::home_server` - * More configurable options for `freeradius` base class - * More sensible permissions on various config files - * Refactor `freeradius::ldap` as `freeradius::module::ldap` and add more params - * Create `freeradius::listen` to manage arbitrary listeners - * Create `freeradius::module::detail` to configure detail loggers - * Create `freeradius::module::eap` to manage instantiations of the `eap` module - * Create `freeradius::module::files` to manage instantiations of the `files` module - * Create `freeradius::module::huntgroup` to manage huntgroups - * Create `freeradius::module::ippool` to manage ippool resources - * Create `freeradius::module::linelog` to configure linelog loggers - * Create `freeradius::module::preprocess` to manage instantiations of the `preprocess` module - * Fix some compatibility problems with Debian/Ubuntu systems - * Allow `freeradius::site` resources (virtual servers) to have their content managed other than just with flat files - * Add more options to `freeradius::sql` - * Add various types of validation for Puppet 4 - -### 2.3.1 - * Fix bug with log rotation throwing errors when radiusd is not running - -### 2.3.0 - * Add support to configure virtual modules for fail-over and load-balancing - -### 2.2.0 - * Add support to configure the krb5 module - -### 2.1.4 - * Fix compatibility with Puppet 4 - -### 2.1.3 - * Fix compatibility with Puppet 4 - -### 2.1.2 - * Write out ldap config with different syntax for FreeRADIUS 3.0.x and 3.1.x when using multiple servers - -### 2.1.1 - - * Fix bug with the facts not reporting version numbers accurately - -### 2.1.0 - - * Various changes to preserve stock modules in a FreeRADIUS installation and be able to toggle them - -### 2.0.1 - - * Fix up LDAP template to allow better compatibility with FreeRADIUS 3.1.x - -### 2.0.0 - - * Drop support for FreeRADIUS 2.x, enabling us to keep the codebase tidier - -### 1.3.0 - - * Add support for defining config templates - -### 1.2.6 - - * Fix a bug that now enables sqltrace (sqllog) to work on FR3 - -### 1.2.5 - - * Switch to use [saz/rsyslog](https://forge.puppetlabs.com/saz/rsyslog) to manage syslog rules - -### 1.2.4 - - * Start with just 1 SQL socket by default to avoid overloading the SQL server - -### 1.2.3 - - * Make facts fail gracefully if radiusd is not installed - -### 1.2.2 - - * Fix a bug that stops statusclients from working - -### 1.2.1 - - * Fix a bug that prevent 1.2.0 from working on FreeRADIUS 2 - -### 1.2.0 - - * Deprecate `netmask` parameter from `freeradius::client` - -### 1.1.0 - - * Add support to supply an array of multiple LDAP servers - -### 1.0.4 - - * Make an educated guess about the version of FR when the fact is unavailable (e.g. on the first Puppet run) - -### 1.0.3 - - * Iron out a couple of issues with LDAP compatibility with Active Directory - -### 1.0.2 - - * Fixed a bug that prevented LDAP from working on any port except 389 - -### 1.0.1 - - * Fixed a bug that caused an error when no proxy config items were defined - -### 1.0.0 - - * Support for FreeRADIUS 3 - * Native support for managing the LDAP module - * Native support for configuring realms (via realms, home_server and home_server_pool) - * Improved handling of attribute filtering - * Improved handling of SQL support - -This release retains support for FreeRADIUS 2 but some of the parameters have changed so you will probably need to make changes to the way you use this module. Upgrade on a dev system first! - -### 0.4.5 - - * Tweak wildcard matching on logrotate config - -### 0.4.4 - - * Fix bug displaying deprecation notice and update documentation to reflect this - -### 0.4.3 - - * Manage log rotation with [rodjek/logrotate](https://forge.puppetlabs.com/rodjek/logrotate) instead of deploying flat files - -### 0.4.2 - - * Provide new SQL option custom_query_file - -### 0.4.1 - - * Cease management of custom logging modules `logtofile` and `logtosyslog` since it does not make sense to manage these globally - * Purge instantiation of unused modules - -### 0.4.0 - - * Move control_socket into its own class and add parameters - * Improve the way the status_server is added or removed - * Delete all unmanaged sites from sites-available - -### 0.3.8 - - * Purge all non-managed sites - -### 0.3.7 - - * Minor linting of code to improve score - * Minor linting of metadata to improve score - -### 0.3.6 - - * Bugfixes and feature improvements in `freeradius::sql` - -### 0.3.5 - - * Add ability to customise SQL socket lifetimes - * Purge all non-managed clients - * Add defined type to blank out unneeded config files without deleting them - -### 0.3.4 - - * Correctly pass template content to control-socket - -### 0.3.3 - - * The default behaviour is now to purge anything in ${confdir}/certs that is not managed by Puppet - -### 0.3.2 - - * Various improvements to support Debian family - * Optional content parameters in various resources - -### 0.3.1 - - * Fix a bug which prevents the module from working properly on Debian/Ubuntu (thanks @diranged) - -### 0.3.0 - - * Add `ensure` parameter to all defined types - -### 0.2.0 - - * Add support for customising `sql.conf` natively by adding `freeradius::sql` - -### 0.1.4 - - * Fix ambiguity about net/netmask in freeradius::client - -### 0.1.3 - - * Add support for managing firewall rules automatically - * Add support for installation certificates & keys - * Make syslog support an optional component - * Various bugfixes - -### 0.1.2 - - * Improved modular installs with optional components - * Improved support for Debian - * Clarify dependencies on other modules - * Lots of bugfixes - -### 0.1.0 - - * Initial release with support for installing FreeRADIUS and configuring servers, modules, clients and other objects using flat files. - * Probably works only with FreeRADIUS 2.x - * Only tested with CentOS 6 +This changelog is used track changes with this module in human readable format. +Feel free to reference tickets with links or other important information the +reader would find useful when determining the level of risk with upgrading. +For more information on changelogs please [see the keeping a changelog site](http://keepachangelog.com/en/0.3.0/). \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100755 index 0000000000000000000000000000000000000000..942bf5adc43b2ffbf4484dc264a2c3b4fe1bf36b --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,75 @@ +# module name + +## Module development setup + +Install all the require gems to run test code +```shell +bundle install (only need to do once) + +``` +## Running Tests + +### Unit tests +This type of testing is fast and should be the first thing you do before committing your code. Mistakes can be found +in a matter of seconds vs minutes/hours. You can test your logic in a unit test. The downside is you need to learn +how to write unit tests which can take some initial time getting used to. + +```shell +bundle exec rake spec + +``` + +### Integration Testing +This type of testing is somewhat manual and requires the use of vagrant and a test vm that is controlled by vagrant. +You can find the list of available test vms by running `vagrant status` in the root of the module directory. There is +at lot of magic happening in the vagrantfile that makes this easy. Windows support with this module has not been added yet. + +```shell + +$ vagrant status +Current machine states: + +win2012r2 not created (vmware_fusion) +win2008r2 not created (vmware_fusion) +centos6 running (vmware_fusion) +``` + +To run a test first you need to define the test code located in module_root/tests directory. This code is nothing more +than a bunch of puppet code that uses your manifest code. You will be using puppet apply to run this code on the vm. +Have a look inside the tests directory for examples. + +Example test file +``` +include profiles::default_linux +file{'/tmp/test.txt': + ensure => file, + content => 'Hello World' +} +``` + +There are a few ways to run the test code against a test vm, both of which have the same outcome. + +```shell +bundle exec rake spec_prep +VAGRANT_MANIFEST=linux.pp vagrant provision centos6 +``` + +or use the rake command which bundles the two commands together + +```shell +bundle exec rake "vagrant_up[linux.pp,centos6]" +``` + +### Acceptance Tests +Acceptance testing is sorta like combining unit testing and integration testing where it tests the code on real systems +automatically across a wide range of operating systems. This is an advanced topic, so you will want to master unit and +integration testing first before writing acceptance tests. + +```shell +bundle exec rake beaker + +``` + + +## CI config doc +https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md diff --git a/Gemfile b/Gemfile index 64c93492a981e477d0b53817f5af2c60c33c7b47..c7f56a31f4bf4f29dd239d69c810b42094efe564 100644 --- a/Gemfile +++ b/Gemfile @@ -2,19 +2,20 @@ source "https://rubygems.org" group :test do gem "rake" - gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.8.3' - gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' + gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 3.8.3' + gem "rspec-puppet" gem "puppetlabs_spec_helper" - gem 'rspec-puppet-utils', :git => 'https://github.com/Accuity/rspec-puppet-utils.git' + gem 'rspec-puppet-utils' gem 'hiera-puppet-helper', :git => 'https://github.com/bobtfish/hiera-puppet-helper.git' gem "metadata-json-lint" gem 'puppet-syntax' gem 'puppet-lint' end +# to disable installing the 50+ gems this group contains run : bundle install --without integration group :integration do - gem "beaker", :git => 'https://github.com/puppetlabs/beaker.git' - gem "beaker-rspec", :git => 'https://github.com/puppetlabs/beaker-rspec.git' + gem "beaker" + gem "beaker-rspec" gem "vagrant-wrapper" gem 'serverspec' end @@ -23,5 +24,7 @@ group :development do gem "travis" gem "travis-lint" gem "puppet-blacksmith" - gem "guard-rake" + gem 'puppet-debugger' +# This gem causes bundler install erorrs +# gem "guard-rake" end diff --git a/Rakefile b/Rakefile index cb628a0ac9a07df26fdb34c28cd42dce57f16d51..b1b0035a882ce988e8f61b57bc0819cda2bfd88e 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ end PuppetLint.configuration.relative = true PuppetLint.configuration.send("disable_80chars") -PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" +PuppetLint.configuration.log_format = "%{path}:%{line}:%{check}:%{KIND}:%{message}" PuppetLint.configuration.fail_on_warnings = true # Forsake support for Puppet 2.6.2 for the benefit of cleaner code. diff --git a/files/.gitkeep b/files/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/spec/classes/control_socket_spec.rb b/spec/classes/control_socket_spec.rb index cde5609de791a4e6d4c4c9a3fe858fb4ee39dea8..41929d6c606597e9ec16801e9c6038b4c5d7bb85 100644 --- a/spec/classes/control_socket_spec.rb +++ b/spec/classes/control_socket_spec.rb @@ -9,28 +9,28 @@ describe 'freeradius::control_socket' do # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera - # 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 { - #:mode => "ro", + # mode: "ro", } 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_freeradius__site('control-socket') - .with( - 'content' => 'template(freeradius/sites-enabled/control-socket.erb)' - ) + is_expected.to contain_freeradius__site('control-socket').with( + content: [], + ) end end diff --git a/spec/classes/freeradius_spec.rb b/spec/classes/freeradius_spec.rb index dd67be91b6304f60a3e18b647daf1481be8518a6..4e5bf15c5f96cdc21b46fbb633050e1c61743186 100644 --- a/spec/classes/freeradius_spec.rb +++ b/spec/classes/freeradius_spec.rb @@ -9,365 +9,426 @@ describe 'freeradius' do # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera - # 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 { - #:control_socket => false, - #:max_servers => "4096", - #:max_requests => "4096", - #:mysql_support => false, - #:perl_support => false, - #:utils_support => false, - #:ldap_support => false, - #:krb5_support => false, - #:wpa_supplicant => false, - #:winbind_support => false, - #:syslog => false, - #:log_auth => 'no', + # control_socket: false, + # max_servers: "4096", + # max_requests: "4096", + # mysql_support: false, + # pgsql_support: false, + # perl_support: false, + # utils_support: false, + # ldap_support: false, + # dhcp_support: false, + # krb5_support: false, + # wpa_supplicant: false, + # winbind_support: false, + # log_destination: "files", + # syslog: false, + # log_auth: "no", + # preserve_mods: true, + # correct_escapes: true, + # manage_logpath: true, + # package_ensure: "installed", + # radacctdir: "$freeradius::params::radacctdir", } 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_notify('This module is only compatible with FreeRADIUS 3.') + end + it do - is_expected.to contain_file('radiusd.conf') - .with( - 'content' => 'template(freeradius/radiusd.conf.fr$freeradius::fr_version.erb)', - 'group' => '$freeradius::fr_group', - 'mode' => '0640', - 'name' => '$freeradius::fr_basepath/radiusd.conf', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_file('[$freeradius::fr_basepath/statusclients.d, $freeradius::fr_basepath, $freeradius::fr_basepath/conf.d, $freeradius::fr_basepath/attr.d, $freeradius::fr_basepath/users.d, $freeradius::fr_basepath/policy.d, $freeradius::fr_basepath/dictionary.d, $freeradius::fr_basepath/scripts]') - .with( - 'ensure' => 'directory', - 'group' => '$freeradius::fr_group', - 'mode' => '0750', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_file('[$freeradius::fr_basepath/certs, $freeradius::fr_basepath/clients.d, $freeradius::fr_basepath/sites-enabled, $freeradius::fr_basepath/sites-available, $freeradius::fr_basepath/instantiate]') - .with( - 'ensure' => 'directory', - 'group' => '$freeradius::fr_group', - 'mode' => '0750', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'purge' => 'true', - 'recurse' => 'true', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_freeradius__module('eap') - .with( - 'ensure' => 'absent' - ) - end - it do - is_expected.to contain_concat('$freeradius::fr_basepath/policy.conf') - .with( - 'group' => '$freeradius::fr_group', - 'mode' => '0640', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_concat__fragment('policy_header') - .with( - 'content' => 'policy {\\n', - 'order' => '10', - 'target' => '$freeradius::fr_basepath/policy.conf' - ) - end - it do - is_expected.to contain_concat__fragment('policy_footer') - .with( - 'content' => '}\\n', - 'order' => '99', - 'target' => '$freeradius::fr_basepath/policy.conf' - ) - end - it do - is_expected.to contain_concat('$freeradius::fr_basepath/proxy.conf') - .with( - 'group' => '$freeradius::fr_group', - 'mode' => '0640', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_concat__fragment('proxy_header') - .with( - 'content' => '# Proxy config\\n\\n', - 'order' => '05', - 'target' => '$freeradius::fr_basepath/proxy.conf' - ) - end - it do - is_expected.to contain_concat('$freeradius::fr_modulepath/attr_filter') - .with( - 'group' => '$freeradius::fr_group', - 'mode' => '0640', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_concat__fragment('attr-default') - .with( - 'content' => 'template(freeradius/attr_default.fr$freeradius::fr_version.erb)', - 'order' => '10', - 'target' => '$freeradius::fr_modulepath/attr_filter' - ) - end - it do - is_expected.to contain_concat('$freeradius::fr_basepath/dictionary') - .with( - 'group' => '$freeradius::fr_group', - 'mode' => '0640', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_concat__fragment('dictionary_header') - .with( - 'order' => '10', - 'source' => 'puppet:///modules/freeradius/dictionary.header', - 'target' => '$freeradius::fr_basepath/dictionary' - ) - end - it do - is_expected.to contain_concat__fragment('dictionary_footer') - .with( - 'order' => '90', - 'source' => 'puppet:///modules/freeradius/dictionary.footer', - 'target' => '$freeradius::fr_basepath/dictionary' - ) - end - it do - is_expected.to contain_package('freeradius') - .with( - 'ensure' => 'installed', - 'name' => '$freeradius::fr_package' - ) - end - it do - is_expected.to contain_service('$freeradius::fr_service') - .with( - 'enable' => 'true', - 'ensure' => 'running', - 'hasrestart' => 'true', - 'hasstatus' => '$freeradius::fr_service_has_status', - 'name' => '$freeradius::fr_service', - 'require' => '[Exec[radiusd-config-test], File[radiusd.conf], User[$freeradius::fr_user], Package[$freeradius::fr_package]]' - ) - end - it do - is_expected.to contain_user('$freeradius::fr_user') - .with( - 'ensure' => 'present', - 'groups' => '$winbind_support ? { true => $freeradius::fr_wbpriv_user, default => undef }', - 'require' => 'Package[$freeradius::fr_package]' - ) - end - it do - is_expected.to contain_group('$freeradius::fr_group') - .with( - 'ensure' => 'present', - 'require' => 'Package[$freeradius::fr_package]' - ) - end - it do - is_expected.to contain_freeradius__module('always') - .with( ) - end - it do - is_expected.to contain_freeradius__module('detail') - .with( ) - end - it do - is_expected.to contain_freeradius__module('detail.log') - .with( ) - end - it do - is_expected.to contain_file('[$freeradius::fr_logpath, $freeradius::fr_logpath/radacct]') - .with( - 'mode' => '0750', - 'require' => 'Package[$freeradius::fr_package]' - ) - end - it do - is_expected.to contain_file('$freeradius::fr_logpath/radius.log') - .with( - 'group' => '$freeradius::fr_group', - 'owner' => '$freeradius::fr_user', - 'require' => '[Package[$freeradius::fr_package], User[$freeradius::fr_user], Group[$freeradius::fr_group]]', - 'seltype' => 'radiusd_log_t' - ) + is_expected.to contain_file('radiusd.conf').with( + name: '$freeradius::fr_basepath/radiusd.conf', + mode: '0644', + owner: 'root', + group: '$freeradius::fr_group', + content: [], + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) end + it do - is_expected.to contain_logrotate__rule('radacct') - .with( - 'compress' => 'true', - 'create' => 'false', - 'missingok' => 'true', - 'path' => '$freeradius::fr_logpath/radacct/*/*.log', - 'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`', - 'rotate' => '7', - 'rotate_every' => 'day', - 'sharedscripts' => 'true' - ) + is_expected.to contain_file(['$freeradius::fr_basepath/statusclients.d', '$freeradius::fr_basepath', '$freeradius::fr_basepath/conf.d', '$freeradius::fr_basepath/attr.d', '$freeradius::fr_basepath/users.d', '$freeradius::fr_basepath/policy.d', '$freeradius::fr_basepath/dictionary.d', '$freeradius::fr_basepath/scripts']).with( + ensure: 'directory', + mode: '0755', + owner: 'root', + group: '$freeradius::fr_group', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) end + it do - is_expected.to contain_logrotate__rule('checkrad') - .with( - 'compress' => 'true', - 'create' => 'true', - 'missingok' => 'true', - 'path' => '$freeradius::fr_logpath/checkrad.log', - 'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`', - 'rotate' => '1', - 'rotate_every' => 'week', - 'sharedscripts' => 'true' - ) + is_expected.to contain_file(['$freeradius::fr_basepath/certs', '$freeradius::fr_basepath/clients.d', '$freeradius::fr_basepath/listen.d', '$freeradius::fr_basepath/sites-enabled', '$freeradius::fr_basepath/mods-enabled', '$freeradius::fr_basepath/instantiate']).with( + ensure: 'directory', + purge: true, + recurse: true, + mode: '0755', + owner: 'root', + group: '$freeradius::fr_group', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) end + it do - is_expected.to contain_logrotate__rule('radiusd') - .with( - 'compress' => 'true', - 'create' => 'true', - 'missingok' => 'true', - 'path' => '$freeradius::fr_logpath/radius*.log', - 'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`', - 'rotate' => '26', - 'rotate_every' => 'week', - 'sharedscripts' => 'true' - ) + is_expected.to contain_freeradius__module(['always', 'cache_eap', 'chap', 'detail', 'detail.log', 'digest', 'dynamic_clients', 'echo', 'exec', 'expiration', 'expr', 'files', 'linelog', 'logintime', 'mschap', 'ntlm_auth', 'pap', 'passwd', 'preprocess', 'radutmp', 'realm', 'replicate', 'soh', 'sradutmp', 'unix', 'unpack', 'utf8']).with( + preserve: true, + ) end + it do - is_expected.to contain_file('[$freeradius::fr_basepath/certs/dh, $freeradius::fr_basepath/certs/random]') - .with( - 'require' => 'Exec[dh, random]' - ) + is_expected.to contain_concat('$freeradius::fr_basepath/policy.conf').with( + owner: 'root', + group: '$freeradius::fr_group', + mode: '0640', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) end + it do - is_expected.to contain_exec('dh') - .with( - 'command' => 'openssl dhparam -out $freeradius::fr_basepath/certs/dh 1024', - 'creates' => '$freeradius::fr_basepath/certs/dh', - 'path' => '/usr/bin' - ) + is_expected.to contain_concat__fragment('policy_header').with( + target: '$freeradius::fr_basepath/policy.conf', + content: 'policy {\n', + order: '10', + ) end + it do - is_expected.to contain_exec('random') - .with( - 'command' => 'dd if=/dev/urandom of=$freeradius::fr_basepath/certs/random count=10 >/dev/null 2>&1', - 'creates' => '$freeradius::fr_basepath/certs/random', - 'path' => '/bin' - ) + is_expected.to contain_concat__fragment('policy_footer').with( + target: '$freeradius::fr_basepath/policy.conf', + content: '}\n', + order: '99', + ) end + it do - is_expected.to contain_exec('radiusd-config-test') - .with( - 'command' => 'sudo radiusd -XC | grep 'Configuration appears to be OK.' | wc -l', - 'logoutput' => 'on_failure', - 'path' => '[/bin/, /sbin/, /usr/bin/, /usr/sbin/]', - 'refreshonly' => 'true', - 'returns' => '0' - ) + is_expected.to contain_concat('$freeradius::fr_basepath/templates.conf').with( + owner: 'root', + group: '$freeradius::fr_group', + mode: '0640', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) end + it do - is_expected.to contain_file('[$freeradius::fr_basepath/sites-available/default, $freeradius::fr_basepath/sites-available/inner-tunnel, $freeradius::fr_basepath/clients.conf, $freeradius::fr_basepath/sql.conf]') - .with( - 'content' => '# FILE INTENTIONALLY BLANK\\n', - 'group' => '$freeradius::fr_group', - 'mode' => '0644', - 'notify' => 'Service[$freeradius::fr_service]', - 'owner' => 'root', - 'require' => '[Package[$freeradius::fr_package], Group[$freeradius::fr_group]]' - ) - end - it do - is_expected.to contain_package('freeradius-mysql') - .with( - 'ensure' => 'installed' - ) - end - it do - is_expected.to contain_package('freeradius-perl') - .with( - 'ensure' => 'installed' - ) - end - it do - is_expected.to contain_package('freeradius-utils') - .with( - 'ensure' => 'installed' - ) - end - it do - is_expected.to contain_package('freeradius-ldap') - .with( - 'ensure' => 'installed' - ) - end - it do - is_expected.to contain_package('freeradius-krb5') - .with( - 'ensure' => 'installed' - ) + is_expected.to contain_concat__fragment('template_header').with( + target: '$freeradius::fr_basepath/templates.conf', + source: 'puppet:///modules/freeradius/template.header', + order: '05', + ) end + it do - is_expected.to contain_package('wpa_supplicant') - .with( - 'ensure' => 'installed', - 'name' => '$freeradius::fr_wpa_supplicant' - ) + is_expected.to contain_concat__fragment('template_footer').with( + target: '$freeradius::fr_basepath/templates.conf', + content: '}\n', + order: '95', + ) end + it do - is_expected.to contain_syslog__rule('radiusd-log') - .with( - 'command' => 'if $programname == 'radiusd' then $freeradius::fr_logpath/radius.log\\n&~', - 'order' => '12' - ) + is_expected.to contain_concat('$freeradius::fr_basepath/proxy.conf').with( + owner: 'root', + group: '$freeradius::fr_group', + mode: '0640', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) end + + it do + is_expected.to contain_concat__fragment('proxy_header').with( + target: '$freeradius::fr_basepath/proxy.conf', + content: '# Proxy config\n\n', + order: '05', + ) + end + + it do + is_expected.to contain_concat('$freeradius::fr_basepath/mods-available/attr_filter').with( + owner: 'root', + group: '$freeradius::fr_group', + mode: '0640', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) + end + it do - is_expected.to contain_exec('delete-radius-rpmnew') - .with( - 'command' => 'find $freeradius::fr_basepath -name *.rpmnew -delete', - 'onlyif' => 'find $freeradius::fr_basepath -name *.rpmnew | grep rpmnew', - 'path' => '[/bin/, /sbin/, /usr/bin/, /usr/sbin/]' - ) + is_expected.to contain_file('$freeradius::fr_modulepath/attr_filter').with( + ensure: 'link', + target: '../mods-available/attr_filter', + ) end + + it do + is_expected.to contain_concat__fragment('attr-default').with( + target: '$freeradius::fr_basepath/mods-available/attr_filter', + content: [], + order: '10', + ) + end + + it do + is_expected.to contain_concat('$freeradius::fr_basepath/dictionary').with( + owner: 'root', + group: '$freeradius::fr_group', + mode: '0640', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + ) + end + + it do + is_expected.to contain_concat__fragment('dictionary_header').with( + target: '$freeradius::fr_basepath/dictionary', + source: 'puppet:///modules/freeradius/dictionary.header', + order: '10', + ) + end + + it do + is_expected.to contain_concat__fragment('dictionary_footer').with( + target: '$freeradius::fr_basepath/dictionary', + source: 'puppet:///modules/freeradius/dictionary.footer', + order: '90', + ) + end + + it do + is_expected.to contain_concat('$freeradius::fr_basepath/mods-config/preprocess/huntgroups').with( + owner: 'root', + group: '$freeradius::fr_group', + mode: '0640', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + ) + end + + it do + is_expected.to contain_concat__fragment('huntgroups_header').with( + target: '$freeradius::fr_basepath/mods-config/preprocess/huntgroups', + source: 'puppet:///modules/freeradius/huntgroups.header', + order: '10', + ) + end + + it do + is_expected.to contain_package('freeradius').with( + ensure: 'installed', + name: '$freeradius::fr_package', + ) + end + + it do + is_expected.to contain_package('freeradius-mysql').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('freeradius-postgresql').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('freeradius-perl').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('freeradius-utils').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('freeradius-ldap').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('freeradius-dhcp').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('freeradius-krb5').with( + ensure: 'installed', + ) + end + + it do + is_expected.to contain_package('wpa_supplicant').with( + ensure: 'installed', + name: '$freeradius::fr_wpa_supplicant', + ) + end + + it do + is_expected.to contain_service('$freeradius::fr_service').with( + ensure: 'running', + name: '$freeradius::fr_service', + require: ['Exec[radiusd-config-test]', 'File[radiusd.conf]', 'User[$freeradius::fr_user]', 'Package[$freeradius::fr_package]'], + enable: true, + hasstatus: '$freeradius::fr_service_has_status', + hasrestart: true, + ) + end + + it do + is_expected.to contain_user('$freeradius::fr_user').with( + ensure: 'present', + groups: [], + require: 'Package[$freeradius::fr_package]', + ) + end + + it do + is_expected.to contain_group('$freeradius::fr_group').with( + ensure: 'present', + require: 'Package[$freeradius::fr_package]', + ) + end + + it do + is_expected.to contain_rsyslog__snippet('12-radiusd-log').with( + content: 'if $programname == 'radiusd' then $freeradius::fr_logpath/radius.log\n&~', + ) + end + + it do + is_expected.to contain_file(['$freeradius::fr_logpath', '$freeradius::fr_logpath/radacct']).with( + mode: '0750', + require: 'Package[$freeradius::fr_package]', + ) + end + + it do + is_expected.to contain_file('$freeradius::fr_logpath/radius.log').with( + owner: '$freeradius::fr_user', + group: '$freeradius::fr_group', + seltype: 'radiusd_log_t', + require: ['Package[$freeradius::fr_package]', 'User[$freeradius::fr_user]', 'Group[$freeradius::fr_group]'], + ) + end + + it do + is_expected.to contain_logrotate__rule('radacct').with( + path: '$freeradius::fr_logpath/radacct/*/*.log', + rotate_every: 'day', + rotate: '7', + create: nil, + missingok: true, + compress: true, + postrotate: 'kill -HUP `cat $freeradius::fr_pidfile`', + sharedscripts: true, + ) + end + + it do + is_expected.to contain_logrotate__rule('checkrad').with( + path: '$freeradius::fr_logpath/checkrad.log', + rotate_every: 'week', + rotate: '1', + create: true, + missingok: true, + compress: true, + postrotate: 'kill -HUP `cat $freeradius::fr_pidfile`', + sharedscripts: true, + ) + end + + it do + is_expected.to contain_logrotate__rule('radiusd').with( + path: '$freeradius::fr_logpath/radius*.log', + rotate_every: 'week', + rotate: '26', + create: true, + missingok: true, + compress: true, + postrotate: 'kill -HUP `cat $freeradius::fr_pidfile`', + sharedscripts: true, + ) + end + + it do + is_expected.to contain_file(['$freeradius::fr_basepath/certs/dh', '$freeradius::fr_basepath/certs/random']).with( + require: 'Exec[dh, random]', + ) + end + + it do + is_expected.to contain_exec('dh').with( + command: 'openssl dhparam -out $freeradius::fr_basepath/certs/dh 1024', + creates: '$freeradius::fr_basepath/certs/dh', + path: '/usr/bin', + ) + end + + it do + is_expected.to contain_exec('random').with( + command: 'dd if=/dev/urandom of=$freeradius::fr_basepath/certs/random count=10 >/dev/null 2>&1', + creates: '$freeradius::fr_basepath/certs/random', + path: '/bin', + ) + end + + it do + is_expected.to contain_exec('radiusd-config-test').with( + command: 'sudo radiusd -XC | grep 'Configuration appears to be OK.' | wc -l', + returns: '0', + refreshonly: true, + logoutput: 'on_failure', + path: ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'], + ) + end + + it do + is_expected.to contain_file(['$freeradius::fr_basepath/clients.conf', '$freeradius::fr_basepath/sql.conf']).with( + content: '# FILE INTENTIONALLY BLANK\n', + mode: '0644', + owner: 'root', + group: '$freeradius::fr_group', + require: ['Package[$freeradius::fr_package]', 'Group[$freeradius::fr_group]'], + notify: 'Service[$freeradius::fr_service]', + ) + end + + it do + is_expected.to contain_exec('delete-radius-rpmnew').with( + command: 'find $freeradius::fr_basepath -name *.rpmnew -delete', + onlyif: 'find $freeradius::fr_basepath -name *.rpmnew | grep rpmnew', + path: ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'], + ) + end + it do - is_expected.to contain_exec('delete-radius-rpmsave') - .with( - 'command' => 'find $freeradius::fr_basepath -name *.rpmsave -delete', - 'onlyif' => 'find $freeradius::fr_basepath -name *.rpmsave | grep rpmsave', - 'path' => '[/bin/, /sbin/, /usr/bin/, /usr/sbin/]' - ) + is_expected.to contain_exec('delete-radius-rpmsave').with( + command: 'find $freeradius::fr_basepath -name *.rpmsave -delete', + onlyif: 'find $freeradius::fr_basepath -name *.rpmsave | grep rpmsave', + path: ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'], + ) end end diff --git a/spec/classes/module/preprocess_spec.rb b/spec/classes/module/preprocess_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..e73c5ac69b487d2e62723a3ade3e21a79dd20ec0 --- /dev/null +++ b/spec/classes/module/preprocess_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::preprocess' 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 + + # 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", + # moddir: "${modconfdir}/${.:instance}", + # huntgroups: "${moddir}/huntgroups", + # hints: "${moddir}/hints", + # with_ascend_hack: "no", + # ascend_channels_per_line: "23", + # with_ntdomain_hack: "no", + # with_specialix_jetstream_hack: "no", + # with_cisco_vsa_hack: "no", + } + 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_freeradius__module('preprocess').with( + ensure: 'present', + content: [], + ) + end +end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index e6740c0870168570073ec26adab64369b12e7b08..a008bf8f6ce5ba663109fb1c47fa92139e8b01d0 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -9,13 +9,13 @@ describe 'freeradius::params' do # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera - # 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 diff --git a/spec/classes/status_server_spec.rb b/spec/classes/status_server_spec.rb index b676286eaea6f7756d0bd38c86b6f643123a6d03..0e4b39323af32919418b0c173da2e882c661658c 100644 --- a/spec/classes/status_server_spec.rb +++ b/spec/classes/status_server_spec.rb @@ -9,30 +9,29 @@ describe 'freeradius::status_server' do # rspec-puppet does not allow you to swap out hiera data on a per test block #include_context :hiera - # 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', - #:port => "18121", - #:listen => "*", + # port: "18121", + # listen: "*", } 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_freeradius__site('status') - .with( - 'content' => 'template(freeradius/sites-enabled/status.erb)' - ) + is_expected.to contain_freeradius__site('status').with( + content: [], + ) end end diff --git a/spec/defines/attr_spec.rb b/spec/defines/attr_spec.rb index cf4a92a88166b3d122d74613033f220729bf8784..11bf272baf71dd8d33766606eb3b8797e4241f7f 100644 --- a/spec/defines/attr_spec.rb +++ b/spec/defines/attr_spec.rb @@ -10,45 +10,48 @@ describe 'freeradius::attr' do #include_context :hiera 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: nil, + # ensure: "present", + # key: "User-Name", + # prefix: "filter", + } 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('$::freeradius::params::fr_moduleconfigpath/attr_filter/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) 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-$name').with( + target: '$::freeradius::params::fr_basepath/mods-available/attr_filter', + content: [], + order: '20', + ) end + end diff --git a/spec/defines/blank_spec.rb b/spec/defines/blank_spec.rb index 6883c8fa8133a16cd2f9f5ec65bb7aff49b31524..398b487d5464761927ad785b53013f1f026e705a 100644 --- a/spec/defines/blank_spec.rb +++ b/spec/defines/blank_spec.rb @@ -10,32 +10,35 @@ describe 'freeradius::blank' do #include_context :hiera 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('$::freeradius::params::fr_basepath/$name').with( + mode: '0644', + owner: 'root', + group: '$::freeradius::params::fr_group', + require: ['File[$::freeradius::params::fr_basepath]', 'Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + 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!', + ) end + end diff --git a/spec/defines/cert_spec.rb b/spec/defines/cert_spec.rb index 7470b58963fde25cc7a7ff97a9951a0ef7700a33..e3ba0b95ac7c4b8345f54f62f1a7b672c4d659bb 100644 --- a/spec/defines/cert_spec.rb +++ b/spec/defines/cert_spec.rb @@ -10,39 +10,42 @@ describe 'freeradius::cert' do #include_context :hiera 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, + # source: :undef, + # content: :undef, + # type: "key", + # 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 }/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('$::freeradius::params::fr_basepath/certs/$name').with( + ensure: 'present', + mode: '', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + content: :undef, + show_diff: nil, + require: ['File[$::freeradius::params::fr_basepath/certs]', 'Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + end diff --git a/spec/defines/client_spec.rb b/spec/defines/client_spec.rb index b926357dce5b7a027c813a05d467510d46f8fef5..2e9e6eaeb6446863b36f28ea3476e763e64a9e81 100644 --- a/spec/defines/client_spec.rb +++ b/spec/defines/client_spec.rb @@ -10,45 +10,83 @@ describe 'freeradius::client' do #include_context :hiera 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, + secret: nil, + # shortname: "$title", + # ip: :undef, + # ip6: :undef, + # proto: :undef, + # require_message_authenticator: "no", + # virtual_server: :undef, + # nastype: :undef, + # login: :undef, + # password: :undef, + # coa_server: :undef, + # response_window: :undef, + # max_connections: :undef, + # lifetime: :undef, + # idle_timeout: :undef, + # redirect: :undef, + # port: :undef, + # srcip: :undef, + # firewall: false, + # ensure: "present", + # attributes: [], + # huntgroups: :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('$::freeradius::params::fr_basepath/clients.d/$title.conf').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: [], + require: ['File[$::freeradius::params::fr_basepath/clients.d]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + 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_firewall('100-$title-undef-v4').with( + proto: 'udp', + dport: :undef, + action: 'accept', + source: :undef, + ) end + + it do + is_expected.to contain_firewall('100-$title-undef-v6').with( + proto: 'udp', + dport: :undef, + action: 'accept', + provider: 'ip6tables', + source: :undef, + ) + end + + it do + is_expected.to contain_freeradius__huntgroup('huntgroup.client.$title.$index').with( + + ) + end + end diff --git a/spec/defines/config_spec.rb b/spec/defines/config_spec.rb index c5be2babb3ee2188534c4ad5a2341366c76426b9..413f756c502e48ff906978df229943b68837f56a 100644 --- a/spec/defines/config_spec.rb +++ b/spec/defines/config_spec.rb @@ -10,37 +10,40 @@ describe 'freeradius::config' do #include_context :hiera 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, + # source: :undef, + # content: :undef, + # 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 }/$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('$::freeradius::params::fr_moduleconfigpath/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + content: :undef, + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + end diff --git a/spec/defines/dictionary_spec.rb b/spec/defines/dictionary_spec.rb index 7f6281643fe3a2665c3a5bb3a19474df898f2a2b..62ad4d259c8937a5887fb9a8ee9d3080315850a0 100644 --- a/spec/defines/dictionary_spec.rb +++ b/spec/defines/dictionary_spec.rb @@ -10,45 +10,50 @@ describe 'freeradius::dictionary' do #include_context :hiera 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: :undef, + # content: :undef, + # order: "50", + # 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 }/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('$::freeradius::params::fr_basepath/dictionary.d/dictionary.$name').with( + ensure: 'present', + mode: '0644', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + content: :undef, + require: ['File[$::freeradius::params::fr_basepath/dictionary.d]', 'Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) 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.$name').with( + target: '$::freeradius::params::fr_basepath/dictionary', + content: '$INCLUDE $::freeradius::params::fr_basepath/dictionary.d/dictionary.$name\n', + order: '50', + require: 'File[$::freeradius::params::fr_basepath/dictionary.d/dictionary.$name]', + ) end + end diff --git a/spec/defines/home_server_pool_spec.rb b/spec/defines/home_server_pool_spec.rb index 3f00fa657bd74a8e8321ed121327c1603c9166a4..a3602d2efe1f82b3d8e2fd6cb4ce78bacd2d6e4c 100644 --- a/spec/defines/home_server_pool_spec.rb +++ b/spec/defines/home_server_pool_spec.rb @@ -10,33 +10,36 @@ describe 'freeradius::home_server_pool' do #include_context :hiera 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: nil, + # type: "fail-over", + # virtual_server: :undef, + # fallback: :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_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-$name').with( + target: '$::freeradius::params::fr_basepath/proxy.conf', + content: [], + order: '20', + ) end + end diff --git a/spec/defines/home_server_spec.rb b/spec/defines/home_server_spec.rb index bc38587289035596559f9eb21418bbb43cd7ec12..a45660516d19275a1fcf8d5d20af0b9f5c36dfa8 100644 --- a/spec/defines/home_server_spec.rb +++ b/spec/defines/home_server_spec.rb @@ -10,36 +10,40 @@ describe 'freeradius::home_server' do #include_context :hiera 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: nil, + # type: "auth", + # ipaddr: :undef, + # ipv6addr: :undef, + # virtual_server: :undef, + # port: "1812", + # proto: "udp", + # status_check: :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_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-$name').with( + target: '$::freeradius::params::fr_basepath/proxy.conf', + content: [], + order: '10', + ) end + end diff --git a/spec/defines/huntgroup_spec.rb b/spec/defines/huntgroup_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..425bc3fc28e18d512023bb27c3d2e73900ffbcfb --- /dev/null +++ b/spec/defines/huntgroup_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::huntgroup' 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 + + 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", + # huntgroup: "$title", + # conditions: [], + # order: "50", + + } + 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('huntgroup.$title').with( + target: '$::freeradius::params::fr_basepath/mods-config/preprocess/huntgroups', + content: '$title\t$conditionals\n', + order: '50', + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + +end diff --git a/spec/defines/instantiate_spec.rb b/spec/defines/instantiate_spec.rb index 436ef83caf73f3148850262ed34e3956814dcc99..863e56231b6dfe17f8536b7f1d43f014ce7f2ae9 100644 --- a/spec/defines/instantiate_spec.rb +++ b/spec/defines/instantiate_spec.rb @@ -10,34 +10,37 @@ describe 'freeradius::instantiate' do #include_context :hiera 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, + # 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('$::freeradius::params::fr_basepath/instantiate/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: '$name', + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + end diff --git a/spec/defines/krb5_spec.rb b/spec/defines/krb5_spec.rb index 753495762a52fcd64f3435a6d8d465595b850349..929379390187b78020ec6e0c359185c9c94cdcc6 100644 --- a/spec/defines/krb5_spec.rb +++ b/spec/defines/krb5_spec.rb @@ -10,40 +10,50 @@ describe 'freeradius::krb5' do #include_context :hiera 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 { - :keytab => 'place_value_here', - :principal => 'place_value_here', - #:start => "${thread[pool].start_servers}", - #:min => "${thread[pool].min_spare_servers}", - #:max => "${thread[pool].max_servers}", - #:spare => "${thread[pool].max_spare_servers}", - #:ensure => "present", + keytab: nil, + principal: nil, + # start: "${thread[pool].start_servers}", + # min: "${thread[pool].min_spare_servers}", + # max: "${thread[pool].max_servers}", + # spare: "${thread[pool].max_spare_servers}", + # 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 }/$fr_version ? { 2 => modules, 3 => mods-enabled, default => modules }/XXreplace_meXX') - .with( - 'content' => 'template(freeradius/krb5.erb)', - '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('$::freeradius::params::fr_basepath/mods-available/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: [], + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + + it do + is_expected.to contain_file('$::freeradius::params::fr_modulepath/$name').with( + ensure: 'link', + target: '../mods-available/$name', + ) + end + end diff --git a/spec/defines/ldap_spec.rb b/spec/defines/ldap_spec.rb index b621e9e2e2a2f9d83014787642c1101b22dbd05f..f4a09de80cc947a5a116aec8174b6486e3a53952 100644 --- a/spec/defines/ldap_spec.rb +++ b/spec/defines/ldap_spec.rb @@ -10,53 +10,69 @@ describe 'freeradius::ldap' do #include_context :hiera 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 { - :identity => 'place_value_here', - :password => 'place_value_here', - :basedn => 'place_value_here', - #:server => ["localhost"], - #:port => 389, - #:uses => 0, - #:idle => 60, - #:probes => 3, - #:interval => 3, - #:timeout => 10, - #:start => "${thread[pool].start_servers}", - #:min => "${thread[pool].min_spare_servers}", - #:max => "${thread[pool].max_servers}", - #:spare => "${thread[pool].max_spare_servers}", - #:ensure => "present", - #:starttls => "no", - #:cafile => undef, - #:certfile => undef, - #:keyfile => undef, - #:requirecert => "allow", + identity: nil, + password: nil, + basedn: nil, + # server: ["localhost"], + # port: "389", + # uses: "0", + # idle: "60", + # probes: "3", + # interval: "3", + # timeout: "10", + # start: "${thread[pool].start_servers}", + # min: "${thread[pool].min_spare_servers}", + # max: "${thread[pool].max_servers}", + # spare: "${thread[pool].max_spare_servers}", + # ensure: "present", + # starttls: "no", + # cafile: :undef, + # certfile: :undef, + # keyfile: :undef, + # requirecert: "allow", + } 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 => modules, 3 => mods-enabled, default => modules }/XXreplace_meXX') - .with( - 'content' => 'template(freeradius/ldap.fr$fr_version.erb)', - '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_freeradius__module__ldap('$name').with( + ensure: 'present', + identity: :undef, + password: :undef, + basedn: :undef, + server: ['localhost'], + port: '389', + uses: '0', + idle: '60', + probes: '3', + interval: '3', + timeout: '10', + start: '${thread[pool].start_servers}', + min: '${thread[pool].min_spare_servers}', + max: '${thread[pool].max_servers}', + spare: '${thread[pool].max_spare_servers}', + starttls: 'no', + cafile: :undef, + certfile: :undef, + keyfile: :undef, + requirecert: 'allow', + ) end + end diff --git a/spec/defines/listen_spec.rb b/spec/defines/listen_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..8bcffd92fdd819137c577932fe5d22ef54089ffd --- /dev/null +++ b/spec/defines/listen_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::listen' 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 + + 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", + # type: "auth", + # ip: :undef, + # ip6: :undef, + # port: "0", + # interface: :undef, + # clients: [], + # max_connections: "16", + # lifetime: "0", + # idle_timeout: "30", + + } + 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('$::freeradius::params::fr_basepath/listen.d/$name.conf').with( + ensure: 'present', + owner: 'root', + group: '$::freeradius::params::fr_group', + mode: '0640', + content: [], + require: ['File[$::freeradius::params::fr_basepath/listen.d]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + +end diff --git a/spec/defines/module/detail_spec.rb b/spec/defines/module/detail_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..3c50109f64e2221a2d3c763dcaa6433375f8e0da --- /dev/null +++ b/spec/defines/module/detail_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::detail' 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 + + 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", + # filename: "${radacctdir}/%{%{Packet-Src-IP-Address}:-%{Packet-Src-IPv6-Address}}/detail-%Y%m%d", + # escape_filenames: "no", + # permissions: "0600", + # group: :undef, + # header: "%t", + # locking: :undef, + # log_packet_header: :undef, + # suppress: [], + + } + 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_freeradius__module('detail.$name').with( + ensure: 'present', + content: [], + ) + end + +end diff --git a/spec/defines/module/eap_spec.rb b/spec/defines/module/eap_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..11eecbb4f9c50a113d41f1fa9bacd7cd555f71bc --- /dev/null +++ b/spec/defines/module/eap_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::eap' 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 + + 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", + # default_eap_type: "md5", + # timer_expire: "60", + # ignore_unknown_eap_types: "no", + # cisco_accounting_username_bug: "no", + # max_sessions: "${max_requests}", + # eap_pwd: false, + # pwd_group: :undef, + # pwd_server_id: :undef, + # pwd_fragment_size: :undef, + # pwd_virtual_server: :undef, + # gtc_challenge: :undef, + # gtc_auth_type: "PAP", + # tls_config_name: "tls-common", + # tls_private_key_password: :undef, + # tls_private_key_file: "${certdir}/server.pem", + # tls_certificate_file: "${certdir}/server.pem", + # tls_ca_file: "${certdir}/ca.pem", + # tls_auto_chain: :undef, + # tls_psk_identity: :undef, + # tls_psk_hexphrase: :undef, + # tls_dh_file: "${certdir}/dh", + # tls_random_file: :undef, + # tls_fragment_size: :undef, + # tls_include_length: :undef, + # tls_check_crl: :undef, + # tls_check_all_crl: :undef, + # tls_allow_expired_crl: :undef, + # tls_ca_path: "${cadir}", + # tls_check_cert_issuer: :undef, + # tls_check_cert_cn: :undef, + # tls_cipher_list: "DEFAULT", + # tls_disable_tlsv1_2: :undef, + # tls_ecdh_curve: "prime256v1", + # tls_cache_enable: "yes", + # tls_cache_lifetime: "24", + # tls_cache_max_entries: "255", + # tls_cache_name: :undef, + # tls_cache_persist_dir: :undef, + # tls_verify_skip_if_ocsp_ok: :undef, + # tls_verify_tmpdir: :undef, + # tls_verify_client: :undef, + # tls_ocsp_enable: "no", + # tls_ocsp_override_cert_url: "yes", + # tls_ocsp_url: "http://127.0.0.1/ocsp/", + # tls_ocsp_use_nonce: :undef, + # tls_ocsp_timeout: :undef, + # tls_ocsp_softfail: :undef, + # tls_virtual_server: :undef, + # ttls_default_eap_type: "md5", + # ttls_copy_request_to_tunnel: "no", + # ttls_use_tunneled_reply: "no", + # ttls_virtual_server: "inner-tunnel", + # ttls_include_length: :undef, + # ttls_require_client_cert: :undef, + # peap_default_eap_type: "mschapv2", + # peap_copy_request_to_tunnel: "no", + # peap_use_tunneled_reply: "no", + # peap_proxy_tunneled_request_as_eap: :undef, + # peap_virtual_server: "inner-tunnel", + # peap_soh: :undef, + # peap_soh_virtual_server: :undef, + # peap_require_client_cert: :undef, + # mschapv2_send_error: :undef, + # mschapv2_identity: :undef, + # eap_md5: true, + # eap_leap: true, + # eap_gtc: true, + # eap_peap: true, + + } + 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_freeradius__module('$name').with( + ensure: 'present', + content: [], + ) + end + +end diff --git a/spec/defines/module/files_spec.rb b/spec/defines/module/files_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..0b89ed56776e6e6645224ebab9f99168bd617517 --- /dev/null +++ b/spec/defines/module/files_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::files' 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 + + 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", + # moddir: "${modconfdir}/${.:instance}", + # key: :undef, + # filename: "${moddir}/authorize", + # usersfile: :undef, + # acctusersfile: :undef, + # preproxy_usersfile: :undef, + # users: [], + # source: :undef, + # 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_freeradius__module('$name').with( + ensure: 'present', + content: [], + ) + end + + it do + is_expected.to contain_file('$usersdir').with( + ensure: '', + owner: 'root', + group: '$::freeradius::params::fr_group', + mode: '0750', + require: 'Freeradius::module[$name]', + ) + end + + it do + is_expected.to contain_file('$userspath').with( + ensure: 'present', + owner: 'root', + group: '$::freeradius::params::fr_group', + mode: '0640', + source: :undef, + content: '', + require: 'File[$usersdir]', + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + +end diff --git a/spec/defines/module/huntgroup_spec.rb b/spec/defines/module/huntgroup_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..9e30e4c324f8870da1997be79e024af3c6eeb3c9 --- /dev/null +++ b/spec/defines/module/huntgroup_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::huntgroup' 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 + + 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 + { + conditions: nil, + # order: "50", + # huntgroup: :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_freeradius__huntgroup('$name').with( + conditions: :undef, + order: '50', + ) + end + +end diff --git a/spec/defines/module/ippool_spec.rb b/spec/defines/module/ippool_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..c20cd5e2090b24de76b478a1b2a67f0a5e993e8f --- /dev/null +++ b/spec/defines/module/ippool_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::ippool' 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 + + 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 + { + range_start: nil, + range_stop: nil, + netmask: nil, + # ensure: "present", + # cache_size: :undef, + # filename: "${db_dir}/db.$name", + # ip_index: "${db_dir}/db.$name.index", + # override: "no", + # maximum_timeout: "0", + # key: :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_freeradius__module('ippool_$name').with( + ensure: 'present', + content: [], + ) + end + +end diff --git a/spec/defines/module/ldap_spec.rb b/spec/defines/module/ldap_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..2f0b0ef736bc1064db61a9d68bde7491fd978eaa --- /dev/null +++ b/spec/defines/module/ldap_spec.rb @@ -0,0 +1,113 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::ldap' 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 + + 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 + { + basedn: nil, + # ensure: "present", + # server: ["localhost"], + # port: "389", + # identity: :undef, + # password: :undef, + # sasl: {}, + # valuepair_attribute: :undef, + # update: :undef, + # edir: :undef, + # edir_autz: :undef, + # user_base_dn: "${..base_dn}", + # user_filter: "(uid=%{%{Stripped-User-Name}:-%{User-Name}})", + # user_sasl: {}, + # user_scope: :undef, + # user_sort_by: :undef, + # user_access_attribute: :undef, + # user_access_positive: :undef, + # group_base_dn: "${..base_dn}", + # group_filter: "(objectClass=posixGroup)", + # group_scope: :undef, + # group_name_attribute: :undef, + # group_membership_filter: :undef, + # group_membership_attribute: "memberOf", + # group_cacheable_name: :undef, + # group_cacheable_dn: :undef, + # group_cache_attribute: :undef, + # group_attribute: :undef, + # profile_filter: :undef, + # profile_default: :undef, + # profile_attribute: :undef, + # client_base_dn: "${..base_dn}", + # client_filter: "(objectClass=radiusClient)", + # client_scope: :undef, + # read_clients: :undef, + # dereference: :undef, + # chase_referrals: "yes", + # rebind: "yes", + # use_referral_credentials: "no", + # session_tracking: :undef, + # timeout: "10", + # timelimit: "3", + # idle: "60", + # probes: "3", + # interval: "3", + # ldap_debug: "0x0028", + # starttls: "no", + # cafile: :undef, + # certfile: :undef, + # keyfile: :undef, + # random_file: :undef, + # requirecert: "allow", + # start: "${thread[pool].start_servers}", + # min: "${thread[pool].min_spare_servers}", + # max: "${thread[pool].max_servers}", + # spare: "${thread[pool].max_spare_servers}", + # uses: "0", + # retry_delay: "30", + # lifetime: "0", + # idle_timeout: "60", + # connect_timeout: "3.0", + + } + 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('$::freeradius::params::fr_basepath/mods-available/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: [], + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + + it do + is_expected.to contain_file('$::freeradius::params::fr_modulepath/$name').with( + ensure: 'link', + target: '../mods-available/$name', + ) + end + +end diff --git a/spec/defines/module/linelog_spec.rb b/spec/defines/module/linelog_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..1444a87841feb534e5ed0a29d644b6f09bfe7348 --- /dev/null +++ b/spec/defines/module/linelog_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::module::linelog' 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 + + 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", + # filename: "${logdir}/linelog", + # escape_filenames: "no", + # permissions: "0600", + # group: :undef, + # syslog_facility: :undef, + # syslog_severity: :undef, + # format: "This is a log message for %{User-Name}", + # reference: "messages.%{%{reply:Packet-Type}:-default}", + # messages: [], + # accounting_request: [], + + } + 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_freeradius__module('linelog_$name').with( + ensure: 'present', + content: [], + ) + end + +end diff --git a/spec/defines/module_spec.rb b/spec/defines/module_spec.rb index 8b1917b306a053a7e32a6feda661bf7b8a8acd15..7dcaf3e105b39f0b91ddd5a82d1f0f1951ed85ec 100644 --- a/spec/defines/module_spec.rb +++ b/spec/defines/module_spec.rb @@ -10,37 +10,57 @@ describe 'freeradius::module' do #include_context :hiera 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, + # source: :undef, + # content: :undef, + # ensure: "present", + # preserve: false, + } 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('$::freeradius::params::fr_modulepath/$name').with( + ensure: '', + target: '../mods-available/$name', + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + + it do + is_expected.to contain_file('$::freeradius::params::fr_basepath/mods-available/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + content: :undef, + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + ) + end + it do - is_expected.to contain_file('$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/$fr_version ? { 2 => modules, 3 => mods-enabled, default => modules }/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('$::freeradius::params::fr_modulepath/$name').with( + ensure: '', + target: '../mods-available/$name', + require: 'File[$::freeradius::params::fr_basepath/mods-available/$name]', + notify: 'Service[$::freeradius::params::fr_service]', + ) end + end diff --git a/spec/defines/policy_spec.rb b/spec/defines/policy_spec.rb index 711008bc1405ef103fd266b8200cb804d5244ba5..31beefa875030f0cda8e610abc1f830f9156865d 100644 --- a/spec/defines/policy_spec.rb +++ b/spec/defines/policy_spec.rb @@ -10,45 +10,48 @@ describe 'freeradius::policy' do #include_context :hiera 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: nil, + # order: "50", + # 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 }/policy.d/XXreplace_meXX') - .with( - 'ensure' => 'present', - 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', - 'mode' => '0644', - 'notify' => 'Service[$fr_service]', - 'owner' => 'root', - 'require' => '[Package[$fr_package], Group[$fr_group]]', - 'source' => '' - ) + is_expected.to contain_file('$::freeradius::params::fr_basepath/policy.d/$name').with( + ensure: 'present', + mode: '0644', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + it do - is_expected.to contain_concat__fragment('policy-XXreplace_meXX') - .with( - 'content' => '\\t$INCLUDE $::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/policy.d/XXreplace_meXX\\n', - 'order' => '50', - 'require' => 'File[$fr_basepath/policy.d/$name]', - 'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/policy.conf' - ) + is_expected.to contain_concat__fragment('policy-$name').with( + target: '$::freeradius::params::fr_basepath/policy.conf', + content: '\t$INCLUDE $::freeradius::params::fr_basepath/policy.d/$name\n', + order: '50', + require: 'File[$::freeradius::params::fr_basepath/policy.d/$name]', + ) end + end diff --git a/spec/defines/realm_spec.rb b/spec/defines/realm_spec.rb index 9d68cfc3d459d09df5e83cde0c04f5949cef4fd5..17e91b8aacdc78d7e0e8b5220c2a732f84cbd036 100644 --- a/spec/defines/realm_spec.rb +++ b/spec/defines/realm_spec.rb @@ -10,34 +10,37 @@ describe 'freeradius::realm' do #include_context :hiera 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 { - #:virtual_server => "", - #:auth_pool => "", - #:acct_pool => "", - #:pool => "", - #:nostrip => false, + # virtual_server: :undef, + # auth_pool: :undef, + # acct_pool: :undef, + # pool: :undef, + # nostrip: false, + } 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('realm-XXreplace_meXX') - .with( - 'content' => 'template(freeradius/realm.erb)', - 'order' => '30', - 'target' => '$::osfamily ? { RedHat => /etc/raddb, Debian => /etc/freeradius, default => /etc/raddb }/proxy.conf' - ) + is_expected.to contain_concat__fragment('realm-$name').with( + target: '$::freeradius::params::fr_basepath/proxy.conf', + content: [], + order: '30', + ) end + end diff --git a/spec/defines/script_spec.rb b/spec/defines/script_spec.rb index 60d48ced782f4ca0c28b9fe06e8232471bd2124a..e94164851677df2b54d22743872a5e8ae29ca74e 100644 --- a/spec/defines/script_spec.rb +++ b/spec/defines/script_spec.rb @@ -10,35 +10,38 @@ describe 'freeradius::script' do #include_context :hiera 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, + source: nil, + # 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 }/scripts/XXreplace_meXX') - .with( - 'ensure' => 'present', - 'group' => '$::osfamily ? { RedHat => radiusd, Debian => freerad, default => radiusd }', - 'mode' => '0750', - 'notify' => 'Service[$fr_service]', - 'owner' => 'root', - 'require' => '[File[$fr_basepath/scripts], Package[$fr_package], Group[$fr_group]]', - 'source' => '' - ) + is_expected.to contain_file('$::freeradius::params::fr_basepath/scripts/$name').with( + ensure: 'present', + mode: '0750', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + require: ['File[$::freeradius::params::fr_basepath/scripts]', 'Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + end diff --git a/spec/defines/site_spec.rb b/spec/defines/site_spec.rb index 4249693923a23e98afd412572eab5454bc68ab46..1f06433d425d79c0435e87cd62b9419d8e00dae5 100644 --- a/spec/defines/site_spec.rb +++ b/spec/defines/site_spec.rb @@ -10,37 +10,56 @@ describe 'freeradius::site' do #include_context :hiera 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, + # ensure: "present", + # source: :undef, + # content: :undef, + # authorize: [], + # authenticate: [], + # preacct: [], + # accounting: [], + # session: [], + # post_auth: [], + # pre_proxy: [], + # post_proxy: [], + # listen: [], + } 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 }/sites-enabled/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('$::freeradius::params::fr_basepath/sites-available/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + source: :undef, + content: '', + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + + it do + is_expected.to contain_file('$::freeradius::params::fr_basepath/sites-enabled/$name').with( + ensure: '', + target: '$::freeradius::params::fr_basepath/sites-available/$name', + ) + end + end diff --git a/spec/defines/sql_spec.rb b/spec/defines/sql_spec.rb index 7a46a1bf7bc2af4174d7ea3c5d9b1a9054c3224a..24b3a84bc0141751d04b1e30f7ec608f8469c15c 100644 --- a/spec/defines/sql_spec.rb +++ b/spec/defines/sql_spec.rb @@ -10,78 +10,93 @@ describe 'freeradius::sql' do #include_context :hiera 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 { - :database => 'place_value_here', - :password => 'place_value_here', - #:server => "localhost", - #:login => "radius", - #:radius_db => "radius", - #:num_sql_socks => "${thread[pool].max_servers}", - #:query_file => "sql/${database}/dialup.conf", - #:custom_query_file => "", - #:lifetime => "0", - #:max_queries => "0", - #:ensure => present, - #:acct_table1 => "radacct", - #:acct_table2 => "radacct", - #:postauth_table => "radpostauth", - #:authcheck_table => "radcheck", - #:authreply_table => "radreply", - #:groupcheck_table => "radgroupcheck", - #:groupreply_table => "radgroupreply", - #:usergroup_table => "radusergroup", - #:deletestalesessions => "yes", - #:sqltrace => "no", - #:sqltracefile => "${logdir}/sqltrace.sql", - #:connect_failure_retry_delay => "60", - #:nas_table => "nas", - #:read_groups => "yes", - #:port => "3306", - #:readclients => "no", + database: nil, + password: nil, + # server: "localhost", + # login: "radius", + # radius_db: "radius", + # num_sql_socks: "${thread[pool].max_servers}", + # query_file: "${modconfdir}/${.:name}/main/${dialect}/queries.conf", + # custom_query_file: :undef, + # lifetime: "0", + # max_queries: "0", + # ensure: "present", + # acct_table1: "radacct", + # acct_table2: "radacct", + # postauth_table: "radpostauth", + # authcheck_table: "radcheck", + # authreply_table: "radreply", + # groupcheck_table: "radgroupcheck", + # groupreply_table: "radgroupreply", + # usergroup_table: "radusergroup", + # deletestalesessions: "yes", + # sqltrace: "no", + # sqltracefile: "${logdir}/sqllog.sql", + # connect_failure_retry_delay: "60", + # nas_table: "nas", + # read_groups: "yes", + # port: "3306", + # readclients: "no", + # pool_start: "1", + # pool_min: "1", + # pool_spare: "1", + # pool_idle_timeout: "60", + # pool_connect_timeout: "3.0", + } 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 => modules, 3 => mods-enabled, default => modules }/XXreplace_meXX') - .with( - 'content' => 'template(freeradius/sql.conf.fr$fr_version.erb)', - '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___freeradius__config('$name-queries.conf').with( + source: :undef, + ) end + it do - is_expected.to contain___freeradius__config('XXreplace_meXX-queries.conf') - .with( - 'source' => '' - ) + is_expected.to contain_file('$::freeradius::params::fr_basepath/mods-available/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: [], + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + it do - is_expected.to contain_logrotate__rule('sqltrace') - .with( - 'compress' => 'true', - 'create' => 'true', - 'missingok' => 'true', - 'path' => '$::osfamily ? { RedHat => /var/log/radius, Debian => /var/log/freeradius, default => /var/log/radius }/${logdir}/sqltrace.sql', - 'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`', - 'rotate' => '1', - 'rotate_every' => 'week' - ) + is_expected.to contain_file('$::freeradius::params::fr_modulepath/$name').with( + ensure: 'link', + target: '../mods-available/$name', + ) end + + it do + is_expected.to contain_logrotate__rule('sqltrace').with( + path: '$::freeradius::params::fr_logpath/${logdir}/sqllog.sql', + rotate_every: 'week', + rotate: '1', + create: true, + compress: true, + missingok: true, + postrotate: 'kill -HUP `cat $freeradius::fr_pidfile`', + ) + end + end diff --git a/spec/defines/statusclient_spec.rb b/spec/defines/statusclient_spec.rb index 4f961f96ed4ecb36573c4d288ee0c48e82f54bc9..1e259a6fa3e4287327ae403927fb38a94ca993d0 100644 --- a/spec/defines/statusclient_spec.rb +++ b/spec/defines/statusclient_spec.rb @@ -10,40 +10,42 @@ describe 'freeradius::statusclient' do #include_context :hiera 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', - #:ip => undef, - #:ip6 => undef, - #:port => undef, - #:shortname => XXreplace_meXX, - #:netmask => undef, - #:ensure => present, + secret: nil, + # ip: :undef, + # ip6: :undef, + # port: :undef, + # shortname: "$name", + # 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 }/statusclients.d/XXreplace_meXX.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], Package[$fr_package], Group[$fr_group]]' - ) + is_expected.to contain_file('$::freeradius::params::fr_basepath/statusclients.d/$name.conf').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: [], + require: ['File[$::freeradius::params::fr_basepath/clients.d]', 'Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) end + end diff --git a/spec/defines/template_spec.rb b/spec/defines/template_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..6f7ff01b4442fe32492f80daa146558d266a1b8e --- /dev/null +++ b/spec/defines/template_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::template' 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 + + 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, + + } + 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('template -$name').with( + target: '$::freeradius::params::fr_basepath/templates.conf', + source: :undef, + content: :undef, + order: '10', + ) + end + +end diff --git a/spec/defines/virtual_module_spec.rb b/spec/defines/virtual_module_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..16dade0be10bb54e3ec386dd2b24874216483d7c --- /dev/null +++ b/spec/defines/virtual_module_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' +require 'shared_contexts' + +describe 'freeradius::virtual_module' 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 + + 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 + { + submodules: nil, + # ensure: "present", + # type: "redundant-load-balance", + + } + 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('$::freeradius::params::fr_basepath/instantiate/$name').with( + ensure: 'present', + mode: '0640', + owner: 'root', + group: '$::freeradius::params::fr_group', + content: [], + require: ['Package[$::freeradius::params::fr_package]', 'Group[$::freeradius::params::fr_group]'], + notify: 'Service[$::freeradius::params::fr_service]', + ) + end + +end diff --git a/spec/shared_contexts.rb b/spec/shared_contexts.rb index f549bde4a0347e297a2019309afc393991c4fb55..e2e7e42e42caad6420182065935685118718b2e5 100644 --- a/spec/shared_contexts.rb +++ b/spec/shared_contexts.rb @@ -8,21 +8,6 @@ hiera_config_file = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures shared_context :global_hiera_data do let(:hiera_data) do { - #"freeradius::control_socket" => '', - #"freeradius::control_socket::mode" => '', - #"freeradius::ldap_support" => '', - #"freeradius::krb5_support" => '', - #"freeradius::max_requests" => '', - #"freeradius::max_servers" => '', - #"freeradius::mysql_support" => '', - #"freeradius::perl_support" => '', - #"freeradius::status_server::listen" => '', - #"freeradius::status_server::port" => '', - #"freeradius::status_server::secret" => '', - #"freeradius::syslog" => '', - #"freeradius::utils_support" => '', - #"freeradius::winbind_support" => '', - #"freeradius::wpa_supplicant" => '', } end diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391