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
@@ -86,7 +86,7 @@ describe Puppet::Type.type(:exec).provider(:posix) do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should not be able to execute shell builtins" do
|
89
|
-
provider.resource[:path] = ['']
|
89
|
+
provider.resource[:path] = ['/bogus/bin']
|
90
90
|
expect { provider.run("cd ..") }.to raise_error(ArgumentError, "Could not find command 'cd'")
|
91
91
|
end
|
92
92
|
|
@@ -6,22 +6,27 @@ describe Puppet::Type.type(:group).provider(:groupadd) do
|
|
6
6
|
described_class.stubs(:command).with(:add).returns '/usr/sbin/groupadd'
|
7
7
|
described_class.stubs(:command).with(:delete).returns '/usr/sbin/groupdel'
|
8
8
|
described_class.stubs(:command).with(:modify).returns '/usr/sbin/groupmod'
|
9
|
+
described_class.stubs(:command).with(:localadd).returns '/usr/sbin/lgroupadd'
|
9
10
|
end
|
10
11
|
|
11
12
|
let(:resource) { Puppet::Type.type(:group).new(:name => 'mygroup', :provider => provider) }
|
12
13
|
let(:provider) { described_class.new(:name => 'mygroup') }
|
13
14
|
|
14
15
|
describe "#create" do
|
16
|
+
before do
|
17
|
+
provider.stubs(:exists?).returns(false)
|
18
|
+
end
|
19
|
+
|
15
20
|
it "should add -o when allowdupe is enabled and the group is being created" do
|
16
21
|
resource[:allowdupe] = :true
|
17
|
-
provider.expects(:execute).with(['/usr/sbin/groupadd', '-o', 'mygroup'])
|
22
|
+
provider.expects(:execute).with(['/usr/sbin/groupadd', '-o', 'mygroup'], kind_of(Hash))
|
18
23
|
provider.create
|
19
24
|
end
|
20
25
|
|
21
26
|
describe "on system that feature system_groups", :if => described_class.system_groups? do
|
22
27
|
it "should add -r when system is enabled and the group is being created" do
|
23
28
|
resource[:system] = :true
|
24
|
-
provider.expects(:execute).with(['/usr/sbin/groupadd', '-r', 'mygroup'])
|
29
|
+
provider.expects(:execute).with(['/usr/sbin/groupadd', '-r', 'mygroup'], kind_of(Hash))
|
25
30
|
provider.create
|
26
31
|
end
|
27
32
|
end
|
@@ -29,10 +34,35 @@ describe Puppet::Type.type(:group).provider(:groupadd) do
|
|
29
34
|
describe "on system that do not feature system_groups", :unless => described_class.system_groups? do
|
30
35
|
it "should not add -r when system is enabled and the group is being created" do
|
31
36
|
resource[:system] = :true
|
32
|
-
provider.expects(:execute).with(['/usr/sbin/groupadd', 'mygroup'])
|
37
|
+
provider.expects(:execute).with(['/usr/sbin/groupadd', 'mygroup'], kind_of(Hash))
|
38
|
+
provider.create
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "on systems with the libuser and forcelocal=true" do
|
43
|
+
before do
|
44
|
+
described_class.has_feature(:libuser)
|
45
|
+
resource[:forcelocal] = :true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should use lgroupadd instead of groupadd" do
|
49
|
+
provider.expects(:execute).with(includes('/usr/sbin/lgroupadd'), has_entry(:custom_environment, has_key('LIBUSER_CONF')))
|
50
|
+
provider.create
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should NOT pass -o to lgroupadd" do
|
54
|
+
resource[:allowdupe] = :true
|
55
|
+
provider.expects(:execute).with(Not(includes('-o')), has_entry(:custom_environment, has_key('LIBUSER_CONF')))
|
33
56
|
provider.create
|
34
57
|
end
|
58
|
+
|
59
|
+
it "should raise an exception for duplicate GID if allowdupe is not set and duplicate GIDs exist" do
|
60
|
+
resource[:gid] = 505
|
61
|
+
provider.stubs(:findgroup).returns(true)
|
62
|
+
lambda { provider.create }.should raise_error(Puppet::Error, "GID 505 already exists, use allowdupe to force group creation")
|
63
|
+
end
|
35
64
|
end
|
65
|
+
|
36
66
|
end
|
37
67
|
|
38
68
|
describe "#gid=" do
|
@@ -21,31 +21,31 @@ describe provider_class do
|
|
21
21
|
|
22
22
|
it "should run pw with no additional flags when no properties are given" do
|
23
23
|
provider.addcmd.must == [provider_class.command(:pw), "groupadd", "testgroup"]
|
24
|
-
provider.expects(:execute).with([provider_class.command(:pw), "groupadd", "testgroup"])
|
24
|
+
provider.expects(:execute).with([provider_class.command(:pw), "groupadd", "testgroup"], kind_of(Hash))
|
25
25
|
provider.create
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should use -o when allowdupe is enabled" do
|
29
29
|
resource[:allowdupe] = true
|
30
|
-
provider.expects(:execute).with(includes("-o"))
|
30
|
+
provider.expects(:execute).with(includes("-o"), kind_of(Hash))
|
31
31
|
provider.create
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should use -g with the correct argument when the gid property is set" do
|
35
35
|
resource[:gid] = 12345
|
36
|
-
provider.expects(:execute).with(all_of(includes("-g"), includes(12345)))
|
36
|
+
provider.expects(:execute).with(all_of(includes("-g"), includes(12345)), kind_of(Hash))
|
37
37
|
provider.create
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should use -M with the correct argument when the members property is set" do
|
41
41
|
resource[:members] = "user1"
|
42
|
-
provider.expects(:execute).with(all_of(includes("-M"), includes("user1")))
|
42
|
+
provider.expects(:execute).with(all_of(includes("-M"), includes("user1")), kind_of(Hash))
|
43
43
|
provider.create
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should use -M with all the given users when the members property is set to an array" do
|
47
47
|
resource[:members] = ["user1", "user2"]
|
48
|
-
provider.expects(:execute).with(all_of(includes("-M"), includes("user1,user2")))
|
48
|
+
provider.expects(:execute).with(all_of(includes("-M"), includes("user1,user2")), kind_of(Hash))
|
49
49
|
provider.create
|
50
50
|
end
|
51
51
|
end
|
@@ -0,0 +1,304 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'puppet/provider/nameservice'
|
5
|
+
require 'etc'
|
6
|
+
|
7
|
+
describe Puppet::Provider::NameService do
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
described_class.initvars
|
11
|
+
described_class.resource_type = faketype
|
12
|
+
end
|
13
|
+
|
14
|
+
# These are values getpwent might give you
|
15
|
+
let :users do
|
16
|
+
[
|
17
|
+
Struct::Passwd.new('root', 'x', 0, 0),
|
18
|
+
Struct::Passwd.new('foo', 'x', 1000, 2000),
|
19
|
+
nil
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
# These are values getgrent might give you
|
24
|
+
let :groups do
|
25
|
+
[
|
26
|
+
Struct::Group.new('root', 'x', 0, %w{root}),
|
27
|
+
Struct::Group.new('bin', 'x', 1, %w{root bin daemon}),
|
28
|
+
nil
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
# A fake struct besides Struct::Group and Struct::Passwd
|
33
|
+
let :fakestruct do
|
34
|
+
Struct.new(:foo, :bar)
|
35
|
+
end
|
36
|
+
|
37
|
+
# A fake value get<foo>ent might return
|
38
|
+
let :fakeetcobject do
|
39
|
+
fakestruct.new('fooval', 'barval')
|
40
|
+
end
|
41
|
+
|
42
|
+
# The provider sometimes relies on @resource for valid properties so let's
|
43
|
+
# create a fake type with properties that match our fake struct.
|
44
|
+
let :faketype do
|
45
|
+
Puppet::Type.newtype(:nameservice_dummytype) do
|
46
|
+
newparam(:name)
|
47
|
+
ensurable
|
48
|
+
newproperty(:foo)
|
49
|
+
newproperty(:bar)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
let :provider do
|
54
|
+
described_class.new(:name => 'bob', :foo => 'fooval', :bar => 'barval')
|
55
|
+
end
|
56
|
+
|
57
|
+
let :resource do
|
58
|
+
resource = faketype.new(:name => 'bob', :ensure => :present)
|
59
|
+
resource.provider = provider
|
60
|
+
resource
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#options" do
|
64
|
+
it "should add options for a valid property" do
|
65
|
+
described_class.options :foo, :key1 => 'val1', :key2 => 'val2'
|
66
|
+
described_class.options :bar, :key3 => 'val3'
|
67
|
+
described_class.option(:foo, :key1).should == 'val1'
|
68
|
+
described_class.option(:foo, :key2).should == 'val2'
|
69
|
+
described_class.option(:bar, :key3).should == 'val3'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should raise an error for an invalid property" do
|
73
|
+
expect { described_class.options :baz, :key1 => 'val1' }.to raise_error(
|
74
|
+
Puppet::Error, 'baz is not a valid attribute for nameservice_dummytype')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#option" do
|
79
|
+
it "should return the correct value" do
|
80
|
+
described_class.options :foo, :key1 => 'val1', :key2 => 'val2'
|
81
|
+
described_class.option(:foo, :key2).should == 'val2'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should symbolize the name first" do
|
85
|
+
described_class.options :foo, :key1 => 'val1', :key2 => 'val2'
|
86
|
+
described_class.option('foo', :key2).should == 'val2'
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return nil if no option has been specified earlier" do
|
90
|
+
described_class.option(:foo, :key2).should be_nil
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return nil if no option for that property has been specified earlier" do
|
94
|
+
described_class.options :bar, :key2 => 'val2'
|
95
|
+
described_class.option(:foo, :key2).should be_nil
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should return nil if no matching key can be found for that property" do
|
99
|
+
described_class.options :foo, :key3 => 'val2'
|
100
|
+
described_class.option(:foo, :key2).should be_nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#section" do
|
105
|
+
it "should raise an error if resource_type has not been set" do
|
106
|
+
described_class.expects(:resource_type).returns nil
|
107
|
+
expect { described_class.section }.to raise_error Puppet::Error, 'Cannot determine Etc section without a resource type'
|
108
|
+
end
|
109
|
+
|
110
|
+
# the return values are hard coded so I am using types that actually make
|
111
|
+
# use of the nameservice provider
|
112
|
+
it "should return pw for users" do
|
113
|
+
described_class.resource_type = Puppet::Type.type(:user)
|
114
|
+
described_class.section.should == 'pw'
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return gr for groups" do
|
118
|
+
described_class.resource_type = Puppet::Type.type(:group)
|
119
|
+
described_class.section.should == 'gr'
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#listbyname" do
|
124
|
+
it "should return a list of users if resource_type is user" do
|
125
|
+
described_class.resource_type = Puppet::Type.type(:user)
|
126
|
+
Etc.expects(:setpwent)
|
127
|
+
Etc.stubs(:getpwent).returns *users
|
128
|
+
Etc.expects(:endpwent)
|
129
|
+
described_class.listbyname.should == %w{root foo}
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should return a list of groups if resource_type is group", :unless => Puppet.features.microsoft_windows? do
|
133
|
+
described_class.resource_type = Puppet::Type.type(:group)
|
134
|
+
Etc.expects(:setgrent)
|
135
|
+
Etc.stubs(:getgrent).returns *groups
|
136
|
+
Etc.expects(:endgrent)
|
137
|
+
described_class.listbyname.should == %w{root bin}
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should yield if a block given" do
|
141
|
+
yield_results = []
|
142
|
+
described_class.resource_type = Puppet::Type.type(:user)
|
143
|
+
Etc.expects(:setpwent)
|
144
|
+
Etc.stubs(:getpwent).returns *users
|
145
|
+
Etc.expects(:endpwent)
|
146
|
+
described_class.listbyname {|x| yield_results << x }
|
147
|
+
yield_results.should == %w{root foo}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "instances" do
|
152
|
+
it "should return a list of objects based on listbyname" do
|
153
|
+
described_class.expects(:listbyname).multiple_yields 'root', 'foo', 'nobody'
|
154
|
+
described_class.instances.map(&:name).should == %w{root foo nobody}
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "validate" do
|
159
|
+
it "should pass if no check is registered at all" do
|
160
|
+
expect { described_class.validate(:foo, 300) }.to_not raise_error
|
161
|
+
expect { described_class.validate('foo', 300) }.to_not raise_error
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should pass if no check for that property is registered" do
|
165
|
+
described_class.verify(:bar, 'Must be 100') { |val| val == 100 }
|
166
|
+
expect { described_class.validate(:foo, 300) }.to_not raise_error
|
167
|
+
expect { described_class.validate('foo', 300) }.to_not raise_error
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should pass if the value is valid" do
|
171
|
+
described_class.verify(:foo, 'Must be 100') { |val| val == 100 }
|
172
|
+
expect { described_class.validate(:foo, 100) }.to_not raise_error
|
173
|
+
expect { described_class.validate('foo', 100) }.to_not raise_error
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should raise an error if the value is invalid" do
|
177
|
+
described_class.verify(:foo, 'Must be 100') { |val| val == 100 }
|
178
|
+
expect { described_class.validate(:foo, 200) }.to raise_error(ArgumentError, 'Invalid value 200: Must be 100')
|
179
|
+
expect { described_class.validate('foo', 200) }.to raise_error(ArgumentError, 'Invalid value 200: Must be 100')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "getinfo" do
|
184
|
+
before :each do
|
185
|
+
# with section=foo we'll call Etc.getfoonam instead of getpwnam or getgrnam
|
186
|
+
described_class.stubs(:section).returns 'foo'
|
187
|
+
resource # initialize the resource so our provider has a @resource instance variable
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should return a hash if we can retrieve something" do
|
191
|
+
Etc.expects(:send).with(:getfoonam, 'bob').returns fakeetcobject
|
192
|
+
provider.expects(:info2hash).with(fakeetcobject).returns(:foo => 'fooval', :bar => 'barval')
|
193
|
+
provider.getinfo(true).should == {:foo => 'fooval', :bar => 'barval'}
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should return nil if we cannot retrieve anything" do
|
197
|
+
Etc.expects(:send).with(:getfoonam, 'bob').raises(ArgumentError, "can't find bob")
|
198
|
+
provider.expects(:info2hash).never
|
199
|
+
provider.getinfo(true).should be_nil
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe "info2hash" do
|
204
|
+
it "should return a hash with all properties" do
|
205
|
+
# we have to have an implementation of posixmethod which has to
|
206
|
+
# convert a propertyname (e.g. comment) into a fieldname of our
|
207
|
+
# Struct (e.g. gecos). I do not want to test posixmethod here so
|
208
|
+
# let's fake an implementation which does not do any translation. We
|
209
|
+
# expect two method invocations because info2hash calls the method
|
210
|
+
# twice if the Struct responds to the propertyname (our fake Struct
|
211
|
+
# provides values for :foo and :bar) TODO: Fix that
|
212
|
+
provider.expects(:posixmethod).with(:foo).returns(:foo).twice
|
213
|
+
provider.expects(:posixmethod).with(:bar).returns(:bar).twice
|
214
|
+
provider.expects(:posixmethod).with(:ensure).returns :ensure
|
215
|
+
provider.info2hash(fakeetcobject).should == { :foo => 'fooval', :bar => 'barval' }
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "munge" do
|
220
|
+
it "should return the input value if no munge method has be defined" do
|
221
|
+
provider.munge(:foo, 100).should == 100
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should return the munged value otherwise" do
|
225
|
+
described_class.options(:foo, :munge => proc { |x| x*2 })
|
226
|
+
provider.munge(:foo, 100).should == 200
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "unmunge" do
|
231
|
+
it "should return the input value if no unmunge method has been defined" do
|
232
|
+
provider.unmunge(:foo, 200).should == 200
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should return the unmunged value otherwise" do
|
236
|
+
described_class.options(:foo, :unmunge => proc { |x| x/2 })
|
237
|
+
provider.unmunge(:foo, 200).should == 100
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
describe "exists?" do
|
243
|
+
it "should return true if we can retrieve anything" do
|
244
|
+
provider.expects(:getinfo).with(true).returns(:foo => 'fooval', :bar => 'barval')
|
245
|
+
provider.should be_exists
|
246
|
+
end
|
247
|
+
it "should return false if we cannot retrieve anything" do
|
248
|
+
provider.expects(:getinfo).with(true).returns nil
|
249
|
+
provider.should_not be_exists
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
describe "get" do
|
254
|
+
before(:each) {described_class.resource_type = faketype }
|
255
|
+
|
256
|
+
it "should return the correct getinfo value" do
|
257
|
+
provider.expects(:getinfo).with(false).returns(:foo => 'fooval', :bar => 'barval')
|
258
|
+
provider.get(:bar).should == 'barval'
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should unmunge the value first" do
|
262
|
+
described_class.options(:bar, :munge => proc { |x| x*2}, :unmunge => proc {|x| x/2})
|
263
|
+
provider.expects(:getinfo).with(false).returns(:foo => 200, :bar => 500)
|
264
|
+
provider.get(:bar).should == 250
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should return nil if getinfo cannot retrieve the value" do
|
268
|
+
provider.expects(:getinfo).with(false).returns(:foo => 'fooval', :bar => 'barval')
|
269
|
+
provider.get(:no_such_key).should be_nil
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
describe "set" do
|
275
|
+
before :each do
|
276
|
+
resource # initialize resource so our provider has a @resource object
|
277
|
+
described_class.verify(:foo, 'Must be 100') { |val| val == 100 }
|
278
|
+
end
|
279
|
+
|
280
|
+
it "should raise an error on invalid values" do
|
281
|
+
expect { provider.set(:foo, 200) }.to raise_error(ArgumentError, 'Invalid value 200: Must be 100')
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should execute the modify command on valid values" do
|
285
|
+
provider.expects(:modifycmd).with(:foo, 100).returns ['/bin/modify', '-f', '100' ]
|
286
|
+
provider.expects(:execute).with ['/bin/modify', '-f', '100']
|
287
|
+
provider.set(:foo, 100)
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should munge the value first" do
|
291
|
+
described_class.options(:foo, :munge => proc { |x| x*2}, :unmunge => proc {|x| x/2})
|
292
|
+
provider.expects(:modifycmd).with(:foo, 200).returns ['/bin/modify', '-f', '200' ]
|
293
|
+
provider.expects(:execute).with ['/bin/modify', '-f', '200']
|
294
|
+
provider.set(:foo, 100)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should fail if the modify command fails" do
|
298
|
+
provider.expects(:modifycmd).with(:foo, 100).returns ['/bin/modify', '-f', '100' ]
|
299
|
+
provider.expects(:execute).with(['/bin/modify', '-f', '100']).raises(Puppet::ExecutionFailure, "Execution of '/bin/modify' returned 1: some_failure")
|
300
|
+
expect { provider.set(:foo, 100) }.to raise_error Puppet::Error, /Could not set foo/
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
@@ -6,18 +6,9 @@ provider_class = Puppet::Type.type(:package).provider(:aix)
|
|
6
6
|
describe provider_class do
|
7
7
|
before(:each) do
|
8
8
|
# Create a mock resource
|
9
|
-
@resource =
|
9
|
+
@resource = Puppet::Type.type(:package).new(:name => 'mypackage', :ensure => :installed, :source => 'mysource', :provider => :aix)
|
10
10
|
|
11
|
-
|
12
|
-
@resource.stubs(:[]).returns(nil)
|
13
|
-
|
14
|
-
# But set name and source
|
15
|
-
@resource.stubs(:[]).with(:name).returns "mypackage"
|
16
|
-
@resource.stubs(:[]).with(:source).returns "mysource"
|
17
|
-
@resource.stubs(:[]).with(:ensure).returns :installed
|
18
|
-
|
19
|
-
@provider = provider_class.new
|
20
|
-
@provider.resource = @resource
|
11
|
+
@provider = @resource.provider
|
21
12
|
end
|
22
13
|
|
23
14
|
[:install, :uninstall, :latest, :query, :update].each do |method|
|
@@ -28,6 +19,7 @@ describe provider_class do
|
|
28
19
|
|
29
20
|
it "should uninstall a package" do
|
30
21
|
@provider.expects(:installp).with('-gu', 'mypackage')
|
22
|
+
@provider.class.expects(:pkglist).with(:pkgname => 'mypackage').returns(nil)
|
31
23
|
@provider.uninstall
|
32
24
|
end
|
33
25
|
|
@@ -43,6 +35,56 @@ describe provider_class do
|
|
43
35
|
@provider.expects(:installp).with('-acgwXY', '-d', 'mysource', 'mypackage 1.2.3.4')
|
44
36
|
@provider.install
|
45
37
|
end
|
38
|
+
|
39
|
+
it "should fail if the specified version is superseded" do
|
40
|
+
@resource[:ensure] = '1.2.3.3'
|
41
|
+
@provider.stubs(:installp).returns <<-OUTPUT
|
42
|
+
+-----------------------------------------------------------------------------+
|
43
|
+
Pre-installation Verification...
|
44
|
+
+-----------------------------------------------------------------------------+
|
45
|
+
Verifying selections...done
|
46
|
+
Verifying requisites...done
|
47
|
+
Results...
|
48
|
+
|
49
|
+
WARNINGS
|
50
|
+
--------
|
51
|
+
Problems described in this section are not likely to be the source of any
|
52
|
+
immediate or serious failures, but further actions may be necessary or
|
53
|
+
desired.
|
54
|
+
|
55
|
+
Already Installed
|
56
|
+
-----------------
|
57
|
+
The number of selected filesets that are either already installed
|
58
|
+
or effectively installed through superseding filesets is 1. See
|
59
|
+
the summaries at the end of this installation for details.
|
60
|
+
|
61
|
+
NOTE: Base level filesets may be reinstalled using the "Force"
|
62
|
+
option (-F flag), or they may be removed, using the deinstall or
|
63
|
+
"Remove Software Products" facility (-u flag), and then reinstalled.
|
64
|
+
|
65
|
+
<< End of Warning Section >>
|
66
|
+
|
67
|
+
+-----------------------------------------------------------------------------+
|
68
|
+
BUILDDATE Verification ...
|
69
|
+
+-----------------------------------------------------------------------------+
|
70
|
+
Verifying build dates...done
|
71
|
+
FILESET STATISTICS
|
72
|
+
------------------
|
73
|
+
1 Selected to be installed, of which:
|
74
|
+
1 Already installed (directly or via superseding filesets)
|
75
|
+
----
|
76
|
+
0 Total to be installed
|
77
|
+
|
78
|
+
|
79
|
+
Pre-installation Failure/Warning Summary
|
80
|
+
----------------------------------------
|
81
|
+
Name Level Pre-installation Failure/Warning
|
82
|
+
-------------------------------------------------------------------------------
|
83
|
+
mypackage 1.2.3.3 Already superseded by 1.2.3.4
|
84
|
+
OUTPUT
|
85
|
+
|
86
|
+
expect { @provider.install }.to raise_error(Puppet::Error, "aix package provider is unable to downgrade packages")
|
87
|
+
end
|
46
88
|
end
|
47
89
|
|
48
90
|
describe "when finding the latest version" do
|