From 34f8fb6938e9b5e2fe6c03a6412d575355b8ffcd Mon Sep 17 00:00:00 2001 From: Blerim Sheqa Date: Mon, 23 Jan 2017 16:38:08 +0100 Subject: [PATCH 1/3] Revert "Merge branch 'feature/workaround-for-puppetdb-14031'" This reverts commit 84a9aeb134d03ac933d4e773b3f25f9b30763412, reversing changes made to 73e83b3ae41828fdaaf45466476a1945fce7adac. --- manifests/feature/idomysql.pp | 4 +- manifests/feature/idopgsql.pp | 4 +- manifests/init.pp | 3 +- manifests/object.pp | 10 +- manifests/object/apiuser.pp | 3 +- manifests/object/checkcommand.pp | 6 +- manifests/object/dependency.pp | 5 +- manifests/object/eventcommand.pp | 1 + manifests/object/host.pp | 6 +- manifests/object/hostgroup.pp | 6 +- manifests/object/notification.pp | 33 +-- manifests/object/notificationcommand.pp | 6 +- manifests/object/scheduleddowntime.pp | 16 +- manifests/object/service.pp | 47 ++-- manifests/object/servicegroup.pp | 15 +- manifests/object/timeperiod.pp | 15 +- manifests/object/user.pp | 23 +- manifests/object/usergroup.pp | 9 +- manifests/object/zone.pp | 6 +- spec/classes/idomysql_spec.rb | 14 +- spec/classes/idopgsql_spec.rb | 14 +- spec/defines/apiuser_spec.rb | 14 +- spec/defines/checkcommand_spec.rb | 16 +- spec/defines/dependency_spec.rb | 14 +- spec/defines/host_spec.rb | 50 +++- spec/defines/hostgroup_spec.rb | 14 +- spec/defines/notification_spec.rb | 56 ++-- spec/defines/notificationcommand_spec.rb | 36 +-- spec/defines/object_spec.rb | 40 ++- spec/defines/service_spec.rb | 318 ++++++++++++++++------- spec/defines/servicegroup_spec.rb | 14 +- spec/defines/timeperiod_spec.rb | 28 +- spec/defines/user_spec.rb | 42 +-- spec/defines/usergroup_spec.rb | 14 +- spec/defines/zone_spec.rb | 14 +- templates/object.conf.erb | 4 +- 36 files changed, 499 insertions(+), 421 deletions(-) diff --git a/manifests/feature/idomysql.pp b/manifests/feature/idomysql.pp index 1d2441f57..6a10e81a8 100644 --- a/manifests/feature/idomysql.pp +++ b/manifests/feature/idomysql.pp @@ -179,7 +179,7 @@ validate_bool($enable_ha) validate_re($failover_timeout, '^\d+[ms]*$') if $cleanup { validate_hash($cleanup) } - if $categories { $_categories = any2array($categories) } else { $_categories = undef } + if $categories { validate_array($categories) } validate_bool($import_schema) if $ssl_capath { validate_absolute_path($ssl_capath) } if $ssl_cipher { validate_string($ssl_cipher) } @@ -311,7 +311,7 @@ enable_ha => $enable_ha, failover_timeout => $failover_timeout, cleanup => $cleanup, - categories => $_categories, + categories => $categories, } diff --git a/manifests/feature/idopgsql.pp b/manifests/feature/idopgsql.pp index d31a2d206..ff0d8da0c 100644 --- a/manifests/feature/idopgsql.pp +++ b/manifests/feature/idopgsql.pp @@ -104,7 +104,7 @@ validate_bool($enable_ha) validate_re($failover_timeout, '^\d+[ms]*$') if $cleanup { validate_hash($cleanup) } - if $categories { $_categories = any2array($categories) } else { $_categories = undef } + if $categories { validate_array($categories) } validate_bool($import_schema) package { 'icinga2-ido-pgsql': @@ -134,7 +134,7 @@ enable_ha => $enable_ha, failover_timeout => $failover_timeout, cleanup => $cleanup, - categories => $_categories, + categories => $categories, } # create object diff --git a/manifests/init.pp b/manifests/init.pp index c5bfbcfdd..b92d4d877 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -138,6 +138,7 @@ validate_bool($enable) validate_bool($manage_repo) validate_bool($manage_service) + validate_array($features) validate_bool($purge_features) validate_hash($constants) validate_array($plugins) @@ -168,5 +169,5 @@ subscribe => Class['::icinga2::config'] } - include prefix(any2array($features), '::icinga2::feature::') + include prefix($features, '::icinga2::feature::') } diff --git a/manifests/object.pp b/manifests/object.pp index 2533c05a2..635b32334 100644 --- a/manifests/object.pp +++ b/manifests/object.pp @@ -91,6 +91,9 @@ unless is_bool($apply) { validate_re($apply, '^.+\s+(=>\s+.+\s+)?in\s+.+$') } if $apply_target { validate_re($apply_target, ['^Host$', '^Service$'], "${apply_target} isn't supported. Valid values are 'Host' and 'Service'.") } + validate_array($import) + validate_array($assign) + validate_array($ignore) validate_hash($attrs) validate_string($object_type) validate_absolute_path($target) @@ -100,10 +103,9 @@ fail('The object type must be different from the apply target') } - $_import = any2array($import) - $_attrs = merge($attrs, { - 'assign where' => any2array($assign), - 'ignore where' => any2array($ignore), + $_attrs = merge($attrs, { + 'assign where' => $assign, + 'ignore where' => $ignore, }) if !defined(Concat[$target]) { diff --git a/manifests/object/apiuser.pp b/manifests/object/apiuser.pp index 53bcc2420..1006cc1f9 100644 --- a/manifests/object/apiuser.pp +++ b/manifests/object/apiuser.pp @@ -63,6 +63,7 @@ validate_string($apiuser_name) validate_string($order) validate_absolute_path($target) + validate_array($permissions) if $password { validate_string($password) } if $client_cn { validate_string($client_cn) } @@ -71,7 +72,7 @@ $attrs = { password => $password, client_cn => $client_cn, - permissions => any2array($permissions), + permissions => $permissions, } # create object diff --git a/manifests/object/checkcommand.pp b/manifests/object/checkcommand.pp index 2bbf4043b..c221b24ec 100644 --- a/manifests/object/checkcommand.pp +++ b/manifests/object/checkcommand.pp @@ -60,18 +60,20 @@ # validation validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") + validate_array($import) validate_absolute_path($target) validate_integer($order) if $checkcommand_name { validate_string($checkcommand_name) } - if $command { $_command = any2array($command) } else { $_command = undef } + if !is_array($command) { validate_string($command) } + if !is_string($command) { validate_array($command) } if $env { validate_hash($env) } if $timeout { validate_integer($timeout) } if $arguments { validate_hash($arguments) } # compose the attributes $attrs = { - command => $_command, + command => $command, env => $env, vars => $vars, timeout => $timeout, diff --git a/manifests/object/dependency.pp b/manifests/object/dependency.pp index d740eee2f..c6f7f9d3c 100644 --- a/manifests/object/dependency.pp +++ b/manifests/object/dependency.pp @@ -102,6 +102,7 @@ unless is_bool($apply) { validate_string($apply) } validate_re($apply_target, ['^Host$', '^Service$'], "${apply_target} isn't supported. Valid values are 'Host' and 'Service'.") + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) @@ -114,7 +115,7 @@ if $disable_notifications { validate_bool ( $disable_notifications ) } if $ignore_soft_states { validate_bool ( $ignore_soft_states ) } if $period { validate_string ( $period ) } - if $states { $_states = any2array($states) } else { $_states = undef } + if $states { validate_array ( $states ) } # compose attributes $attrs = { @@ -126,7 +127,7 @@ 'disable_notifications' => $disable_notifications, 'ignore_soft_states' => $ignore_soft_states, 'period' => $period, - 'states' => $_states, + 'states' => $states, } # create object diff --git a/manifests/object/eventcommand.pp b/manifests/object/eventcommand.pp index b0c4c520d..03055a10e 100644 --- a/manifests/object/eventcommand.pp +++ b/manifests/object/eventcommand.pp @@ -65,6 +65,7 @@ validate_string($eventcommand_name) validate_absolute_path($target) validate_string($order) + validate_array($import) if !is_array($command) { validate_string($command) } if !is_string($command) { validate_array($command) } diff --git a/manifests/object/host.pp b/manifests/object/host.pp index 497a79512..485dd4a76 100644 --- a/manifests/object/host.pp +++ b/manifests/object/host.pp @@ -150,6 +150,7 @@ # validation validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_integer($order) @@ -157,9 +158,8 @@ if $host_name { validate_string($host_name) } if $address { validate_string($address) } if $address6 { validate_string($address6) } + if $groups { validate_array($groups) } if $display_name { validate_string($display_name) } - if $vars { validate_hash($vars) } - if $groups { $_groups = any2array($groups) } else { $_groups = undef } validate_string($check_command) if $max_check_attempts { validate_integer($max_check_attempts) } if $check_period { validate_string($check_period) } @@ -188,7 +188,7 @@ address => $address, address6 => $address6, vars => $vars, - groups => $_groups, + groups => $groups, display_name => $display_name, check_command => $check_command, max_check_attempts => $max_check_attempts, diff --git a/manifests/object/hostgroup.pp b/manifests/object/hostgroup.pp index 3122ed9ea..0a8d3b5ce 100644 --- a/manifests/object/hostgroup.pp +++ b/manifests/object/hostgroup.pp @@ -48,11 +48,13 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($hostgroup_name) + validate_array($assign) + validate_array($ignore) validate_string($order) validate_absolute_path($target) if $display_name { validate_string($display_name) } - if $groups { $_groups = any2array($groups) } else { $_groups = undef } + if $groups { validate_array($groups) } if $ignore != [] and $assign == [] { fail('When attribute ignore is used, assign must be set.') @@ -61,7 +63,7 @@ # compose the attributes $attrs = { display_name => $display_name, - groups => $_groups, + groups => $groups, } # create object diff --git a/manifests/object/notification.pp b/manifests/object/notification.pp index 8a52f5478..d98942f55 100644 --- a/manifests/object/notification.pp +++ b/manifests/object/notification.pp @@ -110,21 +110,24 @@ unless is_bool($apply) { validate_string($apply) } validate_re($apply_target, ['^Host$', '^Service$'], "${apply_target} isn't supported. Valid values are 'Host' and 'Service'.") + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) - validate_string($host_name) - if $service_name { validate_string($service_name) } - if $users { $_users = any2array($users) } else { $_users = undef } - if $user_groups { $_user_groups = any2array($user_groups) } else { $_user_groups = undef } - if $times { validate_hash($times) } - if $command { validate_string($command) } - if $interval { validate_integer($interval) } - if $period { validate_string($period) } - if $zone { validate_string($zone) } - if $types { $_types = any2array($types) } else { $_types = undef } - if $states { $_states = any2array($states) } else { $_states = undef } + validate_string ($host_name) + if $service_name { validate_string ($service_name)} + if $users { validate_array ($users )} + if $user_groups { validate_array ($user_groups )} + if $times { validate_hash ($times )} + if $command { validate_string ($command )} + if $interval { validate_integer ($interval )} + if $period { validate_string ($period )} + if $zone { validate_string ($zone) } + if $types { validate_array ($types) } + if $states { validate_array ($states) } + if $assign { validate_array ($assign) } + if $ignore { validate_array ($ignore) } if $ignore != [] and $assign == [] { fail('When attribute ignore is used, assign must be set.') @@ -135,15 +138,15 @@ 'host_name' => $host_name, 'service_name' => $service_name, 'vars' => $vars, - 'users' => $_users, - 'user_groups' => $_user_groups, + 'users' => $users, + 'user_groups' => $user_groups, 'times' => $times, 'command' => $command, 'interval' => $interval, 'period' => $period, 'zone' => $zone, - 'types' => $_types, - 'states' => $_states, + 'types' => $types, + 'states' => $states, } # create object diff --git a/manifests/object/notificationcommand.pp b/manifests/object/notificationcommand.pp index d9bc9bfd5..9965a2362 100644 --- a/manifests/object/notificationcommand.pp +++ b/manifests/object/notificationcommand.pp @@ -69,18 +69,20 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($notificationcommand_name) + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) - if $command { $_command = any2array($command) } else { $_command = undef } + if !is_array($command) { validate_string($command) } + if !is_string($command) { validate_array($command) } if $env { validate_hash ($env) } if $timeout { validate_integer ($timeout) } if $arguments { validate_hash ($arguments) } # compose attributes $attrs = { - 'command' => $_command, + 'command' => $command, 'env' => $env, 'vars' => $vars, 'timeout' => $timeout, diff --git a/manifests/object/scheduleddowntime.pp b/manifests/object/scheduleddowntime.pp index 6259f515f..506c68861 100644 --- a/manifests/object/scheduleddowntime.pp +++ b/manifests/object/scheduleddowntime.pp @@ -8,15 +8,13 @@ # Set to present enables the object, absent disables it. Defaults to present. # # [*scheduleddowntime_name*] -# Set the Icinga 2 name of the scheduleddowntime object. -# Defaults to title of the define resource. +# Set the Icinga 2 name of the scheduleddowntime object. Defaults to title of the define resource. # # [*host_name*] # The name of the host this comment belongs to. # # [*service_name*] -# The short name of the service this comment belongs to. If omitted, -# this comment object is treated as host comment. +# The short name of the service this comment belongs to. If omitted, this comment object is treated as host comment. # # [*author*] # The author's name. @@ -31,16 +29,14 @@ # The duration as number. # # [*ranges*] -# A dictionary containing information which days and durations -# apply to this timeperiod. +# A dictionary containing information which days and durations apply to this timeperiod. # # [*apply*] -# Dispose an apply instead an object if set to 'true'. Value is taken as -# statement, i.e. 'vhost => config in host.vars.vhosts'. Defaults to false. +# Dispose an apply instead an object if set to 'true'. Value is taken as statement, +# i.e. 'vhost => config in host.vars.vhosts'. Defaults to false. # # [*apply_target*] -# An object type on which to target the apply rule. Valid values -# are `Host` and `Service`. Defaults to `Host`. +# An object type on which to target the apply rule. Valid values are `Host` and `Service`. Defaults to `Host`. # # [*assign*] # Assign user group members using the group assign rules. diff --git a/manifests/object/service.pp b/manifests/object/service.pp index 067878818..d4d774d6b 100644 --- a/manifests/object/service.pp +++ b/manifests/object/service.pp @@ -201,42 +201,43 @@ "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($service_name) unless is_bool($apply) { validate_string($apply) } + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) - if $display_name { validate_string($display_name) } - if $host_name { validate_string($host_name) } - if $groups { $_groups = any2array($groups) } else { $_groups = undef } - if $check_command { validate_string($check_command) } - if $max_check_attempts { validate_integer($max_check_attempts) } - if $check_period { validate_string($check_period) } + if $display_name { validate_string ($display_name) } + validate_string($host_name) + if $groups { validate_array ($groups) } + validate_string($check_command) + if $max_check_attempts { validate_integer ($max_check_attempts) } + if $check_period { validate_string ($check_period) } if $check_timeout { validate_re($check_timeout, '^\d+\.?\d*[d|h|m|s]?$') } if $check_interval { validate_re($check_interval, '^\d+\.?\d*[d|h|m|s]?$') } if $retry_interval { validate_re($retry_interval, '^\d+\.?\d*[d|h|m|s]?$') } - if $enable_notifications { validate_bool($enable_notifications) } - if $enable_active_checks { validate_bool($enable_active_checks) } - if $enable_passive_checks { validate_bool($enable_passive_checks) } - if $enable_event_handler { validate_bool($enable_event_handler) } - if $enable_flapping { validate_bool($enable_flapping) } - if $enable_perfdata { validate_bool($enable_perfdata) } - if $event_command { validate_string($event_command) } - if $flapping_threshold { validate_integer($flapping_threshold) } - if $volatile { validate_bool($volatile) } - if $zone { validate_string($zone) } - if $command_endpoint { validate_string($command_endpoint) } - if $notes { validate_string($notes) } - if $notes_url { validate_string($notes_url) } - if $action_url { validate_string($action_url) } - if $icon_image { validate_absolute_path($icon_image) } - if $icon_image_alt { validate_string($icon_image_alt) } + if $enable_notifications { validate_bool ($enable_notifications) } + if $enable_active_checks { validate_bool ($enable_active_checks) } + if $enable_passive_checks { validate_bool ($enable_passive_checks) } + if $enable_event_handler { validate_bool ($enable_event_handler) } + if $enable_flapping { validate_bool ($enable_flapping) } + if $enable_perfdata { validate_bool ($enable_perfdata) } + if $event_command { validate_string ($event_command) } + if $flapping_threshold { validate_integer ($flapping_threshold) } + if $volatile { validate_bool ($volatile) } + if $zone { validate_string ($zone) } + if $command_endpoint { validate_string ($command_endpoint) } + if $notes { validate_string ($notes) } + if $notes_url { validate_string ($notes_url) } + if $action_url { validate_string ($action_url) } + if $icon_image { validate_absolute_path ($icon_image) } + if $icon_image_alt { validate_string ($icon_image_alt) } # compose the attributes $attrs = { 'display_name' => $display_name , 'host_name' => $host_name , - 'groups' => $_groups , + 'groups' => $groups , 'vars' => $vars , 'check_command' => $check_command , 'max_check_attempts' => $max_check_attempts , diff --git a/manifests/object/servicegroup.pp b/manifests/object/servicegroup.pp index c31a5b056..e45152c9f 100644 --- a/manifests/object/servicegroup.pp +++ b/manifests/object/servicegroup.pp @@ -22,12 +22,12 @@ # [*ignore*] # Exclude users using the group ignore rules. # -# [*import*] -# Sorted List of templates to include. Defaults to an empty list. -# # [*template*] # Set to true creates a template instead of an object. Defaults to false. # +# [*import*] +# Sorted List of templates to include. Defaults to an empty list. +# # [*target*] # Destination config file to store in this object. File will be declared the # first time. @@ -41,11 +41,11 @@ $ensure = present, $servicegroup_name = $title, $display_name = undef, - $groups = undef, + $groups = [], $assign = [], $ignore = [], - $import = [], $template = false, + $import = [], $order = '65', ){ include ::icinga2::params @@ -56,18 +56,19 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($servicegroup_name) + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) + validate_array ( $groups ) if $display_name { validate_string ( $display_name ) } - if $groups { $_groups = any2array($groups) } else { $_groups = undef } # compose attributes $attrs = { 'display_name' => $display_name, - 'groups' => $_groups, + 'groups' => $groups, } # create object diff --git a/manifests/object/timeperiod.pp b/manifests/object/timeperiod.pp index 290ba0a4d..71738d79d 100644 --- a/manifests/object/timeperiod.pp +++ b/manifests/object/timeperiod.pp @@ -60,24 +60,25 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($timeperiod_name) + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) - if $display_name { validate_string($display_name) } - if $ranges { validate_hash($ranges) } - if $prefer_includes { validate_bool($prefer_includes) } - if $excludes { $_excludes = any2array($excludes) } else { $_excludes = undef } - if $includes { $_includes = any2array($includes) } else { $_includes = undef } + if $display_name { validate_string ($display_name) } + if $ranges { validate_hash ($ranges) } + if $prefer_includes { validate_bool ($prefer_includes) } + if $excludes { validate_array ($excludes) } + if $includes { validate_array ($includes) } # compose attributes $attrs = { 'display_name' => $display_name, 'ranges' => $ranges, 'prefer_includes' => $prefer_includes, - 'excludes' => $_excludes, - 'includes' => $_includes, + 'excludes' => $excludes, + 'includes' => $includes, } # create object diff --git a/manifests/object/user.pp b/manifests/object/user.pp index 50c4bb495..dcb9496f8 100644 --- a/manifests/object/user.pp +++ b/manifests/object/user.pp @@ -80,18 +80,19 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($user_name) + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) - if $display_name { validate_string($display_name) } - if $email { validate_string($email) } - if $pager { validate_string($pager) } - if $groups { $_groups = any2array($groups) } else { $_groups = undef } - if $enable_notifications { validate_bool($enable_notifications) } - if $period { validate_string($period) } - if $types { $_types = any2array($types) } else { $_types = undef } - if $states { $_states = any2array ($states) } else { $_states = undef } + if $display_name { validate_string ($display_name) } + if $email { validate_string ($email) } + if $pager { validate_string ($pager) } + if $groups { validate_array ($groups) } + if $enable_notifications { validate_bool ($enable_notifications) } + if $period { validate_string ($period) } + if $types { validate_array ($types) } + if $states { validate_array ($states) } validate_integer ( $order ) @@ -101,11 +102,11 @@ 'email' => $email, 'pager' => $pager, 'vars' => $vars, - 'groups' => $_groups, + 'groups' => $groups, 'enable_notifications' => $enable_notifications, 'period' => $period, - 'types' => $_types, - 'states' => $_states, + 'types' => $types, + 'states' => $states, } # create object diff --git a/manifests/object/usergroup.pp b/manifests/object/usergroup.pp index ceb8c3caf..92bd7d82b 100644 --- a/manifests/object/usergroup.pp +++ b/manifests/object/usergroup.pp @@ -41,7 +41,7 @@ $ensure = present, $usergroup_name = $title, $display_name = undef, - $groups = undef, + $groups = [], $assign = [], $ignore = [], $import = [], @@ -56,12 +56,13 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") validate_string($usergroup_name) + validate_array($import) validate_bool($template) validate_absolute_path($target) validate_string($order) - if $display_name { validate_string($display_name) } - if $groups { $_groups = any2array($groups) } else { $_groups = undef } + if $display_name { validate_string ($display_name) } + if $groups { validate_array ($groups) } if $ignore != [] and $assign == [] { fail('When attribute ignore is used, assign must be set.') @@ -70,7 +71,7 @@ # compose attributes $attrs = { 'display_name' => $display_name, - 'groups' => $_groups, + 'groups' => $groups, } # create object diff --git a/manifests/object/zone.pp b/manifests/object/zone.pp index b04952b36..8da98c647 100644 --- a/manifests/object/zone.pp +++ b/manifests/object/zone.pp @@ -31,7 +31,7 @@ define icinga2::object::zone( $ensure = present, $zone_name = $title, - $endpoints = undef, + $endpoints = [], $parent = undef, $global = false, $target = undef, @@ -48,7 +48,7 @@ validate_string($zone_name) validate_integer($order) - if $endpoints { $_endpoints = any2array($endpoints) } else { $_endpoints = undef } + if $endpoints { validate_array($endpoints) } if $parent { validate_string($parent) } if $global { validate_bool($global) } @@ -68,7 +68,7 @@ } } else { $attrs = { - endpoints => $_endpoints, + endpoints => $endpoints, parent => $parent, } } diff --git a/spec/classes/idomysql_spec.rb b/spec/classes/idomysql_spec.rb index 7317387f5..a36540c2a 100644 --- a/spec/classes/idomysql_spec.rb +++ b/spec/classes/idomysql_spec.rb @@ -33,7 +33,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::IdoMysqlConnection::ido-mysql') .with({ 'target' => '/etc/icinga2/features-available/ido-mysql.conf' }) - .without_content(/categories =/) .with_content(/host = "127.0.0.1"/) .with_content(/port = 3306/) .with_content(/user = "icinga"/) @@ -307,12 +306,10 @@ end - context "#{os} with categories => 'foo'" do + context "#{os} with categories => 'foo' (not a valid array)" do let(:params) { {:categories => 'foo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::IdoMysqlConnection::ido-mysql') - .with({ 'target' => '/etc/icinga2/features-available/ido-mysql.conf' }) - .with_content(/categories = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -376,7 +373,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::IdoMysqlConnection::ido-mysql') .with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/ido-mysql.conf' }) - .without_content(/categories =/) .with_content(/host = "127.0.0.1"/) .with_content(/port = 3306/) .with_content(/user = "icinga"/) @@ -649,12 +645,10 @@ end - context "Windows 2012 R2 with categories => 'foo'" do + context "Windows 2012 R2 with categories => 'foo' (not a valid array)" do let(:params) { {:categories => 'foo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::IdoMysqlConnection::ido-mysql') - .with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/ido-mysql.conf' }) - .with_content(/categories = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end diff --git a/spec/classes/idopgsql_spec.rb b/spec/classes/idopgsql_spec.rb index 23c8a96eb..f881fe5a1 100644 --- a/spec/classes/idopgsql_spec.rb +++ b/spec/classes/idopgsql_spec.rb @@ -29,7 +29,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::IdoPgsqlConnection::ido-pgsql') .with({ 'target' => '/etc/icinga2/features-available/ido-pgsql.conf' }) - .without_content(/categories =/) .with_content(/host = "127.0.0.1"/) .with_content(/port = 5432/) .with_content(/user = "icinga"/) @@ -168,12 +167,10 @@ end - context "#{os} with categories => 'foo'" do + context "#{os} with categories => 'foo' (not a valid array)" do let(:params) { {:categories => 'foo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::IdoPgsqlConnection::ido-pgsql') - .with({ 'target' => '/etc/icinga2/features-available/ido-pgsql.conf' }) - .with_content(/categories = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -234,7 +231,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::IdoPgsqlConnection::ido-pgsql') .with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/ido-pgsql.conf' }) - .without_content(/categories =/) .with_content(/host = "127.0.0.1"/) .with_content(/port = 5432/) .with_content(/user = "icinga"/) @@ -373,12 +369,10 @@ end - context "Windows 2012 R2 with categories => 'foo'" do + context "Windows 2012 R2 with categories => 'foo' (not a valid array)" do let(:params) { {:categories => 'foo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::IdoPgsqlConnection::ido-pgsql') - .with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/ido-pgsql.conf' }) - .with_content(/categories = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end diff --git a/spec/defines/apiuser_spec.rb b/spec/defines/apiuser_spec.rb index 54e87d8d8..b4a55e4f4 100644 --- a/spec/defines/apiuser_spec.rb +++ b/spec/defines/apiuser_spec.rb @@ -61,12 +61,10 @@ end - context "#{os} with permissions => foo" do + context "#{os} with permissions => foo (not a valid array)" do let(:params) { {:permissions => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::ApiUser::bar') - .with({'target' => '/bar/baz'}) - .with_content(/permissions = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end end @@ -143,11 +141,9 @@ end - context "Windows 2012 R2 with permissions => foo" do + context "Windows 2012 R2 with permissions => foo (not a valid array)" do let(:params) { {:permissions => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::ApiUser::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/permissions = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end -end +end \ No newline at end of file diff --git a/spec/defines/checkcommand_spec.rb b/spec/defines/checkcommand_spec.rb index 75a8fb114..24994c741 100644 --- a/spec/defines/checkcommand_spec.rb +++ b/spec/defines/checkcommand_spec.rb @@ -19,7 +19,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::CheckCommand::bar') .with({'target' => '/bar/baz'}) - .without_content(/command =/) .with_content(/object CheckCommand "bar"/) } end @@ -33,12 +32,12 @@ end - context "#{os} with command => PluginDir + /bar" do - let(:params) { {:command => 'PluginDir + /bar', :target => '/bar/baz'} } + context "#{os} with command => foo" do + let(:params) { {:command => 'foo', :target => '/bar/baz'} } it { is_expected.to contain_concat__fragment('icinga2::object::CheckCommand::bar') .with({'target' => '/bar/baz'}) - .with_content(/command = \[ PluginDir \+ "\/bar", \]/) } + .with_content(/command = "foo"/) } end @@ -107,13 +106,12 @@ ] } context "Windows 2012 R2 with all defaults and target => C:/bar/baz" do - let(:params) { {:target => 'C:/bar/baz'} } + let(:params) { {:target => 'C:/bar/baz', :command => ['foocommand']} } it { is_expected.to contain_concat('C:/bar/baz') } it { is_expected.to contain_concat__fragment('icinga2::object::CheckCommand::bar') .with({'target' => 'C:/bar/baz'}) - .without_content(/command =/) .with_content(/object CheckCommand "bar"/) } end @@ -127,12 +125,12 @@ end - context "Windows 2012 R2 with command => PluginDir + /bar" do - let(:params) { {:command => 'PluginDir + /bar', :target => 'C:/bar/baz'} } + context "Windows 2012 R2 with command => foo" do + let(:params) { {:command => 'foo', :target => 'C:/bar/baz'} } it { is_expected.to contain_concat__fragment('icinga2::object::CheckCommand::bar') .with({'target' => 'C:/bar/baz'}) - .with_content(/command = \[ PluginDir \+ "\/bar", \]/) } + .with_content(/command = "foo"/) } end diff --git a/spec/defines/dependency_spec.rb b/spec/defines/dependency_spec.rb index e601e07d1..2ea3033bc 100644 --- a/spec/defines/dependency_spec.rb +++ b/spec/defines/dependency_spec.rb @@ -22,7 +22,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Dependency::bar') .with({'target' => '/bar/baz'}) .with_content(/object Dependency "bar"/) - .without_content(/states =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -188,16 +187,14 @@ end - context "#{os} with states => foo" do + context "#{os} with states => foo (not a valid array)" do let(:params) { { :states => 'foo', :target => '/bar/baz', :parent_host_name => 'parentfoo', :child_host_name => 'childfoo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Dependency::bar') - .with({'target' => '/bar/baz'}) - .with_content(/states = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end end @@ -237,7 +234,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Dependency::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object Dependency "bar"/) - .without_content(/states =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -403,15 +399,13 @@ end - context "Windows 2012 R2 with states => foo" do + context "Windows 2012 R2 with states => foo (not a valid array)" do let(:params) { { :states => 'foo', :target => 'C:/bar/baz', :parent_host_name => 'parentfoo', :child_host_name => 'childfoo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Dependency::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/states = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end diff --git a/spec/defines/host_spec.rb b/spec/defines/host_spec.rb index d87aaa663..77137fad3 100644 --- a/spec/defines/host_spec.rb +++ b/spec/defines/host_spec.rb @@ -20,8 +20,7 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Host::bar') .with({'target' => '/bar/baz'}) .with_content(/object Host "bar"/) - .with_content(/check_command = "foocommand"/) - .without_content(/groups =/)} + .with_content(/check_command = "foocommand"/)} end @@ -32,6 +31,22 @@ end + context "#{os} with import => [foo, bar]" do + let(:params) { {:import => ['foo','bar'], :target => '/bar/baz', :check_command => 'foocommand'} } + + it { is_expected.to contain_concat__fragment('icinga2::object::Host::bar') + .with({'target' => '/bar/baz'}) + .with_content(/import "foo"\n\s*import "bar"/) } + end + + + context "#{os} with import => foo (not a valid array)" do + let(:params) { {:import => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } + + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } + end + + context "#{os} with display_name => foo" do let(:params) { {:display_name => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } @@ -68,12 +83,10 @@ end - context "#{os} with groups => foo" do + context "#{os} with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Host::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -469,8 +482,7 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Host::bar') .with({'target' => '/bar/baz'}) .with_content(/object Host "bar"/) - .with_content(/check_command = "foocommand"/) - .without_content(/groups =/)} + .with_content(/check_command = "foocommand"/)} end @@ -481,6 +493,22 @@ end + context "Windows 2012 R2 with import => [foo, bar]" do + let(:params) { {:import => ['foo','bar'], :target => '/bar/baz', :check_command => 'foocommand'} } + + it { is_expected.to contain_concat__fragment('icinga2::object::Host::bar') + .with({'target' => '/bar/baz'}) + .with_content(/import "foo"\r\n\s*import "bar"/) } + end + + + context "Windows 2012 R2 with import => foo (not a valid array)" do + let(:params) { {:import => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } + + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } + end + + context "Windows 2012 R2 with display_name => foo" do let(:params) { {:display_name => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } @@ -517,12 +545,10 @@ end - context "Windows 2012 R2 with groups => foo" do + context "Windows 2012 R2 with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Host::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end diff --git a/spec/defines/hostgroup_spec.rb b/spec/defines/hostgroup_spec.rb index 33fed251d..95d9c6cc5 100644 --- a/spec/defines/hostgroup_spec.rb +++ b/spec/defines/hostgroup_spec.rb @@ -20,7 +20,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::HostGroup::bar') .with({'target' => '/bar/baz'}) .with_content(/object HostGroup "bar"/) - .without_content(/groups =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -47,12 +46,10 @@ end - context "#{os} with groups => foo" do + context "#{os} with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::HostGroup::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -95,7 +92,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::HostGroup::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object HostGroup "bar"/) - .without_content(/groups =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -122,12 +118,10 @@ end - context "Windows 2012 R2 with groups => foo" do + context "Windows 2012 R2 with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::HostGroup::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end diff --git a/spec/defines/notification_spec.rb b/spec/defines/notification_spec.rb index 5eb4668f2..8218641c7 100644 --- a/spec/defines/notification_spec.rb +++ b/spec/defines/notification_spec.rb @@ -18,10 +18,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') .with({'target' => '/bar/baz'}) - .without_content(/users =/) - .without_content(/user_groups =/) - .without_content(/types =/) - .without_content(/states =/) .with_content(/object Notification "bar"/) .with_content(/host_name = "foohost"/)} @@ -76,12 +72,10 @@ end - context "#{os} with users => foo" do + context "#{os} with users => foo (not a valid array)" do let(:params) { {:users => 'foo', :target => '/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => '/bar/baz'}) - .with_content(/users = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -94,12 +88,10 @@ end - context "#{os} with user_groups => foo" do + context "#{os} with user_groups => foo (not a valid array)" do let(:params) { {:user_groups => 'foo', :target => '/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => '/bar/baz'}) - .with_content(/user_groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -171,12 +163,10 @@ end - context "#{os} with types => foo" do + context "#{os} with types => foo (not a valid array)" do let(:params) { {:types => 'foo', :target => '/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => '/bar/baz'}) - .with_content(/types = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -189,12 +179,10 @@ end - context "#{os} with states => foo" do + context "#{os} with states => foo (not a valid array)" do let(:params) { {:states => 'foo', :target => '/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => '/bar/baz'}) - .with_content(/states = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end context "#{os} with assign => [] and ignore => [ foo ]" do @@ -236,10 +224,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') .with({'target' => 'C:/bar/baz'}) - .without_content(/users =/) - .without_content(/user_groups =/) - .without_content(/types =/) - .without_content(/states =/) .with_content(/object Notification "bar"/) .with_content(/host_name = "foohost"/)} @@ -294,12 +278,10 @@ end - context "Windows 2012 R2 with users => foo" do + context "Windows 2012 R2 with users => foo (not a valid array)" do let(:params) { {:users => 'foo', :target => 'C:/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/users = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -312,12 +294,10 @@ end - context "Windows 2012 R2 with user_groups => foo" do + context "Windows 2012 R2 with user_groups => foo (not a valid array)" do let(:params) { {:user_groups => 'foo', :target => 'C:/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/user_groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -389,12 +369,10 @@ end - context "Windows 2012 R2 with types => foo" do + context "Windows 2012 R2 with types => foo (not a valid array)" do let(:params) { {:types => 'foo', :target => 'C:/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/types = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -407,12 +385,10 @@ end - context "Windows 2012 R2 with states => foo" do + context "Windows 2012 R2 with states => foo (not a valid array)" do let(:params) { {:states => 'foo', :target => 'C:/bar/baz', :host_name => 'foohost'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/states = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end context "Windows 2012 R2 with assign => [] and ignore => [ foo ]" do diff --git a/spec/defines/notificationcommand_spec.rb b/spec/defines/notificationcommand_spec.rb index 1338cce2d..7733383a3 100644 --- a/spec/defines/notificationcommand_spec.rb +++ b/spec/defines/notificationcommand_spec.rb @@ -12,14 +12,14 @@ end context "#{os} with all defaults and target => /bar/baz" do - let(:params) { {:target => '/bar/baz'} } + let(:params) { {:target => '/bar/baz', :command => ['foocommand']} } it { is_expected.to contain_concat('/bar/baz') } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({'target' => '/bar/baz'}) .with_content(/object NotificationCommand "bar"/) - .without_content(/command =/)} + .with_content(/command = \[ "foocommand", \]/)} it { is_expected.to contain_icinga2__object('icinga2::object::NotificationCommand::bar') .that_notifies('Class[icinga2::service]') } @@ -49,12 +49,12 @@ it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({'target' => '/bar/baz'}) - .with_content(/command = \[ "foo", \]/) } + .with_content(/command = "foo"/) } end context "#{os} with env => { foo => 'bar', bar => 'foo' }" do - let(:params) { {:env => { 'foo' => "bar", 'bar' => "foo"}, :target => '/bar/baz'} } + let(:params) { {:env => { 'foo' => "bar", 'bar' => "foo"}, :target => '/bar/baz', :command => ['foocommand'] } } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({ 'target' => '/bar/baz' }) @@ -63,14 +63,14 @@ context "#{os} with env => 'foo' (not a valid hash)" do - let(:params) { {:env => 'foo', :target => '/bar/baz'} } + let(:params) { {:env => 'foo', :target => '/bar/baz', :command => ['foocommand']} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a Hash/) } end context "#{os} with vars => { foo => 'bar', bar => 'foo' }" do - let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => '/bar/baz'} } + let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => '/bar/baz', :command => ['foocommand'] } } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({ 'target' => '/bar/baz' }) @@ -80,7 +80,7 @@ context "#{os} with timeout => 30" do - let(:params) { {:timeout => '30', :target => '/bar/baz'} } + let(:params) { {:timeout => '30', :target => '/bar/baz', :command => ['foocommand']} } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({'target' => '/bar/baz'}) @@ -89,7 +89,7 @@ context "#{os} with timeout => foo (not a valid integer)" do - let(:params) { {:timeout => 'foo', :target => '/bar/baz'} } + let(:params) { {:timeout => 'foo', :target => '/bar/baz', :command => ['foocommand']} } it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } end @@ -108,7 +108,7 @@ context "#{os} with arguments => foo (not a valid hash)" do - let(:params) { {:arguments => 'foo', :target => '/bar/baz'} } + let(:params) { {:arguments => 'foo', :target => '/bar/baz', :command => ['foocommand']} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a Hash/) } end @@ -141,14 +141,14 @@ context "Windows 2012 R2 with all defaults and target => C:/bar/baz" do - let(:params) { {:target => 'C:/bar/baz'} } + let(:params) { {:target => 'C:/bar/baz', :command => ['foocommand']} } it { is_expected.to contain_concat('C:/bar/baz') } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object NotificationCommand "bar"/) - .without_content(/command =/)} + .with_content(/command = \[ "foocommand", \]/)} it { is_expected.to contain_icinga2__object('icinga2::object::NotificationCommand::bar') .that_notifies('Class[icinga2::service]') } @@ -178,12 +178,12 @@ it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({'target' => 'C:/bar/baz'}) - .with_content(/command = \[ "foo", \]/) } + .with_content(/command = "foo"/) } end context "Windows 2012 R2 with env => { foo => 'bar', bar => 'foo' }" do - let(:params) { {:env => { 'foo' => "bar", 'bar' => "foo"}, :target => 'C:/bar/baz'} } + let(:params) { {:env => { 'foo' => "bar", 'bar' => "foo"}, :target => 'C:/bar/baz', :command => ['foocommand'] } } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({ 'target' => 'C:/bar/baz' }) @@ -192,14 +192,14 @@ context "Windows 2012 R2 with env => 'foo' (not a valid hash)" do - let(:params) { {:env => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:env => 'foo', :target => 'C:/bar/baz', :command => ['foocommand']} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a Hash/) } end context "Windows 2012 R2 with vars => { foo => 'bar', bar => 'foo' }" do - let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => 'C:/bar/baz'} } + let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => 'C:/bar/baz', :command => ['foocommand'] } } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({ 'target' => 'C:/bar/baz' }) @@ -209,7 +209,7 @@ context "Windows 2012 R2 with timeout => 30" do - let(:params) { {:timeout => '30', :target => 'C:/bar/baz'} } + let(:params) { {:timeout => '30', :target => 'C:/bar/baz', :command => ['foocommand']} } it { is_expected.to contain_concat__fragment('icinga2::object::NotificationCommand::bar') .with({'target' => 'C:/bar/baz'}) @@ -218,7 +218,7 @@ context "Windows 2012 R2 with timeout => foo (not a valid integer)" do - let(:params) { {:timeout => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:timeout => 'foo', :target => 'C:/bar/baz', :command => ['foocommand']} } it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } end @@ -237,7 +237,7 @@ context "Windows 2012 R2 with arguments => foo (not a valid hash)" do - let(:params) { {:arguments => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:arguments => 'foo', :target => 'C:/bar/baz', :command => ['foocommand']} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a Hash/) } end diff --git a/spec/defines/object_spec.rb b/spec/defines/object_spec.rb index 652a716fa..7b9102cc2 100644 --- a/spec/defines/object_spec.rb +++ b/spec/defines/object_spec.rb @@ -142,11 +142,10 @@ end - context "#{os} with import => foo" do + context "#{os} with import => foo (not a valid array)" do let(:params) { {:import => 'foo', :object_type => 'foo', :target => '/bar/baz', :order => '10'} } - it { is_expected.to contain_concat__fragment('bar') - .with_content(/import "foo"/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -159,15 +158,14 @@ end - context "#{os} with assign => host.vars.os == bar && host.address" do - let(:params) { {:assign => 'host.vars.os == bar && host.address', :object_type => 'foo', :target => '/bar/baz', :order => '10'} } + context "#{os} with assign => foo (not a valid array)" do + let(:params) { {:assign => 'foo', :object_type => 'foo', :target => '/bar/baz', :order => '10'} } - it { is_expected.to contain_concat__fragment('bar') - .with_content(/assign where host.vars.os == "bar" && host.address/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end - context "#{os} with ignore => [ NodeName != baz || !host.display_name ]" do + context "#{os} with ignore => [ NodeName != baz || !host.display_name]" do let(:params) { {:ignore => ['NodeName != baz || !host.display_name'], :object_type => 'foo', :target => '/bar/baz', :order => '10'} } it { is_expected.to contain_concat__fragment('bar') @@ -175,11 +173,10 @@ end - context "#{os} with ignore => NodeName != baz || !host.display_name" do - let(:params) { {:ignore => 'NodeName != baz || !host.display_name', :object_type => 'foo', :target => '/bar/baz', :order => '10'} } + context "#{os} with ignore => foo (not a valid array)" do + let(:params) { {:ignore => 'foo', :object_type => 'foo', :target => '/bar/baz', :order => '10'} } - it { is_expected.to contain_concat__fragment('bar') - .with_content(/ignore where NodeName != "baz" \|{2} !host.display_name/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -370,11 +367,10 @@ end - context "Windows 2012 R2 with import => foo" do + context "Windows 2012 R2 with import => foo (not a valid array)" do let(:params) { {:import => 'foo', :object_type => 'foo', :target => 'C:/bar/baz', :order => '10'} } - it { is_expected.to contain_concat__fragment('bar') - .with_content(/import "foo"/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -387,11 +383,10 @@ end - context "Windows 2012 R2 with assign => host.vars.os == bar && host.address" do - let(:params) { {:assign => 'host.vars.os == bar && host.address', :object_type => 'foo', :target => 'C:/bar/baz', :order => '10'} } + context "Windows 2012 R2 with assign => foo (not a valid array)" do + let(:params) { {:assign => 'foo', :object_type => 'foo', :target => 'C:/bar/baz', :order => '10'} } - it { is_expected.to contain_concat__fragment('bar') - .with_content(/assign where host.vars.os == "bar" && host.address/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -403,11 +398,10 @@ end - context "Windows 2012 R2 with ignore => NodeName != baz || !host.display_name" do - let(:params) { {:ignore => 'NodeName != baz || !host.display_name', :object_type => 'foo', :target => 'C:/bar/baz', :order => '10'} } + context "Windows 2012 R2 with ignore => foo (not a valid array)" do + let(:params) { {:ignore => 'foo', :object_type => 'foo', :target => 'C:/bar/baz', :order => '10'} } - it { is_expected.to contain_concat__fragment('bar') - .with_content(/ignore where NodeName != "baz" \|{2} !host.display_name/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end diff --git a/spec/defines/service_spec.rb b/spec/defines/service_spec.rb index 2e4d4fb06..31e43e5b2 100644 --- a/spec/defines/service_spec.rb +++ b/spec/defines/service_spec.rb @@ -13,13 +13,15 @@ context "#{os} with all defaults and target => /bar/baz" do - let(:params) { {:target => '/bar/baz'} } + let(:params) { { + :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat('/bar/baz') } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) - .without_content(/groups =/) .with_content(/object Service "bar"/) } it { is_expected.to contain_icinga2__object('icinga2::object::Service::bar') @@ -28,7 +30,9 @@ context "#{os} with service_name => foo" do - let(:params) { {:service_name => 'foo', :target => '/bar/baz'} } + let(:params) { {:service_name => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -37,7 +41,9 @@ context "#{os} with display_name => foo" do - let(:params) { {:display_name => 'foo', :target => '/bar/baz'} } + let(:params) { {:display_name => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -46,7 +52,8 @@ context "#{os} with host_name => foo" do - let(:params) { {:host_name => 'foo', :target => '/bar/baz'} } + let(:params) { {:host_name => 'foo', :target => '/bar/baz', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -55,7 +62,9 @@ context "#{os} with groups => [foo, bar]" do - let(:params) { {:groups => ['foo','bar'], :target => '/bar/baz'} } + let(:params) { {:groups => ['foo','bar'], :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -63,16 +72,18 @@ end - context "#{os} with groups => foo" do - let(:params) { {:groups => 'foo', :target => '/bar/baz'} } + context "#{os} with groups => foo (not a valid array)" do + let(:params) { {:groups => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end context "#{os} with vars => { foo => 'bar', bar => 'foo' }" do - let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => '/bar/baz'} } + let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo' } } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({ 'target' => '/bar/baz' }) @@ -82,7 +93,8 @@ context "#{os} with check_command => foo" do - let(:params) { {:check_command => 'foo', :target => '/bar/baz'} } + let(:params) { {:check_command => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -91,7 +103,9 @@ context "#{os} with max_check_attempts => 30" do - let(:params) { {:max_check_attempts => '30', :target => '/bar/baz'} } + let(:params) { {:max_check_attempts => '30', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -100,7 +114,9 @@ context "#{os} with max_check_attempts => foo (not a valid integer)" do - let(:params) { {:max_check_attempts => 'foo', :target => '/bar/baz'} } + let(:params) { {:max_check_attempts => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } end @@ -108,7 +124,8 @@ context "#{os} with check_period => foo" do - let(:params) { {:check_period => 'foo', :target => '/bar/baz'} } + let(:params) { {:check_period => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -126,14 +143,16 @@ context "#{os} with check_interval => foo (not a valid value)" do - let(:params) { {:check_interval => 'foo', :target => '/bar/baz'} } + let(:params) { {:check_interval => 'foo', :target => '/bar/baz', :check_command => 'foocommand'} } it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) } end context "#{os} with retry_interval => 30s" do - let(:params) { {:retry_interval => '30s', :target => '/bar/baz'} } + let(:params) { {:retry_interval => '30s', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -142,14 +161,18 @@ context "#{os} with retry_interval => foo (not a valid value)" do - let(:params) { {:retry_interval => 'foo', :target => '/bar/baz'} } + let(:params) { {:retry_interval => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) } end context "#{os} with enable_notifications => false" do - let(:params) { {:enable_notifications => false, :target => '/bar/baz'} } + let(:params) { {:enable_notifications => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -158,14 +181,18 @@ context "#{os} with enable_notifications => foo (not a valid boolean)" do - let(:params) { {:enable_notifications => 'foo', :target => '/bar/baz'} } + let(:params) { {:enable_notifications => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with enable_active_checks => false" do - let(:params) { {:enable_active_checks => false, :target => '/bar/baz'} } + let(:params) { {:enable_active_checks => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -174,14 +201,18 @@ context "#{os} with enable_active_checks => foo (not a valid boolean)" do - let(:params) { {:enable_active_checks => 'foo', :target => '/bar/baz'} } + let(:params) { {:enable_active_checks => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with enable_passive_checks => false" do - let(:params) { {:enable_passive_checks => false, :target => '/bar/baz'} } + let(:params) { {:enable_passive_checks => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -190,14 +221,18 @@ context "#{os} with enable_passive_checks => foo (not a valid boolean)" do - let(:params) { {:enable_passive_checks => 'foo', :target => '/bar/baz'} } + let(:params) { {:enable_passive_checks => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with enable_event_handler => false" do - let(:params) { {:enable_event_handler => false, :target => '/bar/baz'} } + let(:params) { {:enable_event_handler => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -206,14 +241,18 @@ context "#{os} with enable_event_handler => foo (not a valid boolean)" do - let(:params) { {:enable_event_handler => 'foo', :target => '/bar/baz'} } + let(:params) { {:enable_event_handler => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with enable_flapping => false" do - let(:params) { {:enable_flapping => false, :target => '/bar/baz'} } + let(:params) { {:enable_flapping => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -222,14 +261,18 @@ context "#{os} with enable_flapping => foo (not a valid boolean)" do - let(:params) { {:enable_flapping => 'foo', :target => '/bar/baz'} } + let(:params) { {:enable_flapping => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with enable_perfdata => false" do - let(:params) { {:enable_perfdata => false, :target => '/bar/baz'} } + let(:params) { {:enable_perfdata => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -238,14 +281,18 @@ context "#{os} with enable_perfdata => foo (not a valid boolean)" do - let(:params) { {:enable_perfdata => 'foo', :target => '/bar/baz'} } + let(:params) { {:enable_perfdata => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with event_command => foo" do - let(:params) { {:event_command => 'foo', :target => '/bar/baz'} } + let(:params) { {:event_command => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -254,7 +301,9 @@ context "#{os} with flapping_threshold => 30" do - let(:params) { {:flapping_threshold => '30', :target => '/bar/baz'} } + let(:params) { {:flapping_threshold => '30', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -263,14 +312,18 @@ context "#{os} with flapping_threshold => foo (not a valid integer)" do - let(:params) { {:flapping_threshold => 'foo', :target => '/bar/baz'} } + let(:params) { {:flapping_threshold => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } end context "#{os} with volatile => false" do - let(:params) { {:volatile => false, :target => '/bar/baz'} } + let(:params) { {:volatile => false, :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -279,14 +332,18 @@ context "#{os} with volatile => foo (not a valid boolean)" do - let(:params) { {:volatile => 'foo', :target => '/bar/baz'} } + let(:params) { {:volatile => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "#{os} with zone => foo" do - let(:params) { {:zone => 'foo', :target => '/bar/baz'} } + let(:params) { {:zone => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -295,7 +352,9 @@ context "#{os} with command_endpoint => foo" do - let(:params) { {:command_endpoint => 'foo', :target => '/bar/baz'} } + let(:params) { {:command_endpoint => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -304,7 +363,9 @@ context "#{os} with notes => foo" do - let(:params) { {:notes => 'foo', :target => '/bar/baz'} } + let(:params) { {:notes => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -313,7 +374,9 @@ context "#{os} with notes_url => foo" do - let(:params) { {:notes_url => 'foo', :target => '/bar/baz'} } + let(:params) { {:notes_url => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -322,7 +385,9 @@ context "#{os} with action_url => foo" do - let(:params) { {:action_url => 'foo', :target => '/bar/baz'} } + let(:params) { {:action_url => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -331,7 +396,9 @@ context "#{os} with icon_image = /foo/bar" do - let(:params) { {:icon_image => '/foo/bar', :target => '/bar/baz'} } + let(:params) { {:icon_image => '/foo/bar', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({ 'target' => '/bar/baz' }) @@ -340,14 +407,18 @@ context "#{os} with icon_image = foo/bar (not a valid absolute path)" do - let(:params) { {:icon_image => 'foo/bar', :target => '/bar/baz'} } + let(:params) { {:icon_image => 'foo/bar', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) } end context "#{os} with icon_image_alt => foo" do - let(:params) { {:icon_image_alt => 'foo', :target => '/bar/baz'} } + let(:params) { {:icon_image_alt => 'foo', :target => '/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => '/bar/baz'}) @@ -381,13 +452,15 @@ context "Windows 2012 R2 with all defaults and target => C:/bar/baz" do - let(:params) { {:target => 'C:/bar/baz'} } + let(:params) { { + :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat('C:/bar/baz') } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) - .without_content(/groups =/) .with_content(/object Service "bar"/) } it { is_expected.to contain_icinga2__object('icinga2::object::Service::bar') @@ -396,7 +469,9 @@ context "Windows 2012 R2 with service_name => foo" do - let(:params) { {:service_name => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:service_name => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -405,7 +480,9 @@ context "Windows 2012 R2 with display_name => foo" do - let(:params) { {:display_name => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:display_name => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -414,7 +491,8 @@ context "Windows 2012 R2 with host_name => foo" do - let(:params) { {:host_name => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:host_name => 'foo', :target => 'C:/bar/baz', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -423,7 +501,9 @@ context "Windows 2012 R2 with groups => [foo, bar]" do - let(:params) { {:groups => ['foo','bar'], :target => 'C:/bar/baz'} } + let(:params) { {:groups => ['foo','bar'], :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -431,16 +511,18 @@ end - context "Windows 2012 R2 with groups => foo" do - let(:params) { {:groups => 'foo', :target => 'C:/bar/baz'} } + context "Windows 2012 R2 with groups => foo (not a valid array)" do + let(:params) { {:groups => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end context "Windows 2012 R2 with vars => { foo => 'bar', bar => 'foo' }" do - let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => 'C:/bar/baz'} } + let(:params) { {:vars => { 'foo' => "bar", 'bar' => "foo"}, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo' } } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({ 'target' => 'C:/bar/baz' }) @@ -450,7 +532,8 @@ context "Windows 2012 R2 with check_command => foo" do - let(:params) { {:check_command => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:check_command => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -459,7 +542,9 @@ context "Windows 2012 R2 with max_check_attempts => 30" do - let(:params) { {:max_check_attempts => '30', :target => 'C:/bar/baz'} } + let(:params) { {:max_check_attempts => '30', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -468,14 +553,17 @@ context "Windows 2012 R2 with max_check_attempts => foo (not a valid integer)" do - let(:params) { {:max_check_attempts => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:max_check_attempts => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } end context "Windows 2012 R2 with check_period => foo" do - let(:params) { {:check_period => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:check_period => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -493,14 +581,16 @@ context "Windows 2012 R2 with check_interval => foo (not a valid value)" do - let(:params) { {:check_interval => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:check_interval => 'foo', :target => 'C:/bar/baz', :check_command => 'foocommand'} } it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) } end context "Windows 2012 R2 with retry_interval => 30s" do - let(:params) { {:retry_interval => '30s', :target => 'C:/bar/baz'} } + let(:params) { {:retry_interval => '30s', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -509,14 +599,18 @@ context "Windows 2012 R2 with retry_interval => foo (not a valid value)" do - let(:params) { {:retry_interval => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:retry_interval => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) } end context "Windows 2012 R2 with enable_notifications => false" do - let(:params) { {:enable_notifications => false, :target => 'C:/bar/baz'} } + let(:params) { {:enable_notifications => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -525,14 +619,18 @@ context "Windows 2012 R2 with enable_notifications => foo (not a valid boolean)" do - let(:params) { {:enable_notifications => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:enable_notifications => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with enable_active_checks => false" do - let(:params) { {:enable_active_checks => false, :target => 'C:/bar/baz'} } + let(:params) { {:enable_active_checks => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -541,14 +639,18 @@ context "Windows 2012 R2 with enable_active_checks => foo (not a valid boolean)" do - let(:params) { {:enable_active_checks => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:enable_active_checks => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with enable_passive_checks => false" do - let(:params) { {:enable_passive_checks => false, :target => 'C:/bar/baz'} } + let(:params) { {:enable_passive_checks => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -557,14 +659,18 @@ context "Windows 2012 R2 with enable_passive_checks => foo (not a valid boolean)" do - let(:params) { {:enable_passive_checks => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:enable_passive_checks => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with enable_event_handler => false" do - let(:params) { {:enable_event_handler => false, :target => 'C:/bar/baz'} } + let(:params) { {:enable_event_handler => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -573,14 +679,18 @@ context "Windows 2012 R2 with enable_event_handler => foo (not a valid boolean)" do - let(:params) { {:enable_event_handler => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:enable_event_handler => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with enable_flapping => false" do - let(:params) { {:enable_flapping => false, :target => 'C:/bar/baz'} } + let(:params) { {:enable_flapping => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -589,14 +699,18 @@ context "Windows 2012 R2 with enable_flapping => foo (not a valid boolean)" do - let(:params) { {:enable_flapping => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:enable_flapping => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with enable_perfdata => false" do - let(:params) { {:enable_perfdata => false, :target => 'C:/bar/baz'} } + let(:params) { {:enable_perfdata => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -605,14 +719,18 @@ context "Windows 2012 R2 with enable_perfdata => foo (not a valid boolean)" do - let(:params) { {:enable_perfdata => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:enable_perfdata => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with event_command => foo" do - let(:params) { {:event_command => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:event_command => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -621,7 +739,9 @@ context "Windows 2012 R2 with flapping_threshold => 30" do - let(:params) { {:flapping_threshold => '30', :target => 'C:/bar/baz'} } + let(:params) { {:flapping_threshold => '30', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -630,14 +750,18 @@ context "Windows 2012 R2 with flapping_threshold => foo (not a valid integer)" do - let(:params) { {:flapping_threshold => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:flapping_threshold => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } end context "Windows 2012 R2 with volatile => false" do - let(:params) { {:volatile => false, :target => 'C:/bar/baz'} } + let(:params) { {:volatile => false, :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -646,14 +770,18 @@ context "Windows 2012 R2 with volatile => foo (not a valid boolean)" do - let(:params) { {:volatile => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:volatile => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end context "Windows 2012 R2 with zone => foo" do - let(:params) { {:zone => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:zone => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -662,7 +790,9 @@ context "Windows 2012 R2 with command_endpoint => foo" do - let(:params) { {:command_endpoint => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:command_endpoint => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -671,7 +801,9 @@ context "Windows 2012 R2 with notes => foo" do - let(:params) { {:notes => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:notes => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -680,7 +812,9 @@ context "Windows 2012 R2 with notes_url => foo" do - let(:params) { {:notes_url => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:notes_url => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -689,7 +823,9 @@ context "Windows 2012 R2 with action_url => foo" do - let(:params) { {:action_url => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:action_url => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) @@ -697,7 +833,9 @@ end context "Windows 2012 R2 with icon_image = /foo/bar" do - let(:params) { {:icon_image => '/foo/bar', :target => 'C:/bar/baz'} } + let(:params) { {:icon_image => '/foo/bar', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({ 'target' => 'C:/bar/baz' }) @@ -706,14 +844,18 @@ context "Windows 2012 R2 with icon_image = foo/bar (not a valid absolute path)" do - let(:params) { {:icon_image => 'foo/bar', :target => 'C:/bar/baz'} } + let(:params) { {:icon_image => 'foo/bar', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to raise_error(Puppet::Error, /"foo\/bar" is not an absolute path/) } end context "Windows 2012 R2 with icon_image_alt => foo" do - let(:params) { {:icon_image_alt => 'foo', :target => 'C:/bar/baz'} } + let(:params) { {:icon_image_alt => 'foo', :target => 'C:/bar/baz', + :host_name => 'hostfoo', + :check_command => 'commandfoo'} } it { is_expected.to contain_concat__fragment('icinga2::object::Service::bar') .with({'target' => 'C:/bar/baz'}) diff --git a/spec/defines/servicegroup_spec.rb b/spec/defines/servicegroup_spec.rb index 4c591a4c8..63d75da77 100644 --- a/spec/defines/servicegroup_spec.rb +++ b/spec/defines/servicegroup_spec.rb @@ -19,7 +19,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::ServiceGroup::bar') .with({'target' => '/bar/baz'}) .with_content(/object ServiceGroup "bar"/) - .without_content(/groups =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -55,12 +54,10 @@ end - context "#{os} with groups => foo" do + context "#{os} with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::ServiceGroup::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end end @@ -97,7 +94,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::ServiceGroup::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object ServiceGroup "bar"/) - .without_content(/groups =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -133,11 +129,9 @@ end - context "Windows 2012 R2 with groups => foo" do + context "Windows 2012 R2 with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::ServiceGroup::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end diff --git a/spec/defines/timeperiod_spec.rb b/spec/defines/timeperiod_spec.rb index 0ee18c884..7a59327ee 100644 --- a/spec/defines/timeperiod_spec.rb +++ b/spec/defines/timeperiod_spec.rb @@ -19,8 +19,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::TimePeriod::bar') .with({'target' => '/bar/baz'}) .with_content(/object TimePeriod "bar"/) - .without_content(/excludes =/) - .without_content(/includes =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -88,12 +86,10 @@ end - context "#{os} with excludes => foo" do + context "#{os} with excludes => foo (not a valid array)" do let(:params) { {:excludes => 'foo', :target => '/bar/baz', :ranges => { 'foo' => "bar", 'bar' => "foo"} }} - it { is_expected.to contain_concat__fragment('icinga2::object::TimePeriod::bar') - .with({'target' => '/bar/baz'}) - .with_content(/excludes = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -106,12 +102,10 @@ end - context "#{os} with includes => foo" do + context "#{os} with includes => foo (not a valid array)" do let(:params) { {:includes => 'foo', :target => '/bar/baz', :ranges => { 'foo' => "bar", 'bar' => "foo"} }} - it { is_expected.to contain_concat__fragment('icinga2::object::TimePeriod::bar') - .with({'target' => '/bar/baz'}) - .with_content(/includes = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end end @@ -147,8 +141,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::TimePeriod::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object TimePeriod "bar"/) - .without_content(/excludes =/) - .without_content(/includes =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -216,12 +208,10 @@ end - context "Windows 2012 R2 with excludes => foo" do + context "Windows 2012 R2 with excludes => foo (not a valid array)" do let(:params) { {:excludes => 'foo', :target => 'C:/bar/baz', :ranges => { 'foo' => "bar", 'bar' => "foo"} }} - it { is_expected.to contain_concat__fragment('icinga2::object::TimePeriod::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/excludes = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -234,12 +224,10 @@ end - context "Windows 2012 R2 with includes => foo" do + context "Windows 2012 R2 with includes => foo (not a valid array)" do let(:params) { {:includes => 'foo', :target => 'C:/bar/baz', :ranges => { 'foo' => "bar", 'bar' => "foo"} }} - it { is_expected.to contain_concat__fragment('icinga2::object::TimePeriod::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/includes = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end diff --git a/spec/defines/user_spec.rb b/spec/defines/user_spec.rb index 692eb682b..3bc10f69f 100644 --- a/spec/defines/user_spec.rb +++ b/spec/defines/user_spec.rb @@ -19,9 +19,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') .with({'target' => '/bar/baz'}) .with_content(/object User "bar"/) - .without_content(/groups =/) - .without_content(/types =/) - .without_content(/states =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -85,12 +82,10 @@ end - context "#{os} with groups => foo" do + context "#{os} with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -128,12 +123,10 @@ end - context "#{os} with types => foo" do + context "#{os} with types => foo (not a valid array)" do let(:params) { {:types => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') - .with({'target' => '/bar/baz'}) - .with_content(/types = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -146,12 +139,10 @@ end - context "#{os} with states => foo" do + context "#{os} with states => foo (not a valid array)" do let(:params) { {:states => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') - .with({'target' => '/bar/baz'}) - .with_content(/states = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end end @@ -187,9 +178,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object User "bar"/) - .without_content(/groups =/) - .without_content(/types =/) - .without_content(/states =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -253,12 +241,10 @@ end - context "Windows 2012 R2 with groups => foo" do + context "Windows 2012 R2 with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -296,12 +282,10 @@ end - context "Windows 2012 R2 with types => foo" do + context "Windows 2012 R2 with types => foo (not a valid array)" do let(:params) { {:types => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/types = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -314,12 +298,10 @@ end - context "Windows 2012 R2 with states => foo" do + context "Windows 2012 R2 with states => foo (not a valid array)" do let(:params) { {:states => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::User::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/states = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end end diff --git a/spec/defines/usergroup_spec.rb b/spec/defines/usergroup_spec.rb index 3259efa47..d4d34caea 100644 --- a/spec/defines/usergroup_spec.rb +++ b/spec/defines/usergroup_spec.rb @@ -19,7 +19,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::UserGroup::bar') .with({'target' => '/bar/baz'}) .with_content(/object UserGroup "bar"/) - .without_content(/groups =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -55,12 +54,10 @@ end - context "#{os} with groups => foo" do + context "#{os} with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::UserGroup::bar') - .with({'target' => '/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -103,7 +100,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::UserGroup::bar') .with({'target' => 'C:/bar/baz'}) .with_content(/object UserGroup "bar"/) - .without_content(/groups =/) .without_content(/assign where/) .without_content(/ignore where/) } @@ -139,12 +135,10 @@ end - context "Windows 2012 R2 with groups => foo" do + context "Windows 2012 R2 with groups => foo (not a valid array)" do let(:params) { {:groups => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::UserGroup::bar') - .with({'target' => 'C:/bar/baz'}) - .with_content(/groups = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end diff --git a/spec/defines/zone_spec.rb b/spec/defines/zone_spec.rb index c41fed677..2f9b1decf 100644 --- a/spec/defines/zone_spec.rb +++ b/spec/defines/zone_spec.rb @@ -19,7 +19,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Zone::bar') .with({'target' => '/bar/baz'}) - .without_content(/endpoints =/) .with_content(/object Zone "bar"/) } end @@ -55,11 +54,10 @@ end - context "#{os} with endpoints => foo" do + context "#{os} with endpoints => foo (not a valid array)" do let(:params) { {:endpoints => 'foo', :target => '/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Zone::bar') - .with_content(/endpoints = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -117,7 +115,6 @@ it { is_expected.to contain_concat__fragment('icinga2::object::Zone::bar') .with({'target' => 'C:/bar/baz'}) - .without_content(/endpoints =/) .with_content(/object Zone "bar"/) } end @@ -153,11 +150,10 @@ end - context "Windows 2012 R2 with endpoints => foo" do + context "Windows 2012 R2 with endpoints => foo (not a valid array)" do let(:params) { {:endpoints => 'foo', :target => 'C:/bar/baz'} } - it { is_expected.to contain_concat__fragment('icinga2::object::Zone::bar') - .with_content(/endpoints = \[ "foo", \]/) } + it { is_expected.to raise_error(Puppet::Error, /"foo" is not an Array/) } end @@ -182,4 +178,4 @@ it { is_expected.to raise_error(Puppet::Error, /"foo" is not a boolean/) } end -end +end \ No newline at end of file diff --git a/templates/object.conf.erb b/templates/object.conf.erb index 19f590ce6..24f8ad3fa 100644 --- a/templates/object.conf.erb +++ b/templates/object.conf.erb @@ -10,10 +10,10 @@ "<%= @object_name %>" <% end -%> <% if @apply && @apply_target %>to <%= @apply_target -%><% end -%> { <% end -%> -<% @_import.each do |i| -%> +<% @import.each do |i| -%> import "<%= i %>" <% end -%> -<% unless @_import.empty? %><%= "\n" %><% end -%> +<% unless @import.empty? %><%= "\n" %><% end -%> <% if @apply.is_a?(String) and @apply =~ /^([A-Za-z_]+)\s+in\s+.+$/ -%> <%= scope.function_icinga2_attributes([@_attrs.merge({$1 => :undef}),2]) -%> <% elsif @apply.is_a?(String) and @apply =~ /^([A-Za-z_]+)\s+=>\s+([A-Za-z_]+)\s+in\s+.+$/ %> From f01902e58e0f68ac1fdcf697b6d866506f377637 Mon Sep 17 00:00:00 2001 From: Blerim Sheqa Date: Mon, 23 Jan 2017 19:15:29 +0100 Subject: [PATCH 2/3] Fix required parameters for service and host objects --- manifests/object/host.pp | 2 +- manifests/object/service.pp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/object/host.pp b/manifests/object/host.pp index 485dd4a76..46a245c0d 100644 --- a/manifests/object/host.pp +++ b/manifests/object/host.pp @@ -160,7 +160,7 @@ if $address6 { validate_string($address6) } if $groups { validate_array($groups) } if $display_name { validate_string($display_name) } - validate_string($check_command) + if $check_command { validate_string($check_command) } if $max_check_attempts { validate_integer($max_check_attempts) } if $check_period { validate_string($check_period) } if $check_timeout { validate_re($check_timeout, '^\d+\.?\d*[d|h|m|s]?$') } diff --git a/manifests/object/service.pp b/manifests/object/service.pp index d4d774d6b..198a7b72c 100644 --- a/manifests/object/service.pp +++ b/manifests/object/service.pp @@ -207,9 +207,9 @@ validate_string($order) if $display_name { validate_string ($display_name) } - validate_string($host_name) + if $host_name { validate_string($host_name) } if $groups { validate_array ($groups) } - validate_string($check_command) + if $check_command { validate_string($check_command) } if $max_check_attempts { validate_integer ($max_check_attempts) } if $check_period { validate_string ($check_period) } if $check_timeout { validate_re($check_timeout, '^\d+\.?\d*[d|h|m|s]?$') } From bbaed14b50e19daf801542cf17c696a4e3626bc0 Mon Sep 17 00:00:00 2001 From: Blerim Sheqa Date: Mon, 23 Jan 2017 19:17:22 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 20db7824d..31f0833bb 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ This module has been tested on: Other operating systems or versions may work but have not been tested. +It's recommended to enable the future parser when using this module in combination with exported resources. + ## Usage ### Installing Icinga 2