From b78ff1156f1a2f5de73b7c97198cafe07703b554 Mon Sep 17 00:00:00 2001 From: Ben Ford Date: Sat, 4 Jan 2020 12:10:18 -0800 Subject: [PATCH] Porting functions to the modern Puppet 4.x API --- .../functions/managedmac/compact_hash.rb | 45 ++++++ .../portablehomes_excluded_items.rb | 53 +++++++ .../portablehomes_synced_folders.rb | 51 +++++++ .../managedmac/process_dsconfigad_params.rb | 69 +++++++++ .../managedmac/process_mcx_options.rb | 134 ++++++++++++++++++ .../managedmac/process_mobileconfig_params.rb | 59 ++++++++ .../functions/managedmac/process_mounts.rb | 57 ++++++++ .../managedmac/validate_raw_constructor.rb | 47 ++++++ .../functions/managedmac/version_compare.rb | 42 ++++++ .../functions/managedmac_compact_hash_spec.rb | 41 ++++++ ...edmac_portablehomes_excluded_items_spec.rb | 41 ++++++ ...edmac_portablehomes_synced_folders_spec.rb | 41 ++++++ ...nagedmac_process_dsconfigad_params_spec.rb | 41 ++++++ .../managedmac_process_mcx_options_spec.rb | 41 ++++++ ...gedmac_process_mobileconfig_params_spec.rb | 41 ++++++ .../managedmac_process_mounts_spec.rb | 41 ++++++ ...anagedmac_validate_raw_constructor_spec.rb | 41 ++++++ .../managedmac_version_compare_spec.rb | 41 ++++++ 18 files changed, 926 insertions(+) create mode 100644 lib/puppet/functions/managedmac/compact_hash.rb create mode 100644 lib/puppet/functions/managedmac/portablehomes_excluded_items.rb create mode 100644 lib/puppet/functions/managedmac/portablehomes_synced_folders.rb create mode 100644 lib/puppet/functions/managedmac/process_dsconfigad_params.rb create mode 100644 lib/puppet/functions/managedmac/process_mcx_options.rb create mode 100644 lib/puppet/functions/managedmac/process_mobileconfig_params.rb create mode 100644 lib/puppet/functions/managedmac/process_mounts.rb create mode 100644 lib/puppet/functions/managedmac/validate_raw_constructor.rb create mode 100644 lib/puppet/functions/managedmac/version_compare.rb create mode 100644 spec/functions/managedmac_compact_hash_spec.rb create mode 100644 spec/functions/managedmac_portablehomes_excluded_items_spec.rb create mode 100644 spec/functions/managedmac_portablehomes_synced_folders_spec.rb create mode 100644 spec/functions/managedmac_process_dsconfigad_params_spec.rb create mode 100644 spec/functions/managedmac_process_mcx_options_spec.rb create mode 100644 spec/functions/managedmac_process_mobileconfig_params_spec.rb create mode 100644 spec/functions/managedmac_process_mounts_spec.rb create mode 100644 spec/functions/managedmac_validate_raw_constructor_spec.rb create mode 100644 spec/functions/managedmac_version_compare_spec.rb diff --git a/lib/puppet/functions/managedmac/compact_hash.rb b/lib/puppet/functions/managedmac/compact_hash.rb new file mode 100644 index 0000000..b3abfba --- /dev/null +++ b/lib/puppet/functions/managedmac/compact_hash.rb @@ -0,0 +1,45 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Hash keys with empty or undef values are deleted. Returns resulting Hash. +# +# +Puppet::Functions.create_function(:'managedmac::compact_hash') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + e = "compact_hash(): Wrong number of args: #{args.size} for 1" + raise(Puppet::ParseError, e) if args.size != 1 + + the_hash = args.shift + raise(Puppet::ParseError, "arg was not a Hash") unless the_hash.is_a? Hash + + the_hash.delete_if do |k,v| + (v.empty? if v.respond_to? :empty?) or v == :undef or v.nil? + end + + end +end diff --git a/lib/puppet/functions/managedmac/portablehomes_excluded_items.rb b/lib/puppet/functions/managedmac/portablehomes_excluded_items.rb new file mode 100644 index 0000000..49747f1 --- /dev/null +++ b/lib/puppet/functions/managedmac/portablehomes_excluded_items.rb @@ -0,0 +1,53 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Returns a Array of properly formatted excludeItems Hashes. +# +# +Puppet::Functions.create_function(:'managedmac::portablehomes_excluded_items') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 1 + e = "portablehomes_excluded_items(): Too many args! (#{args.size} instead of 1)" + raise(Puppet::ParseError, e) + end + + unless args[0].is_a? Hash + e = "portablehomes_excluded_items(): Wrong arg type! (#{args[0].class} instead of Hash)" + raise(Puppet::ParseError, e) + end + + args[0].inject([]) do |memo,(k,v)| + v.each do |p| + memo << {'comparison' => k, 'value' => p} + end + memo + end + + + end +end diff --git a/lib/puppet/functions/managedmac/portablehomes_synced_folders.rb b/lib/puppet/functions/managedmac/portablehomes_synced_folders.rb new file mode 100644 index 0000000..d1f02f3 --- /dev/null +++ b/lib/puppet/functions/managedmac/portablehomes_synced_folders.rb @@ -0,0 +1,51 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Returns a Array of properly formatted syncedFolder Hashes. +# +# +Puppet::Functions.create_function(:'managedmac::portablehomes_synced_folders') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 1 + e = "portablehomes_synced_folders(): Too many args! (#{args.size} instead of 1)" + raise(Puppet::ParseError, e) + end + + unless args[0].is_a? Array + e = "portablehomes_synced_folders(): Wrong arg type! (#{args[0].class} instead of Array)" + raise(Puppet::ParseError, e) + end + + args[0].inject([]) do |memo,e| + memo << {'path' => e} + memo + end + + + end +end diff --git a/lib/puppet/functions/managedmac/process_dsconfigad_params.rb b/lib/puppet/functions/managedmac/process_dsconfigad_params.rb new file mode 100644 index 0000000..5135cec --- /dev/null +++ b/lib/puppet/functions/managedmac/process_dsconfigad_params.rb @@ -0,0 +1,69 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Returns a Hash for Dsconfigad type suitable for consumption by +#`create_resources`. It will compact the data and transform Booleans into the +#preferred enable|disable toggle. Accepts a single argument, a Hash. +# +# +Puppet::Functions.create_function(:'managedmac::process_dsconfigad_params') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 1 + e = "process_dsconfigad_params(): Wrong number of args: #{args.size} \ +for 1" + raise(Puppet::ParseError, e) + end + + params = args[0] + + unless params.is_a? Hash + e = "process_dsconfigad_params(): Wrong arg type! (#{params.class} \ +instead of Hash)" + raise(Puppet::ParseError, e) + end + + params.inject({}) do |memo, (key,value)| + value = case value + when NilClass, :absent, :undef + nil + when TrueClass + 'enable' + when FalseClass + 'disable' + else + value + end + unless value.nil? or (value.respond_to? :empty? and value.empty?) + memo[key] = value + end + memo + end + + + end +end diff --git a/lib/puppet/functions/managedmac/process_mcx_options.rb b/lib/puppet/functions/managedmac/process_mcx_options.rb new file mode 100644 index 0000000..cb181ea --- /dev/null +++ b/lib/puppet/functions/managedmac/process_mcx_options.rb @@ -0,0 +1,134 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- +require 'time' + +# ---- original file header ---- +# +# @summary +# Returns a com.apple.ManagedClient.preferences Payload. +# +# +Puppet::Functions.create_function(:'managedmac::process_mcx_options') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 5 + e = "process_mcx_options(): Wrong number of args: #{args.size} for 5" + raise(Puppet::ParseError, e) + end + + bluetooth, + wifi, + loginitems, + suppress_icloud_setup, + hidden_preference_panes = *args + + settings = { + 'com.apple.MCXBluetooth' => {}, + 'com.apple.MCXAirPort' => {}, + 'loginwindow' => {}, + 'com.apple.SetupAssistant' => {}, + 'com.apple.systempreferences' => {}, + } + + case bluetooth + when TrueClass, FalseClass + settings['com.apple.MCXBluetooth'] = { + 'Forced' => [ + { 'mcx_preference_settings' => { 'DisableBluetooth' => true } } + ] + } + else + settings.delete('com.apple.MCXBluetooth') + end + + case wifi + when TrueClass, FalseClass + settings['com.apple.MCXAirPort'] = { + 'Forced' => [ + { 'mcx_preference_settings' => { 'DisableAirPort' => true } } + ] + } + else + settings.delete('com.apple.MCXAirPort') + end + + if loginitems.empty? + settings.delete('loginwindow') + else + values = loginitems.collect do |path| + Hash['Hide', false, 'Path', path] + end + settings['loginwindow'] = { + 'Forced' => [ + { 'mcx_preference_settings' => { + 'AutoLaunchedApplicationDictionary-managed' => values, + 'DisableLoginItemsSuppression' => false, + 'LoginUserMayAddItems' => true, + } + }, + ] + } + end + + case suppress_icloud_setup + when true + settings['com.apple.SetupAssistant'] = { + 'Set-Once' => [ + { 'mcx_data_timestamp' => Time.parse('2013-10-29T17:20:10'), + 'mcx_preference_settings' => { + 'DidSeeCloudSetup' => true, + 'LastSeenCloudProductVersion' => + lookupvar('macosx_productversion_major'), + }, + }, + ] + } + else + settings.delete('com.apple.SetupAssistant') + end + + if hidden_preference_panes.empty? + settings.delete('com.apple.systempreferences') + else + settings['com.apple.systempreferences'] = { + 'Forced' => [ + { 'mcx_preference_settings' => { + 'HiddenPreferencePanes' => hidden_preference_panes, + } + }, + ] + } + end + + return [] if settings.empty? + + # Return a PayloadContent Array + hash = { 'PayloadType' => 'com.apple.ManagedClient.preferences', + 'PayloadContent' => settings, + } + + [hash] + + end +end diff --git a/lib/puppet/functions/managedmac/process_mobileconfig_params.rb b/lib/puppet/functions/managedmac/process_mobileconfig_params.rb new file mode 100644 index 0000000..c5e37c3 --- /dev/null +++ b/lib/puppet/functions/managedmac/process_mobileconfig_params.rb @@ -0,0 +1,59 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Returns a Payload Array for Mobileconfig type. Accepts a Hash. Each key is a +#string representing the PayloadType key. The value of said key is the payload +#data. Keys with empty or :undef values will be expunged. +# +# +Puppet::Functions.create_function(:'managedmac::process_mobileconfig_params') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 1 + e = "process_mobileconfig_params(): Wrong number of args: #{args.size} for 1" + raise(Puppet::ParseError, e) + end + + params = args[0] + + unless params.is_a? Hash + e = "process_mobileconfig_params(): Wrong arg type! (#{params.class} instead of Hash)" + raise(Puppet::ParseError, e) + end + + params.inject([]) do |memo, (domain,hash)| + hash.delete_if { |k,v| (v.respond_to? :empty? and v.empty?) or v == :undef } + unless hash.empty? + hash['PayloadType'] = domain + memo << hash + end + memo + end + + + end +end diff --git a/lib/puppet/functions/managedmac/process_mounts.rb b/lib/puppet/functions/managedmac/process_mounts.rb new file mode 100644 index 0000000..c623a19 --- /dev/null +++ b/lib/puppet/functions/managedmac/process_mounts.rb @@ -0,0 +1,57 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Returns a Payload Hash of properly formatted mounts. Expects Array. +# +# +Puppet::Functions.create_function(:'managedmac::process_mounts') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 1 + e = "process_mounts(): Wrong number of args: #{args.size} for 1" + raise(Puppet::ParseError, e) + end + + urls = args[0] + + unless urls.is_a? Array + e = "process_mounts(): Wrong arg type! (#{urls.class} instead of Array)" + raise(Puppet::ParseError, e) + end + + unless urls.empty? + urls.collect! { |u| Hash['AuthenticateAsLoginUserShortName', true, + 'Hide', false, 'URL', u] } + end + + Hash['PayloadType', 'com.apple.loginitems.managed', + 'AutoLaunchedApplicationDictionary-managed', + [urls].flatten + ] + + end +end diff --git a/lib/puppet/functions/managedmac/validate_raw_constructor.rb b/lib/puppet/functions/managedmac/validate_raw_constructor.rb new file mode 100644 index 0000000..a51f7dd --- /dev/null +++ b/lib/puppet/functions/managedmac/validate_raw_constructor.rb @@ -0,0 +1,47 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Specialized function used to validate raw constructor class resource hashes. +#Expects the value of each key in the resource param to be Hash. If the value is +#not a Hash it's rejected. If the the Hash is exhausted, the resource is +#"validated". +# +# +Puppet::Functions.create_function(:'managedmac::validate_raw_constructor') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + e = "validate_raw_constructor(): Wrong number of args: #{args.size} for 1" + raise(Puppet::ParseError, e) if args.size != 1 + + resources = args.first.dup + resources.reject! { |k,v| v.respond_to? :key } + + e = "one or more invalid resources: #{resources}" + raise(Puppet::ParseError, e) unless resources.empty? + + end +end diff --git a/lib/puppet/functions/managedmac/version_compare.rb b/lib/puppet/functions/managedmac/version_compare.rb new file mode 100644 index 0000000..bfb0035 --- /dev/null +++ b/lib/puppet/functions/managedmac/version_compare.rb @@ -0,0 +1,42 @@ +# This is an autogenerated function, ported from the original legacy version. +# It /should work/ as is, but will not have all the benefits of the modern +# function API. You should see the function docs to learn how to add function +# signatures for type safety and to document this function using puppet-strings. +# +# https://puppet.com/docs/puppet/latest/custom_functions_ruby.html +# +# ---- original file header ---- + +# ---- original file header ---- +# +# @summary +# Expects a pair of version strings. Returns Fixnum: -1 (<), 0 (=) or 1 (>) +# +# +Puppet::Functions.create_function(:'managedmac::version_compare') do + # @param args + # The original array of arguments. Port this to individually managed params + # to get the full benefit of the modern function API. + # + # @return [Data type] + # Describe what the function returns here + # + dispatch :default_impl do + # Call the method named 'default_impl' when this is matched + # Port this to match individual params for better type safety + repeated_param 'Any', :args + end + + + def default_impl(*args) + + + if args.size != 2 + e = "version_compare(): Wrong number of args: #{args.size} for 2" + raise(Puppet::ParseError, e) + end + + Puppet::Util::Package.versioncmp(*args.collect(&:to_s)) + + end +end diff --git a/spec/functions/managedmac_compact_hash_spec.rb b/spec/functions/managedmac_compact_hash_spec.rb new file mode 100644 index 0000000..8cd9605 --- /dev/null +++ b/spec/functions/managedmac_compact_hash_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::compact_hash' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_portablehomes_excluded_items_spec.rb b/spec/functions/managedmac_portablehomes_excluded_items_spec.rb new file mode 100644 index 0000000..40020dc --- /dev/null +++ b/spec/functions/managedmac_portablehomes_excluded_items_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::portablehomes_excluded_items' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_portablehomes_synced_folders_spec.rb b/spec/functions/managedmac_portablehomes_synced_folders_spec.rb new file mode 100644 index 0000000..eb64024 --- /dev/null +++ b/spec/functions/managedmac_portablehomes_synced_folders_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::portablehomes_synced_folders' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_process_dsconfigad_params_spec.rb b/spec/functions/managedmac_process_dsconfigad_params_spec.rb new file mode 100644 index 0000000..34ed6f3 --- /dev/null +++ b/spec/functions/managedmac_process_dsconfigad_params_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::process_dsconfigad_params' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_process_mcx_options_spec.rb b/spec/functions/managedmac_process_mcx_options_spec.rb new file mode 100644 index 0000000..a698c16 --- /dev/null +++ b/spec/functions/managedmac_process_mcx_options_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::process_mcx_options' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_process_mobileconfig_params_spec.rb b/spec/functions/managedmac_process_mobileconfig_params_spec.rb new file mode 100644 index 0000000..2ee3556 --- /dev/null +++ b/spec/functions/managedmac_process_mobileconfig_params_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::process_mobileconfig_params' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_process_mounts_spec.rb b/spec/functions/managedmac_process_mounts_spec.rb new file mode 100644 index 0000000..8da097c --- /dev/null +++ b/spec/functions/managedmac_process_mounts_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::process_mounts' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_validate_raw_constructor_spec.rb b/spec/functions/managedmac_validate_raw_constructor_spec.rb new file mode 100644 index 0000000..ddd3a1d --- /dev/null +++ b/spec/functions/managedmac_validate_raw_constructor_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::validate_raw_constructor' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end diff --git a/spec/functions/managedmac_version_compare_spec.rb b/spec/functions/managedmac_version_compare_spec.rb new file mode 100644 index 0000000..d50b74d --- /dev/null +++ b/spec/functions/managedmac_version_compare_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'managedmac::version_compare' do + # without knowing details about the implementation, this is the only test + # case that we can autogenerate. You should add more examples below! + it { is_expected.not_to eq(nil) } + +################################# +# Below are some example test cases. You may uncomment and modify them to match +# your needs. Notice that they all expect the base error class of `StandardError`. +# This is because the autogenerated function uses an untyped array for parameters +# and relies on your implementation to do the validation. As you convert your +# function to proper dispatches and typed signatures, you should change the +# expected error of the argument validation examples to `ArgumentError`. +# +# Other error types you might encounter include +# +# * StandardError +# * ArgumentError +# * Puppet::ParseError +# +# Read more about writing function unit tests at https://rspec-puppet.com/documentation/functions/ +# +# it 'raises an error if called with no argument' do +# is_expected.to run.with_params.and_raise_error(StandardError) +# end +# +# it 'raises an error if there is more than 1 arguments' do +# is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(StandardError) +# end +# +# it 'raises an error if argument is not the proper type' do +# is_expected.to run.with_params('foo').and_raise_error(StandardError) +# end +# +# it 'returns the proper output' do +# is_expected.to run.with_params(123).and_return('the expected output') +# end +################################# + +end