puppet 5.3.3-universal-darwin → 5.3.4-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/CONTRIBUTING.md +1 -1
- data/Gemfile +3 -0
- data/ext/puppet-test +3 -2
- data/lib/hiera/puppet_function.rb +5 -2
- data/lib/hiera_puppet.rb +3 -3
- data/lib/puppet.rb +2 -5
- data/lib/puppet/agent.rb +22 -2
- data/lib/puppet/agent/locker.rb +6 -5
- data/lib/puppet/application.rb +18 -1
- data/lib/puppet/application/agent.rb +9 -2
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/config.rb +1 -0
- data/lib/puppet/application/device.rb +1 -2
- data/lib/puppet/application/filebucket.rb +22 -5
- data/lib/puppet/application/help.rb +1 -0
- data/lib/puppet/application/lookup.rb +1 -3
- data/lib/puppet/application_support.rb +6 -1
- data/lib/puppet/bindings.rb +2 -1
- data/lib/puppet/configurer.rb +9 -4
- data/lib/puppet/configurer/downloader_factory.rb +10 -0
- data/lib/puppet/configurer/plugin_handler.rb +11 -4
- data/lib/puppet/daemon.rb +2 -2
- data/lib/puppet/defaults.rb +99 -27
- data/lib/puppet/environments.rb +2 -0
- data/lib/puppet/error.rb +5 -15
- data/lib/puppet/external/pson/common.rb +2 -2
- data/lib/puppet/face/catalog.rb +1 -1
- data/lib/puppet/face/config.rb +14 -1
- data/lib/puppet/face/epp.rb +4 -2
- data/lib/puppet/face/help.rb +12 -14
- data/lib/puppet/face/man.rb +1 -0
- data/lib/puppet/face/module/build.rb +1 -1
- data/lib/puppet/face/module/list.rb +6 -17
- data/lib/puppet/face/module/uninstall.rb +14 -3
- data/lib/puppet/face/node.rb +1 -0
- data/lib/puppet/face/status.rb +1 -0
- data/lib/puppet/file_serving/base.rb +2 -1
- data/lib/puppet/file_serving/configuration.rb +3 -0
- data/lib/puppet/file_serving/configuration/parser.rb +23 -9
- data/lib/puppet/file_serving/mount/locales.rb +35 -0
- data/lib/puppet/forge.rb +2 -1
- data/lib/puppet/forge/errors.rb +24 -22
- data/lib/puppet/functions/binary_file.rb +1 -0
- data/lib/puppet/functions/each.rb +10 -4
- data/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
- data/lib/puppet/functions/lookup.rb +2 -2
- data/lib/puppet/functions/map.rb +12 -2
- data/lib/puppet/functions/slice.rb +2 -3
- data/lib/puppet/functions/unique.rb +1 -1
- data/lib/puppet/functions/yaml_data.rb +1 -1
- data/lib/puppet/gettext/config.rb +144 -41
- data/lib/puppet/gettext/module_translations.rb +42 -0
- data/lib/puppet/graph/relationship_graph.rb +1 -1
- data/lib/puppet/graph/simple_graph.rb +3 -3
- data/lib/puppet/indirector/catalog/compiler.rb +40 -25
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +3 -3
- data/lib/puppet/indirector/facts/network_device.rb +2 -2
- data/lib/puppet/indirector/file_bucket_file/file.rb +4 -1
- data/lib/puppet/indirector/indirection.rb +17 -9
- data/lib/puppet/indirector/ldap.rb +2 -2
- data/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
- data/lib/puppet/indirector/rest.rb +8 -5
- data/lib/puppet/indirector/ssl_file.rb +2 -2
- data/lib/puppet/indirector/terminus.rb +3 -3
- data/lib/puppet/interface.rb +2 -1
- data/lib/puppet/interface/action.rb +41 -24
- data/lib/puppet/interface/action_builder.rb +14 -5
- data/lib/puppet/interface/action_manager.rb +1 -1
- data/lib/puppet/interface/documentation.rb +21 -10
- data/lib/puppet/interface/face_collection.rb +4 -2
- data/lib/puppet/interface/option.rb +36 -15
- data/lib/puppet/interface/option_builder.rb +23 -9
- data/lib/puppet/interface/option_manager.rb +8 -3
- data/lib/puppet/metatype/manager.rb +7 -3
- data/lib/puppet/module.rb +18 -21
- data/lib/puppet/module_tool/errors/installer.rb +18 -20
- data/lib/puppet/module_tool/errors/shared.rb +20 -15
- data/lib/puppet/module_tool/errors/uninstaller.rb +1 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
- data/lib/puppet/module_tool/tar/mini.rb +57 -4
- data/lib/puppet/network/auth_config_parser.rb +18 -13
- data/lib/puppet/network/authstore.rb +2 -2
- data/lib/puppet/network/client_request.rb +1 -1
- data/lib/puppet/network/format.rb +3 -3
- data/lib/puppet/network/http/api/indirection_type.rb +1 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
- data/lib/puppet/network/http/error.rb +7 -7
- data/lib/puppet/network/http/factory.rb +9 -0
- data/lib/puppet/network/http/rack.rb +2 -2
- data/lib/puppet/network/http/webrick.rb +2 -4
- data/lib/puppet/node.rb +25 -6
- data/lib/puppet/node/environment.rb +14 -0
- data/lib/puppet/node/facts.rb +9 -0
- data/lib/puppet/parameter.rb +3 -3
- data/lib/puppet/parameter/value_collection.rb +9 -9
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/ast/node.rb +2 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
- data/lib/puppet/parser/compiler.rb +6 -5
- data/lib/puppet/parser/functions.rb +1 -1
- data/lib/puppet/parser/functions/generate.rb +2 -4
- data/lib/puppet/parser/functions/inline_template.rb +1 -2
- data/lib/puppet/parser/functions/sprintf.rb +17 -3
- data/lib/puppet/parser/functions/template.rb +6 -2
- data/lib/puppet/parser/resource.rb +30 -31
- data/lib/puppet/parser/scope.rb +20 -11
- data/lib/puppet/parser/templatewrapper.rb +4 -3
- data/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
- data/lib/puppet/pops/functions/dispatch.rb +1 -1
- data/lib/puppet/pops/functions/function.rb +8 -2
- data/lib/puppet/pops/issue_reporter.rb +7 -2
- data/lib/puppet/pops/issues.rb +10 -4
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/loader/module_loaders.rb +5 -2
- data/lib/puppet/pops/loader/static_loader.rb +1 -1
- data/lib/puppet/pops/loaders.rb +7 -3
- data/lib/puppet/pops/lookup/explainer.rb +2 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +2 -2
- data/lib/puppet/pops/lookup/lookup_adapter.rb +4 -4
- data/lib/puppet/pops/merge_strategy.rb +6 -3
- data/lib/puppet/pops/migration/migration_checker.rb +8 -8
- data/lib/puppet/pops/model/ast_transformer.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +4 -2
- data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
- data/lib/puppet/pops/types/iterable.rb +2 -0
- data/lib/puppet/pops/types/p_object_type.rb +36 -15
- data/lib/puppet/pops/types/type_calculator.rb +2 -1
- data/lib/puppet/pops/types/type_factory.rb +3 -1
- data/lib/puppet/pops/types/type_mismatch_describer.rb +19 -6
- data/lib/puppet/pops/types/type_parser.rb +7 -7
- data/lib/puppet/pops/types/types.rb +10 -4
- data/lib/puppet/pops/validation.rb +14 -12
- data/lib/puppet/property.rb +14 -6
- data/lib/puppet/property/ensure.rb +2 -2
- data/lib/puppet/provider.rb +4 -4
- data/lib/puppet/provider/group/aix.rb +4 -2
- data/lib/puppet/provider/ldap.rb +2 -2
- data/lib/puppet/provider/naginator.rb +1 -1
- data/lib/puppet/provider/nameservice.rb +7 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +7 -8
- data/lib/puppet/provider/package/opkg.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +9 -6
- data/lib/puppet/provider/package/pkgutil.rb +3 -3
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +4 -4
- data/lib/puppet/provider/selmodule/semodule.rb +5 -3
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/init.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +2 -2
- data/lib/puppet/provider/service/runit.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +2 -0
- data/lib/puppet/provider/service/systemd.rb +1 -0
- data/lib/puppet/provider/service/upstart.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +13 -6
- data/lib/puppet/provider/user/openbsd.rb +2 -1
- data/lib/puppet/provider/yumrepo/inifile.rb +2 -1
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/reference/configuration.rb +4 -2
- data/lib/puppet/relationship.rb +2 -1
- data/lib/puppet/reports/store.rb +1 -1
- data/lib/puppet/resource.rb +7 -5
- data/lib/puppet/resource/capability_finder.rb +14 -11
- data/lib/puppet/resource/catalog.rb +33 -18
- data/lib/puppet/resource/type.rb +5 -5
- data/lib/puppet/settings.rb +19 -13
- data/lib/puppet/settings/base_setting.rb +23 -8
- data/lib/puppet/settings/config_file.rb +14 -4
- data/lib/puppet/settings/environment_conf.rb +19 -9
- data/lib/puppet/ssl/base.rb +9 -4
- data/lib/puppet/ssl/oids.rb +8 -2
- data/lib/puppet/syntax_checkers/base64.rb +5 -6
- data/lib/puppet/transaction.rb +7 -3
- data/lib/puppet/transaction/persistence.rb +16 -1
- data/lib/puppet/transaction/report.rb +6 -0
- data/lib/puppet/type.rb +27 -35
- data/lib/puppet/type/file.rb +2 -1
- data/lib/puppet/type/file/data_sync.rb +2 -1
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/group.rb +1 -1
- data/lib/puppet/type/mount.rb +1 -1
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/schedule.rb +26 -14
- data/lib/puppet/type/user.rb +9 -3
- data/lib/puppet/type/zone.rb +1 -1
- data/lib/puppet/util.rb +27 -21
- data/lib/puppet/util/at_fork/solaris.rb +6 -4
- data/lib/puppet/util/command_line.rb +5 -0
- data/lib/puppet/util/command_line/trollop.rb +6 -5
- data/lib/puppet/util/errors.rb +61 -8
- data/lib/puppet/util/fileparsing.rb +3 -5
- data/lib/puppet/util/http_proxy.rb +14 -6
- data/lib/puppet/util/instance_loader.rb +1 -3
- data/lib/puppet/util/ldap/manager.rb +6 -3
- data/lib/puppet/util/log.rb +19 -24
- data/lib/puppet/util/logging.rb +21 -28
- data/lib/puppet/util/methodhelper.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +21 -13
- data/lib/puppet/util/plist.rb +3 -1
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/provider_features.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/lib/puppet/util/reference.rb +2 -3
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +2 -2
- data/lib/puppet/util/windows/eventlog.rb +10 -5
- data/lib/puppet/util/windows/file.rb +61 -9
- data/lib/puppet/util/windows/process.rb +1 -1
- data/lib/puppet/util/windows/taskscheduler.rb +2 -2
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +5 -1
- data/lib/puppet/version.rb +1 -1
- data/locales/en/puppet.po +19 -0
- data/locales/ja/puppet.po +2739 -809
- data/locales/puppet.pot +2367 -734
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
- data/spec/integration/agent/logging_spec.rb +2 -0
- data/spec/integration/faces/plugin_spec.rb +1 -0
- data/spec/integration/network/authconfig_spec.rb +2 -2
- data/spec/integration/parser/collection_spec.rb +2 -2
- data/spec/integration/parser/scope_spec.rb +16 -3
- data/spec/integration/provider/cron/crontab_spec.rb +1 -0
- data/spec/integration/transaction/report_spec.rb +5 -0
- data/spec/lib/matchers/json.rb +14 -13
- data/spec/unit/agent_spec.rb +33 -0
- data/spec/unit/application/config_spec.rb +4 -0
- data/spec/unit/application/lookup_spec.rb +30 -0
- data/spec/unit/application_spec.rb +18 -0
- data/spec/unit/configurer/downloader_factory_spec.rb +33 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +71 -16
- data/spec/unit/environments_spec.rb +15 -0
- data/spec/unit/face/config_spec.rb +8 -9
- data/spec/unit/face/epp_face_spec.rb +2 -2
- data/spec/unit/face/plugin_spec.rb +50 -4
- data/spec/unit/file_serving/configuration/parser_spec.rb +2 -2
- data/spec/unit/file_serving/mount/locales_spec.rb +73 -0
- data/spec/unit/functions/break_spec.rb +108 -50
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/hiera_spec.rb +0 -1
- data/spec/unit/functions/lookup_spec.rb +85 -19
- data/spec/unit/functions/next_spec.rb +1 -1
- data/spec/unit/functions/return_spec.rb +2 -2
- data/spec/unit/gettext/config_spec.rb +125 -0
- data/spec/unit/gettext/module_loading_spec.rb +53 -0
- data/spec/unit/indirector/json_spec.rb +0 -11
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +1 -1
- data/spec/unit/interface_spec.rb +12 -0
- data/spec/unit/module_spec.rb +0 -28
- data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
- data/spec/unit/network/http/factory_spec.rb +22 -0
- data/spec/unit/network/http/webrick_spec.rb +30 -29
- data/spec/unit/node/environment_spec.rb +16 -0
- data/spec/unit/node_spec.rb +102 -16
- data/spec/unit/parser/environment_compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/sprintf_spec.rb +26 -0
- data/spec/unit/parser/resource/param_spec.rb +1 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +9 -9
- data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_containers_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +40 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
- data/spec/unit/provider/selmodule_spec.rb +6 -0
- data/spec/unit/provider/service/init_spec.rb +1 -1
- data/spec/unit/provider/service/smf_spec.rb +2 -0
- data/spec/unit/provider/service/systemd_spec.rb +14 -0
- data/spec/unit/resource/catalog_spec.rb +12 -2
- data/spec/unit/settings/config_file_spec.rb +1 -1
- data/spec/unit/transaction/persistence_spec.rb +42 -0
- data/spec/unit/transaction/report_spec.rb +19 -4
- data/spec/unit/transaction_spec.rb +27 -0
- data/spec/unit/type/schedule_spec.rb +14 -0
- data/spec/unit/type_spec.rb +3 -3
- data/spec/unit/util/errors_spec.rb +1 -1
- data/spec/unit/util/http_proxy_spec.rb +37 -0
- data/spec/unit/util/log_spec.rb +3 -3
- data/spec/unit/util/logging_spec.rb +7 -7
- data/spec/unit/util/monkey_patches_spec.rb +6 -2
- metadata +3435 -3416
- checksums.yaml +0 -7
- data/spec/unit/gettext_config_spec.rb +0 -57
@@ -198,16 +198,5 @@ describe Puppet::Indirector::JSON do
|
|
198
198
|
create_file('foo.json~', 'foo-backup')
|
199
199
|
expect(subject.search(request('f*')).map(&:value)).to eq(['foo-json'])
|
200
200
|
end
|
201
|
-
|
202
|
-
it "raises if the content contains binary" do
|
203
|
-
binary = "\xC0\xFF".force_encoding(Encoding::BINARY)
|
204
|
-
|
205
|
-
File.binwrite(subject.path('foo.json', ''), "foo-json")
|
206
|
-
File.binwrite(subject.path("foo#{binary}.bin", ''), "foo-binary")
|
207
|
-
|
208
|
-
expect {
|
209
|
-
subject.search(request('*'))
|
210
|
-
}.to raise_error Puppet::Error, /Could not parse JSON data/
|
211
|
-
end
|
212
201
|
end
|
213
202
|
end
|
@@ -56,7 +56,7 @@ describe Puppet::Node::Exec do
|
|
56
56
|
it "should set the resulting parameters as the node parameters" do
|
57
57
|
@result[:parameters] = {"a" => "b", "c" => "d"}
|
58
58
|
@searcher.find(request)
|
59
|
-
expect(@node.parameters).to eq({"a" => "b", "c" => "d"})
|
59
|
+
expect(@node.parameters).to eq({"a" => "b", "c" => "d", "environment" => "*root*"})
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should set the resulting classes as the node classes" do
|
@@ -332,7 +332,7 @@ describe "Puppet::InfoService" do
|
|
332
332
|
expect(result).to eq({
|
333
333
|
"production"=>{
|
334
334
|
"#{code_dir}/borked.pp"=>
|
335
|
-
{:error=>"Syntax error at '+'
|
335
|
+
{:error=>"Syntax error at '+' (file: #{code_dir}/borked.pp, line: 1, column: 30)",
|
336
336
|
},
|
337
337
|
} # end production env
|
338
338
|
})
|
data/spec/unit/interface_spec.rb
CHANGED
@@ -126,6 +126,18 @@ describe Puppet::Interface do
|
|
126
126
|
expect { subject[:foo, '0.0.1'] }.to raise_error Puppet::Error
|
127
127
|
end
|
128
128
|
|
129
|
+
describe 'when raising NoMethodErrors' do
|
130
|
+
subject { described_class.new(:foo, '1.0.0') }
|
131
|
+
|
132
|
+
it 'includes the face name in the error message' do
|
133
|
+
expect { subject.boombaz }.to raise_error(NoMethodError, /#{subject.name}/)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'includes the face version in the error message' do
|
137
|
+
expect { subject.boombaz }.to raise_error(NoMethodError, /#{subject.version}/)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
129
141
|
it_should_behave_like "things that declare options" do
|
130
142
|
def add_options_to(&block)
|
131
143
|
subject.new(:with_options, '0.0.1', &block)
|
data/spec/unit/module_spec.rb
CHANGED
@@ -227,8 +227,6 @@ describe Puppet::Module do
|
|
227
227
|
tasks_dir = "#{mod_dir}/tasks"
|
228
228
|
locale_dir = "#{mod_dir}/locales"
|
229
229
|
Puppet::FileSystem.stubs(:exist?).with(metadata_file).returns true
|
230
|
-
# Skip checking for translation config file
|
231
|
-
Puppet::FileSystem.stubs(:exist?).with(locale_dir).returns false
|
232
230
|
end
|
233
231
|
mod = PuppetSpec::Modules.create(
|
234
232
|
'test_gte_req',
|
@@ -445,31 +443,6 @@ describe Puppet::Module do
|
|
445
443
|
end
|
446
444
|
end
|
447
445
|
|
448
|
-
|
449
|
-
describe "initialize_i18n" do
|
450
|
-
|
451
|
-
let(:modpath) { tmpdir('modpath') }
|
452
|
-
let(:modname) { 'i18n' }
|
453
|
-
let(:modroot) { "#{modpath}/#{modname}/" }
|
454
|
-
let(:locale_dir) { "#{modroot}locales" }
|
455
|
-
let(:mod_obj) { PuppetSpec::Modules.create( modname, modpath, :metadata => { :dependencies => [] }, :env => env ) }
|
456
|
-
|
457
|
-
it "is expected to initialize an un-initialized module" do
|
458
|
-
expect(Puppet::GettextConfig.translations_loaded?("puppetlabs-#{modname}")).to be false
|
459
|
-
|
460
|
-
FileUtils.mkdir_p(locale_dir)
|
461
|
-
Puppet::FileSystem.stubs(:exist?).with(locale_dir).returns(true)
|
462
|
-
|
463
|
-
mod_obj.initialize_i18n
|
464
|
-
|
465
|
-
expect(Puppet::GettextConfig.translations_loaded?("puppetlabs-#{modname}")).to be true
|
466
|
-
end
|
467
|
-
|
468
|
-
it "is expected return nil if module is intiailized" do
|
469
|
-
expect(mod_obj.initialize_i18n).to be nil
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
446
|
describe "when managing supported platforms" do
|
474
447
|
it "should support specifying a supported platform" do
|
475
448
|
mod.supports "solaris"
|
@@ -612,7 +585,6 @@ describe Puppet::Module do
|
|
612
585
|
|
613
586
|
it "after the module is initialized" do
|
614
587
|
Puppet::FileSystem.expects(:exist?).with(mod_tasks_dir).never
|
615
|
-
Puppet::GettextConfig.expects(:load_translations).returns(false)
|
616
588
|
Puppet::Module::Task.expects(:tasks_in_module).never
|
617
589
|
Puppet::Module.new(mod_name, @modpath, env)
|
618
590
|
end
|
@@ -8,10 +8,17 @@ describe Puppet::ModuleTool::Tar::Mini, :if => (Puppet.features.minitar? and Pup
|
|
8
8
|
let(:destfile) { '/the/dest/file.tar.gz' }
|
9
9
|
let(:minitar) { described_class.new }
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
class MockFileStatEntry
|
12
|
+
def initialize(mode = 0100)
|
13
|
+
@mode = mode
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "unpacks a tar file with correct permissions" do
|
18
|
+
entry = unpacks_the_entry(:file_start, 'thefile')
|
13
19
|
|
14
20
|
minitar.unpack(sourcefile, destdir, 'uid')
|
21
|
+
expect(entry.instance_variable_get(:@mode)).to eq(0755)
|
15
22
|
end
|
16
23
|
|
17
24
|
it "does not allow an absolute path" do
|
@@ -41,20 +48,42 @@ describe Puppet::ModuleTool::Tar::Mini, :if => (Puppet.features.minitar? and Pup
|
|
41
48
|
"Attempt to install file with an invalid path into \"#{File.expand_path('/the/thedir')}\" under \"#{destdir}\"")
|
42
49
|
end
|
43
50
|
|
51
|
+
it "unpacks on Windows" do
|
52
|
+
unpacks_the_entry(:file_start, 'thefile', nil)
|
53
|
+
|
54
|
+
entry = minitar.unpack(sourcefile, destdir, 'uid')
|
55
|
+
# Windows does not use these permissions.
|
56
|
+
expect(entry.instance_variable_get(:@mode)).to eq(nil)
|
57
|
+
end
|
58
|
+
|
44
59
|
it "packs a tar file" do
|
45
60
|
writer = stub('GzipWriter')
|
46
61
|
|
47
62
|
Zlib::GzipWriter.expects(:open).with(destfile).yields(writer)
|
48
|
-
|
63
|
+
stats = {:mode => 0222}
|
64
|
+
Archive::Tar::Minitar.expects(:pack).with(sourcedir, writer).yields(:file_start, 'abc', stats)
|
65
|
+
|
66
|
+
minitar.pack(sourcedir, destfile)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "packs a tar file on Windows" do
|
70
|
+
writer = stub('GzipWriter')
|
71
|
+
|
72
|
+
Zlib::GzipWriter.expects(:open).with(destfile).yields(writer)
|
73
|
+
Archive::Tar::Minitar.expects(:pack).with(sourcedir, writer).
|
74
|
+
yields(:file_start, 'abc', {:entry => MockFileStatEntry.new(nil)})
|
49
75
|
|
50
76
|
minitar.pack(sourcedir, destfile)
|
51
77
|
end
|
52
78
|
|
53
|
-
def unpacks_the_entry(type, name)
|
79
|
+
def unpacks_the_entry(type, name, mode = 0100)
|
54
80
|
reader = stub('GzipReader')
|
55
81
|
|
56
82
|
Zlib::GzipReader.expects(:open).with(sourcefile).yields(reader)
|
57
83
|
minitar.expects(:find_valid_files).with(reader).returns([name])
|
58
|
-
|
84
|
+
entry = MockFileStatEntry.new(mode)
|
85
|
+
Archive::Tar::Minitar.expects(:unpack).with(reader, destdir, [name]).
|
86
|
+
yields(type, name, {:entry => entry})
|
87
|
+
entry
|
59
88
|
end
|
60
89
|
end
|
@@ -94,5 +94,27 @@ describe Puppet::Network::HTTP::Factory do
|
|
94
94
|
expect(conn.read_timeout).to eq(120)
|
95
95
|
end
|
96
96
|
end
|
97
|
+
|
98
|
+
context 'source address' do
|
99
|
+
it 'defaults to system-defined' do
|
100
|
+
skip "Requires Ruby >= 2.0" unless RUBY_VERSION.to_i >= 2
|
101
|
+
conn = create_connection(site)
|
102
|
+
|
103
|
+
expect(conn.local_host).to be(nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'sets the local_host address' do
|
107
|
+
Puppet[:sourceaddress] = "127.0.0.1"
|
108
|
+
if RUBY_VERSION.to_i >= 2
|
109
|
+
conn = create_connection(site)
|
110
|
+
|
111
|
+
expect(conn.local_host).to eq('127.0.0.1')
|
112
|
+
else
|
113
|
+
expect {
|
114
|
+
create_connection(site)
|
115
|
+
}.to raise_error(ArgumentError, "Setting 'sourceaddress' is unsupported by this version of Net::HTTP.")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
97
119
|
end
|
98
120
|
end
|
@@ -14,31 +14,37 @@ describe Puppet::Network::HTTP::WEBrick do
|
|
14
14
|
|
15
15
|
let(:address) { '127.0.0.1' }
|
16
16
|
let(:port) { 31337 }
|
17
|
-
|
18
|
-
let(:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
17
|
+
let(:server) { Puppet::Network::HTTP::WEBrick.new }
|
18
|
+
let(:localcacert) { make_absolute("/ca/crt") }
|
19
|
+
let(:ssl_server_ca_auth) { make_absolute("/ca/ssl_server_auth_file") }
|
20
|
+
let(:key) { stub 'key', :content => "mykey" }
|
21
|
+
let(:cert) { stub 'cert', :content => "mycert" }
|
22
|
+
let(:host) { stub 'host', :key => key, :certificate => cert, :name => "yay", :ssl_store => "mystore" }
|
24
23
|
|
25
24
|
let(:mock_ssl_context) do
|
26
25
|
stub('ssl_context', :ciphers= => nil)
|
27
26
|
end
|
28
27
|
|
28
|
+
let(:socket) { mock('socket') }
|
29
29
|
let(:mock_webrick) do
|
30
|
-
stub('webrick',
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
server = stub('webrick',
|
31
|
+
:[] => {},
|
32
|
+
:listeners => [],
|
33
|
+
:status => :Running,
|
34
|
+
:mount => nil,
|
35
|
+
:shutdown => nil,
|
36
|
+
:ssl_context => mock_ssl_context)
|
37
|
+
server.stubs(:start).yields(socket)
|
38
|
+
IO.stubs(:select).with([socket], nil, nil, anything).returns(true)
|
39
|
+
socket.stubs(:accept)
|
40
|
+
server.stubs(:run).with(socket)
|
41
|
+
server
|
38
42
|
end
|
39
43
|
|
40
44
|
before :each do
|
41
45
|
WEBrick::HTTPServer.stubs(:new).returns(mock_webrick)
|
46
|
+
Puppet::SSL::Certificate.indirection.stubs(:find).with('ca').returns cert
|
47
|
+
Puppet::SSL::Host.stubs(:localhost).returns host
|
42
48
|
end
|
43
49
|
|
44
50
|
describe "when turning on listening" do
|
@@ -88,6 +94,13 @@ describe Puppet::Network::HTTP::WEBrick do
|
|
88
94
|
expect(server).to be_listening
|
89
95
|
end
|
90
96
|
|
97
|
+
it "is passed a yet to be accepted socket" do
|
98
|
+
socket.expects(:accept)
|
99
|
+
|
100
|
+
server.listen(address, port)
|
101
|
+
server.unlisten
|
102
|
+
end
|
103
|
+
|
91
104
|
describe "when the REST protocol is requested" do
|
92
105
|
it "should register the REST handler at /" do
|
93
106
|
# We don't care about the options here.
|
@@ -192,18 +205,6 @@ describe Puppet::Network::HTTP::WEBrick do
|
|
192
205
|
end
|
193
206
|
|
194
207
|
describe "when configuring ssl" do
|
195
|
-
let(:server) { Puppet::Network::HTTP::WEBrick.new }
|
196
|
-
let(:localcacert) { make_absolute("/ca/crt") }
|
197
|
-
let(:ssl_server_ca_auth) { make_absolute("/ca/ssl_server_auth_file") }
|
198
|
-
let(:key) { stub 'key', :content => "mykey" }
|
199
|
-
let(:cert) { stub 'cert', :content => "mycert" }
|
200
|
-
let(:host) { stub 'host', :key => key, :certificate => cert, :name => "yay", :ssl_store => "mystore" }
|
201
|
-
|
202
|
-
before :each do
|
203
|
-
Puppet::SSL::Certificate.indirection.stubs(:find).with('ca').returns cert
|
204
|
-
Puppet::SSL::Host.stubs(:localhost).returns host
|
205
|
-
end
|
206
|
-
|
207
208
|
it "should use the key from the localhost SSL::Host instance" do
|
208
209
|
Puppet::SSL::Host.expects(:localhost).returns host
|
209
210
|
host.expects(:key).returns key
|
@@ -236,8 +237,8 @@ describe Puppet::Network::HTTP::WEBrick do
|
|
236
237
|
expect(server.setup_ssl[:SSLCACertificateFile]).to eq(ssl_server_ca_auth)
|
237
238
|
end
|
238
239
|
|
239
|
-
it "should start ssl immediately" do
|
240
|
-
expect(server.setup_ssl[:SSLStartImmediately]).to
|
240
|
+
it "should not start ssl immediately" do
|
241
|
+
expect(server.setup_ssl[:SSLStartImmediately]).to eq(false)
|
241
242
|
end
|
242
243
|
|
243
244
|
it "should enable ssl" do
|
@@ -492,4 +492,20 @@ describe Puppet::Node::Environment do
|
|
492
492
|
end
|
493
493
|
end
|
494
494
|
|
495
|
+
describe "managing module translations" do
|
496
|
+
it "creates a new text domain the first time we try to use the text domain" do
|
497
|
+
Puppet::GettextConfig.expects(:reset_text_domain).with(env.name)
|
498
|
+
Puppet::ModuleTranslations.expects(:load_from_modulepath)
|
499
|
+
|
500
|
+
env.use_text_domain
|
501
|
+
end
|
502
|
+
|
503
|
+
it "uses the existing text domain once it has been created" do
|
504
|
+
env.use_text_domain
|
505
|
+
|
506
|
+
Puppet::GettextConfig.expects(:use_text_domain).with(env.name)
|
507
|
+
env.use_text_domain
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
495
511
|
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'matchers/json'
|
4
|
+
require 'puppet_spec/files'
|
4
5
|
|
5
6
|
describe Puppet::Node do
|
6
7
|
include JSONMatchers
|
8
|
+
include PuppetSpec::Files
|
7
9
|
|
8
10
|
let(:environment) { Puppet::Node::Environment.create(:bar, []) }
|
9
11
|
let(:env_loader) { Puppet::Environments::Static.new(environment) }
|
@@ -115,8 +117,9 @@ describe Puppet::Node do
|
|
115
117
|
end
|
116
118
|
|
117
119
|
it "limits the serialization of environment to be just the name" do
|
118
|
-
|
119
|
-
|
120
|
+
yaml_file = file_containing("temp_yaml", @node.to_yaml)
|
121
|
+
node_yaml = Puppet::Util::Yaml.load_file(yaml_file, false, true)
|
122
|
+
expect(node_yaml['environment']).to eq('production')
|
120
123
|
end
|
121
124
|
end
|
122
125
|
|
@@ -155,6 +158,13 @@ describe Puppet::Node do
|
|
155
158
|
expect(@node).to set_json_attribute('parameters').to({"a" => "b", "c" => "d"})
|
156
159
|
end
|
157
160
|
|
161
|
+
it "does not include the environment parameter in the json" do
|
162
|
+
@node.parameters = {"a" => "b", "c" => "d"}
|
163
|
+
@node.environment = environment
|
164
|
+
expect(@node.parameters).to eq({"a"=>"b", "c"=>"d", "environment"=>"bar"})
|
165
|
+
expect(@node).to set_json_attribute('parameters').to({"a" => "b", "c" => "d"})
|
166
|
+
end
|
167
|
+
|
158
168
|
it "does not include the parameters if there are none" do
|
159
169
|
expect(@node).to_not set_json_attribute('parameters')
|
160
170
|
end
|
@@ -186,12 +196,14 @@ describe Puppet::Node do
|
|
186
196
|
|
187
197
|
it "includes parameters if set" do
|
188
198
|
@node.parameters = {"a" => "b", "c" => "d"}
|
189
|
-
expect(Puppet::Node).to read_json_attribute('parameters').from(@node.to_json).as({"a" => "b", "c" => "d"})
|
199
|
+
expect(Puppet::Node).to read_json_attribute('parameters').from(@node.to_json).as({"a" => "b", "c" => "d", "environment" => "production"})
|
190
200
|
end
|
191
201
|
|
192
202
|
it "deserializes environment to environment_name as a symbol" do
|
193
|
-
|
194
|
-
|
203
|
+
Puppet.override(:environments => env_loader) do
|
204
|
+
@node.environment = environment
|
205
|
+
expect(Puppet::Node).to read_json_attribute('environment_name').from(@node.to_json).as(:bar)
|
206
|
+
end
|
195
207
|
end
|
196
208
|
end
|
197
209
|
end
|
@@ -291,7 +303,10 @@ describe Puppet::Node, "when merging facts" do
|
|
291
303
|
|
292
304
|
context "with an env loader" do
|
293
305
|
let(:environment) { Puppet::Node::Environment.create(:one, []) }
|
294
|
-
let(:
|
306
|
+
let(:environment_two) { Puppet::Node::Environment.create(:two, []) }
|
307
|
+
let(:environment_three) { Puppet::Node::Environment.create(:three, []) }
|
308
|
+
let(:environment_prod) { Puppet::Node::Environment.create(:production, []) }
|
309
|
+
let(:env_loader) { Puppet::Environments::Static.new(environment, environment_two, environment_three, environment_prod) }
|
295
310
|
|
296
311
|
around do |example|
|
297
312
|
Puppet.override(:environments => env_loader) do
|
@@ -299,18 +314,89 @@ describe Puppet::Node, "when merging facts" do
|
|
299
314
|
end
|
300
315
|
end
|
301
316
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
317
|
+
context "when a node is initialized from a data hash" do
|
318
|
+
context "when a node is initialzed with an environment" do
|
319
|
+
it "uses 'environment' when provided" do
|
320
|
+
my_node = Puppet::Node.from_data_hash("environment" => "one", "name" => "my_node")
|
321
|
+
expect(my_node.environment.name).to eq(:one)
|
322
|
+
end
|
323
|
+
|
324
|
+
it "uses the environment parameter when provided" do
|
325
|
+
my_node = Puppet::Node.from_data_hash("parameters" => {"environment" => "one"}, "name" => "my_node")
|
326
|
+
expect(my_node.environment.name).to eq(:one)
|
327
|
+
end
|
328
|
+
|
329
|
+
it "uses the environment when also given an environment parameter" do
|
330
|
+
my_node = Puppet::Node.from_data_hash("parameters" => {"environment" => "one"}, "name" => "my_node", "environment" => "two")
|
331
|
+
expect(my_node.environment.name).to eq(:two)
|
332
|
+
end
|
333
|
+
|
334
|
+
it "uses 'environment' when an environment fact has been merged" do
|
335
|
+
my_node = Puppet::Node.from_data_hash("environment" => "one", "name" => "my_node")
|
336
|
+
my_node.fact_merge Puppet::Node::Facts.new "my_node", "environment" => "two"
|
337
|
+
expect(my_node.environment.name).to eq(:one)
|
338
|
+
end
|
339
|
+
|
340
|
+
it "uses an environment parameter when an environment fact has been merged" do
|
341
|
+
my_node = Puppet::Node.from_data_hash("parameters" => {"environment" => "one"}, "name" => "my_node")
|
342
|
+
my_node.fact_merge Puppet::Node::Facts.new "my_node", "environment" => "two"
|
343
|
+
expect(my_node.environment.name).to eq(:one)
|
344
|
+
end
|
345
|
+
|
346
|
+
it "uses an environment when an environment parameter has been given and an environment fact has been merged" do
|
347
|
+
my_node = Puppet::Node.from_data_hash("parameters" => {"environment" => "two"}, "name" => "my_node", "environment" => "one")
|
348
|
+
my_node.fact_merge Puppet::Node::Facts.new "my_node", "environment" => "three"
|
349
|
+
expect(my_node.environment.name).to eq(:one)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
context "when a node is initialized without an environment" do
|
354
|
+
it "should use the server's default environment" do
|
355
|
+
my_node = Puppet::Node.from_data_hash("name" => "my_node")
|
356
|
+
expect(my_node.environment.name).to eq(:production)
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should use the server's default when an environment fact has been merged" do
|
360
|
+
my_node = Puppet::Node.from_data_hash("name" => "my_node")
|
361
|
+
my_node.fact_merge Puppet::Node::Facts.new "my_node", "environment" => "two"
|
362
|
+
expect(my_node.environment.name).to eq(:production)
|
363
|
+
end
|
364
|
+
end
|
307
365
|
end
|
308
366
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
367
|
+
context "when a node is initialized from new" do
|
368
|
+
|
369
|
+
context "when a node is initialzed with an environment" do
|
370
|
+
|
371
|
+
it "adds the environment to the list of parameters" do
|
372
|
+
Puppet[:environment] = "one"
|
373
|
+
@node = Puppet::Node.new("testnode", :environment => "one")
|
374
|
+
@node.merge "two" => "three"
|
375
|
+
expect(@node.parameters["environment"]).to eq("one")
|
376
|
+
end
|
377
|
+
|
378
|
+
it "when merging, syncs the environment parameter to a node's existing environment" do
|
379
|
+
@node = Puppet::Node.new("testnode", :environment => "one")
|
380
|
+
@node.merge "environment" => "two"
|
381
|
+
expect(@node.parameters["environment"]).to eq("one")
|
382
|
+
end
|
383
|
+
|
384
|
+
it "merging facts does not override that environment" do
|
385
|
+
@node = Puppet::Node.new("testnode", :environment => "one")
|
386
|
+
@node.fact_merge Puppet::Node::Facts.new "testnode", "environment" => "two"
|
387
|
+
expect(@node.environment.name.to_s).to eq("one")
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
context "when a node is initialized without an environment" do
|
392
|
+
|
393
|
+
it "it perfers an environment name to an environment fact" do
|
394
|
+
@node = Puppet::Node.new("testnode")
|
395
|
+
@node.environment_name = "one"
|
396
|
+
@node.fact_merge Puppet::Node::Facts.new "testnode", "environment" => "two"
|
397
|
+
expect(@node.environment.name.to_s).to eq("one")
|
398
|
+
end
|
399
|
+
end
|
314
400
|
end
|
315
401
|
end
|
316
402
|
end
|