puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32
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 +5 -0
- data/Gemfile +17 -9
- data/README.md +1 -0
- data/conf/fileserver.conf +4 -3
- data/ext/README.environment +8 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/control +2 -2
- data/ext/debian/puppet-common.dirs +4 -0
- data/ext/debian/rules +4 -0
- data/ext/emacs/puppet-mode-init.el +1 -1
- data/ext/emacs/puppet-mode.el +36 -17
- data/ext/redhat/client.init +3 -3
- data/ext/redhat/puppet.spec.erb +9 -0
- data/ext/systemd/puppet.service +3 -4
- data/ext/systemd/puppetmaster.service +1 -3
- data/install.rb +1 -1
- data/lib/puppet.rb +2 -1
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application.rb +17 -17
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/configurer.rb +4 -1
- data/lib/puppet/configurer/downloader.rb +13 -12
- data/lib/puppet/configurer/plugin_handler.rb +3 -3
- data/lib/puppet/context.rb +6 -1
- data/lib/puppet/defaults.rb +82 -12
- data/lib/puppet/environments.rb +169 -13
- data/lib/puppet/external/nagios/grammar.ry +2 -0
- data/lib/puppet/external/nagios/parser.rb +28 -19
- data/lib/puppet/face/config.rb +19 -6
- data/lib/puppet/face/module/generate.rb +209 -7
- data/lib/puppet/face/module/install.rb +17 -16
- data/lib/puppet/face/module/list.rb +83 -82
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +10 -9
- data/lib/puppet/face/parser.rb +3 -2
- data/lib/puppet/face/plugin.rb +8 -4
- data/lib/puppet/file_bucket/dipper.rb +6 -3
- data/lib/puppet/file_bucket/file.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +1 -1
- data/lib/puppet/file_system/memory_file.rb +27 -1
- data/lib/puppet/file_system/memory_impl.rb +15 -1
- data/lib/puppet/forge.rb +148 -52
- data/lib/puppet/forge/cache.rb +5 -1
- data/lib/puppet/forge/errors.rb +10 -0
- data/lib/puppet/forge/repository.rb +61 -26
- data/lib/puppet/functions.rb +548 -0
- data/lib/puppet/functions/assert_type.rb +42 -0
- data/lib/puppet/functions/import.rb +7 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/rest.rb +18 -0
- data/lib/puppet/loaders.rb +20 -0
- data/lib/puppet/module.rb +2 -2
- data/lib/puppet/module_tool.rb +40 -14
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/module_tool/applications/application.rb +35 -26
- data/lib/puppet/module_tool/applications/builder.rb +16 -6
- data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
- data/lib/puppet/module_tool/applications/installer.rb +196 -35
- data/lib/puppet/module_tool/applications/searcher.rb +1 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
- data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
- data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
- data/lib/puppet/module_tool/checksums.rb +5 -8
- data/lib/puppet/module_tool/errors/installer.rb +12 -44
- data/lib/puppet/module_tool/errors/shared.rb +84 -11
- data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
- data/lib/puppet/module_tool/install_directory.rb +7 -6
- data/lib/puppet/module_tool/installed_modules.rb +92 -0
- data/lib/puppet/module_tool/local_tarball.rb +91 -0
- data/lib/puppet/module_tool/metadata.rb +119 -115
- data/lib/puppet/module_tool/modulefile.rb +9 -9
- data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
- data/lib/puppet/module_tool/tar.rb +3 -7
- data/lib/puppet/module_tool/tar/gnu.rb +21 -9
- data/lib/puppet/module_tool/tar/mini.rb +2 -8
- data/lib/puppet/network/http/api/v1.rb +1 -1
- data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
- data/lib/puppet/network/http/issues.rb +1 -0
- data/lib/puppet/network/http_pool.rb +15 -6
- data/lib/puppet/node/environment.rb +91 -20
- data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
- data/lib/puppet/parser/collector.rb +1 -1
- data/lib/puppet/parser/compiler.rb +50 -7
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/pops.rb +22 -1
- data/lib/puppet/pops/adapters.rb +8 -1
- data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
- data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
- data/lib/puppet/pops/binder/producers.rb +2 -2
- data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
- data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
- data/lib/puppet/pops/evaluator/closure.rb +57 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
- data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
- data/lib/puppet/pops/functions/dispatch.rb +71 -0
- data/lib/puppet/pops/functions/dispatcher.rb +237 -0
- data/lib/puppet/pops/functions/function.rb +77 -0
- data/lib/puppet/pops/issues.rb +12 -0
- data/lib/puppet/pops/loader/base_loader.rb +102 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
- data/lib/puppet/pops/loader/gem_support.rb +49 -0
- data/lib/puppet/pops/loader/loader.rb +180 -0
- data/lib/puppet/pops/loader/loader_paths.rb +137 -0
- data/lib/puppet/pops/loader/module_loaders.rb +242 -0
- data/lib/puppet/pops/loader/null_loader.rb +44 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
- data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
- data/lib/puppet/pops/loader/static_loader.rb +69 -0
- data/lib/puppet/pops/loader/uri_helper.rb +22 -0
- data/lib/puppet/pops/loaders.rb +240 -0
- data/lib/puppet/pops/model/factory.rb +13 -5
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
- data/lib/puppet/pops/parser/egrammar.ra +31 -18
- data/lib/puppet/pops/parser/eparser.rb +1137 -1106
- data/lib/puppet/pops/parser/lexer2.rb +17 -16
- data/lib/puppet/pops/semantic_error.rb +17 -0
- data/lib/puppet/pops/types/type_calculator.rb +150 -15
- data/lib/puppet/pops/types/type_factory.rb +69 -0
- data/lib/puppet/pops/types/type_parser.rb +9 -0
- data/lib/puppet/pops/types/types.rb +65 -4
- data/lib/puppet/pops/validation/checker4_0.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/cron/crontab.rb +13 -2
- data/lib/puppet/provider/package.rb +24 -0
- data/lib/puppet/provider/package/apt.rb +6 -1
- data/lib/puppet/provider/package/gem.rb +8 -2
- data/lib/puppet/provider/package/msi.rb +0 -15
- data/lib/puppet/provider/package/openbsd.rb +0 -24
- data/lib/puppet/provider/package/rpm.rb +3 -29
- data/lib/puppet/provider/package/windows.rb +0 -15
- data/lib/puppet/provider/package/yum.rb +101 -24
- data/lib/puppet/provider/package/yumhelper.py +31 -1
- data/lib/puppet/provider/package/zypper.rb +10 -28
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +3 -0
- data/lib/puppet/provider/service/openbsd.rb +318 -0
- data/lib/puppet/provider/service/redhat.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
- data/lib/puppet/resource.rb +13 -9
- data/lib/puppet/resource/catalog.rb +12 -6
- data/lib/puppet/resource/type_collection.rb +3 -3
- data/lib/puppet/settings.rb +57 -36
- data/lib/puppet/settings/config_file.rb +5 -0
- data/lib/puppet/settings/environment_conf.rb +147 -0
- data/lib/puppet/settings/ttl_setting.rb +48 -0
- data/lib/puppet/ssl/certificate_authority.rb +2 -3
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/status.rb +1 -1
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/type/augeas.rb +13 -1
- data/lib/puppet/type/cron.rb +32 -18
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/file/checksum.rb +15 -5
- data/lib/puppet/type/file/content.rb +3 -1
- data/lib/puppet/type/file/source.rb +5 -5
- data/lib/puppet/type/package.rb +12 -17
- data/lib/puppet/type/resources.rb +3 -1
- data/lib/puppet/type/scheduled_task.rb +4 -5
- data/lib/puppet/type/service.rb +12 -2
- data/lib/puppet/type/user.rb +106 -0
- data/lib/puppet/type/yumrepo.rb +9 -1
- data/lib/puppet/util/checksums.rb +60 -1
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/execution.rb +20 -16
- data/lib/puppet/util/feature.rb +3 -0
- data/lib/puppet/util/logging.rb +19 -12
- data/lib/puppet/util/rubygems.rb +10 -0
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/windows/security.rb +5 -3
- data/lib/puppet/vendor/load_semantic.rb +1 -0
- data/lib/puppet/vendor/require_vendored.rb +2 -0
- data/lib/puppet/vendor/semantic/Gemfile +20 -0
- data/lib/puppet/vendor/semantic/Rakefile +69 -0
- data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/java.tgz +0 -0
- data/spec/fixtures/stdlib.tgz +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
- data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
- data/spec/fixtures/unit/type/user/authorized_keys +5 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/configurer_spec.rb +2 -2
- data/spec/integration/faces/plugin_spec.rb +62 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/node/environment_spec.rb +2 -2
- data/spec/integration/parser/future_compiler_spec.rb +96 -142
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
- data/spec/integration/provider/cron/crontab_spec.rb +35 -0
- data/spec/integration/type/file_spec.rb +74 -72
- data/spec/integration/util/windows/security_spec.rb +17 -0
- data/spec/lib/matchers/resource.rb +45 -13
- data/spec/lib/puppet_spec/files.rb +18 -0
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
- data/spec/shared_contexts/checksums.rb +55 -0
- data/spec/unit/application/apply_spec.rb +10 -7
- data/spec/unit/application/doc_spec.rb +17 -10
- data/spec/unit/application/indirection_base_spec.rb +18 -10
- data/spec/unit/application/inspect_spec.rb +22 -20
- data/spec/unit/configurer/downloader_spec.rb +7 -6
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/context_spec.rb +23 -0
- data/spec/unit/environments_spec.rb +274 -16
- data/spec/unit/face/config_spec.rb +111 -11
- data/spec/unit/face/module/install_spec.rb +14 -85
- data/spec/unit/face/module/list_spec.rb +108 -62
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/module/uninstall_spec.rb +21 -42
- data/spec/unit/face/parser_spec.rb +5 -2
- data/spec/unit/file_bucket/dipper_spec.rb +92 -86
- data/spec/unit/file_bucket/file_spec.rb +23 -75
- data/spec/unit/file_serving/metadata_spec.rb +74 -74
- data/spec/unit/forge/module_release_spec.rb +131 -0
- data/spec/unit/forge/repository_spec.rb +21 -20
- data/spec/unit/forge_spec.rb +99 -23
- data/spec/unit/functions/assert_type_spec.rb +59 -0
- data/spec/unit/functions4_spec.rb +671 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
- data/spec/unit/indirector/facts/facter_spec.rb +9 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
- data/spec/unit/indirector/rest_spec.rb +8 -0
- data/spec/unit/interface/face_collection_spec.rb +35 -23
- data/spec/unit/module_spec.rb +20 -8
- data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
- data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
- data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
- data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
- data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
- data/spec/unit/module_tool/metadata_spec.rb +223 -14
- data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/module_tool/tar_spec.rb +4 -18
- data/spec/unit/module_tool_spec.rb +123 -27
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http_pool_spec.rb +21 -0
- data/spec/unit/network/rights_spec.rb +10 -8
- data/spec/unit/node/environment_spec.rb +27 -2
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/generate_spec.rb +4 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
- data/spec/unit/pops/types/type_factory_spec.rb +101 -0
- data/spec/unit/pops/types/type_parser_spec.rb +22 -0
- data/spec/unit/property/list_spec.rb +9 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
- data/spec/unit/provider/cron/crontab_spec.rb +1 -0
- data/spec/unit/provider/cron/parsed_spec.rb +15 -0
- data/spec/unit/provider/naginator_spec.rb +14 -0
- data/spec/unit/provider/package/apt_spec.rb +78 -64
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/rpm_spec.rb +6 -6
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +199 -104
- data/spec/unit/provider/package/zypper_spec.rb +41 -15
- data/spec/unit/provider/service/openbsd_spec.rb +129 -22
- data/spec/unit/provider/service/redhat_spec.rb +18 -4
- data/spec/unit/provider/service/systemd_spec.rb +5 -9
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
- data/spec/unit/resource/catalog_spec.rb +20 -104
- data/spec/unit/resource/type_collection_spec.rb +10 -9
- data/spec/unit/settings/config_file_spec.rb +29 -6
- data/spec/unit/settings/environment_conf_spec.rb +51 -0
- data/spec/unit/settings_spec.rb +97 -12
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
- data/spec/unit/type/augeas_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +6 -7
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/content_spec.rb +277 -207
- data/spec/unit/type/file_spec.rb +9 -7
- data/spec/unit/type/user_spec.rb +106 -18
- data/spec/unit/type/yumrepo_spec.rb +8 -0
- data/spec/unit/util/checksums_spec.rb +12 -5
- data/spec/unit/util/diff_spec.rb +8 -0
- data/spec/unit/util/execution_spec.rb +4 -4
- data/spec/unit/util/feature_spec.rb +2 -0
- data/spec/unit/util/logging_spec.rb +14 -4
- data/spec/unit/util/rdoc/parser_spec.rb +5 -4
- data/spec/unit/util/rubygems_spec.rb +14 -0
- data/tasks/parallel.rake +2 -2
- metadata +154 -21
- checksums.yaml +0 -7
- data/lib/puppet/module_tool/applications/generator.rb +0 -142
- data/lib/puppet/module_tool/skeleton.rb +0 -37
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
- data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
- data/lib/puppet/module_tool/tar/solaris.rb +0 -5
- data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
- data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -30,6 +30,12 @@ describe checksum do
|
|
30
30
|
@checksum.sum("foobar").should == "{md5}#{sum}"
|
31
31
|
end
|
32
32
|
|
33
|
+
it "when using digest_algorithm 'sha256' should return the summed contents with a checksum label" do
|
34
|
+
sum = Digest::SHA256.hexdigest("foobar")
|
35
|
+
@resource[:checksum] = :sha256
|
36
|
+
@checksum.sum("foobar").should == "{sha256}#{sum}"
|
37
|
+
end
|
38
|
+
|
33
39
|
it "should use :md5 as its default type" do
|
34
40
|
@checksum.default.should == :md5
|
35
41
|
end
|
@@ -4,211 +4,220 @@ require 'puppet/network/http_pool'
|
|
4
4
|
|
5
5
|
require 'puppet/network/resolver'
|
6
6
|
|
7
|
-
|
8
|
-
describe content do
|
7
|
+
describe Puppet::Type.type(:file).attrclass(:content), :uses_checksums => true do
|
9
8
|
include PuppetSpec::Files
|
9
|
+
|
10
|
+
let(:filename) { tmpfile('testfile') }
|
11
|
+
|
12
|
+
let(:catalog) { Puppet::Resource::Catalog.new }
|
13
|
+
|
14
|
+
let(:resource) { Puppet::Type.type(:file).new :path => filename, :catalog => catalog }
|
15
|
+
|
10
16
|
before do
|
11
|
-
|
12
|
-
|
13
|
-
@resource = Puppet::Type.type(:file).new :path => @filename, :catalog => @catalog
|
14
|
-
File.open(@filename, 'w') {|f| f.write "initial file content"}
|
15
|
-
content.stubs(:standalone?).returns(false)
|
17
|
+
File.open(filename, 'w') {|f| f.write "initial file content"}
|
18
|
+
described_class.stubs(:standalone?).returns(false)
|
16
19
|
end
|
17
20
|
|
18
21
|
describe "when determining the checksum type" do
|
22
|
+
let(:content) { described_class.new(:resource => resource) }
|
23
|
+
|
19
24
|
it "should use the type specified in the source checksum if a source is set" do
|
20
|
-
|
21
|
-
|
25
|
+
resource[:source] = File.expand_path("/foo")
|
26
|
+
resource.parameter(:source).expects(:checksum).returns "{md5lite}eh"
|
22
27
|
|
23
|
-
|
24
|
-
@content.checksum_type.should == :md5lite
|
28
|
+
content.checksum_type.should == :md5lite
|
25
29
|
end
|
26
30
|
|
27
31
|
it "should use the type specified by the checksum parameter if no source is set" do
|
28
|
-
|
32
|
+
resource[:checksum] = :md5lite
|
29
33
|
|
30
|
-
|
31
|
-
|
34
|
+
content.checksum_type.should == :md5lite
|
35
|
+
end
|
36
|
+
|
37
|
+
with_digest_algorithms do
|
38
|
+
it "should use the type specified by digest_algorithm by default" do
|
39
|
+
content.checksum_type.should == digest_algorithm.intern
|
40
|
+
end
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
35
44
|
describe "when determining the actual content to write" do
|
45
|
+
let(:content) { described_class.new(:resource => resource) }
|
46
|
+
|
36
47
|
it "should use the set content if available" do
|
37
|
-
|
38
|
-
|
39
|
-
@content.actual_content.should == "ehness"
|
48
|
+
content.should = "ehness"
|
49
|
+
content.actual_content.should == "ehness"
|
40
50
|
end
|
41
51
|
|
42
52
|
it "should not use the content from the source if the source is set" do
|
43
53
|
source = mock 'source'
|
44
54
|
|
45
|
-
|
55
|
+
resource.expects(:parameter).never.with(:source).returns source
|
46
56
|
|
47
|
-
|
48
|
-
@content.actual_content.should be_nil
|
57
|
+
content.actual_content.should be_nil
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
52
61
|
describe "when setting the desired content" do
|
62
|
+
let(:content) { described_class.new(:resource => resource) }
|
63
|
+
|
53
64
|
it "should make the actual content available via an attribute" do
|
54
|
-
|
55
|
-
|
56
|
-
@content.should = "this is some content"
|
65
|
+
content.stubs(:checksum_type).returns "md5"
|
66
|
+
content.should = "this is some content"
|
57
67
|
|
58
|
-
|
68
|
+
content.actual_content.should == "this is some content"
|
59
69
|
end
|
60
70
|
|
61
|
-
|
62
|
-
|
63
|
-
|
71
|
+
with_digest_algorithms do
|
72
|
+
it "should store the checksum as the desired content" do
|
73
|
+
d = digest("this is some content")
|
64
74
|
|
65
|
-
|
66
|
-
|
75
|
+
content.stubs(:checksum_type).returns digest_algorithm
|
76
|
+
content.should = "this is some content"
|
67
77
|
|
68
|
-
|
69
|
-
|
78
|
+
content.should.must == "{#{digest_algorithm}}#{d}"
|
79
|
+
end
|
70
80
|
|
71
|
-
|
72
|
-
|
73
|
-
@content.should = :absent
|
81
|
+
it "should not checksum 'absent'" do
|
82
|
+
content.should = :absent
|
74
83
|
|
75
|
-
|
76
|
-
|
84
|
+
content.should.must == :absent
|
85
|
+
end
|
77
86
|
|
78
|
-
|
79
|
-
|
80
|
-
digest = Digest::MD5.hexdigest("this is some content")
|
87
|
+
it "should accept a checksum as the desired content" do
|
88
|
+
d = digest("this is some content")
|
81
89
|
|
82
|
-
|
83
|
-
|
90
|
+
string = "{#{digest_algorithm}}#{d}"
|
91
|
+
content.should = string
|
84
92
|
|
85
|
-
|
93
|
+
content.should.must == string
|
94
|
+
end
|
86
95
|
end
|
87
96
|
|
88
97
|
it "should convert the value to ASCII-8BIT", :if => "".respond_to?(:encode) do
|
89
|
-
|
90
|
-
@content.should= "Let's make a \u{2603}"
|
98
|
+
content.should= "Let's make a \u{2603}"
|
91
99
|
|
92
|
-
|
100
|
+
content.actual_content.should == "Let's make a \xE2\x98\x83".force_encoding(Encoding::ASCII_8BIT)
|
93
101
|
end
|
94
102
|
end
|
95
103
|
|
96
104
|
describe "when retrieving the current content" do
|
105
|
+
let(:content) { described_class.new(:resource => resource) }
|
106
|
+
|
97
107
|
it "should return :absent if the file does not exist" do
|
98
|
-
|
99
|
-
@resource.expects(:stat).returns nil
|
108
|
+
resource.expects(:stat).returns nil
|
100
109
|
|
101
|
-
|
110
|
+
content.retrieve.should == :absent
|
102
111
|
end
|
103
112
|
|
104
113
|
it "should not manage content on directories" do
|
105
|
-
@content = content.new(:resource => @resource)
|
106
|
-
|
107
114
|
stat = mock 'stat', :ftype => "directory"
|
108
|
-
|
115
|
+
resource.expects(:stat).returns stat
|
109
116
|
|
110
|
-
|
117
|
+
content.retrieve.should be_nil
|
111
118
|
end
|
112
119
|
|
113
120
|
it "should not manage content on links" do
|
114
|
-
@content = content.new(:resource => @resource)
|
115
|
-
|
116
121
|
stat = mock 'stat', :ftype => "link"
|
117
|
-
|
122
|
+
resource.expects(:stat).returns stat
|
118
123
|
|
119
|
-
|
124
|
+
content.retrieve.should be_nil
|
120
125
|
end
|
121
126
|
|
122
127
|
it "should always return the checksum as a string" do
|
123
|
-
|
124
|
-
@resource[:checksum] = :mtime
|
128
|
+
resource[:checksum] = :mtime
|
125
129
|
|
126
130
|
stat = mock 'stat', :ftype => "file"
|
127
|
-
|
131
|
+
resource.expects(:stat).returns stat
|
128
132
|
|
129
133
|
time = Time.now
|
130
|
-
|
134
|
+
resource.parameter(:checksum).expects(:mtime_file).with(resource[:path]).returns time
|
131
135
|
|
132
|
-
|
136
|
+
content.retrieve.should == "{mtime}#{time}"
|
133
137
|
end
|
134
138
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
139
|
+
with_digest_algorithms do
|
140
|
+
it "should return the checksum of the file if it exists and is a normal file" do
|
141
|
+
stat = mock 'stat', :ftype => "file"
|
142
|
+
resource.expects(:stat).returns stat
|
143
|
+
resource.parameter(:checksum).expects("#{digest_algorithm}_file".intern).with(resource[:path]).returns "mysum"
|
140
144
|
|
141
|
-
|
145
|
+
content.retrieve.should == "{#{digest_algorithm}}mysum"
|
146
|
+
end
|
142
147
|
end
|
143
148
|
end
|
144
149
|
|
145
150
|
describe "when testing whether the content is in sync" do
|
151
|
+
let(:content) { described_class.new(:resource => resource) }
|
152
|
+
|
146
153
|
before do
|
147
|
-
|
148
|
-
@content = content.new(:resource => @resource)
|
154
|
+
resource[:ensure] = :file
|
149
155
|
end
|
150
156
|
|
151
157
|
it "should return true if the resource shouldn't be a regular file" do
|
152
|
-
|
153
|
-
|
154
|
-
|
158
|
+
resource.expects(:should_be_file?).returns false
|
159
|
+
content.should = "foo"
|
160
|
+
content.must be_safe_insync("whatever")
|
155
161
|
end
|
156
162
|
|
157
163
|
it "should warn that no content will be synced to links when ensure is :present" do
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
164
|
+
resource[:ensure] = :present
|
165
|
+
resource[:content] = 'foo'
|
166
|
+
resource.stubs(:should_be_file?).returns false
|
167
|
+
resource.stubs(:stat).returns mock("stat", :ftype => "link")
|
162
168
|
|
163
|
-
|
169
|
+
resource.expects(:warning).with {|msg| msg =~ /Ensure set to :present but file type is/}
|
164
170
|
|
165
|
-
|
171
|
+
content.insync? :present
|
166
172
|
end
|
167
173
|
|
168
174
|
it "should return false if the current content is :absent" do
|
169
|
-
|
170
|
-
|
175
|
+
content.should = "foo"
|
176
|
+
content.should_not be_safe_insync(:absent)
|
171
177
|
end
|
172
178
|
|
173
179
|
it "should return false if the file should be a file but is not present" do
|
174
|
-
|
175
|
-
|
180
|
+
resource.expects(:should_be_file?).returns true
|
181
|
+
content.should = "foo"
|
176
182
|
|
177
|
-
|
183
|
+
content.should_not be_safe_insync(:absent)
|
178
184
|
end
|
179
185
|
|
180
186
|
describe "and the file exists" do
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
@content.should_not be_safe_insync("other content")
|
188
|
-
end
|
187
|
+
with_digest_algorithms do
|
188
|
+
before do
|
189
|
+
resource.stubs(:stat).returns mock("stat")
|
190
|
+
resource[:checksum] = digest_algorithm
|
191
|
+
content.should = "some content"
|
192
|
+
end
|
189
193
|
|
190
|
-
|
191
|
-
|
192
|
-
|
194
|
+
it "should return false if the current contents are different from the desired content" do
|
195
|
+
content.should_not be_safe_insync("other content")
|
196
|
+
end
|
193
197
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
Puppet[:show_diff] = cfg
|
198
|
-
@resource.stubs(:show_diff?).returns param
|
199
|
-
@resource[:loglevel] = "debug"
|
200
|
-
end
|
198
|
+
it "should return true if the sum for the current contents is the same as the sum for the desired content" do
|
199
|
+
content.must be_safe_insync("{#{digest_algorithm}}" + digest("some content"))
|
200
|
+
end
|
201
201
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
[true, false].product([true, false]).each do |cfg, param|
|
203
|
+
describe "and Puppet[:show_diff] is #{cfg} and show_diff => #{param}" do
|
204
|
+
before do
|
205
|
+
Puppet[:show_diff] = cfg
|
206
|
+
resource.stubs(:show_diff?).returns param
|
207
|
+
resource[:loglevel] = "debug"
|
207
208
|
end
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
209
|
+
|
210
|
+
if cfg and param
|
211
|
+
it "should display a diff" do
|
212
|
+
content.expects(:diff).returns("my diff").once
|
213
|
+
content.expects(:debug).with("\nmy diff").once
|
214
|
+
content.should_not be_safe_insync("other content")
|
215
|
+
end
|
216
|
+
else
|
217
|
+
it "should not display a diff" do
|
218
|
+
content.expects(:diff).never
|
219
|
+
content.should_not be_safe_insync("other content")
|
220
|
+
end
|
212
221
|
end
|
213
222
|
end
|
214
223
|
end
|
@@ -217,189 +226,250 @@ describe content do
|
|
217
226
|
|
218
227
|
describe "and :replace is false" do
|
219
228
|
before do
|
220
|
-
|
229
|
+
resource.stubs(:replace?).returns false
|
221
230
|
end
|
222
231
|
|
223
232
|
it "should be insync if the file exists and the content is different" do
|
224
|
-
|
233
|
+
resource.stubs(:stat).returns mock('stat')
|
225
234
|
|
226
|
-
|
235
|
+
content.must be_safe_insync("whatever")
|
227
236
|
end
|
228
237
|
|
229
238
|
it "should be insync if the file exists and the content is right" do
|
230
|
-
|
239
|
+
resource.stubs(:stat).returns mock('stat')
|
231
240
|
|
232
|
-
|
241
|
+
content.must be_safe_insync("something")
|
233
242
|
end
|
234
243
|
|
235
244
|
it "should not be insync if the file does not exist" do
|
236
|
-
|
237
|
-
|
245
|
+
content.should = "foo"
|
246
|
+
content.should_not be_safe_insync(:absent)
|
238
247
|
end
|
239
248
|
end
|
240
249
|
end
|
241
250
|
|
242
|
-
|
243
|
-
|
244
|
-
@content = content.new(:resource => @resource)
|
245
|
-
@content.should = "some content"
|
251
|
+
describe "when changing the content" do
|
252
|
+
let(:content) { described_class.new(:resource => resource) }
|
246
253
|
|
247
|
-
|
248
|
-
|
254
|
+
before do
|
255
|
+
resource.stubs(:[]).with(:path).returns "/boo"
|
256
|
+
resource.stubs(:stat).returns "eh"
|
249
257
|
end
|
250
258
|
|
251
259
|
it "should use the file's :write method to write the content" do
|
252
|
-
|
260
|
+
resource.expects(:write).with(:content)
|
253
261
|
|
254
|
-
|
262
|
+
content.sync
|
255
263
|
end
|
256
264
|
|
257
265
|
it "should return :file_changed if the file already existed" do
|
258
|
-
|
259
|
-
|
260
|
-
|
266
|
+
resource.expects(:stat).returns "something"
|
267
|
+
resource.stubs(:write)
|
268
|
+
content.sync.should == :file_changed
|
261
269
|
end
|
262
270
|
|
263
271
|
it "should return :file_created if the file did not exist" do
|
264
|
-
|
265
|
-
|
266
|
-
|
272
|
+
resource.expects(:stat).returns nil
|
273
|
+
resource.stubs(:write)
|
274
|
+
content.sync.should == :file_created
|
267
275
|
end
|
268
276
|
end
|
269
277
|
|
270
278
|
describe "when writing" do
|
271
|
-
|
272
|
-
|
273
|
-
|
279
|
+
let(:content) { described_class.new(:resource => resource) }
|
280
|
+
|
281
|
+
let(:fh) { File.open(filename, 'wb') }
|
274
282
|
|
275
283
|
it "should attempt to read from the filebucket if no actual content nor source exists" do
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
@fh.close
|
284
|
+
content.should = "{md5}foo"
|
285
|
+
content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo"
|
286
|
+
content.write(fh)
|
287
|
+
fh.close
|
281
288
|
end
|
282
289
|
|
283
290
|
describe "from actual content" do
|
284
291
|
before(:each) do
|
285
|
-
|
292
|
+
content.stubs(:actual_content).returns("this is content")
|
286
293
|
end
|
287
294
|
|
288
295
|
it "should write to the given file handle" do
|
289
296
|
fh = mock 'filehandle'
|
290
297
|
fh.expects(:print).with("this is content")
|
291
|
-
|
298
|
+
content.write(fh)
|
292
299
|
end
|
293
300
|
|
294
301
|
it "should return the current checksum value" do
|
295
|
-
|
296
|
-
|
302
|
+
resource.parameter(:checksum).expects(:sum_stream).returns "checksum"
|
303
|
+
content.write(fh).should == "checksum"
|
297
304
|
end
|
298
305
|
end
|
299
306
|
|
300
307
|
describe "from a file bucket" do
|
301
308
|
it "should fail if a file bucket cannot be retrieved" do
|
302
|
-
|
303
|
-
|
304
|
-
|
309
|
+
content.should = "{md5}foo"
|
310
|
+
content.resource.expects(:bucket).returns nil
|
311
|
+
expect { content.write(fh) }.to raise_error(Puppet::Error)
|
305
312
|
end
|
306
313
|
|
307
314
|
it "should fail if the file bucket cannot find any content" do
|
308
|
-
|
315
|
+
content.should = "{md5}foo"
|
309
316
|
bucket = stub 'bucket'
|
310
|
-
|
317
|
+
content.resource.expects(:bucket).returns bucket
|
311
318
|
bucket.expects(:getfile).with("foo").raises "foobar"
|
312
|
-
|
319
|
+
expect { content.write(fh) }.to raise_error(Puppet::Error)
|
313
320
|
end
|
314
321
|
|
315
322
|
it "should write the returned content to the file" do
|
316
|
-
|
323
|
+
content.should = "{md5}foo"
|
317
324
|
bucket = stub 'bucket'
|
318
|
-
|
325
|
+
content.resource.expects(:bucket).returns bucket
|
319
326
|
bucket.expects(:getfile).with("foo").returns "mycontent"
|
320
327
|
|
321
328
|
fh = mock 'filehandle'
|
322
329
|
fh.expects(:print).with("mycontent")
|
323
|
-
|
330
|
+
content.write(fh)
|
324
331
|
end
|
325
332
|
end
|
326
333
|
|
327
334
|
describe "from local source" do
|
335
|
+
let(:source_content) { "source file content\r\n"*10000 }
|
328
336
|
before(:each) do
|
329
|
-
|
330
|
-
|
337
|
+
sourcename = tmpfile('source')
|
338
|
+
resource[:backup] = false
|
339
|
+
resource[:source] = sourcename
|
331
340
|
|
332
|
-
|
333
|
-
@sourcefile = File.open(@sourcename, 'wb') {|f| f.write @source_content}
|
341
|
+
File.open(sourcename, 'wb') {|f| f.write source_content}
|
334
342
|
|
335
|
-
|
336
|
-
|
343
|
+
# This needs to be invoked to properly initialize the content property,
|
344
|
+
# or attempting to write a file will fail.
|
345
|
+
resource.newattr(:content)
|
337
346
|
end
|
338
347
|
|
339
348
|
it "should copy content from the source to the file" do
|
340
|
-
|
349
|
+
source = resource.parameter(:source)
|
350
|
+
resource.write(source)
|
341
351
|
|
342
|
-
Puppet::FileSystem.binread(
|
352
|
+
Puppet::FileSystem.binread(filename).should == source_content
|
343
353
|
end
|
344
354
|
|
345
|
-
|
346
|
-
|
347
|
-
|
355
|
+
with_digest_algorithms do
|
356
|
+
it "should return the checksum computed" do
|
357
|
+
File.open(filename, 'wb') do |file|
|
358
|
+
resource[:checksum] = digest_algorithm
|
359
|
+
content.write(file).should == "{#{digest_algorithm}}#{digest(source_content)}"
|
360
|
+
end
|
348
361
|
end
|
349
362
|
end
|
350
363
|
end
|
351
364
|
|
352
|
-
describe "from
|
365
|
+
describe "from an explicit fileserver" do
|
366
|
+
let(:source_content) { "source file content\n"*10000 }
|
367
|
+
let(:response) { stub_everything 'response' }
|
368
|
+
let(:source) { resource.newattr(:source) }
|
369
|
+
|
353
370
|
before(:each) do
|
354
|
-
|
355
|
-
|
356
|
-
@source_content = "source file content\n"*10000
|
357
|
-
@response.stubs(:read_body).multiple_yields(*(["source file content\n"]*10000))
|
371
|
+
resource[:backup] = false
|
372
|
+
response.stubs(:read_body).multiple_yields(*(["source file content\n"]*10000))
|
358
373
|
|
359
|
-
|
360
|
-
|
361
|
-
Puppet::Network::HttpPool.stubs(:http_instance).returns @conn
|
374
|
+
conn = mock('connection')
|
375
|
+
conn.stubs(:request_get).yields response
|
362
376
|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
377
|
+
Puppet::Network::HttpPool.expects(:http_instance).with('somehostname',any_parameters).returns(conn).at_least_once
|
378
|
+
|
379
|
+
# This needs to be invoked to properly initialize the content property,
|
380
|
+
# or attempting to write a file will fail.
|
381
|
+
resource.newattr(:content)
|
382
|
+
|
383
|
+
source.stubs(:metadata).returns stub_everything('metadata', :source => "puppet://somehostname/test/foo", :ftype => 'file')
|
367
384
|
end
|
368
385
|
|
369
|
-
|
370
|
-
|
386
|
+
describe "and the request was successful" do
|
387
|
+
before { response.stubs(:code).returns '200' }
|
388
|
+
|
389
|
+
it "should write the contents to the file" do
|
390
|
+
resource.write(source)
|
391
|
+
Puppet::FileSystem.binread(filename).should == source_content
|
392
|
+
end
|
371
393
|
|
372
|
-
|
394
|
+
with_digest_algorithms do
|
395
|
+
it "should return the checksum computed" do
|
396
|
+
File.open(filename, 'w') do |file|
|
397
|
+
resource[:checksum] = digest_algorithm
|
398
|
+
content.write(file).should == "{#{digest_algorithm}}#{digest(source_content)}"
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
373
402
|
end
|
374
403
|
|
375
404
|
it "should not write anything if source is not found" do
|
376
|
-
|
377
|
-
|
378
|
-
File.read(
|
405
|
+
response.stubs(:code).returns("404")
|
406
|
+
expect { resource.write(source) }.to raise_error(Net::HTTPError, /404/)
|
407
|
+
File.read(filename).should == "initial file content"
|
379
408
|
end
|
380
409
|
|
381
410
|
it "should raise an HTTP error in case of server error" do
|
382
|
-
|
383
|
-
|
411
|
+
response.stubs(:code).returns("500")
|
412
|
+
expect { content.write(fh) }.to raise_error(Net::HTTPError, /500/)
|
413
|
+
end
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
describe "from remote source" do
|
418
|
+
let(:source_content) { "source file content\n"*10000 }
|
419
|
+
let(:response) { stub_everything 'response' }
|
420
|
+
let(:source) { resource.newattr(:source) }
|
421
|
+
|
422
|
+
before(:each) do
|
423
|
+
resource[:backup] = false
|
424
|
+
response.stubs(:read_body).multiple_yields(*(["source file content\n"]*10000))
|
425
|
+
|
426
|
+
conn = stub_everything 'connection'
|
427
|
+
conn.stubs(:request_get).yields response
|
428
|
+
Puppet::Network::HttpPool.stubs(:http_instance).returns conn
|
429
|
+
|
430
|
+
# This needs to be invoked to properly initialize the content property,
|
431
|
+
# or attempting to write a file will fail.
|
432
|
+
resource.newattr(:content)
|
433
|
+
source.stubs(:metadata).returns stub_everything('metadata', :source => "puppet://somehostname/test/foo", :ftype => 'file')
|
384
434
|
end
|
385
435
|
|
386
|
-
|
387
|
-
|
388
|
-
|
436
|
+
describe "and the request was successful" do
|
437
|
+
before { response.stubs(:code).returns '200' }
|
438
|
+
|
439
|
+
it "should write the contents to the file" do
|
440
|
+
resource.write(source)
|
441
|
+
Puppet::FileSystem.binread(filename).should == source_content
|
442
|
+
end
|
443
|
+
|
444
|
+
with_digest_algorithms do
|
445
|
+
it "should return the checksum computed" do
|
446
|
+
File.open(filename, 'w') do |file|
|
447
|
+
resource[:checksum] = digest_algorithm
|
448
|
+
content.write(file).should == "{#{digest_algorithm}}#{digest(source_content)}"
|
449
|
+
end
|
450
|
+
end
|
389
451
|
end
|
390
452
|
end
|
453
|
+
|
454
|
+
it "should not write anything if source is not found" do
|
455
|
+
response.stubs(:code).returns("404")
|
456
|
+
expect {resource.write(source)}.to raise_error(Net::HTTPError, /404/)
|
457
|
+
File.read(filename).should == "initial file content"
|
458
|
+
end
|
459
|
+
|
460
|
+
it "should raise an HTTP error in case of server error" do
|
461
|
+
response.stubs(:code).returns("500")
|
462
|
+
expect { content.write(fh) }.to raise_error(Net::HTTPError, /500/)
|
463
|
+
end
|
391
464
|
end
|
392
465
|
|
393
466
|
# These are testing the implementation rather than the desired behaviour; while that bites, there are a whole
|
394
467
|
# pile of other methods in the File type that depend on intimate details of this implementation and vice-versa.
|
395
468
|
# If these blow up, you are gonna have to review the callers to make sure they don't explode! --daniel 2011-02-01
|
396
469
|
describe "each_chunk_from should work" do
|
397
|
-
before do
|
398
|
-
@content = content.new(:resource => @resource)
|
399
|
-
end
|
400
470
|
|
401
471
|
it "when content is a string" do
|
402
|
-
|
472
|
+
content.each_chunk_from('i_am_a_string') { |chunk| chunk.should == 'i_am_a_string' }
|
403
473
|
end
|
404
474
|
|
405
475
|
# The following manifest is a case where source and content.should are both set
|
@@ -409,54 +479,54 @@ describe content do
|
|
409
479
|
# }
|
410
480
|
it "when content checksum comes from source" do
|
411
481
|
source_param = Puppet::Type.type(:file).attrclass(:source)
|
412
|
-
source = source_param.new(:resource =>
|
413
|
-
|
482
|
+
source = source_param.new(:resource => resource)
|
483
|
+
content.should = "{md5}123abcd"
|
414
484
|
|
415
|
-
|
416
|
-
|
485
|
+
content.expects(:chunk_file_from_source).returns('from_source')
|
486
|
+
content.each_chunk_from(source) { |chunk| chunk.should == 'from_source' }
|
417
487
|
end
|
418
488
|
|
419
489
|
it "when no content, source, but ensure present" do
|
420
|
-
|
421
|
-
|
490
|
+
resource[:ensure] = :present
|
491
|
+
content.each_chunk_from(nil) { |chunk| chunk.should == '' }
|
422
492
|
end
|
423
493
|
|
424
494
|
# you might do this if you were just auditing
|
425
495
|
it "when no content, source, but ensure file" do
|
426
|
-
|
427
|
-
|
496
|
+
resource[:ensure] = :file
|
497
|
+
content.each_chunk_from(nil) { |chunk| chunk.should == '' }
|
428
498
|
end
|
429
499
|
|
430
500
|
it "when source_or_content is nil and content not a checksum" do
|
431
|
-
|
501
|
+
content.each_chunk_from(nil) { |chunk| chunk.should == '' }
|
432
502
|
end
|
433
503
|
|
434
504
|
# the content is munged so that if it's a checksum nil gets passed in
|
435
505
|
it "when content is a checksum it should try to read from filebucket" do
|
436
|
-
|
437
|
-
|
438
|
-
|
506
|
+
content.should = "{md5}123abcd"
|
507
|
+
content.expects(:read_file_from_filebucket).once.returns('im_a_filebucket')
|
508
|
+
content.each_chunk_from(nil) { |chunk| chunk.should == 'im_a_filebucket' }
|
439
509
|
end
|
440
510
|
|
441
511
|
it "when running as puppet apply" do
|
442
512
|
Puppet[:default_file_terminus] = "file_server"
|
443
513
|
source_or_content = stubs('source_or_content')
|
444
514
|
source_or_content.expects(:content).once.returns :whoo
|
445
|
-
|
515
|
+
content.each_chunk_from(source_or_content) { |chunk| chunk.should == :whoo }
|
446
516
|
end
|
447
517
|
|
448
518
|
it "when running from source with a local file" do
|
449
519
|
source_or_content = stubs('source_or_content')
|
450
520
|
source_or_content.expects(:local?).returns true
|
451
|
-
|
452
|
-
|
521
|
+
content.expects(:chunk_file_from_disk).with(source_or_content).once.yields 'woot'
|
522
|
+
content.each_chunk_from(source_or_content) { |chunk| chunk.should == 'woot' }
|
453
523
|
end
|
454
524
|
|
455
525
|
it "when running from source with a remote file" do
|
456
526
|
source_or_content = stubs('source_or_content')
|
457
527
|
source_or_content.expects(:local?).returns false
|
458
|
-
|
459
|
-
|
528
|
+
content.expects(:chunk_file_from_source).with(source_or_content).once.yields 'woot'
|
529
|
+
content.each_chunk_from(source_or_content) { |chunk| chunk.should == 'woot' }
|
460
530
|
end
|
461
531
|
end
|
462
532
|
end
|