puppet 3.1.1 → 3.2.0.rc1
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 +2 -2
- data/Gemfile +32 -19
- data/README_DEVELOPER.md +332 -14
- data/Rakefile +9 -5
- data/ext/build_defaults.yaml +2 -3
- data/ext/debian/changelog.erb +6 -0
- data/ext/debian/control +6 -6
- data/ext/envpuppet +4 -4
- data/ext/project_data.yaml +1 -0
- data/ext/puppet-nm-dispatcher +13 -0
- data/ext/redhat/puppet.spec.erb +17 -0
- data/ext/suse/client.init +1 -1
- data/ext/systemd/puppetagent.service +2 -2
- data/ext/systemd/puppetmaster.service +2 -2
- data/lib/hiera/scope.rb +29 -11
- data/lib/hiera_puppet.rb +1 -3
- data/lib/puppet/agent.rb +3 -3
- data/lib/puppet/application.rb +2 -2
- data/lib/puppet/application/agent.rb +27 -12
- data/lib/puppet/application/apply.rb +11 -1
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/doc.rb +13 -9
- data/lib/puppet/application/filebucket.rb +0 -1
- data/lib/puppet/application/kick.rb +1 -0
- data/lib/puppet/application/master.rb +16 -8
- data/lib/puppet/daemon.rb +19 -64
- data/lib/puppet/defaults.rb +61 -5
- data/lib/puppet/error.rb +15 -4
- data/lib/puppet/external/nagios/grammar.ry +1 -1
- data/lib/puppet/external/nagios/makefile +1 -1
- data/lib/puppet/external/nagios/parser.rb +185 -618
- data/lib/puppet/external/pson/pure/parser.rb +47 -1
- data/lib/puppet/face/certificate.rb +3 -3
- data/lib/puppet/face/module.rb +1 -1
- data/lib/puppet/face/module/changes.rb +3 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/node/clean.rb +5 -5
- data/lib/puppet/feature/base.rb +3 -1
- data/lib/puppet/feature/libuser.rb +8 -0
- data/lib/puppet/file_serving/fileset.rb +9 -1
- data/lib/puppet/forge.rb +28 -5
- data/lib/puppet/forge/errors.rb +34 -0
- data/lib/puppet/forge/repository.rb +1 -1
- data/lib/puppet/indirector.rb +4 -1
- data/lib/puppet/indirector/catalog/compiler.rb +37 -30
- data/lib/puppet/indirector/facts/inventory_active_record.rb +1 -0
- data/lib/puppet/indirector/indirection.rb +28 -15
- data/lib/puppet/indirector/rest.rb +18 -10
- data/lib/puppet/interface.rb +11 -4
- data/lib/puppet/interface/action.rb +1 -3
- data/lib/puppet/interface/action_builder.rb +0 -3
- data/lib/puppet/interface/action_manager.rb +0 -3
- data/lib/puppet/interface/face_collection.rb +0 -2
- data/lib/puppet/interface/option.rb +0 -2
- data/lib/puppet/interface/option_builder.rb +0 -2
- data/lib/puppet/interface/option_manager.rb +0 -2
- data/lib/puppet/metatype/manager.rb +1 -1
- data/lib/puppet/module_tool.rb +1 -0
- data/lib/puppet/module_tool/applications/application.rb +0 -3
- data/lib/puppet/module_tool/applications/builder.rb +8 -20
- data/lib/puppet/module_tool/applications/checksummer.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +1 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +3 -11
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +18 -1
- data/lib/puppet/module_tool/modulefile.rb +2 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +1 -1
- data/lib/puppet/module_tool/tar.rb +17 -0
- data/lib/puppet/module_tool/tar/gnu.rb +9 -0
- data/lib/puppet/module_tool/tar/mini.rb +39 -0
- data/lib/puppet/module_tool/tar/solaris.rb +5 -0
- data/lib/puppet/network/http.rb +1 -0
- data/lib/puppet/network/http/connection.rb +9 -23
- data/lib/puppet/network/http/handler.rb +38 -7
- data/lib/puppet/network/http/rack/rest.rb +14 -3
- data/lib/puppet/network/http/webrick.rb +3 -1
- data/lib/puppet/network/http/webrick/rest.rb +11 -2
- data/lib/puppet/node/environment.rb +3 -1
- data/lib/puppet/parameter.rb +32 -29
- data/lib/puppet/parameter/package_options.rb +1 -1
- data/lib/puppet/parameter/path.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +7 -3
- data/lib/puppet/parser/ast.rb +3 -1
- data/lib/puppet/parser/ast/arithmetic_operator.rb +56 -12
- data/lib/puppet/parser/ast/astarray.rb +1 -1
- data/lib/puppet/parser/ast/block_expression.rb +41 -0
- data/lib/puppet/parser/ast/function.rb +13 -2
- data/lib/puppet/parser/ast/lambda.rb +107 -0
- data/lib/puppet/parser/ast/leaf.rb +1 -2
- data/lib/puppet/parser/ast/method_call.rb +77 -0
- data/lib/puppet/parser/ast/vardef.rb +7 -0
- data/lib/puppet/parser/compiler.rb +27 -16
- data/lib/puppet/parser/e_parser_adapter.rb +120 -0
- data/lib/puppet/parser/files.rb +7 -6
- data/lib/puppet/parser/functions.rb +10 -8
- data/lib/puppet/parser/functions/collect.rb +43 -0
- data/lib/puppet/parser/functions/each.rb +96 -0
- data/lib/puppet/parser/functions/foreach.rb +96 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +2 -2
- data/lib/puppet/parser/functions/hiera.rb +20 -2
- data/lib/puppet/parser/functions/hiera_array.rb +21 -2
- data/lib/puppet/parser/functions/hiera_hash.rb +23 -2
- data/lib/puppet/parser/functions/hiera_include.rb +33 -2
- data/lib/puppet/parser/functions/inline_template.rb +4 -4
- data/lib/puppet/parser/functions/reduce.rb +74 -0
- data/lib/puppet/parser/functions/reject.rb +46 -0
- data/lib/puppet/parser/functions/select.rb +46 -0
- data/lib/puppet/parser/functions/slice.rb +96 -0
- data/lib/puppet/parser/functions/template.rb +2 -2
- data/lib/puppet/parser/grammar.ra +7 -4
- data/lib/puppet/parser/lexer.rb +10 -0
- data/lib/puppet/parser/methods.rb +69 -0
- data/lib/puppet/parser/parser.rb +855 -808
- data/lib/puppet/parser/parser_factory.rb +62 -0
- data/lib/puppet/parser/parser_support.rb +8 -2
- data/lib/puppet/parser/scope.rb +153 -47
- data/lib/puppet/parser/templatewrapper.rb +28 -21
- data/lib/puppet/parser/type_loader.rb +3 -1
- data/lib/puppet/pops.rb +40 -0
- data/lib/puppet/pops/adaptable.rb +190 -0
- data/lib/puppet/pops/adapters.rb +65 -0
- data/lib/puppet/pops/containment.rb +37 -0
- data/lib/puppet/pops/issues.rb +258 -0
- data/lib/puppet/pops/label_provider.rb +71 -0
- data/lib/puppet/pops/model/ast_transformer.rb +636 -0
- data/lib/puppet/pops/model/ast_tree_dumper.rb +378 -0
- data/lib/puppet/pops/model/factory.rb +804 -0
- data/lib/puppet/pops/model/model.rb +567 -0
- data/lib/puppet/pops/model/model_label_provider.rb +75 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +352 -0
- data/lib/puppet/pops/model/tree_dumper.rb +59 -0
- data/lib/puppet/pops/parser/egrammar.ra +723 -0
- data/lib/puppet/pops/parser/eparser.rb +2300 -0
- data/lib/puppet/pops/parser/grammar.ra +746 -0
- data/lib/puppet/pops/parser/lexer.rb +842 -0
- data/lib/puppet/pops/parser/makefile +13 -0
- data/lib/puppet/pops/parser/parser_support.rb +203 -0
- data/lib/puppet/pops/patterns.rb +35 -0
- data/lib/puppet/pops/utils.rb +104 -0
- data/lib/puppet/pops/validation.rb +297 -0
- data/lib/puppet/pops/validation/checker3_1.rb +551 -0
- data/lib/puppet/pops/validation/validator_factory_3_1.rb +41 -0
- data/lib/puppet/pops/visitable.rb +6 -0
- data/lib/puppet/pops/visitor.rb +50 -0
- data/lib/puppet/property.rb +37 -28
- data/lib/puppet/property/ensure.rb +2 -2
- data/lib/puppet/property/ordered_list.rb +1 -1
- data/lib/puppet/provider.rb +26 -30
- data/lib/puppet/provider/aixobject.rb +45 -44
- data/lib/puppet/provider/augeas/augeas.rb +0 -1
- data/lib/puppet/provider/confiner.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +107 -67
- data/lib/puppet/provider/group/groupadd.rb +59 -3
- data/lib/puppet/provider/interface/cisco.rb +4 -4
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/nameservice.rb +22 -6
- data/lib/puppet/provider/nameservice/pw.rb +1 -1
- data/lib/puppet/provider/package/aix.rb +28 -4
- data/lib/puppet/provider/package/gem.rb +0 -2
- data/lib/puppet/provider/package/macports.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +249 -4
- data/lib/puppet/provider/package/opkg.rb +77 -0
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +30 -16
- data/lib/puppet/provider/package/yum.rb +3 -3
- data/lib/puppet/provider/parsedfile.rb +80 -3
- data/lib/puppet/provider/selmodule/semodule.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +0 -4
- data/lib/puppet/provider/service/freebsd.rb +2 -2
- data/lib/puppet/provider/service/gentoo.rb +0 -9
- data/lib/puppet/provider/service/init.rb +27 -2
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/openwrt.rb +36 -0
- data/lib/puppet/provider/service/redhat.rb +0 -9
- data/lib/puppet/provider/service/src.rb +38 -4
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/service/upstart.rb +1 -8
- data/lib/puppet/provider/user/aix.rb +4 -10
- data/lib/puppet/provider/user/pw.rb +6 -10
- data/lib/puppet/provider/user/useradd.rb +129 -31
- data/lib/puppet/provider/vlan/cisco.rb +4 -4
- data/lib/puppet/reference/function.rb +2 -2
- data/lib/puppet/reference/indirection.rb +46 -5
- data/lib/puppet/reference/metaparameter.rb +2 -2
- data/lib/puppet/reports.rb +5 -5
- data/lib/puppet/reports/rrdgraph.rb +4 -4
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/type.rb +13 -11
- data/lib/puppet/scheduler.rb +16 -0
- data/lib/puppet/scheduler/job.rb +53 -0
- data/lib/puppet/scheduler/scheduler.rb +45 -0
- data/lib/puppet/scheduler/splay_job.rb +32 -0
- data/lib/puppet/scheduler/timer.rb +13 -0
- data/lib/puppet/settings/base_setting.rb +1 -1
- data/lib/puppet/simple_graph.rb +4 -4
- data/lib/puppet/ssl/base.rb +12 -2
- data/lib/puppet/ssl/certificate.rb +4 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -1
- data/lib/puppet/ssl/certificate_revocation_list.rb +4 -1
- data/lib/puppet/ssl/configuration.rb +32 -0
- data/lib/puppet/ssl/host.rb +18 -21
- data/lib/puppet/ssl/key.rb +4 -1
- data/lib/puppet/ssl/validator.rb +116 -0
- data/lib/puppet/transaction.rb +1 -1
- data/lib/puppet/transaction/event.rb +3 -10
- data/lib/puppet/transaction/event_manager.rb +8 -1
- data/lib/puppet/transaction/report.rb +17 -16
- data/lib/puppet/type.rb +77 -69
- data/lib/puppet/type/cron.rb +20 -8
- data/lib/puppet/type/exec.rb +9 -3
- data/lib/puppet/type/file.rb +95 -21
- data/lib/puppet/type/file/content.rb +1 -1
- data/lib/puppet/type/file/mode.rb +7 -1
- data/lib/puppet/type/file/source.rb +2 -2
- data/lib/puppet/type/group.rb +11 -0
- data/lib/puppet/type/scheduled_task.rb +5 -1
- data/lib/puppet/type/service.rb +1 -1
- data/lib/puppet/type/ssh_authorized_key.rb +2 -2
- data/lib/puppet/type/user.rb +24 -6
- data/lib/puppet/util.rb +12 -2
- data/lib/puppet/util/classgen.rb +4 -4
- data/lib/puppet/util/colors.rb +55 -0
- data/lib/puppet/util/command_line/trollop.rb +4 -4
- data/lib/puppet/util/errors.rb +39 -3
- data/lib/puppet/util/fileparsing.rb +5 -0
- data/lib/puppet/util/filetype.rb +11 -9
- data/lib/puppet/util/instrumentation/instrumentable.rb +2 -2
- data/lib/puppet/util/libuser.conf +15 -0
- data/lib/puppet/util/libuser.rb +12 -0
- data/lib/puppet/util/monkey_patches.rb +48 -0
- data/lib/puppet/util/network_device.rb +1 -1
- data/lib/puppet/util/network_device/base.rb +2 -2
- data/lib/puppet/util/network_device/cisco/device.rb +29 -19
- data/lib/puppet/util/network_device/config.rb +5 -2
- data/lib/puppet/util/network_device/ipcalc.rb +1 -1
- data/lib/puppet/util/network_device/transport/ssh.rb +4 -3
- data/lib/puppet/util/network_device/transport/telnet.rb +4 -2
- data/lib/puppet/util/plugins.rb +4 -4
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/profiler.rb +28 -0
- data/lib/puppet/util/profiler/logging.rb +47 -0
- data/lib/puppet/util/profiler/none.rb +8 -0
- data/lib/puppet/util/profiler/object_counts.rb +17 -0
- data/lib/puppet/util/profiler/wall_clock.rb +34 -0
- data/lib/puppet/util/provider_features.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +5 -5
- data/lib/puppet/util/ssl.rb +38 -0
- data/lib/puppet/util/subclass_loader.rb +1 -5
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/process.rb +3 -0
- data/lib/puppet/util/windows/root_certs.rb +86 -0
- data/lib/puppet/util/windows/security.rb +1 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/integration/provider/cron/crontab/create_normal_entry +19 -0
- data/spec/fixtures/integration/provider/cron/crontab/create_special_entry +18 -0
- data/spec/fixtures/integration/provider/cron/crontab/crontab_user1 +15 -0
- data/spec/fixtures/integration/provider/cron/crontab/crontab_user2 +4 -0
- data/spec/fixtures/integration/provider/cron/crontab/modify_entry +13 -0
- data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input1 +15 -0
- data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input2 +6 -0
- data/spec/fixtures/integration/provider/cron/crontab/remove_named_resource +12 -0
- data/spec/fixtures/integration/provider/cron/crontab/remove_unnamed_resource +14 -0
- data/spec/fixtures/unit/pops/parser/lexer/aliastest.pp +16 -0
- data/spec/fixtures/unit/pops/parser/lexer/append.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/argumentdefaults.pp +14 -0
- data/spec/fixtures/unit/pops/parser/lexer/arithmetic_expression.pp +8 -0
- data/spec/fixtures/unit/pops/parser/lexer/arraytrailingcomma.pp +3 -0
- data/spec/fixtures/unit/pops/parser/lexer/casestatement.pp +65 -0
- data/spec/fixtures/unit/pops/parser/lexer/classheirarchy.pp +15 -0
- data/spec/fixtures/unit/pops/parser/lexer/classincludes.pp +17 -0
- data/spec/fixtures/unit/pops/parser/lexer/classpathtest.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/collection.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/collection_override.pp +8 -0
- data/spec/fixtures/unit/pops/parser/lexer/collection_within_virtual_definitions.pp +20 -0
- data/spec/fixtures/unit/pops/parser/lexer/componentmetaparams.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/componentrequire.pp +8 -0
- data/spec/fixtures/unit/pops/parser/lexer/deepclassheirarchy.pp +23 -0
- data/spec/fixtures/unit/pops/parser/lexer/defineoverrides.pp +17 -0
- data/spec/fixtures/unit/pops/parser/lexer/emptyclass.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/emptyexec.pp +3 -0
- data/spec/fixtures/unit/pops/parser/lexer/emptyifelse.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/falsevalues.pp +3 -0
- data/spec/fixtures/unit/pops/parser/lexer/filecreate.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/fqdefinition.pp +5 -0
- data/spec/fixtures/unit/pops/parser/lexer/fqparents.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/funccomma.pp +5 -0
- data/spec/fixtures/unit/pops/parser/lexer/hash.pp +33 -0
- data/spec/fixtures/unit/pops/parser/lexer/ifexpression.pp +12 -0
- data/spec/fixtures/unit/pops/parser/lexer/implicititeration.pp +15 -0
- data/spec/fixtures/unit/pops/parser/lexer/multilinecomments.pp +10 -0
- data/spec/fixtures/unit/pops/parser/lexer/multipleclass.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/multipleinstances.pp +7 -0
- data/spec/fixtures/unit/pops/parser/lexer/multisubs.pp +13 -0
- data/spec/fixtures/unit/pops/parser/lexer/namevartest.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/scopetest.pp +13 -0
- data/spec/fixtures/unit/pops/parser/lexer/selectorvalues.pp +49 -0
- data/spec/fixtures/unit/pops/parser/lexer/simpledefaults.pp +5 -0
- data/spec/fixtures/unit/pops/parser/lexer/simpleselector.pp +38 -0
- data/spec/fixtures/unit/pops/parser/lexer/singleary.pp +19 -0
- data/spec/fixtures/unit/pops/parser/lexer/singlequote.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/singleselector.pp +22 -0
- data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +11 -0
- data/spec/fixtures/unit/pops/parser/lexer/tag.pp +9 -0
- data/spec/fixtures/unit/pops/parser/lexer/tagged.pp +35 -0
- data/spec/fixtures/unit/pops/parser/lexer/virtualresources.pp +14 -0
- data/spec/fixtures/unit/provider/cron/crontab/single_line.yaml +4 -4
- data/spec/fixtures/unit/provider/cron/crontab/vixie_header.txt +3 -0
- data/spec/fixtures/unit/provider/cron/parsed/managed +6 -0
- data/spec/fixtures/unit/provider/cron/parsed/simple +9 -0
- data/spec/fixtures/unit/provider/parsedfile/simple.txt +4 -0
- data/spec/fixtures/unit/provider/service/systemd/list_units +18 -0
- data/spec/integration/parser/collector_spec.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +252 -227
- data/spec/integration/parser/parser_spec.rb +171 -53
- data/spec/integration/parser/scope_spec.rb +1 -1
- data/spec/integration/provider/cron/crontab_spec.rb +187 -0
- data/spec/integration/provider/service/systemd_spec.rb +20 -0
- data/spec/integration/type/file_spec.rb +21 -21
- data/spec/integration/type/package_spec.rb +1 -1
- data/spec/lib/puppet_spec/database.rb +2 -5
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/application/apply_spec.rb +16 -1
- data/spec/unit/application/describe_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +55 -32
- data/spec/unit/application/kick_spec.rb +8 -6
- data/spec/unit/application/master_spec.rb +4 -4
- data/spec/unit/daemon_spec.rb +1 -1
- data/spec/unit/forge/errors_spec.rb +40 -0
- data/spec/unit/forge/repository_spec.rb +11 -1
- data/spec/unit/forge_spec.rb +13 -3
- data/spec/unit/hiera/backend/puppet_backend_spec.rb +1 -0
- data/spec/unit/hiera/scope_spec.rb +48 -25
- data/spec/unit/indirector/catalog/active_record_spec.rb +6 -3
- data/spec/unit/indirector/catalog/compiler_spec.rb +3 -28
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +1 -1
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +154 -150
- data/spec/unit/indirector/indirection_spec.rb +5 -0
- data/spec/unit/indirector/resource/active_record_spec.rb +5 -22
- data/spec/unit/indirector_spec.rb +7 -1
- data/spec/unit/interface/action_builder_spec.rb +1 -1
- data/spec/unit/interface/action_manager_spec.rb +0 -2
- data/spec/unit/interface/action_spec.rb +1 -1
- data/spec/unit/interface/documentation_spec.rb +0 -2
- data/spec/unit/interface/face_collection_spec.rb +1 -1
- data/spec/unit/interface/option_builder_spec.rb +1 -1
- data/spec/unit/interface/option_spec.rb +0 -1
- data/spec/unit/module_spec.rb +17 -19
- data/spec/unit/module_tool/application_spec.rb +1 -3
- data/spec/unit/module_tool/applications/builder_spec.rb +38 -0
- data/spec/unit/module_tool/applications/checksummer_spec.rb +134 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +71 -91
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -3
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +18 -26
- data/spec/unit/module_tool/applications/unpacker_spec.rb +19 -52
- data/spec/unit/module_tool/tar/gnu_spec.rb +19 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +59 -0
- data/spec/unit/module_tool/tar/solaris_spec.rb +19 -0
- data/spec/unit/network/http/connection_spec.rb +17 -2
- data/spec/unit/network/http/handler_spec.rb +195 -167
- data/spec/unit/network/http/rack/rest_spec.rb +26 -4
- data/spec/unit/network/http/webrick/rest_spec.rb +28 -1
- data/spec/unit/network/http/webrick_spec.rb +12 -3
- data/spec/unit/node/environment_spec.rb +421 -404
- data/spec/unit/parser/ast/arithmetic_operator_spec.rb +98 -2
- data/spec/unit/parser/collector_spec.rb +4 -4
- data/spec/unit/parser/compiler_spec.rb +13 -13
- data/spec/unit/parser/eparser_adapter_spec.rb +407 -0
- data/spec/unit/parser/functions/extlookup_spec.rb +20 -17
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +5 -0
- data/spec/unit/parser/functions/hiera_include_spec.rb +0 -2
- data/spec/unit/parser/functions/hiera_spec.rb +0 -2
- data/spec/unit/parser/functions_spec.rb +27 -15
- data/spec/unit/parser/methods/collect_spec.rb +110 -0
- data/spec/unit/parser/methods/each_spec.rb +91 -0
- data/spec/unit/parser/methods/foreach_spec.rb +91 -0
- data/spec/unit/parser/methods/reduce_spec.rb +67 -0
- data/spec/unit/parser/methods/reject_spec.rb +73 -0
- data/spec/unit/parser/methods/select_spec.rb +79 -0
- data/spec/unit/parser/methods/shared.rb +61 -0
- data/spec/unit/parser/methods/slice_spec.rb +97 -0
- data/spec/unit/parser/parser_spec.rb +2 -2
- data/spec/unit/parser/scope_spec.rb +39 -16
- data/spec/unit/parser/templatewrapper_spec.rb +6 -5
- data/spec/unit/parser/type_loader_spec.rb +191 -165
- data/spec/unit/pops/adaptable_spec.rb +143 -0
- data/spec/unit/pops/containment_spec.rb +25 -0
- data/spec/unit/pops/factory_rspec_helper.rb +77 -0
- data/spec/unit/pops/factory_spec.rb +329 -0
- data/spec/unit/pops/issues_spec.rb +26 -0
- data/spec/unit/pops/label_provider_spec.rb +42 -0
- data/spec/unit/pops/model/ast_transformer_spec.rb +65 -0
- data/spec/unit/pops/model/model_spec.rb +37 -0
- data/spec/unit/pops/parser/lexer_spec.rb +884 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +248 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +93 -0
- data/spec/unit/pops/parser/parse_conditionals_spec.rb +159 -0
- data/spec/unit/pops/parser/parse_containers_spec.rb +175 -0
- data/spec/unit/pops/parser/parse_resource_spec.rb +228 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +11 -0
- data/spec/unit/pops/parser/parser_spec.rb +15 -0
- data/spec/unit/pops/parser/rgen_sanitycheck_spec.rb +16 -0
- data/spec/unit/pops/transformer/transform_basic_expressions_spec.rb +243 -0
- data/spec/unit/pops/transformer/transform_calls_spec.rb +80 -0
- data/spec/unit/pops/transformer/transform_conditionals_spec.rb +132 -0
- data/spec/unit/pops/transformer/transform_containers_spec.rb +182 -0
- data/spec/unit/pops/transformer/transform_resource_spec.rb +185 -0
- data/spec/unit/pops/transformer/transformer_rspec_helper.rb +27 -0
- data/spec/unit/pops/visitor_spec.rb +94 -0
- data/spec/unit/property_spec.rb +11 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +3 -0
- data/spec/unit/provider/cron/crontab_spec.rb +97 -7
- data/spec/unit/provider/cron/parsed_spec.rb +325 -0
- data/spec/unit/provider/exec/posix_spec.rb +1 -1
- data/spec/unit/provider/group/groupadd_spec.rb +33 -3
- data/spec/unit/provider/group/pw_spec.rb +5 -5
- data/spec/unit/provider/nameservice_spec.rb +304 -0
- data/spec/unit/provider/package/aix_spec.rb +53 -11
- data/spec/unit/provider/package/aptrpm_spec.rb +6 -0
- data/spec/unit/provider/package/gem_spec.rb +6 -11
- data/spec/unit/provider/package/nim_spec.rb +216 -7
- data/spec/unit/provider/package/opkg_spec.rb +180 -0
- data/spec/unit/provider/package/rpm_spec.rb +149 -3
- data/spec/unit/provider/package/yum_spec.rb +6 -5
- data/spec/unit/provider/parsedfile_spec.rb +122 -28
- data/spec/unit/provider/service/freebsd_spec.rb +18 -0
- data/spec/unit/provider/service/init_spec.rb +108 -87
- data/spec/unit/provider/service/launchd_spec.rb +2 -2
- data/spec/unit/provider/service/openwrt_spec.rb +109 -0
- data/spec/unit/provider/service/src_spec.rb +117 -41
- data/spec/unit/provider/service/systemd_spec.rb +125 -17
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/aix_spec.rb +42 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +1 -0
- data/spec/unit/provider/user/pw_spec.rb +24 -12
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +179 -15
- data/spec/unit/resource/type_spec.rb +3 -3
- data/spec/unit/scheduler/job_spec.rb +79 -0
- data/spec/unit/scheduler/scheduler_spec.rb +129 -0
- data/spec/unit/scheduler/splay_job_spec.rb +35 -0
- data/spec/unit/ssl/base_spec.rb +3 -9
- data/spec/unit/ssl/certificate_authority_spec.rb +1 -0
- data/spec/unit/ssl/certificate_request_spec.rb +3 -1
- data/spec/unit/ssl/certificate_spec.rb +3 -1
- data/spec/unit/ssl/configuration_spec.rb +74 -0
- data/spec/unit/ssl/host_spec.rb +28 -7
- data/spec/unit/ssl/validator_spec.rb +311 -0
- data/spec/unit/transaction/event_manager_spec.rb +49 -0
- data/spec/unit/transaction/event_spec.rb +20 -5
- data/spec/unit/transaction/report_spec.rb +8 -0
- data/spec/unit/type/cron_spec.rb +9 -0
- data/spec/unit/type/exec_spec.rb +11 -0
- data/spec/unit/type/file/content_spec.rb +20 -20
- data/spec/unit/type/file/mode_spec.rb +6 -0
- data/spec/unit/type/file/source_spec.rb +9 -7
- data/spec/unit/type/file_spec.rb +22 -3
- data/spec/unit/type/service_spec.rb +34 -21
- data/spec/unit/type_spec.rb +46 -1
- data/spec/unit/util/backups_spec.rb +2 -2
- data/spec/unit/util/execution_spec.rb +4 -1
- data/spec/unit/util/filetype_spec.rb +6 -0
- data/spec/unit/util/monkey_patches_spec.rb +18 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +37 -0
- data/spec/unit/util/network_device/config_spec.rb +14 -0
- data/spec/unit/util/network_device_spec.rb +3 -3
- data/spec/unit/util/profiler/logging_spec.rb +81 -0
- data/spec/unit/util/profiler/none_spec.rb +12 -0
- data/spec/unit/util/profiler/object_counts_spec.rb +14 -0
- data/spec/unit/util/profiler/wall_clock_spec.rb +13 -0
- data/spec/unit/util/pson_spec.rb +5 -0
- data/spec/unit/util/ssl_spec.rb +51 -0
- data/spec/unit/util/windows/root_certs_spec.rb +15 -0
- data/spec/unit/util_spec.rb +28 -0
- metadata +2593 -2307
- data/spec/unit/module_tool/applications/application_spec.rb +0 -19
@@ -31,6 +31,16 @@ describe "Puppet::Network::HTTP::RackREST", :if => Puppet.features.rack? do
|
|
31
31
|
Rack::Request.new(env)
|
32
32
|
end
|
33
33
|
|
34
|
+
describe "#headers" do
|
35
|
+
it "should return the headers (parsed from env with prefix 'HTTP_')" do
|
36
|
+
req = mk_req('/', {'HTTP_Accept' => 'myaccept',
|
37
|
+
'HTTP_X-Custom-Header' => 'mycustom',
|
38
|
+
'NOT_HTTP_foo' => 'not an http header'})
|
39
|
+
@handler.headers(req).should == {"accept" => 'myaccept',
|
40
|
+
"x-custom-header" => 'mycustom'}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
34
44
|
describe "and using the HTTP Handler interface" do
|
35
45
|
it "should return the HTTP_ACCEPT parameter as the accept header" do
|
36
46
|
req = mk_req('/', 'HTTP_ACCEPT' => 'myaccept')
|
@@ -198,30 +208,42 @@ describe "Puppet::Network::HTTP::RackREST", :if => Puppet.features.rack? do
|
|
198
208
|
end
|
199
209
|
|
200
210
|
describe "with pre-validated certificates" do
|
201
|
-
it "should retrieve the hostname by
|
211
|
+
it "should retrieve the hostname by finding the CN given in :ssl_client_header, in the format returned by Apache (RFC2253)" do
|
212
|
+
Puppet[:ssl_client_header] = "myheader"
|
213
|
+
req = mk_req('/', "myheader" => "O=Foo\\, Inc,CN=host.domain.com")
|
214
|
+
@handler.params(req)[:node].should == "host.domain.com"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should retrieve the hostname by finding the CN given in :ssl_client_header, in the format returned by nginx" do
|
202
218
|
Puppet[:ssl_client_header] = "myheader"
|
203
219
|
req = mk_req('/', "myheader" => "/CN=host.domain.com")
|
204
220
|
@handler.params(req)[:node].should == "host.domain.com"
|
205
221
|
end
|
206
222
|
|
223
|
+
it "should retrieve the hostname by finding the CN given in :ssl_client_header, ignoring other fields" do
|
224
|
+
Puppet[:ssl_client_header] = "myheader"
|
225
|
+
req = mk_req('/', "myheader" => 'ST=Denial,CN=host.domain.com,O=Domain\\, Inc.')
|
226
|
+
@handler.params(req)[:node].should == "host.domain.com"
|
227
|
+
end
|
228
|
+
|
207
229
|
it "should use the :ssl_client_header to determine the parameter for checking whether the host certificate is valid" do
|
208
230
|
Puppet[:ssl_client_header] = "certheader"
|
209
231
|
Puppet[:ssl_client_verify_header] = "myheader"
|
210
|
-
req = mk_req('/', "myheader" => "SUCCESS", "certheader" => "
|
232
|
+
req = mk_req('/', "myheader" => "SUCCESS", "certheader" => "CN=host.domain.com")
|
211
233
|
@handler.params(req)[:authenticated].should be_true
|
212
234
|
end
|
213
235
|
|
214
236
|
it "should consider the host unauthenticated if the validity parameter does not contain 'SUCCESS'" do
|
215
237
|
Puppet[:ssl_client_header] = "certheader"
|
216
238
|
Puppet[:ssl_client_verify_header] = "myheader"
|
217
|
-
req = mk_req('/', "myheader" => "whatever", "certheader" => "
|
239
|
+
req = mk_req('/', "myheader" => "whatever", "certheader" => "CN=host.domain.com")
|
218
240
|
@handler.params(req)[:authenticated].should be_false
|
219
241
|
end
|
220
242
|
|
221
243
|
it "should consider the host unauthenticated if no certificate information is present" do
|
222
244
|
Puppet[:ssl_client_header] = "certheader"
|
223
245
|
Puppet[:ssl_client_verify_header] = "myheader"
|
224
|
-
req = mk_req('/', "myheader" => nil, "certheader" => "
|
246
|
+
req = mk_req('/', "myheader" => nil, "certheader" => "CN=host.domain.com")
|
225
247
|
@handler.params(req)[:authenticated].should be_false
|
226
248
|
end
|
227
249
|
|
@@ -41,6 +41,20 @@ describe Puppet::Network::HTTP::WEBrickREST do
|
|
41
41
|
@handler.service(@request, @response).should == "stuff"
|
42
42
|
end
|
43
43
|
|
44
|
+
describe "#headers" do
|
45
|
+
let(:fake_request) { {"Foo" => "bar", "BAZ" => "bam" } }
|
46
|
+
|
47
|
+
it "should iterate over the request object using #each" do
|
48
|
+
fake_request.expects(:each)
|
49
|
+
@handler.headers(fake_request)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return a hash with downcased header names" do
|
53
|
+
result = @handler.headers(fake_request)
|
54
|
+
result.should == fake_request.inject({}) { |m,(k,v)| m[k.downcase] = v; m }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
44
58
|
describe "when using the Handler interface" do
|
45
59
|
it "should use the 'accept' request parameter as the Accept header" do
|
46
60
|
@request.expects(:[]).with("accept").returns "foobar"
|
@@ -173,8 +187,10 @@ describe Puppet::Network::HTTP::WEBrickREST do
|
|
173
187
|
end
|
174
188
|
|
175
189
|
it "should pass the client's certificate name to model method if a certificate is present" do
|
176
|
-
|
190
|
+
subj = stub 'subj'
|
191
|
+
cert = stub 'cert', :subject => subj
|
177
192
|
@request.stubs(:client_cert).returns cert
|
193
|
+
Puppet::Util::SSL.expects(:cn_from_subject).with(subj).returns 'host.domain.com'
|
178
194
|
@handler.params(@request)[:node].should == "host.domain.com"
|
179
195
|
end
|
180
196
|
|
@@ -185,6 +201,17 @@ describe Puppet::Network::HTTP::WEBrickREST do
|
|
185
201
|
|
186
202
|
@handler.params(@request)[:node].should == :resolved_node
|
187
203
|
end
|
204
|
+
|
205
|
+
it "should resolve the node name with an ip address look-up if CN parsing fails" do
|
206
|
+
subj = stub 'subj'
|
207
|
+
cert = stub 'cert', :subject => subj
|
208
|
+
@request.stubs(:client_cert).returns cert
|
209
|
+
Puppet::Util::SSL.expects(:cn_from_subject).with(subj).returns nil
|
210
|
+
|
211
|
+
@handler.expects(:resolve_node).returns(:resolved_node)
|
212
|
+
|
213
|
+
@handler.params(@request)[:node].should == :resolved_node
|
214
|
+
end
|
188
215
|
end
|
189
216
|
end
|
190
217
|
end
|
@@ -43,9 +43,18 @@ describe Puppet::Network::HTTP::WEBrick do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should tell webrick to listen on the specified address and port" do
|
46
|
-
WEBrick::HTTPServer.expects(:new).with
|
47
|
-
|
48
|
-
|
46
|
+
WEBrick::HTTPServer.expects(:new).with(
|
47
|
+
has_entries(:Port => 31337, :BindAddress => "127.0.0.1")
|
48
|
+
).returns(mock_webrick)
|
49
|
+
server.listen(address, port)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should not perform reverse lookups" do
|
53
|
+
WEBrick::HTTPServer.expects(:new).with(
|
54
|
+
has_entry(:DoNotReverseLookup => true)
|
55
|
+
).returns(mock_webrick)
|
56
|
+
BasicSocket.expects(:do_not_reverse_lookup=).with(true)
|
57
|
+
|
49
58
|
server.listen(address, port)
|
50
59
|
end
|
51
60
|
|
@@ -6,6 +6,7 @@ require 'tmpdir'
|
|
6
6
|
require 'puppet/node/environment'
|
7
7
|
require 'puppet/util/execution'
|
8
8
|
require 'puppet_spec/modules'
|
9
|
+
require 'puppet/parser/parser_factory'
|
9
10
|
|
10
11
|
describe Puppet::Node::Environment do
|
11
12
|
let(:env) { Puppet::Node::Environment.new("testing") }
|
@@ -15,438 +16,454 @@ describe Puppet::Node::Environment do
|
|
15
16
|
Puppet::Node::Environment.clear
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
it "should use the filetimeout for the ttl for the module list" do
|
23
|
-
Puppet::Node::Environment.attr_ttl(:modules).should == Integer(Puppet[:filetimeout])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should use the default environment if no name is provided while initializing an environment" do
|
27
|
-
Puppet[:environment] = "one"
|
28
|
-
Puppet::Node::Environment.new.name.should == :one
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should treat environment instances as singletons" do
|
32
|
-
Puppet::Node::Environment.new("one").should equal(Puppet::Node::Environment.new("one"))
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should treat an environment specified as names or strings as equivalent" do
|
36
|
-
Puppet::Node::Environment.new(:one).should equal(Puppet::Node::Environment.new("one"))
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should return its name when converted to a string" do
|
40
|
-
Puppet::Node::Environment.new(:one).to_s.should == "one"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should just return any provided environment if an environment is provided as the name" do
|
44
|
-
one = Puppet::Node::Environment.new(:one)
|
45
|
-
Puppet::Node::Environment.new(one).should equal(one)
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "when managing known resource types" do
|
49
|
-
before do
|
50
|
-
@collection = Puppet::Resource::TypeCollection.new(env)
|
51
|
-
env.stubs(:perform_initial_import).returns(Puppet::Parser::AST::Hostclass.new(''))
|
52
|
-
Thread.current[:known_resource_types] = nil
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should create a resource type collection if none exists" do
|
56
|
-
Puppet::Resource::TypeCollection.expects(:new).with(env).returns @collection
|
57
|
-
env.known_resource_types.should equal(@collection)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should reuse any existing resource type collection" do
|
61
|
-
env.known_resource_types.should equal(env.known_resource_types)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should perform the initial import when creating a new collection" do
|
65
|
-
env.expects(:perform_initial_import).returns(Puppet::Parser::AST::Hostclass.new(''))
|
66
|
-
env.known_resource_types
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should return the same collection even if stale if it's the same thread" do
|
70
|
-
Puppet::Resource::TypeCollection.stubs(:new).returns @collection
|
71
|
-
env.known_resource_types.stubs(:stale?).returns true
|
72
|
-
|
73
|
-
env.known_resource_types.should equal(@collection)
|
19
|
+
shared_examples_for 'the environment' do
|
20
|
+
it "should use the filetimeout for the ttl for the modulepath" do
|
21
|
+
Puppet::Node::Environment.attr_ttl(:modulepath).should == Integer(Puppet[:filetimeout])
|
74
22
|
end
|
75
|
-
|
76
|
-
it "should
|
77
|
-
|
78
|
-
|
79
|
-
env.known_resource_types.should equal(@collection)
|
23
|
+
|
24
|
+
it "should use the filetimeout for the ttl for the module list" do
|
25
|
+
Puppet::Node::Environment.attr_ttl(:modules).should == Integer(Puppet[:filetimeout])
|
80
26
|
end
|
81
|
-
|
82
|
-
it "should
|
83
|
-
|
84
|
-
Puppet::
|
85
|
-
env.known_resource_types.should equal(@original_thread_type_collection)
|
86
|
-
|
87
|
-
@original_thread_type_collection.expects(:require_reparse?).returns(false)
|
88
|
-
Puppet::Resource::TypeCollection.stubs(:new).with(env).returns @collection
|
89
|
-
|
90
|
-
t = Thread.new {
|
91
|
-
env.known_resource_types.should equal(@original_thread_type_collection)
|
92
|
-
}
|
93
|
-
t.join
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should generate a new TypeCollection if the current one requires reparsing" do
|
97
|
-
old_type_collection = env.known_resource_types
|
98
|
-
old_type_collection.stubs(:require_reparse?).returns true
|
99
|
-
Thread.current[:known_resource_types] = nil
|
100
|
-
new_type_collection = env.known_resource_types
|
101
|
-
|
102
|
-
new_type_collection.should be_a Puppet::Resource::TypeCollection
|
103
|
-
new_type_collection.should_not equal(old_type_collection)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should validate the modulepath directories" do
|
108
|
-
real_file = tmpdir('moduledir')
|
109
|
-
path = %W[/one /two #{real_file}].join(File::PATH_SEPARATOR)
|
110
|
-
|
111
|
-
Puppet[:modulepath] = path
|
112
|
-
|
113
|
-
env.modulepath.should == [real_file]
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
|
117
|
-
Puppet::Util.withenv("PUPPETLIB" => %w{/l1 /l2}.join(File::PATH_SEPARATOR)) do
|
118
|
-
module_path = %w{/one /two}.join(File::PATH_SEPARATOR)
|
119
|
-
env.expects(:validate_dirs).with(%w{/l1 /l2 /one /two}).returns %w{/l1 /l2 /one /two}
|
120
|
-
env.expects(:[]).with(:modulepath).returns module_path
|
121
|
-
|
122
|
-
env.modulepath.should == %w{/l1 /l2 /one /two}
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "when validating modulepath or manifestdir directories" do
|
127
|
-
before :each do
|
128
|
-
@path_one = tmpdir("path_one")
|
129
|
-
@path_two = tmpdir("path_one")
|
130
|
-
sep = File::PATH_SEPARATOR
|
131
|
-
Puppet[:modulepath] = "#{@path_one}#{sep}#{@path_two}"
|
27
|
+
|
28
|
+
it "should use the default environment if no name is provided while initializing an environment" do
|
29
|
+
Puppet[:environment] = "one"
|
30
|
+
Puppet::Node::Environment.new.name.should == :one
|
132
31
|
end
|
133
|
-
|
134
|
-
it "should
|
135
|
-
|
136
|
-
FileTest.expects(:directory?).with(@path_two).returns false
|
137
|
-
|
138
|
-
env.validate_dirs([@path_one, @path_two]).should == [@path_one]
|
32
|
+
|
33
|
+
it "should treat environment instances as singletons" do
|
34
|
+
Puppet::Node::Environment.new("one").should equal(Puppet::Node::Environment.new("one"))
|
139
35
|
end
|
140
|
-
|
141
|
-
it "should
|
142
|
-
|
143
|
-
|
144
|
-
two = File.expand_path(File.join(Dir.getwd, "two"))
|
145
|
-
env.validate_dirs([@path_one, 'two']).should == [@path_one, two]
|
36
|
+
|
37
|
+
it "should treat an environment specified as names or strings as equivalent" do
|
38
|
+
Puppet::Node::Environment.new(:one).should equal(Puppet::Node::Environment.new("one"))
|
146
39
|
end
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
it "should have a method for returning the environment name" do
|
151
|
-
Puppet::Node::Environment.new("testing").name.should == :testing
|
40
|
+
|
41
|
+
it "should return its name when converted to a string" do
|
42
|
+
Puppet::Node::Environment.new(:one).to_s.should == "one"
|
152
43
|
end
|
153
|
-
|
154
|
-
it "should
|
155
|
-
|
44
|
+
|
45
|
+
it "should just return any provided environment if an environment is provided as the name" do
|
46
|
+
one = Puppet::Node::Environment.new(:one)
|
47
|
+
Puppet::Node::Environment.new(one).should equal(one)
|
156
48
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
49
|
+
|
50
|
+
describe "when managing known resource types" do
|
51
|
+
before do
|
52
|
+
@collection = Puppet::Resource::TypeCollection.new(env)
|
53
|
+
env.stubs(:perform_initial_import).returns(Puppet::Parser::AST::Hostclass.new(''))
|
54
|
+
Thread.current[:known_resource_types] = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should create a resource type collection if none exists" do
|
58
|
+
Puppet::Resource::TypeCollection.expects(:new).with(env).returns @collection
|
59
|
+
env.known_resource_types.should equal(@collection)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should reuse any existing resource type collection" do
|
63
|
+
env.known_resource_types.should equal(env.known_resource_types)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should perform the initial import when creating a new collection" do
|
67
|
+
env.expects(:perform_initial_import).returns(Puppet::Parser::AST::Hostclass.new(''))
|
68
|
+
env.known_resource_types
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return the same collection even if stale if it's the same thread" do
|
72
|
+
Puppet::Resource::TypeCollection.stubs(:new).returns @collection
|
73
|
+
env.known_resource_types.stubs(:stale?).returns true
|
74
|
+
|
75
|
+
env.known_resource_types.should equal(@collection)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return the current thread associated collection if there is one" do
|
79
|
+
Thread.current[:known_resource_types] = @collection
|
80
|
+
|
81
|
+
env.known_resource_types.should equal(@collection)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should give to all threads using the same environment the same collection if the collection isn't stale" do
|
85
|
+
@original_thread_type_collection = Puppet::Resource::TypeCollection.new(env)
|
86
|
+
Puppet::Resource::TypeCollection.expects(:new).with(env).returns @original_thread_type_collection
|
87
|
+
env.known_resource_types.should equal(@original_thread_type_collection)
|
88
|
+
|
89
|
+
@original_thread_type_collection.expects(:require_reparse?).returns(false)
|
90
|
+
Puppet::Resource::TypeCollection.stubs(:new).with(env).returns @collection
|
91
|
+
|
92
|
+
t = Thread.new {
|
93
|
+
env.known_resource_types.should equal(@original_thread_type_collection)
|
94
|
+
}
|
95
|
+
t.join
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should generate a new TypeCollection if the current one requires reparsing" do
|
99
|
+
old_type_collection = env.known_resource_types
|
100
|
+
old_type_collection.stubs(:require_reparse?).returns true
|
101
|
+
Thread.current[:known_resource_types] = nil
|
102
|
+
new_type_collection = env.known_resource_types
|
103
|
+
|
104
|
+
new_type_collection.should be_a Puppet::Resource::TypeCollection
|
105
|
+
new_type_collection.should_not equal(old_type_collection)
|
106
|
+
end
|
161
107
|
end
|
162
|
-
|
163
|
-
it "should
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
108
|
+
|
109
|
+
it "should validate the modulepath directories" do
|
110
|
+
real_file = tmpdir('moduledir')
|
111
|
+
path = %W[/one /two #{real_file}].join(File::PATH_SEPARATOR)
|
112
|
+
|
113
|
+
Puppet[:modulepath] = path
|
114
|
+
|
115
|
+
env.modulepath.should == [real_file]
|
169
116
|
end
|
170
|
-
|
171
|
-
it "should
|
172
|
-
|
173
|
-
|
174
|
-
|
117
|
+
|
118
|
+
it "should prefix the value of the 'PUPPETLIB' environment variable to the module path if present" do
|
119
|
+
Puppet::Util.withenv("PUPPETLIB" => %w{/l1 /l2}.join(File::PATH_SEPARATOR)) do
|
120
|
+
module_path = %w{/one /two}.join(File::PATH_SEPARATOR)
|
121
|
+
env.expects(:validate_dirs).with(%w{/l1 /l2 /one /two}).returns %w{/l1 /l2 /one /two}
|
122
|
+
env.expects(:[]).with(:modulepath).returns module_path
|
123
|
+
|
124
|
+
env.modulepath.should == %w{/l1 /l2 /one /two}
|
125
|
+
end
|
175
126
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
127
|
+
|
128
|
+
describe "when validating modulepath or manifestdir directories" do
|
129
|
+
before :each do
|
130
|
+
@path_one = tmpdir("path_one")
|
131
|
+
@path_two = tmpdir("path_one")
|
132
|
+
sep = File::PATH_SEPARATOR
|
133
|
+
Puppet[:modulepath] = "#{@path_one}#{sep}#{@path_two}"
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should not return non-directories" do
|
137
|
+
FileTest.expects(:directory?).with(@path_one).returns true
|
138
|
+
FileTest.expects(:directory?).with(@path_two).returns false
|
139
|
+
|
140
|
+
env.validate_dirs([@path_one, @path_two]).should == [@path_one]
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should use the current working directory to fully-qualify unqualified paths" do
|
144
|
+
FileTest.stubs(:directory?).returns true
|
145
|
+
|
146
|
+
two = File.expand_path(File.join(Dir.getwd, "two"))
|
147
|
+
env.validate_dirs([@path_one, 'two']).should == [@path_one, two]
|
148
|
+
end
|
182
149
|
end
|
183
|
-
|
184
|
-
describe "
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
@first = File.join(dir, "first")
|
189
|
-
@second = File.join(dir, "second")
|
190
|
-
Puppet[:modulepath] = "#{@first}#{File::PATH_SEPARATOR}#{@second}"
|
191
|
-
|
192
|
-
FileUtils.mkdir_p(@first)
|
193
|
-
FileUtils.mkdir_p(@second)
|
150
|
+
|
151
|
+
describe "when modeling a specific environment" do
|
152
|
+
it "should have a method for returning the environment name" do
|
153
|
+
Puppet::Node::Environment.new("testing").name.should == :testing
|
194
154
|
end
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
env.modules_by_path.should == {
|
199
|
-
@first => [],
|
200
|
-
@second => []
|
201
|
-
}
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should include modules even if they exist in multiple dirs in the modulepath" do
|
205
|
-
modpath1 = File.join(@first, "foo")
|
206
|
-
FileUtils.mkdir_p(modpath1)
|
207
|
-
modpath2 = File.join(@second, "foo")
|
208
|
-
FileUtils.mkdir_p(modpath2)
|
209
|
-
|
210
|
-
env.modules_by_path.should == {
|
211
|
-
@first => [Puppet::Module.new('foo', modpath1, env)],
|
212
|
-
@second => [Puppet::Module.new('foo', modpath2, env)]
|
213
|
-
}
|
214
|
-
end
|
215
|
-
|
216
|
-
it "should ignore modules with invalid names" do
|
217
|
-
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
218
|
-
FileUtils.mkdir_p(File.join(@first, 'foo2'))
|
219
|
-
FileUtils.mkdir_p(File.join(@first, 'foo-bar'))
|
220
|
-
FileUtils.mkdir_p(File.join(@first, 'foo_bar'))
|
221
|
-
FileUtils.mkdir_p(File.join(@first, 'foo=bar'))
|
222
|
-
FileUtils.mkdir_p(File.join(@first, 'foo bar'))
|
223
|
-
FileUtils.mkdir_p(File.join(@first, 'foo.bar'))
|
224
|
-
FileUtils.mkdir_p(File.join(@first, '-foo'))
|
225
|
-
FileUtils.mkdir_p(File.join(@first, 'foo-'))
|
226
|
-
FileUtils.mkdir_p(File.join(@first, 'foo--bar'))
|
227
|
-
|
228
|
-
env.modules_by_path[@first].collect{|mod| mod.name}.sort.should == %w{foo foo-bar foo2 foo_bar}
|
229
|
-
end
|
230
|
-
|
155
|
+
|
156
|
+
it "should provide an array-like accessor method for returning any environment-specific setting" do
|
157
|
+
env.should respond_to(:[])
|
231
158
|
end
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
'foo',
|
237
|
-
@first,
|
238
|
-
:metadata => {
|
239
|
-
:author => 'puppetlabs',
|
240
|
-
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => ">= 1.0.0" }]
|
241
|
-
}
|
242
|
-
)
|
243
|
-
PuppetSpec::Modules.create(
|
244
|
-
'bar',
|
245
|
-
@second,
|
246
|
-
:metadata => {
|
247
|
-
:author => 'puppetlabs',
|
248
|
-
:dependencies => [{ 'name' => 'puppetlabs/foo', "version_requirement" => "<= 2.0.0" }]
|
249
|
-
}
|
250
|
-
)
|
251
|
-
PuppetSpec::Modules.create(
|
252
|
-
'baz',
|
253
|
-
@first,
|
254
|
-
:metadata => {
|
255
|
-
:author => 'puppetlabs',
|
256
|
-
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => "3.0.0" }]
|
257
|
-
}
|
258
|
-
)
|
259
|
-
PuppetSpec::Modules.create(
|
260
|
-
'alpha',
|
261
|
-
@first,
|
262
|
-
:metadata => {
|
263
|
-
:author => 'puppetlabs',
|
264
|
-
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => "~3.0.0" }]
|
265
|
-
}
|
266
|
-
)
|
267
|
-
|
268
|
-
env.module_requirements.should == {
|
269
|
-
'puppetlabs/alpha' => [],
|
270
|
-
'puppetlabs/foo' => [
|
271
|
-
{
|
272
|
-
"name" => "puppetlabs/bar",
|
273
|
-
"version" => "9.9.9",
|
274
|
-
"version_requirement" => "<= 2.0.0"
|
275
|
-
}
|
276
|
-
],
|
277
|
-
'puppetlabs/bar' => [
|
278
|
-
{
|
279
|
-
"name" => "puppetlabs/alpha",
|
280
|
-
"version" => "9.9.9",
|
281
|
-
"version_requirement" => "~3.0.0"
|
282
|
-
},
|
283
|
-
{
|
284
|
-
"name" => "puppetlabs/baz",
|
285
|
-
"version" => "9.9.9",
|
286
|
-
"version_requirement" => "3.0.0"
|
287
|
-
},
|
288
|
-
{
|
289
|
-
"name" => "puppetlabs/foo",
|
290
|
-
"version" => "9.9.9",
|
291
|
-
"version_requirement" => ">= 1.0.0"
|
292
|
-
}
|
293
|
-
],
|
294
|
-
'puppetlabs/baz' => []
|
295
|
-
}
|
296
|
-
end
|
159
|
+
|
160
|
+
it "should ask the Puppet settings instance for the setting qualified with the environment name" do
|
161
|
+
Puppet.settings.set_value(:server, "myval", :testing)
|
162
|
+
env[:server].should == "myval"
|
297
163
|
end
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
:environment => env
|
306
|
-
)
|
307
|
-
env.module_by_forge_name('puppetlabs/baz').should == mod
|
308
|
-
end
|
309
|
-
|
310
|
-
it "should not find modules with same name by the wrong author" do
|
311
|
-
mod = PuppetSpec::Modules.create(
|
312
|
-
'baz',
|
313
|
-
@first,
|
314
|
-
:metadata => {:author => 'sneakylabs'},
|
315
|
-
:environment => env
|
316
|
-
)
|
317
|
-
env.module_by_forge_name('puppetlabs/baz').should == nil
|
318
|
-
end
|
319
|
-
|
320
|
-
it "should return nil when the module can't be found" do
|
321
|
-
env.module_by_forge_name('ima/nothere').should be_nil
|
322
|
-
end
|
164
|
+
|
165
|
+
it "should be able to return an individual module that exists in its module path" do
|
166
|
+
env.stubs(:modules).returns [Puppet::Module.new('one', "/one", mock("env"))]
|
167
|
+
|
168
|
+
mod = env.module('one')
|
169
|
+
mod.should be_a(Puppet::Module)
|
170
|
+
mod.name.should == 'one'
|
323
171
|
end
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
172
|
+
|
173
|
+
it "should not return a module if the module doesn't exist" do
|
174
|
+
env.stubs(:modules).returns [Puppet::Module.new('one', "/one", mock("env"))]
|
175
|
+
|
176
|
+
env.module('two').should be_nil
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should return nil if asked for a module that does not exist in its path" do
|
180
|
+
modpath = tmpdir('modpath')
|
181
|
+
env.modulepath = [modpath]
|
182
|
+
|
183
|
+
env.module("one").should be_nil
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "module data" do
|
187
|
+
before do
|
188
|
+
dir = tmpdir("deep_path")
|
189
|
+
|
190
|
+
@first = File.join(dir, "first")
|
191
|
+
@second = File.join(dir, "second")
|
192
|
+
Puppet[:modulepath] = "#{@first}#{File::PATH_SEPARATOR}#{@second}"
|
193
|
+
|
194
|
+
FileUtils.mkdir_p(@first)
|
195
|
+
FileUtils.mkdir_p(@second)
|
328
196
|
end
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
197
|
+
|
198
|
+
describe "#modules_by_path" do
|
199
|
+
it "should return an empty list if there are no modules" do
|
200
|
+
env.modules_by_path.should == {
|
201
|
+
@first => [],
|
202
|
+
@second => []
|
203
|
+
}
|
333
204
|
end
|
334
|
-
|
335
|
-
|
205
|
+
|
206
|
+
it "should include modules even if they exist in multiple dirs in the modulepath" do
|
207
|
+
modpath1 = File.join(@first, "foo")
|
208
|
+
FileUtils.mkdir_p(modpath1)
|
209
|
+
modpath2 = File.join(@second, "foo")
|
210
|
+
FileUtils.mkdir_p(modpath2)
|
211
|
+
|
212
|
+
env.modules_by_path.should == {
|
213
|
+
@first => [Puppet::Module.new('foo', modpath1, env)],
|
214
|
+
@second => [Puppet::Module.new('foo', modpath2, env)]
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should ignore modules with invalid names" do
|
219
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
220
|
+
FileUtils.mkdir_p(File.join(@first, 'foo2'))
|
221
|
+
FileUtils.mkdir_p(File.join(@first, 'foo-bar'))
|
222
|
+
FileUtils.mkdir_p(File.join(@first, 'foo_bar'))
|
223
|
+
FileUtils.mkdir_p(File.join(@first, 'foo=bar'))
|
224
|
+
FileUtils.mkdir_p(File.join(@first, 'foo bar'))
|
225
|
+
FileUtils.mkdir_p(File.join(@first, 'foo.bar'))
|
226
|
+
FileUtils.mkdir_p(File.join(@first, '-foo'))
|
227
|
+
FileUtils.mkdir_p(File.join(@first, 'foo-'))
|
228
|
+
FileUtils.mkdir_p(File.join(@first, 'foo--bar'))
|
229
|
+
|
230
|
+
env.modules_by_path[@first].collect{|mod| mod.name}.sort.should == %w{foo foo-bar foo2 foo_bar}
|
336
231
|
end
|
337
|
-
|
232
|
+
|
338
233
|
end
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
234
|
+
|
235
|
+
describe "#module_requirements" do
|
236
|
+
it "should return a list of what modules depend on other modules" do
|
237
|
+
PuppetSpec::Modules.create(
|
238
|
+
'foo',
|
239
|
+
@first,
|
240
|
+
:metadata => {
|
241
|
+
:author => 'puppetlabs',
|
242
|
+
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => ">= 1.0.0" }]
|
243
|
+
}
|
244
|
+
)
|
245
|
+
PuppetSpec::Modules.create(
|
246
|
+
'bar',
|
247
|
+
@second,
|
248
|
+
:metadata => {
|
249
|
+
:author => 'puppetlabs',
|
250
|
+
:dependencies => [{ 'name' => 'puppetlabs/foo', "version_requirement" => "<= 2.0.0" }]
|
251
|
+
}
|
252
|
+
)
|
253
|
+
PuppetSpec::Modules.create(
|
254
|
+
'baz',
|
255
|
+
@first,
|
256
|
+
:metadata => {
|
257
|
+
:author => 'puppetlabs',
|
258
|
+
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => "3.0.0" }]
|
259
|
+
}
|
260
|
+
)
|
261
|
+
PuppetSpec::Modules.create(
|
262
|
+
'alpha',
|
263
|
+
@first,
|
264
|
+
:metadata => {
|
265
|
+
:author => 'puppetlabs',
|
266
|
+
:dependencies => [{ 'name' => 'puppetlabs/bar', "version_requirement" => "~3.0.0" }]
|
267
|
+
}
|
268
|
+
)
|
269
|
+
|
270
|
+
env.module_requirements.should == {
|
271
|
+
'puppetlabs/alpha' => [],
|
272
|
+
'puppetlabs/foo' => [
|
273
|
+
{
|
274
|
+
"name" => "puppetlabs/bar",
|
275
|
+
"version" => "9.9.9",
|
276
|
+
"version_requirement" => "<= 2.0.0"
|
277
|
+
}
|
278
|
+
],
|
279
|
+
'puppetlabs/bar' => [
|
280
|
+
{
|
281
|
+
"name" => "puppetlabs/alpha",
|
282
|
+
"version" => "9.9.9",
|
283
|
+
"version_requirement" => "~3.0.0"
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"name" => "puppetlabs/baz",
|
287
|
+
"version" => "9.9.9",
|
288
|
+
"version_requirement" => "3.0.0"
|
289
|
+
},
|
290
|
+
{
|
291
|
+
"name" => "puppetlabs/foo",
|
292
|
+
"version" => "9.9.9",
|
293
|
+
"version_requirement" => ">= 1.0.0"
|
294
|
+
}
|
295
|
+
],
|
296
|
+
'puppetlabs/baz' => []
|
297
|
+
}
|
298
|
+
end
|
345
299
|
end
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
300
|
+
|
301
|
+
describe ".module_by_forge_name" do
|
302
|
+
it "should find modules by forge_name" do
|
303
|
+
mod = PuppetSpec::Modules.create(
|
304
|
+
'baz',
|
305
|
+
@first,
|
306
|
+
:metadata => {:author => 'puppetlabs'},
|
307
|
+
:environment => env
|
308
|
+
)
|
309
|
+
env.module_by_forge_name('puppetlabs/baz').should == mod
|
310
|
+
end
|
311
|
+
|
312
|
+
it "should not find modules with same name by the wrong author" do
|
313
|
+
mod = PuppetSpec::Modules.create(
|
314
|
+
'baz',
|
315
|
+
@first,
|
316
|
+
:metadata => {:author => 'sneakylabs'},
|
317
|
+
:environment => env
|
318
|
+
)
|
319
|
+
env.module_by_forge_name('puppetlabs/baz').should == nil
|
320
|
+
end
|
321
|
+
|
322
|
+
it "should return nil when the module can't be found" do
|
323
|
+
env.module_by_forge_name('ima/nothere').should be_nil
|
324
|
+
end
|
356
325
|
end
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
326
|
+
|
327
|
+
describe ".modules" do
|
328
|
+
it "should return an empty list if there are no modules" do
|
329
|
+
env.modules.should == []
|
330
|
+
end
|
331
|
+
|
332
|
+
it "should return a module named for every directory in each module path" do
|
333
|
+
%w{foo bar}.each do |mod_name|
|
334
|
+
FileUtils.mkdir_p(File.join(@first, mod_name))
|
335
|
+
end
|
336
|
+
%w{bee baz}.each do |mod_name|
|
337
|
+
FileUtils.mkdir_p(File.join(@second, mod_name))
|
338
|
+
end
|
339
|
+
env.modules.collect{|mod| mod.name}.sort.should == %w{foo bar bee baz}.sort
|
340
|
+
end
|
341
|
+
|
342
|
+
it "should remove duplicates" do
|
343
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
344
|
+
FileUtils.mkdir_p(File.join(@second, 'foo'))
|
345
|
+
|
346
|
+
env.modules.collect{|mod| mod.name}.sort.should == %w{foo}
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should ignore modules with invalid names" do
|
350
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
351
|
+
FileUtils.mkdir_p(File.join(@first, 'foo2'))
|
352
|
+
FileUtils.mkdir_p(File.join(@first, 'foo-bar'))
|
353
|
+
FileUtils.mkdir_p(File.join(@first, 'foo_bar'))
|
354
|
+
FileUtils.mkdir_p(File.join(@first, 'foo=bar'))
|
355
|
+
FileUtils.mkdir_p(File.join(@first, 'foo bar'))
|
356
|
+
|
357
|
+
env.modules.collect{|mod| mod.name}.sort.should == %w{foo foo-bar foo2 foo_bar}
|
358
|
+
end
|
359
|
+
|
360
|
+
it "should create modules with the correct environment" do
|
361
|
+
FileUtils.mkdir_p(File.join(@first, 'foo'))
|
362
|
+
env.modules.each {|mod| mod.environment.should == env }
|
363
|
+
end
|
364
|
+
|
361
365
|
end
|
362
|
-
|
366
|
+
end
|
367
|
+
|
368
|
+
it "should cache the module list" do
|
369
|
+
env.modulepath = %w{/a}
|
370
|
+
Dir.expects(:entries).once.with("/a").returns %w{foo}
|
371
|
+
|
372
|
+
env.modules
|
373
|
+
env.modules
|
363
374
|
end
|
364
375
|
end
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
it "should accept an environment directly" do
|
387
|
-
@helper.environment = Puppet::Node::Environment.new(:foo)
|
388
|
-
@helper.environment.name.should == :foo
|
376
|
+
|
377
|
+
describe Puppet::Node::Environment::Helper do
|
378
|
+
before do
|
379
|
+
@helper = Object.new
|
380
|
+
@helper.extend(Puppet::Node::Environment::Helper)
|
381
|
+
end
|
382
|
+
|
383
|
+
it "should be able to set and retrieve the environment as a symbol" do
|
384
|
+
@helper.environment = :foo
|
385
|
+
@helper.environment.name.should == :foo
|
386
|
+
end
|
387
|
+
|
388
|
+
it "should accept an environment directly" do
|
389
|
+
@helper.environment = Puppet::Node::Environment.new(:foo)
|
390
|
+
@helper.environment.name.should == :foo
|
391
|
+
end
|
392
|
+
|
393
|
+
it "should accept an environment as a string" do
|
394
|
+
@helper.environment = 'foo'
|
395
|
+
@helper.environment.name.should == :foo
|
396
|
+
end
|
389
397
|
end
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
398
|
+
|
399
|
+
describe "when performing initial import" do
|
400
|
+
before do
|
401
|
+
@parser = Puppet::Parser::ParserFactory.parser("test")
|
402
|
+
# @parser = Puppet::Parser::EParserAdapter.new(Puppet::Parser::Parser.new("test")) # TODO: FIX PARSER FACTORY
|
403
|
+
Puppet::Parser::ParserFactory.stubs(:parser).returns @parser
|
404
|
+
end
|
405
|
+
|
406
|
+
it "should set the parser's string to the 'code' setting and parse if code is available" do
|
407
|
+
Puppet.settings[:code] = "my code"
|
408
|
+
@parser.expects(:string=).with "my code"
|
409
|
+
@parser.expects(:parse)
|
410
|
+
env.instance_eval { perform_initial_import }
|
411
|
+
end
|
412
|
+
|
413
|
+
it "should set the parser's file to the 'manifest' setting and parse if no code is available and the manifest is available" do
|
414
|
+
filename = tmpfile('myfile')
|
415
|
+
File.open(filename, 'w'){|f| }
|
416
|
+
Puppet.settings[:manifest] = filename
|
417
|
+
@parser.expects(:file=).with filename
|
418
|
+
@parser.expects(:parse)
|
419
|
+
env.instance_eval { perform_initial_import }
|
420
|
+
end
|
421
|
+
|
422
|
+
it "should pass the manifest file to the parser even if it does not exist on disk" do
|
423
|
+
filename = tmpfile('myfile')
|
424
|
+
Puppet.settings[:code] = ""
|
425
|
+
Puppet.settings[:manifest] = filename
|
426
|
+
@parser.expects(:file=).with(filename).once
|
427
|
+
@parser.expects(:parse).once
|
428
|
+
env.instance_eval { perform_initial_import }
|
429
|
+
end
|
430
|
+
|
431
|
+
it "should fail helpfully if there is an error importing" do
|
432
|
+
File.stubs(:exist?).returns true
|
433
|
+
env.stubs(:known_resource_types).returns Puppet::Resource::TypeCollection.new(env)
|
434
|
+
@parser.expects(:file=).once
|
435
|
+
@parser.expects(:parse).raises ArgumentError
|
436
|
+
lambda { env.instance_eval { perform_initial_import } }.should raise_error(Puppet::Error)
|
437
|
+
end
|
438
|
+
|
439
|
+
it "should not do anything if the ignore_import settings is set" do
|
440
|
+
Puppet.settings[:ignoreimport] = true
|
441
|
+
@parser.expects(:string=).never
|
442
|
+
@parser.expects(:file=).never
|
443
|
+
@parser.expects(:parse).never
|
444
|
+
env.instance_eval { perform_initial_import }
|
445
|
+
end
|
446
|
+
|
447
|
+
it "should mark the type collection as needing a reparse when there is an error parsing" do
|
448
|
+
@parser.expects(:parse).raises Puppet::ParseError.new("Syntax error at ...")
|
449
|
+
env.stubs(:known_resource_types).returns Puppet::Resource::TypeCollection.new(env)
|
450
|
+
|
451
|
+
lambda { env.instance_eval { perform_initial_import } }.should raise_error(Puppet::Error, /Syntax error at .../)
|
452
|
+
env.known_resource_types.require_reparse?.should be_true
|
453
|
+
end
|
394
454
|
end
|
395
455
|
end
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
@parser = Puppet::Parser::Parser.new("test")
|
400
|
-
Puppet::Parser::Parser.stubs(:new).returns @parser
|
401
|
-
end
|
402
|
-
|
403
|
-
it "should set the parser's string to the 'code' setting and parse if code is available" do
|
404
|
-
Puppet.settings[:code] = "my code"
|
405
|
-
@parser.expects(:string=).with "my code"
|
406
|
-
@parser.expects(:parse)
|
407
|
-
env.instance_eval { perform_initial_import }
|
408
|
-
end
|
409
|
-
|
410
|
-
it "should set the parser's file to the 'manifest' setting and parse if no code is available and the manifest is available" do
|
411
|
-
filename = tmpfile('myfile')
|
412
|
-
File.open(filename, 'w'){|f| }
|
413
|
-
Puppet.settings[:manifest] = filename
|
414
|
-
@parser.expects(:file=).with filename
|
415
|
-
@parser.expects(:parse)
|
416
|
-
env.instance_eval { perform_initial_import }
|
417
|
-
end
|
418
|
-
|
419
|
-
it "should pass the manifest file to the parser even if it does not exist on disk" do
|
420
|
-
filename = tmpfile('myfile')
|
421
|
-
Puppet.settings[:code] = ""
|
422
|
-
Puppet.settings[:manifest] = filename
|
423
|
-
@parser.expects(:file=).with(filename).once
|
424
|
-
@parser.expects(:parse).once
|
425
|
-
env.instance_eval { perform_initial_import }
|
426
|
-
end
|
427
|
-
|
428
|
-
it "should fail helpfully if there is an error importing" do
|
429
|
-
File.stubs(:exist?).returns true
|
430
|
-
env.stubs(:known_resource_types).returns Puppet::Resource::TypeCollection.new(env)
|
431
|
-
@parser.expects(:file=).once
|
432
|
-
@parser.expects(:parse).raises ArgumentError
|
433
|
-
lambda { env.instance_eval { perform_initial_import } }.should raise_error(Puppet::Error)
|
434
|
-
end
|
435
|
-
|
436
|
-
it "should not do anything if the ignore_import settings is set" do
|
437
|
-
Puppet.settings[:ignoreimport] = true
|
438
|
-
@parser.expects(:string=).never
|
439
|
-
@parser.expects(:file=).never
|
440
|
-
@parser.expects(:parse).never
|
441
|
-
env.instance_eval { perform_initial_import }
|
456
|
+
describe 'with classic parser' do
|
457
|
+
before :each do
|
458
|
+
Puppet[:parser] = 'current'
|
442
459
|
end
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
lambda { env.instance_eval { perform_initial_import } }.should raise_error(Puppet::Error, /Syntax error at .../)
|
449
|
-
env.known_resource_types.require_reparse?.should be_true
|
460
|
+
it_behaves_like 'the environment'
|
461
|
+
end
|
462
|
+
describe 'with future parser' do
|
463
|
+
before :each do
|
464
|
+
Puppet[:parser] = 'future'
|
450
465
|
end
|
466
|
+
it_behaves_like 'the environment'
|
451
467
|
end
|
468
|
+
|
452
469
|
end
|