puppet 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +20 -20
- data/Guardfile.example +76 -0
- data/LICENSE +189 -4
- data/README.md +3 -3
- data/Rakefile +5 -2
- data/ext/solaris/smf/svc-puppetd +8 -1
- data/ext/solaris/smf/svc-puppetmasterd +8 -1
- data/lib/puppet/application/apply.rb +100 -59
- data/lib/puppet/application/cert.rb +4 -114
- data/lib/puppet/application/device.rb +48 -32
- data/lib/puppet/application/script.rb +1 -1
- data/lib/puppet/application/ssl.rb +135 -51
- data/lib/puppet/application.rb +5 -0
- data/lib/puppet/configurer.rb +2 -3
- data/lib/puppet/defaults.rb +33 -49
- data/lib/puppet/etc.rb +20 -0
- data/lib/puppet/face/config.rb +3 -3
- data/lib/puppet/face/key.rb +1 -1
- data/lib/puppet/face/node/clean.rb +0 -1
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/functions/abs.rb +1 -1
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/module/task.rb +29 -38
- data/lib/puppet/pal/catalog_compiler.rb +96 -0
- data/lib/puppet/pal/compiler.rb +221 -0
- data/lib/puppet/pal/function_signature.rb +52 -0
- data/lib/puppet/pal/json_catalog_encoder.rb +67 -0
- data/lib/puppet/pal/pal_api.rb +15 -0
- data/lib/puppet/pal/pal_impl.rb +523 -0
- data/lib/puppet/pal/plan_signature.rb +71 -0
- data/lib/puppet/pal/script_compiler.rb +71 -0
- data/lib/puppet/pal/task_signature.rb +58 -0
- data/lib/puppet/parser/catalog_compiler.rb +24 -0
- data/lib/puppet/parser/compiler.rb +3 -1
- data/lib/puppet/parser/functions/generate.rb +7 -6
- data/lib/puppet/plugins/configuration.rb +5 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -3
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +19 -10
- data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/lib/puppet/pops/pcore.rb +10 -33
- data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
- data/lib/puppet/pops/serialization.rb +1 -0
- data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/lib/puppet/pops/types/string_converter.rb +18 -4
- data/lib/puppet/pops/validation/checker4_0.rb +17 -2
- data/lib/puppet/provider/exec.rb +59 -57
- data/lib/puppet/provider/group/aix.rb +18 -2
- data/lib/puppet/provider/group/windows_adsi.rb +7 -3
- data/lib/puppet/provider/nameservice.rb +1 -25
- data/lib/puppet/provider/package/dnf.rb +2 -0
- data/lib/puppet/provider/package/pkgng.rb +37 -21
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/windows/exe_package.rb +16 -10
- data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/launchd.rb +19 -3
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/provider/service/systemd.rb +19 -0
- data/lib/puppet/provider/service/upstart.rb +1 -0
- data/lib/puppet/provider/service/windows.rb +22 -5
- data/lib/puppet/provider/user/aix.rb +48 -2
- data/lib/puppet/provider/user/useradd.rb +2 -10
- data/lib/puppet/provider/user/windows_adsi.rb +9 -1
- data/lib/puppet/resource/catalog.rb +1 -5
- data/lib/puppet/resource.rb +3 -1
- data/lib/puppet/ssl/host.rb +26 -16
- data/lib/puppet/syntax_checkers/epp.rb +34 -0
- data/lib/puppet/syntax_checkers/pp.rb +34 -0
- data/lib/puppet/transaction/event_manager.rb +13 -1
- data/lib/puppet/transaction/persistence.rb +1 -1
- data/lib/puppet/transaction/resource_harness.rb +3 -1
- data/lib/puppet/type/group.rb +29 -1
- data/lib/puppet/type/package.rb +5 -1
- data/lib/puppet/type/resources.rb +12 -2
- data/lib/puppet/type/schedule.rb +7 -0
- data/lib/puppet/type/service.rb +12 -0
- data/lib/puppet/type/user.rb +5 -2
- data/lib/puppet/type.rb +6 -0
- data/lib/puppet/util/command_line.rb +2 -3
- data/lib/puppet/util/execution.rb +15 -1
- data/lib/puppet/util/filetype.rb +56 -8
- data/lib/puppet/util/log/destinations.rb +3 -2
- data/lib/puppet/util/logging.rb +3 -2
- data/lib/puppet/util/posix.rb +15 -0
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +12 -0
- data/lib/puppet/util/windows/adsi.rb +79 -2
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/process.rb +23 -3
- data/lib/puppet/util/windows/registry.rb +29 -5
- data/lib/puppet/util/windows/security.rb +14 -0
- data/lib/puppet/util/windows/service.rb +294 -74
- data/lib/puppet/util/windows/user.rb +3 -5
- data/lib/puppet/util.rb +7 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +1 -0
- data/lib/puppet_pal.rb +5 -1099
- data/locales/ja/puppet.po +952 -986
- data/locales/puppet.pot +592 -347
- data/man/man5/puppet.conf.5 +26 -31
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +4 -4
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +23 -19
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +2 -2
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +26 -3
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/bad_func_load.rb +11 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query +7 -1
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query.zsh +1 -0
- data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
- data/spec/integration/application/apply_spec.rb +4 -1
- data/spec/integration/parser/collection_spec.rb +4 -8
- data/spec/integration/provider/service/windows_spec.rb +5 -5
- data/spec/integration/ssl/key_spec.rb +0 -4
- data/spec/integration/transaction_spec.rb +559 -0
- data/spec/integration/type/file_spec.rb +6 -6
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/integration/util/windows/security_spec.rb +10 -7
- data/spec/integration/util/windows/user_spec.rb +37 -17
- data/spec/lib/puppet/test_ca.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/apply_spec.rb +55 -2
- data/spec/unit/application/device_spec.rb +10 -7
- data/spec/unit/application/face_base_spec.rb +1 -1
- data/spec/unit/application/lookup_spec.rb +2 -1
- data/spec/unit/application/ssl_spec.rb +178 -109
- data/spec/unit/application_spec.rb +29 -11
- data/spec/unit/configurer/downloader_spec.rb +1 -1
- data/spec/unit/configurer_spec.rb +16 -5
- data/spec/unit/etc_spec.rb +25 -0
- data/spec/unit/face/node_spec.rb +1 -3
- data/spec/unit/face/parser_spec.rb +15 -0
- data/spec/unit/file_serving/fileset_spec.rb +11 -11
- data/spec/unit/functions/logging_spec.rb +10 -3
- data/spec/unit/indirector/catalog/json_spec.rb +9 -3
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +2 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +36 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
- data/spec/unit/pops/loaders/loader_spec.rb +9 -17
- data/spec/unit/pops/loaders/loaders_spec.rb +48 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -0
- data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
- data/spec/unit/pops/types/string_converter_spec.rb +25 -1
- data/spec/unit/pops/types/task_spec.rb +42 -116
- data/spec/unit/pops/validator/validator_spec.rb +24 -10
- data/spec/unit/provider/exec/posix_spec.rb +24 -0
- data/spec/unit/provider/group/aix_spec.rb +20 -6
- data/spec/unit/provider/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- data/spec/unit/provider/group/windows_adsi_spec.rb +42 -33
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
- data/spec/unit/provider/package/aix_spec.rb +5 -8
- data/spec/unit/provider/package/apt_spec.rb +3 -6
- data/spec/unit/provider/package/dnf_spec.rb +38 -25
- data/spec/unit/provider/package/dpkg_spec.rb +18 -21
- data/spec/unit/provider/package/freebsd_spec.rb +4 -7
- data/spec/unit/provider/package/gem_spec.rb +41 -41
- data/spec/unit/provider/package/hpux_spec.rb +7 -10
- data/spec/unit/provider/package/macports_spec.rb +13 -15
- data/spec/unit/provider/package/nim_spec.rb +3 -10
- data/spec/unit/provider/package/openbsd_spec.rb +14 -17
- data/spec/unit/provider/package/pip3_spec.rb +3 -6
- data/spec/unit/provider/package/pip_spec.rb +45 -49
- data/spec/unit/provider/package/pkgin_spec.rb +13 -18
- data/spec/unit/provider/package/pkgng_spec.rb +32 -27
- data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
- data/spec/unit/provider/package/tdnf_spec.rb +9 -12
- data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +4 -4
- data/spec/unit/provider/package/yum_spec.rb +30 -16
- data/spec/unit/provider/package/zypper_spec.rb +17 -19
- data/spec/unit/provider/service/bsd_spec.rb +7 -9
- data/spec/unit/provider/service/daemontools_spec.rb +12 -16
- data/spec/unit/provider/service/debian_spec.rb +6 -10
- data/spec/unit/provider/service/freebsd_spec.rb +2 -2
- data/spec/unit/provider/service/launchd_spec.rb +19 -0
- data/spec/unit/provider/service/openbsd_spec.rb +13 -17
- data/spec/unit/provider/service/rcng_spec.rb +2 -4
- data/spec/unit/provider/service/redhat_spec.rb +12 -11
- data/spec/unit/provider/service/runit_spec.rb +7 -14
- data/spec/unit/provider/service/smf_spec.rb +77 -13
- data/spec/unit/provider/service/src_spec.rb +11 -16
- data/spec/unit/provider/service/systemd_spec.rb +39 -1
- data/spec/unit/provider/service/windows_spec.rb +39 -7
- data/spec/unit/provider/user/aix_spec.rb +43 -2
- data/spec/unit/provider/user/hpux_spec.rb +3 -5
- data/spec/unit/provider/user/ldap_spec.rb +29 -32
- data/spec/unit/provider/user/pw_spec.rb +10 -13
- data/spec/unit/provider/user/useradd_spec.rb +2 -2
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/puppet_pal_2pec.rb +6 -6
- data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +31 -0
- data/spec/unit/ssl/host_spec.rb +22 -1
- data/spec/unit/ssl/key_spec.rb +2 -4
- data/spec/unit/task_spec.rb +50 -5
- data/spec/unit/transaction/event_manager_spec.rb +12 -1
- data/spec/unit/transaction/persistence_spec.rb +4 -4
- data/spec/unit/transaction/resource_harness_spec.rb +18 -0
- data/spec/unit/type/group_spec.rb +11 -3
- data/spec/unit/type/resources_spec.rb +18 -0
- data/spec/unit/type/service_spec.rb +27 -1
- data/spec/unit/util/execution_spec.rb +77 -0
- data/spec/unit/util/filetype_spec.rb +13 -5
- data/spec/unit/util/log/destinations_spec.rb +10 -0
- data/spec/unit/util/logging_spec.rb +58 -41
- data/spec/unit/util/monkey_patches_spec.rb +18 -5
- data/spec/unit/util/posix_spec.rb +28 -0
- data/spec/unit/util/selinux_spec.rb +4 -0
- data/spec/unit/util/storage_spec.rb +107 -0
- data/spec/unit/util/suidmanager_spec.rb +1 -3
- data/spec/unit/util/windows/adsi_spec.rb +95 -0
- data/spec/unit/util/windows/service_spec.rb +377 -131
- metadata +24 -11
- data/ext/autotest/Rakefile +0 -8
- data/ext/autotest/config +0 -43
- data/ext/autotest/readme.rst +0 -16
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -7
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +0 -1
- data/spec/watchr.rb +0 -137
|
@@ -147,12 +147,12 @@ describe Puppet::FileServing::Fileset do
|
|
|
147
147
|
top_names = %w{one two .svn CVS}
|
|
148
148
|
sub_names = %w{file1 file2 .svn CVS 0 false}
|
|
149
149
|
|
|
150
|
-
Dir.stubs(:entries).with(path).returns(top_names)
|
|
150
|
+
Dir.stubs(:entries).with(path, encoding: Encoding::UTF_8).returns(top_names)
|
|
151
151
|
top_names.each do |subdir|
|
|
152
152
|
@files << subdir # relative path
|
|
153
153
|
subpath = File.join(path, subdir)
|
|
154
154
|
Puppet::FileSystem.stubs(stat_method).with(subpath).returns @dirstat
|
|
155
|
-
Dir.stubs(:entries).with(subpath).returns(sub_names)
|
|
155
|
+
Dir.stubs(:entries).with(subpath, encoding: Encoding::UTF_8).returns(sub_names)
|
|
156
156
|
sub_names.each do |file|
|
|
157
157
|
@files << File.join(subdir, file) # relative path
|
|
158
158
|
subfile_path = File.join(subpath, file)
|
|
@@ -173,7 +173,7 @@ describe Puppet::FileServing::Fileset do
|
|
|
173
173
|
extend Mocha::API
|
|
174
174
|
path = File.join(base_path, name)
|
|
175
175
|
Puppet::FileSystem.stubs(:lstat).with(path).returns MockStat.new(path, true)
|
|
176
|
-
Dir.stubs(:entries).with(path).returns(['.', '..'] + entries.map(&:name))
|
|
176
|
+
Dir.stubs(:entries).with(path, encoding: Encoding::UTF_8).returns(['.', '..'] + entries.map(&:name))
|
|
177
177
|
entries.each do |entry|
|
|
178
178
|
entry.mock(path)
|
|
179
179
|
end
|
|
@@ -295,7 +295,7 @@ describe Puppet::FileServing::Fileset do
|
|
|
295
295
|
link_path = File.join(path, "mylink")
|
|
296
296
|
Puppet::FileSystem.expects(:stat).with(link_path).raises(Errno::ENOENT)
|
|
297
297
|
|
|
298
|
-
Dir.stubs(:entries).with(path).returns(["mylink"])
|
|
298
|
+
Dir.stubs(:entries).with(path, encoding: Encoding::UTF_8).returns(["mylink"])
|
|
299
299
|
|
|
300
300
|
fileset = Puppet::FileServing::Fileset.new(path)
|
|
301
301
|
|
|
@@ -319,9 +319,9 @@ describe Puppet::FileServing::Fileset do
|
|
|
319
319
|
end
|
|
320
320
|
|
|
321
321
|
it "returns a hash of all files in each fileset with the value being the base path" do
|
|
322
|
-
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one uno})
|
|
323
|
-
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two dos})
|
|
324
|
-
Dir.expects(:entries).with(make_absolute("/third/path")).returns(%w{three tres})
|
|
322
|
+
Dir.expects(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).returns(%w{one uno})
|
|
323
|
+
Dir.expects(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).returns(%w{two dos})
|
|
324
|
+
Dir.expects(:entries).with(make_absolute("/third/path"), encoding: Encoding::UTF_8).returns(%w{three tres})
|
|
325
325
|
|
|
326
326
|
expect(Puppet::FileServing::Fileset.merge(*@filesets)).to eq({
|
|
327
327
|
"." => make_absolute("/first/path"),
|
|
@@ -335,15 +335,15 @@ describe Puppet::FileServing::Fileset do
|
|
|
335
335
|
end
|
|
336
336
|
|
|
337
337
|
it "includes the base directory from the first fileset" do
|
|
338
|
-
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
|
|
339
|
-
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{two})
|
|
338
|
+
Dir.expects(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).returns(%w{one})
|
|
339
|
+
Dir.expects(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).returns(%w{two})
|
|
340
340
|
|
|
341
341
|
expect(Puppet::FileServing::Fileset.merge(*@filesets)["."]).to eq(make_absolute("/first/path"))
|
|
342
342
|
end
|
|
343
343
|
|
|
344
344
|
it "uses the base path of the first found file when relative file paths conflict" do
|
|
345
|
-
Dir.expects(:entries).with(make_absolute("/first/path")).returns(%w{one})
|
|
346
|
-
Dir.expects(:entries).with(make_absolute("/second/path")).returns(%w{one})
|
|
345
|
+
Dir.expects(:entries).with(make_absolute("/first/path"), encoding: Encoding::UTF_8).returns(%w{one})
|
|
346
|
+
Dir.expects(:entries).with(make_absolute("/second/path"), encoding: Encoding::UTF_8).returns(%w{one})
|
|
347
347
|
|
|
348
348
|
expect(Puppet::FileServing::Fileset.merge(*@filesets)["one"]).to eq(make_absolute("/first/path"))
|
|
349
349
|
end
|
|
@@ -18,9 +18,16 @@ describe 'the log function' do
|
|
|
18
18
|
|
|
19
19
|
def expect_log(code, log_level, message)
|
|
20
20
|
logs = collect_logs(code)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
|
|
22
|
+
# There's a chance that additional messages could have been
|
|
23
|
+
# added during code compilation like debug messages from
|
|
24
|
+
# Facter. This happened on Appveyor when the Appveyor image
|
|
25
|
+
# failed to resolve the domain fact. Since these messages are
|
|
26
|
+
# not relevant to our test, and since they can (possibly) be
|
|
27
|
+
# injected at any location in our logs array, it is good enough
|
|
28
|
+
# to assert that our desired log _is_ included in the logs array
|
|
29
|
+
# instead of trying to figure out _where_ it is included.
|
|
30
|
+
expect(logs).to include(satisfy { |log| log.level == log_level && log.message == message })
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
before(:each) do
|
|
@@ -17,8 +17,9 @@ describe Puppet::Resource::Catalog::Json do
|
|
|
17
17
|
let(:binary) { "\xC0\xFF".force_encoding(Encoding::BINARY) }
|
|
18
18
|
let(:key) { 'foo' }
|
|
19
19
|
let(:file) { subject.path(key) }
|
|
20
|
+
let(:env) { Puppet::Node::Environment.create(:testing, []) }
|
|
20
21
|
let(:catalog) do
|
|
21
|
-
catalog = Puppet::Resource::Catalog.new(key,
|
|
22
|
+
catalog = Puppet::Resource::Catalog.new(key, env)
|
|
22
23
|
catalog.add_resource(Puppet::Resource.new(:file, '/tmp/a_file', :parameters => { :content => binary }))
|
|
23
24
|
catalog
|
|
24
25
|
end
|
|
@@ -27,6 +28,11 @@ describe Puppet::Resource::Catalog::Json do
|
|
|
27
28
|
Puppet.run_mode.stubs(:master?).returns(true)
|
|
28
29
|
Puppet[:server_datadir] = tmpdir('jsondir')
|
|
29
30
|
FileUtils.mkdir_p(File.join(Puppet[:server_datadir], 'indirector_testing'))
|
|
31
|
+
Puppet.push_context(:loaders => Puppet::Pops::Loaders.new(env))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
after :each do
|
|
35
|
+
Puppet.pop_context()
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
it 'saves a catalog containing binary content' do
|
|
@@ -43,7 +49,7 @@ describe Puppet::Resource::Catalog::Json do
|
|
|
43
49
|
parsed_catalog = subject.find(request)
|
|
44
50
|
|
|
45
51
|
content = parsed_catalog.resource(:file, '/tmp/a_file')[:content]
|
|
46
|
-
expect(content.bytes.to_a).to eq(binary.bytes.to_a)
|
|
52
|
+
expect(content.binary_buffer.bytes.to_a).to eq(binary.bytes.to_a)
|
|
47
53
|
end
|
|
48
54
|
|
|
49
55
|
it 'searches for catalogs contains binary content' do
|
|
@@ -55,7 +61,7 @@ describe Puppet::Resource::Catalog::Json do
|
|
|
55
61
|
|
|
56
62
|
expect(parsed_catalogs.size).to eq(1)
|
|
57
63
|
content = parsed_catalogs.first.resource(:file, '/tmp/a_file')[:content]
|
|
58
|
-
expect(content.bytes.to_a).to eq(binary.bytes.to_a)
|
|
64
|
+
expect(content.binary_buffer.bytes.to_a).to eq(binary.bytes.to_a)
|
|
59
65
|
end
|
|
60
66
|
end
|
|
61
67
|
end
|
|
@@ -141,7 +141,7 @@ describe Puppet::Indirector::Yaml do
|
|
|
141
141
|
dir_containing_instances([one, two])
|
|
142
142
|
|
|
143
143
|
request = indirection.request(:search, "*", nil)
|
|
144
|
-
expect(terminus.search(request)).to
|
|
144
|
+
expect(terminus.search(request)).to contain_exactly(one, two)
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "should return an array containing a single instance of fact when globbing 'one*'" do
|
|
@@ -97,7 +97,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
|
97
97
|
:verify => ConstantErrorValidator.new(
|
|
98
98
|
:fails_with => 'hostname was not match with server certificate',
|
|
99
99
|
:peer_certs => [Puppet::TestCa.new.generate('not_my_server',
|
|
100
|
-
:subject_alt_names => 'DNS:foo,DNS:bar,DNS:baz,DNS:not_my_server')
|
|
100
|
+
:subject_alt_names => 'DNS:foo,DNS:bar,DNS:baz,DNS:not_my_server')[:cert]]))
|
|
101
101
|
|
|
102
102
|
expect do
|
|
103
103
|
connection.get('request')
|
|
@@ -120,7 +120,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
|
120
120
|
it "should check all peer certificates for upcoming expiration", :unless => Puppet::Util::Platform.windows? || RUBY_PLATFORM == 'java' do
|
|
121
121
|
Puppet[:confdir] = tmpdir('conf')
|
|
122
122
|
cert = Puppet::TestCa.new.generate('server',
|
|
123
|
-
:subject_alt_names => 'DNS:foo,DNS:bar,DNS:baz,DNS:server')
|
|
123
|
+
:subject_alt_names => 'DNS:foo,DNS:bar,DNS:baz,DNS:server')[:cert]
|
|
124
124
|
|
|
125
125
|
connection = Puppet::Network::HTTP::Connection.new(
|
|
126
126
|
host, port,
|
|
@@ -1385,6 +1385,24 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
|
|
|
1385
1385
|
expect(parser.evaluate_string(scope, src)).to eq('dGhlIHF1aWNrIHJlZCBmb3g=')
|
|
1386
1386
|
end
|
|
1387
1387
|
|
|
1388
|
+
it "parses pp syntax checked specification" do
|
|
1389
|
+
src = <<-CODE
|
|
1390
|
+
@(END:pp)
|
|
1391
|
+
$x = 42
|
|
1392
|
+
|- END
|
|
1393
|
+
CODE
|
|
1394
|
+
expect(parser.evaluate_string(scope, src)).to eq('$x = 42')
|
|
1395
|
+
end
|
|
1396
|
+
|
|
1397
|
+
it "parses epp syntax checked specification" do
|
|
1398
|
+
src = <<-CODE
|
|
1399
|
+
@(END:epp)
|
|
1400
|
+
<% $x = 42 %><%= $x %>
|
|
1401
|
+
|- END
|
|
1402
|
+
CODE
|
|
1403
|
+
expect(parser.evaluate_string(scope, src)).to eq('<% $x = 42 %><%= $x %>')
|
|
1404
|
+
end
|
|
1405
|
+
|
|
1388
1406
|
it "parses json syntax checked specification with error and reports it" do
|
|
1389
1407
|
src = <<-CODE
|
|
1390
1408
|
@(END:json)
|
|
@@ -1403,6 +1421,24 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
|
|
|
1403
1421
|
expect { parser.evaluate_string(scope, src)}.to raise_error(/Cannot parse invalid Base64 string/)
|
|
1404
1422
|
end
|
|
1405
1423
|
|
|
1424
|
+
it "parses pp syntax checked specification with error and reports it" do
|
|
1425
|
+
src = <<-CODE
|
|
1426
|
+
@(END:pp)
|
|
1427
|
+
$x ==== 42
|
|
1428
|
+
|- END
|
|
1429
|
+
CODE
|
|
1430
|
+
expect{parser.evaluate_string(scope, src)}.to raise_error(/Invalid produced text having syntax: 'pp'/)
|
|
1431
|
+
end
|
|
1432
|
+
|
|
1433
|
+
it "parses epp syntax checked specification with error and reports it" do
|
|
1434
|
+
src = <<-CODE
|
|
1435
|
+
@(END:epp)
|
|
1436
|
+
<% $x ==== 42 %>
|
|
1437
|
+
|- END
|
|
1438
|
+
CODE
|
|
1439
|
+
expect{parser.evaluate_string(scope, src)}.to raise_error(/Invalid produced text having syntax: 'epp'/)
|
|
1440
|
+
end
|
|
1441
|
+
|
|
1406
1442
|
it "parses interpolated heredoc expression" do
|
|
1407
1443
|
src = <<-CODE
|
|
1408
1444
|
$pname = 'Fjodor'
|
|
@@ -30,22 +30,40 @@ describe 'when converting to 3.x' do
|
|
|
30
30
|
expect(converter.convert(v, {}, nil)).to equal(v)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
it 'converts
|
|
33
|
+
it 'converts top level symbol :undef to the given undef value' do
|
|
34
34
|
expect(converter.convert(:undef, {}, 'undef value')).to eql('undef value')
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
it 'converts
|
|
37
|
+
it 'converts top level nil value to the given undef value' do
|
|
38
38
|
expect(converter.convert(nil, {}, 'undef value')).to eql('undef value')
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
it '
|
|
42
|
-
expect(converter.convert({'foo' => :undef}, {}, 'undef value')).to eql({'foo' =>
|
|
41
|
+
it 'converts nested :undef in a hash to nil' do
|
|
42
|
+
expect(converter.convert({'foo' => :undef}, {}, 'undef value')).to eql({'foo' => nil})
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'converts nested :undef in an array to nil' do
|
|
46
|
+
expect(converter.convert(['boo', :undef], {}, 'undef value')).to eql(['boo', nil])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'converts deeply nested :undef in to nil' do
|
|
50
|
+
expect(converter.convert({'foo' => [[:undef]], 'bar' => { 'x' => :undef }}, {}, 'undef value')).to eql({'foo' => [[nil]], 'bar' => { 'x' => nil}})
|
|
43
51
|
end
|
|
44
52
|
|
|
45
53
|
it 'does not converts nil to given undef value when nested in an array' do
|
|
46
54
|
expect(converter.convert({'foo' => nil}, {}, 'undef value')).to eql({'foo' => nil})
|
|
47
55
|
end
|
|
48
56
|
|
|
57
|
+
it 'does not convert top level symbols' do
|
|
58
|
+
expect(converter.convert(:default, {}, 'undef value')).to eql(:default)
|
|
59
|
+
expect(converter.convert(:whatever, {}, 'undef value')).to eql(:whatever)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'does not convert nested symbols' do
|
|
63
|
+
expect(converter.convert([:default], {}, 'undef value')).to eql([:default])
|
|
64
|
+
expect(converter.convert([:whatever], {}, 'undef value')).to eql([:whatever])
|
|
65
|
+
end
|
|
66
|
+
|
|
49
67
|
it 'does not convert a Regex instance to string' do
|
|
50
68
|
v = /^[A-Z]$/
|
|
51
69
|
expect(converter.convert(v, {}, nil)).to equal(v)
|
|
@@ -329,13 +329,6 @@ describe 'The Loader' do
|
|
|
329
329
|
'bad_syntax.json' => <<-TXT.unindent,
|
|
330
330
|
text => This is not a task because JSON is unparsable
|
|
331
331
|
TXT
|
|
332
|
-
'bad_content.sh' => '',
|
|
333
|
-
'bad_content.json' => <<-JSON.unindent,
|
|
334
|
-
{
|
|
335
|
-
"description": "This is not a task because parameters is misspelled",
|
|
336
|
-
"paramters": { "string_param": { "type": "String[1]" } }
|
|
337
|
-
}
|
|
338
|
-
JSON
|
|
339
332
|
'missing_adjacent.json' => <<-JSON.unindent,
|
|
340
333
|
{
|
|
341
334
|
"description": "This is not a task because there is no adjacent file with the same base name",
|
|
@@ -415,7 +408,7 @@ describe 'The Loader' do
|
|
|
415
408
|
contain_exactly(tn(:task, 'c::foo')))
|
|
416
409
|
end
|
|
417
410
|
expect(logs.select { |log| log.level == :warning }.map { |log| log.message }).to(
|
|
418
|
-
contain_exactly(/unexpected token/, /
|
|
411
|
+
contain_exactly(/unexpected token/, /No source besides task metadata was found/)
|
|
419
412
|
)
|
|
420
413
|
end
|
|
421
414
|
|
|
@@ -427,11 +420,11 @@ describe 'The Loader' do
|
|
|
427
420
|
contain_exactly(tn(:task, 'c::foo')))
|
|
428
421
|
end
|
|
429
422
|
expect(logs.select { |log| log.level == :warning }.map { |log| log.message }).to be_empty
|
|
430
|
-
expect(error_collector.size).to eql(
|
|
423
|
+
expect(error_collector.size).to eql(2)
|
|
431
424
|
expect(error_collector.all? { |e| e.is_a?(Puppet::DataTypes::Error) })
|
|
432
425
|
expect(error_collector.all? { |e| e.issue_code == Puppet::Pops::Issues::LOADER_FAILURE.issue_code })
|
|
433
426
|
expect(error_collector.map { |e| e.details['original_error'] }).to(
|
|
434
|
-
contain_exactly(/unexpected token/, /
|
|
427
|
+
contain_exactly(/unexpected token/, /No source besides task metadata was found/)
|
|
435
428
|
)
|
|
436
429
|
end
|
|
437
430
|
|
|
@@ -454,8 +447,7 @@ describe 'The Loader' do
|
|
|
454
447
|
end
|
|
455
448
|
|
|
456
449
|
context 'with no explicit dependencies' do
|
|
457
|
-
|
|
458
|
-
let(:modules) {
|
|
450
|
+
let(:modules) do
|
|
459
451
|
{
|
|
460
452
|
'a' => {
|
|
461
453
|
'functions' => a_functions,
|
|
@@ -475,12 +467,12 @@ describe 'The Loader' do
|
|
|
475
467
|
'types' => c_types,
|
|
476
468
|
},
|
|
477
469
|
}
|
|
470
|
+
end
|
|
478
471
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
472
|
+
it 'discover is only called once on dependent loader' do
|
|
473
|
+
ModuleLoaders::FileBased.any_instance.expects(:discover).times(4).with(:type, nil, Pcore::RUNTIME_NAME_AUTHORITY).returns([])
|
|
474
|
+
expect(loader.private_loader.discover(:type) { |t| t.name =~ /^.::.*\z/ }).to(contain_exactly())
|
|
475
|
+
end
|
|
484
476
|
end
|
|
485
477
|
end
|
|
486
478
|
end
|
|
@@ -420,6 +420,54 @@ describe 'loaders' do
|
|
|
420
420
|
function = loader.load_typed(typed_name(:function, 'user::caller_ws')).value
|
|
421
421
|
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'passed in scope'")
|
|
422
422
|
end
|
|
423
|
+
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
context 'when causing a 3x load followed by a 4x load' do
|
|
427
|
+
let(:env) { environment_for(mix_4x_and_3x_functions) }
|
|
428
|
+
let(:compiler) { Puppet::Parser::Compiler.new(Puppet::Node.new("test", :environment => env)) }
|
|
429
|
+
let(:scope) { compiler.topscope }
|
|
430
|
+
let(:loader) { compiler.loaders.private_loader_for_module('user') }
|
|
431
|
+
|
|
432
|
+
before(:each) do
|
|
433
|
+
Puppet.push_context(:current_environment => scope.environment, :global_scope => scope, :loaders => compiler.loaders)
|
|
434
|
+
end
|
|
435
|
+
after(:each) do
|
|
436
|
+
Puppet.pop_context
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
it "a 3x function with code outside body is reported as an error" do
|
|
440
|
+
expect { loader.load_typed(typed_name(:function, 'bad_func_load')) }.to raise_error(/Illegal legacy function definition/)
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
context 'when causing a 3x load followed by a 4x load' do
|
|
445
|
+
let(:env) { environment_for(mix_4x_and_3x_functions) }
|
|
446
|
+
let(:compiler) { Puppet::Parser::Compiler.new(Puppet::Node.new("test", :environment => env)) }
|
|
447
|
+
let(:scope) { compiler.topscope }
|
|
448
|
+
let(:loader) { compiler.loaders.private_loader_for_module('user') }
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
before(:each) do
|
|
452
|
+
Puppet.push_context(:current_environment => scope.environment, :global_scope => scope, :loaders => compiler.loaders)
|
|
453
|
+
end
|
|
454
|
+
after(:each) do
|
|
455
|
+
Puppet.pop_context
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it 'a 3x function is loaded once' do
|
|
459
|
+
# create a 3x function that when called will do a load of "callee_ws"
|
|
460
|
+
Puppet::Parser::Functions::newfunction(:callee, :type => :rvalue, :arity => 1) do |args|
|
|
461
|
+
function_callee_ws(['passed in scope'])
|
|
462
|
+
end
|
|
463
|
+
Puppet.expects(:warning).with(any_parameters).never
|
|
464
|
+
scope['passed_in_scope'] = 'value'
|
|
465
|
+
function = loader.load_typed(typed_name(:function, 'callee')).value
|
|
466
|
+
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'value'")
|
|
467
|
+
|
|
468
|
+
function = loader.load_typed(typed_name(:function, 'callee_ws')).value
|
|
469
|
+
expect(function.call(scope, 'passed in scope')).to eql("usee::callee_ws() got 'value'")
|
|
470
|
+
end
|
|
423
471
|
end
|
|
424
472
|
|
|
425
473
|
context 'loading' do
|
|
@@ -104,8 +104,8 @@ describe 'FileBased module loader' do
|
|
|
104
104
|
|
|
105
105
|
task = module_loader.load_typed(typed_name(:task, 'testmodule::foo')).value
|
|
106
106
|
expect(task.name).to eq('testmodule::foo')
|
|
107
|
-
expect(task.
|
|
108
|
-
expect(task.
|
|
107
|
+
expect(task.files.length).to eq(1)
|
|
108
|
+
expect(task.files[0]['name']).to eq('foo.py')
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it 'can load tasks with multiple implementations' do
|
|
@@ -116,7 +116,7 @@ describe 'FileBased module loader' do
|
|
|
116
116
|
|
|
117
117
|
task = module_loader.load_typed(typed_name(:task, 'testmodule::foo')).value
|
|
118
118
|
expect(task.name).to eq('testmodule::foo')
|
|
119
|
-
expect(task.
|
|
119
|
+
expect(task.files.map {|impl| impl['name']}).to eq(['foo.py', 'foo.ps1'])
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
it 'can load multiple tasks with multiple files' do
|
|
@@ -128,11 +128,11 @@ describe 'FileBased module loader' do
|
|
|
128
128
|
foobar_task = module_loader.load_typed(typed_name(:task, 'testmodule::foobar')).value
|
|
129
129
|
|
|
130
130
|
expect(foo_task.name).to eq('testmodule::foo')
|
|
131
|
-
expect(foo_task.
|
|
132
|
-
expect(foo_task.
|
|
131
|
+
expect(foo_task.files.length).to eq(1)
|
|
132
|
+
expect(foo_task.files[0]['name']).to eq('foo.py')
|
|
133
133
|
expect(foobar_task.name).to eq('testmodule::foobar')
|
|
134
|
-
expect(foobar_task.
|
|
135
|
-
expect(foobar_task.
|
|
134
|
+
expect(foobar_task.files.length).to eq(1)
|
|
135
|
+
expect(foobar_task.files[0]['name']).to eq('foobar.py')
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "won't load tasks with invalid names" do
|
|
@@ -140,6 +140,22 @@ describe "egrammar parsing heredoc" do
|
|
|
140
140
|
].join("\n"))
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
+
it "parses interpolated [] expression by looking at the correct preceding char for space" do
|
|
144
|
+
# NOTE: Important not to use the left margin feature here
|
|
145
|
+
src = <<-CODE
|
|
146
|
+
$xxxxxxx = @("END")
|
|
147
|
+
${facts['os']['family']}
|
|
148
|
+
XXXXXXX XXX
|
|
149
|
+
END
|
|
150
|
+
CODE
|
|
151
|
+
expect(dump(parse(src))).to eq([
|
|
152
|
+
"(= $xxxxxxx (@()",
|
|
153
|
+
" (sublocated (cat (str (slice (slice $facts 'os') 'family')) '",
|
|
154
|
+
"XXXXXXX XXX",
|
|
155
|
+
"'))",
|
|
156
|
+
"))"].join("\n"))
|
|
157
|
+
end
|
|
158
|
+
|
|
143
159
|
it 'parses multiple heredocs on the same line' do
|
|
144
160
|
src = <<-CODE
|
|
145
161
|
notice({ @(foo) => @(bar) })
|
|
@@ -153,6 +153,15 @@ module Serialization
|
|
|
153
153
|
expect(val2).to eql(val)
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
+
it 'ACII_8BIT String as Binary' do
|
|
157
|
+
val = Types::PBinaryType::Binary.from_base64('w5ZzdGVuIG1lZCByw7ZzdGVuCg==')
|
|
158
|
+
strval = val.binary_buffer
|
|
159
|
+
write(strval)
|
|
160
|
+
val2 = read
|
|
161
|
+
expect(val2).to be_a(Types::PBinaryType::Binary)
|
|
162
|
+
expect(val2).to eql(val)
|
|
163
|
+
end
|
|
164
|
+
|
|
156
165
|
it 'URI' do
|
|
157
166
|
val = URI('http://bob:ewing@dallas.example.com:8080/oil/baron?crude=cash#leftovers')
|
|
158
167
|
write(val)
|
|
@@ -68,6 +68,28 @@ describe 'Timespan type' do
|
|
|
68
68
|
CODE
|
|
69
69
|
expect(eval_and_collect_notices(code)).to eq(%w(true false))
|
|
70
70
|
end
|
|
71
|
+
|
|
72
|
+
it 'accepts integer values when specifying the range' do
|
|
73
|
+
code = <<-CODE
|
|
74
|
+
notice(Timespan(1) =~ Timespan[1, 2])
|
|
75
|
+
notice(Timespan(3) =~ Timespan[1])
|
|
76
|
+
notice(Timespan(0) =~ Timespan[default, 2])
|
|
77
|
+
notice(Timespan(0) =~ Timespan[1, 2])
|
|
78
|
+
notice(Timespan(3) =~ Timespan[1, 2])
|
|
79
|
+
CODE
|
|
80
|
+
expect(eval_and_collect_notices(code)).to eq(%w(true true true false false))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'accepts float values when specifying the range' do
|
|
84
|
+
code = <<-CODE
|
|
85
|
+
notice(Timespan(1.0) =~ Timespan[1.0, 2.0])
|
|
86
|
+
notice(Timespan(3.0) =~ Timespan[1.0])
|
|
87
|
+
notice(Timespan(0.0) =~ Timespan[default, 2.0])
|
|
88
|
+
notice(Timespan(0.0) =~ Timespan[1.0, 2.0])
|
|
89
|
+
notice(Timespan(3.0) =~ Timespan[1.0, 2.0])
|
|
90
|
+
CODE
|
|
91
|
+
expect(eval_and_collect_notices(code)).to eq(%w(true true true false false))
|
|
92
|
+
end
|
|
71
93
|
end
|
|
72
94
|
|
|
73
95
|
context 'a Timespan instance' do
|
|
@@ -74,6 +74,25 @@ describe 'Timestamp type' do
|
|
|
74
74
|
CODE
|
|
75
75
|
expect(eval_and_collect_notices(code)).to eq(%w(true false))
|
|
76
76
|
end
|
|
77
|
+
|
|
78
|
+
it 'accepts integer values when specifying the range' do
|
|
79
|
+
code = <<-CODE
|
|
80
|
+
notice(Timestamp(1) =~ Timestamp[1, 2])
|
|
81
|
+
notice(Timestamp(3) =~ Timestamp[1])
|
|
82
|
+
notice(Timestamp(0) =~ Timestamp[default, 2])
|
|
83
|
+
CODE
|
|
84
|
+
expect(eval_and_collect_notices(code)).to eq(%w(true true true))
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'accepts float values when specifying the range' do
|
|
88
|
+
code = <<-CODE
|
|
89
|
+
notice(Timestamp(1.0) =~ Timestamp[1.0, 2.0])
|
|
90
|
+
notice(Timestamp(3.0) =~ Timestamp[1.0])
|
|
91
|
+
notice(Timestamp(0.0) =~ Timestamp[default, 2.0])
|
|
92
|
+
CODE
|
|
93
|
+
expect(eval_and_collect_notices(code)).to eq(%w(true true true))
|
|
94
|
+
end
|
|
95
|
+
|
|
77
96
|
end
|
|
78
97
|
|
|
79
98
|
context 'a Timestamp instance' do
|
|
@@ -128,10 +128,14 @@ describe 'The string converter' do
|
|
|
128
128
|
expect(converter.convert("hello\tworld.\r\nSun is brigth today.", string_formats)).to eq('"hello\\tworld.\\r\\nSun is brigth today."')
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
it '
|
|
131
|
+
it 'single quoted result for string that is plain ascii without \\, $ or control characters' do
|
|
132
132
|
expect(converter.convert('hello world', string_formats)).to eq("'hello world'")
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
+
it 'double quoted result when using %#p if it would otherwise be single quoted' do
|
|
136
|
+
expect(converter.convert('hello world', '%#p')).to eq('"hello world"')
|
|
137
|
+
end
|
|
138
|
+
|
|
135
139
|
it 'quoted 5-byte unicode chars' do
|
|
136
140
|
expect(converter.convert("smile \u{1f603}.", string_formats)).to eq("'smile \u{1F603}.'")
|
|
137
141
|
end
|
|
@@ -707,6 +711,15 @@ describe 'The string converter' do
|
|
|
707
711
|
expect(formatted).to eq(result)
|
|
708
712
|
end
|
|
709
713
|
|
|
714
|
+
it 'applies a short form format' do
|
|
715
|
+
result = [
|
|
716
|
+
"[1,",
|
|
717
|
+
" [2, 3],",
|
|
718
|
+
" 4]"
|
|
719
|
+
].join("\n")
|
|
720
|
+
expect(converter.convert([1, [2,3], 4], '%#a')).to eq(result)
|
|
721
|
+
end
|
|
722
|
+
|
|
710
723
|
it 'treats hashes as nested arrays wrt indentation' do
|
|
711
724
|
string_formats = { Puppet::Pops::Types::PArrayType::DEFAULT => { 'format' => '%#a', 'separator' =>", " } }
|
|
712
725
|
# formatting matters here
|
|
@@ -855,6 +868,17 @@ describe 'The string converter' do
|
|
|
855
868
|
expect(converter.convert({1 => "hello", 2 => {3=> "world"}}, string_formats)).to eq(result)
|
|
856
869
|
end
|
|
857
870
|
|
|
871
|
+
it 'applies a short form format' do
|
|
872
|
+
result = [
|
|
873
|
+
"{",
|
|
874
|
+
" 1 => {",
|
|
875
|
+
" 2 => 3",
|
|
876
|
+
" },",
|
|
877
|
+
" 4 => 5",
|
|
878
|
+
"}"].join("\n")
|
|
879
|
+
expect(converter.convert({1 => {2 => 3}, 4 => 5}, '%#h')).to eq(result)
|
|
880
|
+
end
|
|
881
|
+
|
|
858
882
|
context "containing an array" do
|
|
859
883
|
it 'the hash and array renders without breaks and indentation by default' do
|
|
860
884
|
result = "{1 => [1, 2, 3]}"
|