puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +0 -3
- data/MAINTAINERS +76 -0
- data/README.md +0 -6
- data/Rakefile +2 -2
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/configurer.rb +2 -2
- data/lib/puppet/data_providers.rb +1 -0
- data/lib/puppet/data_providers/data_adapter.rb +1 -0
- data/lib/puppet/data_providers/data_function_support.rb +1 -0
- data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_config.rb +1 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
- data/lib/puppet/data_providers/hiera_support.rb +1 -2
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/environments.rb +5 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/epp.rb +57 -11
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/functions.rb +23 -24
- data/lib/puppet/functions/alert.rb +14 -0
- data/lib/puppet/functions/binary_file.rb +25 -0
- data/lib/puppet/functions/break.rb +22 -0
- data/lib/puppet/functions/contain.rb +33 -0
- data/lib/puppet/functions/crit.rb +14 -0
- data/lib/puppet/functions/debug.rb +14 -0
- data/lib/puppet/functions/emerg.rb +14 -0
- data/lib/puppet/functions/epp.rb +1 -1
- data/lib/puppet/functions/err.rb +14 -0
- data/lib/puppet/functions/find_file.rb +31 -0
- data/lib/puppet/functions/include.rb +21 -0
- data/lib/puppet/functions/info.rb +14 -0
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/functions/next.rb +23 -0
- data/lib/puppet/functions/notice.rb +14 -0
- data/lib/puppet/functions/regsubst.rb +12 -16
- data/lib/puppet/functions/require.rb +37 -0
- data/lib/puppet/functions/return.rb +22 -0
- data/lib/puppet/functions/strftime.rb +35 -0
- data/lib/puppet/functions/warning.rb +14 -0
- data/lib/puppet/generate/models/type/type.rb +4 -0
- data/lib/puppet/generate/templates/type/pcore.erb +2 -1
- data/lib/puppet/indirector/face.rb +6 -1
- data/lib/puppet/network/http/error.rb +2 -2
- data/lib/puppet/network/http/handler.rb +2 -2
- data/lib/puppet/node/environment.rb +11 -0
- data/lib/puppet/parser/ast.rb +5 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
- data/lib/puppet/parser/compiler.rb +29 -1
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/assert_type.rb +1 -1
- data/lib/puppet/parser/functions/binary_file.rb +24 -0
- data/lib/puppet/parser/functions/break.rb +39 -0
- data/lib/puppet/parser/functions/contain.rb +7 -15
- data/lib/puppet/parser/functions/defined.rb +2 -2
- data/lib/puppet/parser/functions/dig.rb +1 -1
- data/lib/puppet/parser/functions/each.rb +1 -1
- data/lib/puppet/parser/functions/epp.rb +2 -2
- data/lib/puppet/parser/functions/filter.rb +1 -1
- data/lib/puppet/parser/functions/find_file.rb +28 -0
- data/lib/puppet/parser/functions/hiera.rb +4 -4
- data/lib/puppet/parser/functions/hiera_array.rb +1 -1
- data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/include.rb +4 -8
- data/lib/puppet/parser/functions/inline_epp.rb +1 -1
- data/lib/puppet/parser/functions/lest.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +4 -2
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/match.rb +1 -1
- data/lib/puppet/parser/functions/new.rb +414 -18
- data/lib/puppet/parser/functions/next.rb +38 -0
- data/lib/puppet/parser/functions/reduce.rb +1 -1
- data/lib/puppet/parser/functions/regsubst.rb +4 -2
- data/lib/puppet/parser/functions/require.rb +4 -27
- data/lib/puppet/parser/functions/return.rb +71 -0
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +13 -8
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/functions/step.rb +1 -1
- data/lib/puppet/parser/functions/strftime.rb +185 -0
- data/lib/puppet/parser/functions/then.rb +1 -1
- data/lib/puppet/parser/functions/type.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +3 -3
- data/lib/puppet/parser/resource.rb +8 -5
- data/lib/puppet/parser/scope.rb +1 -1
- data/lib/puppet/plugins/configuration.rb +8 -0
- data/lib/puppet/plugins/data_providers.rb +1 -0
- data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
- data/lib/puppet/plugins/data_providers/registry.rb +1 -0
- data/lib/puppet/pops.rb +4 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
- data/lib/puppet/pops/evaluator/closure.rb +81 -12
- data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
- data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
- data/lib/puppet/pops/functions/dispatch.rb +9 -2
- data/lib/puppet/pops/functions/dispatcher.rb +3 -1
- data/lib/puppet/pops/functions/function.rb +19 -2
- data/lib/puppet/pops/issues.rb +9 -0
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/loader.rb +17 -0
- data/lib/puppet/pops/loader/static_loader.rb +0 -41
- data/lib/puppet/pops/lookup.rb +12 -0
- data/lib/puppet/pops/lookup/context.rb +86 -0
- data/lib/puppet/pops/lookup/explainer.rb +46 -6
- data/lib/puppet/pops/lookup/invocation.rb +19 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +20 -8
- data/lib/puppet/pops/model/model_label_provider.rb +3 -0
- data/lib/puppet/pops/model/model_meta.rb +2 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
- data/lib/puppet/pops/parser/egrammar.ra +11 -6
- data/lib/puppet/pops/parser/eparser.rb +1112 -1086
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/pcore.rb +1 -0
- data/lib/puppet/pops/puppet_stack.rb +3 -3
- data/lib/puppet/pops/resource/param.rb +5 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
- data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
- data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
- data/lib/puppet/pops/serialization/deserializer.rb +5 -1
- data/lib/puppet/pops/serialization/extension.rb +2 -0
- data/lib/puppet/pops/serialization/json.rb +76 -26
- data/lib/puppet/pops/serialization/serializer.rb +5 -1
- data/lib/puppet/pops/serialization/time_factory.rb +2 -1
- data/lib/puppet/pops/time/timespan.rb +718 -0
- data/lib/puppet/pops/time/timestamp.rb +148 -0
- data/lib/puppet/pops/types/p_binary_type.rb +220 -0
- data/lib/puppet/pops/types/p_object_type.rb +12 -6
- data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
- data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
- data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
- data/lib/puppet/pops/types/string_converter.rb +62 -0
- data/lib/puppet/pops/types/type_asserter.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +17 -3
- data/lib/puppet/pops/types/type_factory.rb +35 -1
- data/lib/puppet/pops/types/type_formatter.rb +64 -11
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
- data/lib/puppet/pops/types/type_parser.rb +18 -4
- data/lib/puppet/pops/types/types.rb +98 -63
- data/lib/puppet/pops/validation.rb +9 -1
- data/lib/puppet/pops/validation/checker4_0.rb +7 -0
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +3 -6
- data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
- data/lib/puppet/provider/mount/parsed.rb +18 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
- data/lib/puppet/provider/package/gem.rb +6 -1
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +5 -1
- data/lib/puppet/provider/package/pkgng.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +10 -0
- data/lib/puppet/provider/service/launchd.rb +1 -0
- data/lib/puppet/provider/user/directoryservice.rb +6 -6
- data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/resource.rb +54 -12
- data/lib/puppet/resource/capability_finder.rb +15 -9
- data/lib/puppet/resource/catalog.rb +25 -6
- data/lib/puppet/resource/type.rb +3 -1
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +12 -4
- data/lib/puppet/syntax_checkers/base64.rb +41 -0
- data/lib/puppet/syntax_checkers/json.rb +0 -2
- data/lib/puppet/transaction.rb +6 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
- data/lib/puppet/transaction/report.rb +7 -2
- data/lib/puppet/type.rb +2 -1
- data/lib/puppet/type/file/checksum.rb +1 -0
- data/lib/puppet/type/file/content.rb +4 -4
- data/lib/puppet/type/mount.rb +44 -0
- data/lib/puppet/type/ssh_authorized_key.rb +1 -1
- data/lib/puppet/type/tidy.rb +3 -0
- data/lib/puppet/type/user.rb +12 -6
- data/lib/puppet/util/log.rb +25 -0
- data/lib/puppet/util/plist.rb +8 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_x.rb +7 -1
- data/spec/integration/application/apply_spec.rb +118 -0
- data/spec/integration/parser/compiler_spec.rb +28 -0
- data/spec/integration/parser/pcore_resource_spec.rb +40 -3
- data/spec/integration/provider/mount_spec.rb +2 -1
- data/spec/integration/util/windows/principal_spec.rb +2 -2
- data/spec/integration/util/windows/registry_spec.rb +4 -4
- data/spec/lib/puppet_spec/compiler.rb +5 -1
- data/spec/lib/puppet_spec/unindent.rb +5 -0
- data/spec/shared_contexts/types_setup.rb +6 -0
- data/spec/shared_examples/rhel_package_provider.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/agent_spec.rb +11 -0
- data/spec/unit/application/lookup_spec.rb +94 -3
- data/spec/unit/capability_spec.rb +22 -0
- data/spec/unit/configurer_spec.rb +8 -0
- data/spec/unit/face/epp_face_spec.rb +22 -3
- data/spec/unit/functions/assert_type_spec.rb +3 -3
- data/spec/unit/functions/binary_file_spec.rb +46 -0
- data/spec/unit/functions/break_spec.rb +89 -0
- data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
- data/spec/unit/functions/find_file_spec.rb +69 -0
- data/spec/unit/functions/include_spec.rb +175 -0
- data/spec/unit/functions/logging_spec.rb +54 -0
- data/spec/unit/functions/lookup_spec.rb +3 -3
- data/spec/unit/functions/new_spec.rb +105 -5
- data/spec/unit/functions/next_spec.rb +93 -0
- data/spec/unit/functions/require_spec.rb +83 -0
- data/spec/unit/functions/return_spec.rb +105 -0
- data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
- data/spec/unit/functions/strftime_spec.rb +152 -0
- data/spec/unit/functions4_spec.rb +22 -0
- data/spec/unit/indirector/face_spec.rb +10 -2
- data/spec/unit/network/http/error_spec.rb +1 -2
- data/spec/unit/network/http/handler_spec.rb +6 -5
- data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
- data/spec/unit/parser/functions/hiera_spec.rb +1 -1
- data/spec/unit/parser/functions/lookup_spec.rb +1 -1
- data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
- data/spec/unit/parser/functions/split_spec.rb +1 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
- data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
- data/spec/unit/pops/lookup/context_spec.rb +149 -0
- data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
- data/spec/unit/pops/puppet_stack_spec.rb +1 -1
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
- data/spec/unit/pops/serialization/packer_spec.rb +34 -14
- data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
- data/spec/unit/pops/time/timespan_spec.rb +121 -0
- data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
- data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
- data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
- data/spec/unit/pops/types/string_converter_spec.rb +89 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
- data/spec/unit/pops/types/type_parser_spec.rb +87 -4
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +23 -0
- data/spec/unit/provider/mount/parsed_spec.rb +47 -29
- data/spec/unit/provider/package/pkg_spec.rb +109 -99
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
- data/spec/unit/provider/user/aix_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
- data/spec/unit/resource/capability_finder_spec.rb +29 -7
- data/spec/unit/resource/catalog_spec.rb +127 -0
- data/spec/unit/ssl/certificate_request_spec.rb +1 -1
- data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
- data/spec/unit/transaction/persistence_spec.rb +1 -6
- data/spec/unit/transaction/report_spec.rb +23 -0
- data/spec/unit/transaction_spec.rb +38 -0
- data/spec/unit/type/mount_spec.rb +5 -0
- data/spec/unit/util/plist_spec.rb +14 -2
- metadata +71 -12
- data/spec/integration/parser/functions/require_spec.rb +0 -43
- data/spec/unit/parser/functions/include_spec.rb +0 -55
- data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -90,6 +90,7 @@ describe provider_class, :unless => Puppet.features.microsoft_windows? do
|
|
90
90
|
it "should be able to parse name if it includes whitespace" do
|
91
91
|
expect(@provider_class.parse_line('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC7pHZ1XRj3tXbFpPFhMGU1bVwz7jr13zt/wuE+pVIJA8GlmHYuYtIxHPfDHlkixdwLachCpSQUL9NbYkkRFRn9m6PZ7125ohE4E4m96QS6SGSQowTiRn4Lzd9LV38g93EMHjPmEkdSq7MY4uJEd6DUYsLvaDYdIgBiLBIWPA3OrQ== fancy user')[:name]).to eq('fancy user')
|
92
92
|
expect(@provider_class.parse_line('from="host1.reductlivelabs.com,host.reductivelabs.com",command="/usr/local/bin/run",ssh-pty ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC7pHZ1XRj3tXbFpPFhMGU1bVwz7jr13zt/wuE+pVIJA8GlmHYuYtIxHPfDHlkixdwLachCpSQUL9NbYkkRFRn9m6PZ7125ohE4E4m96QS6SGSQowTiRn4Lzd9LV38g93EMHjPmEkdSq7MY4uJEd6DUYsLvaDYdIgBiLBIWPA3OrQ== fancy user')[:name]).to eq('fancy user')
|
93
|
+
expect(@provider_class.parse_line('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC7pHZ1XRj3tXbFpPFhMGU1bVwz7jr13zt/wuE+pVIJA8GlmHYuYtIxHPfDHlkixdwLachCpSQUL9NbYkkRFRn9m6PZ7125ohE4E4m96QS6SGSQowTiRn4Lzd9LV38g93EMHjPmEkdSq7MY4uJEd6DUYsLvaDYdIgBiLBIWPA3OrQ== whitespace fan')[:name]).to eq('whitespace fan')
|
93
94
|
end
|
94
95
|
|
95
96
|
it "should be able to parse options containing commas via its parse_options method" do
|
@@ -84,7 +84,7 @@ guest id=100 pgrp=usr groups=usr home=/home/guest
|
|
84
84
|
it "should allow a single attribute to be specified" do
|
85
85
|
@resource.stubs(:original_parameters).returns({ :attributes => single_attribute_array })
|
86
86
|
keys = @provider.managed_attribute_keys(existing_attributes)
|
87
|
-
keys.
|
87
|
+
expect(keys).to be_include(:rlogin)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -60,12 +60,18 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
60
60
|
}
|
61
61
|
end
|
62
62
|
|
63
|
+
let(:sha512_shadowhashdata_array) do
|
64
|
+
['62706c69 73743030 d101025d 53414c54 45442d53 48413531 324f1044 7ea7d592 131f57b2 c8f8bdbc '\
|
65
|
+
'ec8d9df1 2128a386 393a4f00 c7619bac 2622a44d 451419d1 1da512d5 915ab98e 39718ac9 4083fe2e '\
|
66
|
+
'fd6bf710 a54d477f 8ff735b1 2587192d 080b1900 00000000 00010100 00000000 00000300 00000000 '\
|
67
|
+
'00000000 00000000 000060']
|
68
|
+
end
|
63
69
|
# The below value is the result of executing
|
64
70
|
# `dscl -plist . read /Users/<username> ShadowHashData` on a 10.7
|
65
71
|
# system and converting it to a native Ruby Hash with Plist.parse_xml
|
66
72
|
let(:sha512_shadowhashdata_hash) do
|
67
73
|
{
|
68
|
-
'dsAttrTypeNative:ShadowHashData' =>
|
74
|
+
'dsAttrTypeNative:ShadowHashData' => sha512_shadowhashdata_array
|
69
75
|
}
|
70
76
|
end
|
71
77
|
|
@@ -93,12 +99,21 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
93
99
|
'7ea7d592131f57b2c8f8bdbcec8d9df12128a386393a4f00c7619bac2622a44d451419d11da512d5915ab98e39718ac94083fe2efd6bf710a54d477f8ff735b12587192d'
|
94
100
|
end
|
95
101
|
|
102
|
+
let(:pbkdf2_shadowhashdata_array) do
|
103
|
+
['62706c69 73743030 d101025f 10145341 4c544544 2d534841 3531322d 50424b44 4632d303 04050607 '\
|
104
|
+
'0857656e 74726f70 79547361 6c745a69 74657261 74696f6e 734f1080 0590ade1 9e6953c1 35ae872a '\
|
105
|
+
'e7761823 5df7d46c 63de7f9a 0fcdf2cd 9e7d85e4 b7ca8681 01235b61 58e05a30 9805ee48 14b027a4 '\
|
106
|
+
'be9c23ec 2926bc81 72269aff ba5c9a59 85e81091 fa689807 6d297f1f aa75fa61 7551ef16 71d75200 '\
|
107
|
+
'55c4a0d9 7b9b9c58 05aa322b aedbcd8e e9c52381 1653ac2e a9e9c8d8 f1ac519a 0f2b595e 4f102093 '\
|
108
|
+
'77c46908 a1c8ac2c 3e45c0d4 4da8ad0f cd85ec5c 14d9a59f fc40c9da 31f0ec11 60b0080b 22293136 '\
|
109
|
+
'41c4e700 00000000 00010100 00000000 00000900 00000000 00000000 00000000 0000ea']
|
110
|
+
end
|
96
111
|
# The below value is the result of executing
|
97
112
|
# `dscl -plist . read /Users/<username> ShadowHashData` on a 10.8
|
98
113
|
# system and converting it to a native Ruby Hash with Plist.parse_xml
|
99
114
|
let(:pbkdf2_shadowhashdata_hash) do
|
100
115
|
{
|
101
|
-
"dsAttrTypeNative:ShadowHashData"=>
|
116
|
+
"dsAttrTypeNative:ShadowHashData"=> pbkdf2_shadowhashdata_array
|
102
117
|
}
|
103
118
|
end
|
104
119
|
|
@@ -148,12 +163,47 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
148
163
|
24752
|
149
164
|
end
|
150
165
|
|
166
|
+
let(:pbkdf2_and_ssha512_shadowhashdata_array) do
|
167
|
+
['62706c69 73743030 d2010203 0a5f1014 53414c54 45442d53 48413531 322d5042 4b444632 5d53414c '\
|
168
|
+
'5445442d 53484135 3132d304 05060708 0957656e 74726f70 79547361 6c745a69 74657261 74696f6e '\
|
169
|
+
'734f1080 0590ade1 9e6953c1 35ae872a e7761823 5df7d46c 63de7f9a 0fcdf2cd 9e7d85e4 b7ca8681 '\
|
170
|
+
'01235b61 58e05a30 9805ee48 14b027a4 be9c23ec 2926bc81 72269aff ba5c9a59 85e81091 fa689807 '\
|
171
|
+
'6d297f1f aa75fa61 7551ef16 71d75200 55c4a0d9 7b9b9c58 05aa322b aedbcd8e e9c52381 1653ac2e '\
|
172
|
+
'a9e9c8d8 f1ac519a 0f2b595e 4f102093 77c46908 a1c8ac2c 3e45c0d4 4da8ad0f cd85ec5c 14d9a59f '\
|
173
|
+
'fc40c9da 31f0ec11 60b04f10 447ea7d5 92131f57 b2c8f8bd bcec8d9d f12128a3 86393a4f 00c7619b '\
|
174
|
+
'ac2622a4 4d451419 d11da512 d5915ab9 8e39718a c94083fe 2efd6bf7 10a54d47 7f8ff735 b1258719 '\
|
175
|
+
'2d000800 0d002400 32003900 41004600 5100d400 f700fa00 00000000 00020100 00000000 00000b00 '\
|
176
|
+
'00000000 00000000 00000000 000141']
|
177
|
+
end
|
178
|
+
|
179
|
+
let(:pbkdf2_and_ssha512_shadowhashdata_hash) do
|
180
|
+
{
|
181
|
+
'dsAttrTypeNative:ShadowHashData' => pbkdf2_and_ssha512_shadowhashdata_array
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
let (:pbkdf2_and_ssha512_embedded_plist) do
|
186
|
+
"bplist00\xD2\x01\x02\x03\n_\x10\x14SALTED-SHA512-PBKDF2]SALTED-SHA512\xD3\x04\x05\x06\a\b\tWentropyTsaltZiterationsO\x10\x80\x05\x90\xAD\xE1\x9EiS\xC15\xAE\x87*\xE7v\x18#]\xF7\xD4lc\xDE\x7F\x9A\x0F\xCD\xF2\xCD\x9E}\x85\xE4\xB7\xCA\x86\x81\x01#[aX\xE0Z0\x98\x05\xEEH\x14\xB0'\xA4\xBE\x9C#\xEC)&\xBC\x81r&\x9A\xFF\xBA\\\x9AY\x85\xE8\x10\x91\xFAh\x98\am)\x7F\x1F\xAAu\xFAauQ\xEF\x16q\xD7R\x00U\xC4\xA0\xD9{\x9B\x9CX\x05\xAA2+\xAE\xDB\xCD\x8E\xE9\xC5#\x81\x16S\xAC.\xA9\xE9\xC8\xD8\xF1\xACQ\x9A\x0F+Y^O\x10 \x93w\xC4i\b\xA1\xC8\xAC,>E\xC0\xD4M\xA8\xAD\x0F\xCD\x85\xEC\\\x14\xD9\xA5\x9F\xFC@\xC9\xDA1\xF0\xEC\x11`\xB0O\x10D~\xA7\xD5\x92\x13\x1FW\xB2\xC8\xF8\xBD\xBC\xEC\x8D\x9D\xF1!(\xA3\x869:O\x00\xC7a\x9B\xAC&\"\xA4ME\x14\x19\xD1\x1D\xA5\x12\xD5\x91Z\xB9\x8E9q\x8A\xC9@\x83\xFE.\xFDk\xF7\x10\xA5MG\x7F\x8F\xF75\xB1%\x87\x19-\x00\b\x00\r\x00$\x002\x009\x00A\x00F\x00Q\x00\xD4\x00\xF7\x00\xFA\x00\x00\x00\x00\x00\x00\x02\x01\x00\x00\x00\x00\x00\x00\x00\v\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01A"
|
187
|
+
end
|
188
|
+
|
189
|
+
let (:pbkdf2_and_ssha512_embedded_bplist_hash) do
|
190
|
+
{
|
191
|
+
"SALTED-SHA512-PBKDF2" => {
|
192
|
+
"entropy" => pbkdf2_pw_string,
|
193
|
+
"salt" => pbkdf2_salt_value,
|
194
|
+
"iterations" => pbkdf2_iterations_value,
|
195
|
+
},
|
196
|
+
"SALTED-SHA512" => sha512_password_hash
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
151
200
|
# The below represents output of 'dscl -plist . readall /Users' converted to
|
152
201
|
# a native Ruby hash if only one user were installed on the system.
|
153
202
|
# This lets us check the behavior of all the methods necessary to return a
|
154
203
|
# user's groups property by controlling the data provided by dscl
|
155
|
-
let(:
|
156
|
-
|
204
|
+
let(:testuser_base) do
|
205
|
+
{
|
206
|
+
"dsAttrTypeStandard:RecordName" =>["nonexistent_user"],
|
157
207
|
"dsAttrTypeStandard:UniqueID" =>["1000"],
|
158
208
|
"dsAttrTypeStandard:AuthenticationAuthority"=>
|
159
209
|
[";Kerberosv5;;testuser@LKDC:SHA1.4383E152D9D394AA32D13AE98F6F6E1FE8D00F81;LKDC:SHA1.4383E152D9D394AA32D13AE98F6F6E1FE8D00F81",
|
@@ -172,7 +222,14 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
172
222
|
["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n <plist version=\"1.0\">\n <dict>\n <key>failedLoginCount</key>\n <integer>0</integer>\n <key>failedLoginTimestamp</key>\n <date>2001-01-01T00:00:00Z</date>\n <key>lastLoginTimestamp</key>\n <date>2001-01-01T00:00:00Z</date>\n <key>passwordTimestamp</key>\n <date>2012-08-10T23:53:50Z</date>\n </dict>\n </plist>\n "],
|
173
223
|
"dsAttrTypeStandard:UserShell" =>["/bin/bash"],
|
174
224
|
"dsAttrTypeNative:ShadowHashData" =>
|
175
|
-
["62706c69 73743030 d101025d 53414c54 45442d53 48413531 324f1044 7ea7d592 131f57b2 c8f8bdbc ec8d9df1 2128a386 393a4f00 c7619bac 2622a44d 451419d1 1da512d5 915ab98e 39718ac9 4083fe2e fd6bf710 a54d477f 8ff735b1 2587192d 080b1900 00000000 00010100 00000000 00000300 00000000 00000000 00000000 000060"]
|
225
|
+
["62706c69 73743030 d101025d 53414c54 45442d53 48413531 324f1044 7ea7d592 131f57b2 c8f8bdbc ec8d9df1 2128a386 393a4f00 c7619bac 2622a44d 451419d1 1da512d5 915ab98e 39718ac9 4083fe2e fd6bf710 a54d477f 8ff735b1 2587192d 080b1900 00000000 00010100 00000000 00000300 00000000 00000000 00000000 000060"]
|
226
|
+
}
|
227
|
+
end
|
228
|
+
let(:testuser_hash) do
|
229
|
+
[
|
230
|
+
testuser_base.merge(sha512_shadowhashdata_hash),
|
231
|
+
testuser_base.merge(pbkdf2_shadowhashdata_hash),
|
232
|
+
]
|
176
233
|
end
|
177
234
|
|
178
235
|
# The below represents the result of running Plist.parse_xml on XML
|
@@ -320,7 +377,7 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
320
377
|
:groups => 'testgroup,third',
|
321
378
|
:comment => username,
|
322
379
|
:password => sha512_password_hash,
|
323
|
-
:shadowhashdata =>
|
380
|
+
:shadowhashdata => sha512_shadowhashdata_array,
|
324
381
|
:name => username,
|
325
382
|
:uid => 1000,
|
326
383
|
:gid => 22,
|
@@ -331,9 +388,9 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
331
388
|
before :each do
|
332
389
|
provider.class.stubs(:get_os_version).returns('10.7')
|
333
390
|
provider.class.stubs(:get_all_users).returns(testuser_hash)
|
334
|
-
provider.class.stubs(:get_attribute_from_dscl).with('Users', username, 'ShadowHashData').returns(sha512_shadowhashdata_hash)
|
335
391
|
provider.class.stubs(:get_list_of_groups).returns(group_plist_hash_guid)
|
336
392
|
provider.class.stubs(:convert_binary_to_hash).with(sha512_embedded_bplist).returns(sha512_embedded_bplist_hash)
|
393
|
+
provider.class.stubs(:convert_binary_to_hash).with(pbkdf2_embedded_plist).returns(pbkdf2_embedded_bplist_hash)
|
337
394
|
provider.class.prefetch({})
|
338
395
|
end
|
339
396
|
|
@@ -346,19 +403,21 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
346
403
|
end
|
347
404
|
|
348
405
|
it 'should return a hash of resource attributes' do
|
349
|
-
expect(provider.class.generate_attribute_hash(user_plist_hash)).to eq(user_plist_resource)
|
406
|
+
expect(provider.class.generate_attribute_hash(user_plist_hash.merge(sha512_shadowhashdata_hash))).to eq(user_plist_resource)
|
350
407
|
end
|
351
408
|
end
|
352
409
|
|
353
|
-
describe 'self#generate_attribute_hash
|
410
|
+
describe 'self#generate_attribute_hash with pbkdf2 and ssha512' do
|
354
411
|
let(:user_plist_resource) do
|
355
412
|
{
|
356
413
|
:ensure => :present,
|
357
414
|
:provider => :directoryservice,
|
358
415
|
:groups => 'testgroup,third',
|
359
416
|
:comment => username,
|
360
|
-
:password =>
|
361
|
-
:
|
417
|
+
:password => pbkdf2_password_hash,
|
418
|
+
:iterations => pbkdf2_iterations_value,
|
419
|
+
:salt => pbkdf2_salt_value,
|
420
|
+
:shadowhashdata => pbkdf2_and_ssha512_shadowhashdata_array,
|
362
421
|
:name => username,
|
363
422
|
:uid => 1000,
|
364
423
|
:gid => 22,
|
@@ -366,28 +425,41 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
366
425
|
}
|
367
426
|
end
|
368
427
|
|
369
|
-
|
428
|
+
before :each do
|
370
429
|
provider.class.stubs(:get_os_version).returns('10.7')
|
371
430
|
provider.class.stubs(:get_all_users).returns(testuser_hash)
|
372
|
-
provider.class.stubs(:get_attribute_from_dscl).with('Users', username, 'ShadowHashData').returns(nil)
|
373
431
|
provider.class.stubs(:get_list_of_groups).returns(group_plist_hash_guid)
|
374
|
-
provider.class.stubs(:convert_binary_to_hash).with(sha512_embedded_bplist).returns(sha512_embedded_bplist_hash)
|
375
432
|
provider.class.prefetch({})
|
376
|
-
expect(provider.class.generate_attribute_hash(user_plist_hash)).to eq(user_plist_resource)
|
377
433
|
end
|
434
|
+
|
435
|
+
it 'should return a hash of resource attributes' do
|
436
|
+
expect(provider.class.generate_attribute_hash(user_plist_hash.merge(pbkdf2_and_ssha512_shadowhashdata_hash))).to eq(user_plist_resource)
|
437
|
+
end
|
438
|
+
|
378
439
|
end
|
379
440
|
|
380
|
-
describe '#
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
441
|
+
describe 'self#generate_attribute_hash empty shadowhashdata' do
|
442
|
+
let(:user_plist_resource) do
|
443
|
+
{
|
444
|
+
:ensure => :present,
|
445
|
+
:provider => :directoryservice,
|
446
|
+
:groups => 'testgroup,third',
|
447
|
+
:comment => username,
|
448
|
+
:password => '*',
|
449
|
+
:shadowhashdata => nil,
|
450
|
+
:name => username,
|
451
|
+
:uid => 1000,
|
452
|
+
:gid => 22,
|
453
|
+
:home => user_path
|
454
|
+
}
|
386
455
|
end
|
387
456
|
|
388
|
-
it 'should
|
389
|
-
provider.
|
390
|
-
|
457
|
+
it 'should handle empty shadowhashdata' do
|
458
|
+
provider.class.stubs(:get_os_version).returns('10.7')
|
459
|
+
provider.class.stubs(:get_all_users).returns([testuser_base])
|
460
|
+
provider.class.stubs(:get_list_of_groups).returns(group_plist_hash_guid)
|
461
|
+
provider.class.prefetch({})
|
462
|
+
expect(provider.class.generate_attribute_hash(user_plist_hash)).to eq(user_plist_resource)
|
391
463
|
end
|
392
464
|
end
|
393
465
|
|
@@ -445,16 +517,17 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
445
517
|
|
446
518
|
before :each do
|
447
519
|
provider.class.stubs(:get_all_users).returns(testuser_hash)
|
448
|
-
provider.class.stubs(:get_attribute_from_dscl).with('Users', username, 'ShadowHashData').returns([])
|
449
520
|
provider.class.stubs(:get_os_version).returns('10.7')
|
450
521
|
end
|
451
522
|
|
452
523
|
it "should return a list of groups if the user's name matches GroupMembership" do
|
524
|
+
provider.class.expects(:get_list_of_groups).returns(group_plist_hash)
|
453
525
|
provider.class.expects(:get_list_of_groups).returns(group_plist_hash)
|
454
526
|
expect(provider.class.prefetch({}).first.groups).to eq('second,testgroup')
|
455
527
|
end
|
456
528
|
|
457
529
|
it "should return a list of groups if the user's GUID matches GroupMembers" do
|
530
|
+
provider.class.expects(:get_list_of_groups).returns(group_plist_hash_guid)
|
458
531
|
provider.class.expects(:get_list_of_groups).returns(group_plist_hash_guid)
|
459
532
|
expect(provider.class.prefetch({}).first.groups).to eq('testgroup,third')
|
460
533
|
end
|
@@ -505,7 +578,6 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
505
578
|
end
|
506
579
|
|
507
580
|
it 'should call dscl to add necessary groups' do
|
508
|
-
provider.class.expects(:get_attribute_from_dscl).with('Users', username, 'ShadowHashData').returns([])
|
509
581
|
provider.class.expects(:get_attribute_from_dscl).with('Users', username, 'GeneratedUID').returns({'dsAttrTypeStandard:GeneratedUID' => ['guidnonexistent_user']})
|
510
582
|
provider.expects(:groups).returns('two,three')
|
511
583
|
provider.expects(:dscl).with('.', '-merge', '/Groups/one', 'GroupMembership', 'nonexistent_user')
|
@@ -515,15 +587,15 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
515
587
|
end
|
516
588
|
|
517
589
|
it 'should call the get_salted_sha512 method on 10.7 and return the correct hash' do
|
518
|
-
provider.class.expects(:get_attribute_from_dscl).with('Users', username, 'ShadowHashData').returns(sha512_shadowhashdata_hash)
|
519
590
|
provider.class.expects(:convert_binary_to_hash).with(sha512_embedded_bplist).returns(sha512_embedded_bplist_hash)
|
591
|
+
provider.class.expects(:convert_binary_to_hash).with(pbkdf2_embedded_plist).returns(pbkdf2_embedded_bplist_hash)
|
520
592
|
expect(provider.class.prefetch({}).first.password).to eq(sha512_password_hash)
|
521
593
|
end
|
522
594
|
|
523
595
|
it 'should call the get_salted_sha512_pbkdf2 method on 10.8 and return the correct hash' do
|
524
|
-
provider.class.expects(:
|
596
|
+
provider.class.expects(:convert_binary_to_hash).with(sha512_embedded_bplist).returns(sha512_embedded_bplist_hash)
|
525
597
|
provider.class.expects(:convert_binary_to_hash).with(pbkdf2_embedded_plist).returns(pbkdf2_embedded_bplist_hash)
|
526
|
-
expect(provider.class.prefetch({}).
|
598
|
+
expect(provider.class.prefetch({}).last.password).to eq(pbkdf2_password_hash)
|
527
599
|
end
|
528
600
|
|
529
601
|
end
|
@@ -1057,7 +1129,6 @@ describe Puppet::Type.type(:user).provider(:directoryservice) do
|
|
1057
1129
|
before :each do
|
1058
1130
|
provider.class.stubs(:get_all_users).returns(all_users_hash)
|
1059
1131
|
provider.class.stubs(:get_list_of_groups).returns(group_plist_hash_guid)
|
1060
|
-
provider.class.stubs(:get_attribute_from_dscl).with('Users', 'testuser', 'ShadowHashData').returns({})
|
1061
1132
|
provider.class.prefetch({})
|
1062
1133
|
end
|
1063
1134
|
|
@@ -71,29 +71,50 @@ describe Puppet::Resource::CapabilityFinder do
|
|
71
71
|
let(:capability) { Puppet::Resource.new('Cap', 'cap') }
|
72
72
|
let(:code_id) { 'b59e5df0578ef411f773ee6c33d8073c50e7b8fe' }
|
73
73
|
|
74
|
-
it 'should search for the resource without including code_id' do
|
74
|
+
it 'should search for the resource without including code_id or environment' do
|
75
75
|
resources = [{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"ahost"}}]
|
76
|
-
Puppet::Resource::CapabilityFinder.stubs(:search).with(
|
76
|
+
Puppet::Resource::CapabilityFinder.stubs(:search).with(nil, nil, capability).returns resources
|
77
77
|
|
78
78
|
result = Puppet::Resource::CapabilityFinder.find('production', code_id, Puppet::Resource.new('Cap', 'cap'))
|
79
79
|
expect(result['host']).to eq('ahost')
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should return nil if no resource is found' do
|
83
|
-
Puppet::Resource::CapabilityFinder.stubs(:search).with(
|
83
|
+
Puppet::Resource::CapabilityFinder.stubs(:search).with(nil, nil, capability).returns []
|
84
84
|
|
85
85
|
result = Puppet::Resource::CapabilityFinder.find('production', code_id, capability)
|
86
86
|
expect(result).to be_nil
|
87
87
|
end
|
88
88
|
|
89
|
-
describe 'when multiple results are returned' do
|
89
|
+
describe 'when multiple results are returned for different environments' do
|
90
90
|
let(:resources) do
|
91
|
-
[{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"ahost"}},
|
92
|
-
{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"bhost"}}]
|
91
|
+
[{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"ahost"}, "tags"=>["producer:production"]},
|
92
|
+
{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"bhost"}, "tags"=>["producer:other_env"]}]
|
93
93
|
end
|
94
94
|
|
95
95
|
before :each do
|
96
|
-
Puppet::Resource::CapabilityFinder.stubs(:search).with(
|
96
|
+
Puppet::Resource::CapabilityFinder.stubs(:search).with(nil, nil, capability).returns resources
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should return the resource matching environment' do
|
100
|
+
result = Puppet::Resource::CapabilityFinder.find('production', code_id, capability)
|
101
|
+
expect(result['host']).to eq('ahost')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should return nil if no resource matches environment' do
|
105
|
+
result = Puppet::Resource::CapabilityFinder.find('bad_env', code_id, capability)
|
106
|
+
expect(result).to be_nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'when multiple results are returned for the same environment' do
|
111
|
+
let(:resources) do
|
112
|
+
[{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"ahost"}, "tags"=>["producer:production"]},
|
113
|
+
{"type"=>"Cap", "title"=>"cap", "parameters"=>{"host"=>"bhost"}, "tags"=>["producer:production"]}]
|
114
|
+
end
|
115
|
+
|
116
|
+
before :each do
|
117
|
+
Puppet::Resource::CapabilityFinder.stubs(:search).with(nil, nil, capability).returns resources
|
97
118
|
end
|
98
119
|
|
99
120
|
it 'should return the resource matching code_id' do
|
@@ -117,6 +138,7 @@ describe Puppet::Resource::CapabilityFinder do
|
|
117
138
|
end
|
118
139
|
|
119
140
|
it 'should fail if no code_id was specified' do
|
141
|
+
Puppet::Resource::CapabilityFinder.stubs(:search).with('production', nil, capability).returns resources
|
120
142
|
expect { Puppet::Resource::CapabilityFinder.find('production', nil, capability) }.to raise_error(Puppet::DevError, /expected exactly one resource/)
|
121
143
|
end
|
122
144
|
end
|
@@ -843,6 +843,133 @@ describe Puppet::Resource::Catalog, "when converting a resource catalog to pson"
|
|
843
843
|
MANIFEST
|
844
844
|
expect(catalog.to_pson).to validate_against('api/schemas/catalog.json')
|
845
845
|
end
|
846
|
+
|
847
|
+
context 'when dealing with parameters that have non-Data values' do
|
848
|
+
context 'and rich_data is enabled' do
|
849
|
+
before(:each) do
|
850
|
+
Puppet[:rich_data] = true
|
851
|
+
end
|
852
|
+
|
853
|
+
let(:catalog_w_regexp) { compile_to_catalog("notify {'foo': message => /[a-z]+/ }") }
|
854
|
+
|
855
|
+
it 'should generate ext_parameters for parameter values that are not Data' do
|
856
|
+
expect(catalog_w_regexp.to_json).to include('"ext_parameters":{"message":[48,"[a-z]+"]}')
|
857
|
+
end
|
858
|
+
|
859
|
+
it 'should validate ext_parameters against the schema' do
|
860
|
+
expect(catalog_w_regexp.to_json).to validate_against('api/schemas/catalog.json')
|
861
|
+
end
|
862
|
+
|
863
|
+
it 'should read and convert ext_parameters containing Regexp from json' do
|
864
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog_w_regexp.to_json))
|
865
|
+
message = catalog2.resource('notify', 'foo')['message']
|
866
|
+
expect(message).to be_a(Regexp)
|
867
|
+
expect(message).to eql(/[a-z]+/)
|
868
|
+
end
|
869
|
+
|
870
|
+
it 'should read and convert ext_parameters containing Version from json' do
|
871
|
+
catalog = compile_to_catalog("notify {'foo': message => SemVer('1.0.0') }")
|
872
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
873
|
+
message = catalog2.resource('notify', 'foo')['message']
|
874
|
+
expect(message).to be_a(Semantic::Version)
|
875
|
+
expect(message).to eql(Semantic::Version.parse('1.0.0'))
|
876
|
+
end
|
877
|
+
|
878
|
+
it 'should read and convert ext_parameters containing VersionRange from json' do
|
879
|
+
catalog = compile_to_catalog("notify {'foo': message => SemVerRange('>=1.0.0') }")
|
880
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
881
|
+
message = catalog2.resource('notify', 'foo')['message']
|
882
|
+
expect(message).to be_a(Semantic::VersionRange)
|
883
|
+
expect(message).to eql(Semantic::VersionRange.parse('>=1.0.0'))
|
884
|
+
end
|
885
|
+
|
886
|
+
it 'should read and convert ext_parameters containing Timespan from json' do
|
887
|
+
catalog = compile_to_catalog("notify {'foo': message => Timespan(1234) }")
|
888
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
889
|
+
message = catalog2.resource('notify', 'foo')['message']
|
890
|
+
expect(message).to be_a(Puppet::Pops::Time::Timespan)
|
891
|
+
expect(message).to eql(Puppet::Pops::Time::Timespan.parse('1234', '%S'))
|
892
|
+
end
|
893
|
+
|
894
|
+
it 'should read and convert ext_parameters containing Timestamp from json' do
|
895
|
+
catalog = compile_to_catalog("notify {'foo': message => Timestamp('2016-09-15T08:32:16.123 UTC') }")
|
896
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
897
|
+
message = catalog2.resource('notify', 'foo')['message']
|
898
|
+
expect(message).to be_a(Puppet::Pops::Time::Timestamp)
|
899
|
+
expect(message).to eql(Puppet::Pops::Time::Timestamp.parse('2016-09-15T08:32:16.123 UTC'))
|
900
|
+
end
|
901
|
+
|
902
|
+
it 'should read and convert ext_parameters containing hash with rich data from json' do
|
903
|
+
catalog = compile_to_catalog("notify {'foo': message => { 'version' => SemVer('1.0.0'), 'time' => Timestamp('2016-09-15T08:32:16.123 UTC') }}")
|
904
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
905
|
+
message = catalog2.resource('notify', 'foo')['message']
|
906
|
+
expect(message).to be_a(Hash)
|
907
|
+
expect(message['version']).to eql(Semantic::Version.parse('1.0.0'))
|
908
|
+
expect(message['time']).to eql(Puppet::Pops::Time::Timestamp.parse('2016-09-15T08:32:16.123 UTC'))
|
909
|
+
end
|
910
|
+
|
911
|
+
it 'should read and convert ext_parameters containing an array with rich data from json' do
|
912
|
+
catalog = compile_to_catalog("notify {'foo': message => [ SemVer('1.0.0'), Timestamp('2016-09-15T08:32:16.123 UTC') ] }")
|
913
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
914
|
+
message = catalog2.resource('notify', 'foo')['message']
|
915
|
+
expect(message).to be_a(Array)
|
916
|
+
expect(message[0]).to eql(Semantic::Version.parse('1.0.0'))
|
917
|
+
expect(message[1]).to eql(Puppet::Pops::Time::Timestamp.parse('2016-09-15T08:32:16.123 UTC'))
|
918
|
+
end
|
919
|
+
end
|
920
|
+
|
921
|
+
context 'and rich_data is disabled' do
|
922
|
+
before(:each) do
|
923
|
+
Puppet[:rich_data] = false
|
924
|
+
end
|
925
|
+
|
926
|
+
let(:catalog_w_regexp) { compile_to_catalog("notify {'foo': message => /[a-z]+/ }") }
|
927
|
+
|
928
|
+
it 'should not generate ext_parameters for parameter values that are not Data' do
|
929
|
+
expect(catalog_w_regexp.to_json).not_to include('"ext_parameters":{"message":[48,"[a-z]+"]}')
|
930
|
+
end
|
931
|
+
|
932
|
+
it 'should convert parameter containing Regexp into strings' do
|
933
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog_w_regexp.to_json))
|
934
|
+
message = catalog2.resource('notify', 'foo')['message']
|
935
|
+
expect(message).to be_a(String)
|
936
|
+
expect(message).to eql('/[a-z]+/')
|
937
|
+
end
|
938
|
+
|
939
|
+
it 'should convert parameter containing Version into string' do
|
940
|
+
catalog = compile_to_catalog("notify {'foo': message => SemVer('1.0.0') }")
|
941
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
942
|
+
message = catalog2.resource('notify', 'foo')['message']
|
943
|
+
expect(message).to be_a(String)
|
944
|
+
expect(message).to eql('1.0.0')
|
945
|
+
end
|
946
|
+
|
947
|
+
it 'should convert parameter containing VersionRange into string' do
|
948
|
+
catalog = compile_to_catalog("notify {'foo': message => SemVerRange('>=1.0.0') }")
|
949
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
950
|
+
message = catalog2.resource('notify', 'foo')['message']
|
951
|
+
expect(message).to be_a(String)
|
952
|
+
expect(message).to eql('>=1.0.0')
|
953
|
+
end
|
954
|
+
|
955
|
+
it 'should convert parameter containing Timespan into string' do
|
956
|
+
catalog = compile_to_catalog("notify {'foo': message => Timespan(1234) }")
|
957
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
958
|
+
message = catalog2.resource('notify', 'foo')['message']
|
959
|
+
expect(message).to be_a(String)
|
960
|
+
expect(message).to eql('0-00:20:34.0')
|
961
|
+
end
|
962
|
+
|
963
|
+
it 'should convert parameter containing Timestamp into string' do
|
964
|
+
catalog = compile_to_catalog("notify {'foo': message => Timestamp('2016-09-15T08:32:16.123 UTC') }")
|
965
|
+
catalog2 = Puppet::Resource::Catalog.from_data_hash(JSON.parse(catalog.to_json))
|
966
|
+
message = catalog2.resource('notify', 'foo')['message']
|
967
|
+
expect(message).to be_a(String)
|
968
|
+
expect(message).to eql('2016-09-15T08:32:16.123 UTC')
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
end
|
846
973
|
end
|
847
974
|
|
848
975
|
describe Puppet::Resource::Catalog, "when converting to pson" do
|