puppet 3.3.2 → 3.4.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 +22 -0
- data/Gemfile +11 -2
- data/README.md +13 -17
- data/README_DEVELOPER.md +1 -1
- data/Rakefile +1 -1
- data/examples/hiera/README.md +4 -4
- data/ext/debian/puppetmaster.init +1 -0
- data/ext/debian/rules +2 -5
- data/ext/nagios/check_puppet.rb +7 -7
- data/ext/osx/file_mapping.yaml +1 -1
- data/ext/osx/preflight.erb +34 -19
- data/ext/rack/{files/config.ru → config.ru} +0 -0
- data/ext/rack/{files/apache2.conf → example-passenger-vhost.conf} +6 -0
- data/ext/redhat/puppet.spec.erb +20 -2
- data/ext/systemd/{puppetagent.service → puppet.service} +0 -0
- data/lib/hiera_puppet.rb +2 -2
- data/lib/puppet/agent.rb +1 -6
- data/lib/puppet/application.rb +15 -2
- data/lib/puppet/application/agent.rb +2 -7
- data/lib/puppet/application/apply.rb +8 -13
- data/lib/puppet/application/cert.rb +47 -7
- data/lib/puppet/application/device.rb +1 -6
- data/lib/puppet/application/face_base.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +3 -12
- data/lib/puppet/application/master.rb +1 -6
- data/lib/puppet/application/queue.rb +1 -6
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/coercion.rb +11 -0
- data/lib/puppet/configurer.rb +5 -3
- data/lib/puppet/configurer/downloader.rb +3 -1
- data/lib/puppet/configurer/plugin_handler.rb +10 -0
- data/lib/puppet/confine.rb +80 -0
- data/lib/puppet/{provider/confine → confine}/exists.rb +3 -3
- data/lib/puppet/{provider/confine → confine}/false.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/feature.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/true.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/variable.rb +2 -2
- data/lib/puppet/{provider/confine_collection.rb → confine_collection.rb} +4 -4
- data/lib/puppet/{provider/confiner.rb → confiner.rb} +4 -4
- data/lib/puppet/daemon.rb +2 -6
- data/lib/puppet/data_binding.rb +2 -30
- data/lib/puppet/defaults.rb +283 -174
- data/lib/puppet/error.rb +1 -0
- data/lib/puppet/external/nagios.rb +0 -2
- data/lib/puppet/external/nagios/base.rb +4 -3
- data/lib/puppet/external/nagios/grammar.ry +173 -112
- data/lib/puppet/external/nagios/parser.rb +233 -184
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/generate.rb +5 -7
- data/lib/puppet/face/parser.rb +12 -2
- data/lib/puppet/face/plugin.rb +6 -0
- data/lib/puppet/feature/base.rb +16 -0
- data/lib/puppet/feature/external_facts.rb +5 -0
- data/lib/puppet/feature/libuser.rb +1 -1
- data/lib/puppet/feature/msgpack.rb +1 -0
- data/lib/puppet/feature/rails.rb +2 -2
- data/lib/puppet/file_bucket/dipper.rb +8 -6
- data/lib/puppet/file_bucket/file.rb +17 -1
- data/lib/puppet/file_serving/base.rb +21 -10
- data/lib/puppet/file_serving/configuration.rb +5 -7
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +3 -3
- data/lib/puppet/file_serving/metadata.rb +22 -18
- data/lib/puppet/file_serving/mount/file.rb +1 -1
- data/lib/puppet/file_serving/mount/pluginfacts.rb +35 -0
- data/lib/puppet/file_system.rb +3 -0
- data/lib/puppet/file_system/file.rb +261 -0
- data/lib/puppet/file_system/file18.rb +5 -0
- data/lib/puppet/file_system/file19.rb +5 -0
- data/lib/puppet/file_system/file19windows.rb +113 -0
- data/lib/puppet/file_system/memory_file.rb +31 -0
- data/lib/puppet/file_system/tempfile.rb +20 -0
- data/lib/puppet/indirector/active_record.rb +1 -0
- data/lib/puppet/indirector/catalog/compiler.rb +28 -0
- data/lib/puppet/indirector/certificate_request/memory.rb +6 -0
- data/lib/puppet/indirector/data_binding/hiera.rb +46 -2
- data/lib/puppet/indirector/direct_file_server.rb +2 -2
- data/lib/puppet/indirector/facts/facter.rb +25 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +60 -74
- data/lib/puppet/indirector/indirection.rb +5 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/key/ca.rb +4 -0
- data/lib/puppet/indirector/key/file.rb +7 -3
- data/lib/puppet/indirector/key/memory.rb +6 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +2 -2
- data/lib/puppet/indirector/request.rb +17 -11
- data/lib/puppet/indirector/resource/ral.rb +5 -0
- data/lib/puppet/indirector/resource/rest.rb +1 -0
- data/lib/puppet/indirector/resource/store_configs.rb +4 -0
- data/lib/puppet/indirector/rest.rb +2 -1
- data/lib/puppet/indirector/ssl_file.rb +7 -7
- data/lib/puppet/indirector/terminus.rb +4 -0
- data/lib/puppet/indirector/yaml.rb +3 -3
- data/lib/puppet/interface/documentation.rb +4 -11
- data/lib/puppet/module.rb +19 -6
- data/lib/puppet/module_tool/applications/builder.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +1 -1
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +7 -3
- data/lib/puppet/module_tool/metadata.rb +6 -2
- data/lib/puppet/module_tool/tar.rb +2 -1
- data/lib/puppet/module_tool/tar/gnu.rb +6 -2
- data/lib/puppet/module_tool/tar/mini.rb +2 -0
- data/lib/puppet/module_tool/tar/solaris.rb +2 -5
- data/lib/puppet/network/authconfig.rb +0 -2
- data/lib/puppet/network/authentication.rb +1 -1
- data/lib/puppet/network/authstore.rb +6 -7
- data/lib/puppet/network/format.rb +2 -3
- data/lib/puppet/network/format_handler.rb +16 -11
- data/lib/puppet/network/format_support.rb +14 -0
- data/lib/puppet/network/formats.rb +26 -0
- data/lib/puppet/network/http/connection.rb +8 -41
- data/lib/puppet/network/http/handler.rb +28 -32
- data/lib/puppet/network/http/webrick.rb +15 -22
- data/lib/puppet/network/http_pool.rb +43 -9
- data/lib/puppet/network/rights.rb +0 -0
- data/lib/puppet/node.rb +24 -8
- data/lib/puppet/node/environment.rb +18 -20
- data/lib/puppet/node/facts.rb +23 -6
- data/lib/puppet/parameter.rb +15 -2
- data/lib/puppet/parameter/boolean.rb +5 -0
- data/lib/puppet/parameter/value_collection.rb +6 -4
- data/lib/puppet/parser/ast/resourceparam.rb +2 -1
- data/lib/puppet/parser/compiler.rb +25 -9
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +12 -21
- data/lib/puppet/parser/functions/collect.rb +6 -35
- data/lib/puppet/parser/functions/contain.rb +26 -0
- data/lib/puppet/parser/functions/create_resources.rb +5 -0
- data/lib/puppet/parser/functions/extlookup.rb +2 -2
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/{reject.rb → filter.rb} +13 -12
- data/lib/puppet/parser/functions/fqdn_rand.rb +13 -5
- data/lib/puppet/parser/functions/include.rb +18 -1
- data/lib/puppet/parser/functions/map.rb +44 -0
- data/lib/puppet/parser/functions/select.rb +6 -38
- data/lib/puppet/parser/lexer.rb +1 -1
- data/lib/puppet/parser/parser_support.rb +1 -1
- data/lib/puppet/parser/resource.rb +6 -45
- data/lib/puppet/parser/scope.rb +33 -2
- data/lib/puppet/parser/type_loader.rb +4 -60
- data/lib/puppet/pops/binder/bindings_loader.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config.rb +3 -3
- data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +2 -2
- data/lib/puppet/pops/issues.rb +4 -0
- data/lib/puppet/pops/model/ast_transformer.rb +4 -1
- data/lib/puppet/pops/model/model_label_provider.rb +1 -1
- data/lib/puppet/pops/parser/egrammar.ra +5 -24
- data/lib/puppet/pops/parser/eparser.rb +859 -902
- data/lib/puppet/pops/parser/lexer.rb +48 -30
- data/lib/puppet/pops/parser/parser_support.rb +1 -1
- data/lib/puppet/pops/patterns.rb +4 -4
- data/lib/puppet/pops/utils.rb +1 -1
- data/lib/puppet/pops/validation/checker3_1.rb +25 -20
- data/lib/puppet/provider.rb +23 -6
- data/lib/puppet/provider/aixobject.rb +0 -0
- data/lib/puppet/provider/augeas/augeas.rb +21 -5
- data/lib/puppet/provider/confine.rb +5 -79
- data/lib/puppet/provider/cron/crontab.rb +0 -0
- data/lib/puppet/provider/exec.rb +9 -7
- data/lib/puppet/provider/exec/posix.rb +10 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/file/posix.rb +1 -0
- data/lib/puppet/provider/file/windows.rb +16 -5
- data/lib/puppet/provider/group/aix.rb +0 -0
- data/lib/puppet/provider/group/windows_adsi.rb +33 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +0 -0
- data/lib/puppet/provider/maillist/mailman.rb +0 -0
- data/lib/puppet/provider/mount/parsed.rb +0 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +1 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -0
- data/lib/puppet/provider/package/blastwave.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -0
- data/lib/puppet/provider/package/gem.rb +0 -0
- data/lib/puppet/provider/package/macports.rb +0 -0
- data/lib/puppet/provider/package/msi.rb +4 -10
- data/lib/puppet/provider/package/nim.rb +8 -8
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/opkg.rb +0 -0
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +39 -3
- data/lib/puppet/provider/package/sun.rb +3 -3
- data/lib/puppet/provider/package/sunfreeware.rb +0 -0
- data/lib/puppet/provider/package/windows.rb +12 -19
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +2 -2
- data/lib/puppet/provider/parsedfile.rb +0 -0
- data/lib/puppet/provider/port/parsed.rb +0 -0
- data/lib/puppet/provider/service/base.rb +0 -0
- data/lib/puppet/provider/service/bsd.rb +3 -3
- data/lib/puppet/provider/service/daemontools.rb +8 -8
- data/lib/puppet/provider/service/debian.rb +0 -0
- data/lib/puppet/provider/service/freebsd.rb +3 -3
- data/lib/puppet/provider/service/init.rb +5 -4
- data/lib/puppet/provider/service/launchd.rb +35 -24
- data/lib/puppet/provider/service/openbsd.rb +23 -0
- data/lib/puppet/provider/service/redhat.rb +0 -0
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +0 -0
- data/lib/puppet/provider/service/src.rb +0 -0
- data/lib/puppet/provider/service/systemd.rb +0 -0
- data/lib/puppet/provider/service/upstart.rb +3 -3
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -2
- data/lib/puppet/provider/sshkey/parsed.rb +0 -0
- data/lib/puppet/provider/user/aix.rb +0 -0
- data/lib/puppet/provider/user/directoryservice.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/reference/configuration.rb +1 -2
- data/lib/puppet/reference/indirection.rb +12 -14
- data/lib/puppet/relationship.rb +7 -4
- data/lib/puppet/reports.rb +2 -2
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/store.rb +3 -3
- data/lib/puppet/reports/tagmail.rb +2 -2
- data/lib/puppet/resource.rb +66 -8
- data/lib/puppet/resource/catalog.rb +18 -25
- data/lib/puppet/resource/status.rb +10 -4
- data/lib/puppet/run.rb +6 -2
- data/lib/puppet/settings.rb +39 -119
- data/lib/puppet/settings/base_setting.rb +8 -9
- data/lib/puppet/settings/directory_setting.rb +8 -0
- data/lib/puppet/settings/file_setting.rb +35 -1
- data/lib/puppet/settings/priority_setting.rb +42 -0
- data/lib/puppet/ssl.rb +4 -0
- data/lib/puppet/ssl/certificate.rb +18 -0
- data/lib/puppet/ssl/certificate_authority.rb +101 -72
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +44 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +21 -17
- data/lib/puppet/ssl/certificate_factory.rb +38 -12
- data/lib/puppet/ssl/certificate_request.rb +201 -47
- data/lib/puppet/ssl/certificate_request_attributes.rb +34 -0
- data/lib/puppet/ssl/certificate_revocation_list.rb +2 -2
- data/lib/puppet/ssl/host.rb +21 -10
- data/lib/puppet/ssl/inventory.rb +6 -10
- data/lib/puppet/ssl/key.rb +1 -1
- data/lib/puppet/ssl/oids.rb +78 -0
- data/lib/puppet/ssl/validator.rb +41 -97
- data/lib/puppet/ssl/validator/default_validator.rb +153 -0
- data/lib/puppet/ssl/validator/no_validator.rb +17 -0
- data/lib/puppet/status.rb +4 -0
- data/lib/puppet/test/test_helper.rb +5 -0
- data/lib/puppet/transaction.rb +13 -0
- data/lib/puppet/transaction/event.rb +8 -3
- data/lib/puppet/transaction/report.rb +6 -2
- data/lib/puppet/transaction/resource_harness.rb +173 -115
- data/lib/puppet/type.rb +30 -13
- data/lib/puppet/type/augeas.rb +12 -46
- data/lib/puppet/type/component.rb +1 -7
- data/lib/puppet/type/cron.rb +0 -0
- data/lib/puppet/type/exec.rb +13 -1
- data/lib/puppet/type/file.rb +19 -10
- data/lib/puppet/type/file/checksum.rb +0 -0
- data/lib/puppet/type/file/content.rb +3 -0
- data/lib/puppet/type/file/ensure.rb +33 -15
- data/lib/puppet/type/file/group.rb +0 -0
- data/lib/puppet/type/file/mode.rb +6 -2
- data/lib/puppet/type/file/owner.rb +0 -0
- data/lib/puppet/type/file/source.rb +65 -14
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/file/type.rb +0 -0
- data/lib/puppet/type/filebucket.rb +0 -0
- data/lib/puppet/type/group.rb +18 -0
- data/lib/puppet/type/host.rb +0 -0
- data/lib/puppet/type/k5login.rb +4 -4
- data/lib/puppet/type/mailalias.rb +0 -0
- data/lib/puppet/type/maillist.rb +0 -0
- data/lib/puppet/type/mount.rb +15 -1
- data/lib/puppet/type/package.rb +7 -1
- data/lib/puppet/type/port.rb +0 -0
- data/lib/puppet/type/schedule.rb +9 -4
- data/lib/puppet/type/service.rb +1 -1
- data/lib/puppet/type/sshkey.rb +0 -0
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +3 -0
- data/lib/puppet/type/yumrepo.rb +8 -6
- data/lib/puppet/type/zpool.rb +0 -0
- data/lib/puppet/util.rb +4 -31
- data/lib/puppet/util/adsi.rb +73 -17
- data/lib/puppet/util/autoload.rb +3 -3
- data/lib/puppet/util/backups.rb +4 -4
- data/lib/puppet/util/cacher.rb +7 -13
- data/lib/puppet/util/checksums.rb +2 -2
- data/lib/puppet/util/classgen.rb +3 -1
- data/lib/puppet/util/colors.rb +1 -0
- data/lib/puppet/util/command_line.rb +5 -0
- data/lib/puppet/util/docs.rb +33 -27
- data/lib/puppet/util/execution.rb +42 -18
- data/lib/puppet/util/filetype.rb +3 -3
- data/lib/puppet/util/instance_loader.rb +2 -2
- data/lib/puppet/util/instrumentation.rb +23 -42
- data/lib/puppet/util/instrumentation/data.rb +11 -4
- data/lib/puppet/util/instrumentation/indirection_probe.rb +11 -4
- data/lib/puppet/util/instrumentation/instrumentable.rb +7 -14
- data/lib/puppet/util/instrumentation/listener.rb +15 -8
- data/lib/puppet/util/instrumentation/listeners/log.rb +4 -10
- data/lib/puppet/util/instrumentation/listeners/performance.rb +8 -14
- data/lib/puppet/util/limits.rb +12 -0
- data/lib/puppet/util/lockfile.rb +2 -2
- data/lib/puppet/util/log.rb +14 -6
- data/lib/puppet/util/log/destinations.rb +23 -1
- data/lib/puppet/util/metric.rb +9 -3
- data/lib/puppet/util/monkey_patches.rb +7 -2
- data/lib/puppet/util/network_device/config.rb +1 -1
- data/lib/puppet/util/plugins.rb +1 -1
- data/lib/puppet/util/posix.rb +0 -0
- data/lib/puppet/util/profiler.rb +7 -2
- data/lib/puppet/util/provider_features.rb +2 -2
- data/lib/puppet/util/rdoc.rb +28 -30
- data/lib/puppet/util/rdoc/code_objects.rb +75 -25
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +12 -487
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +477 -0
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc1.rb +19 -0
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +14 -0
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +2 -2
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/tag_set.rb +29 -0
- data/lib/puppet/util/tagging.rb +8 -24
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/watcher.rb +1 -1
- data/lib/puppet/util/windows.rb +3 -0
- data/lib/puppet/util/windows/access_control_entry.rb +84 -0
- data/lib/puppet/util/windows/access_control_list.rb +106 -0
- data/lib/puppet/util/windows/file.rb +213 -0
- data/lib/puppet/util/windows/process.rb +199 -0
- data/lib/puppet/util/windows/root_certs.rb +52 -37
- data/lib/puppet/util/windows/security.rb +270 -245
- data/lib/puppet/util/windows/security_descriptor.rb +62 -0
- data/lib/puppet/util/windows/sid.rb +26 -4
- data/lib/puppet/version.rb +2 -2
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +1 -1
- data/spec/fixtures/unit/indirector/{hiera → data_binding/hiera}/global.yaml +0 -0
- data/spec/fixtures/unit/indirector/data_binding/hiera/invalid.yaml +1 -0
- data/spec/fixtures/unit/module/trailing-comma.json +24 -0
- data/spec/fixtures/unit/util/monkey_patches/x509.pem +32 -0
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/configurer_spec.rb +4 -2
- data/spec/integration/data_binding.rb +100 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +16 -13
- data/spec/integration/indirector/direct_file_server_spec.rb +3 -5
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -2
- data/spec/integration/node/facts_spec.rb +1 -1
- data/spec/integration/node_spec.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +90 -0
- data/spec/integration/parser/parser_spec.rb +2 -2
- data/spec/integration/provider/cron/crontab_spec.rb +3 -5
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/autosign_spec.rb +90 -0
- data/spec/integration/ssl/certificate_authority_spec.rb +62 -69
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -1
- data/spec/integration/ssl/host_spec.rb +1 -1
- data/spec/integration/transaction_spec.rb +13 -13
- data/spec/integration/type/exec_spec.rb +2 -2
- data/spec/integration/type/file_spec.rb +287 -45
- data/spec/integration/type/tidy_spec.rb +3 -3
- data/spec/integration/util/rdoc/parser_spec.rb +236 -35
- data/spec/integration/util/settings_spec.rb +1 -1
- data/spec/integration/util/windows/process_spec.rb +22 -0
- data/spec/integration/util/windows/security_spec.rb +316 -106
- data/spec/lib/matchers/containment_matchers.rb +52 -0
- data/spec/lib/puppet_spec/compiler.rb +6 -0
- data/spec/lib/puppet_spec/files.rb +20 -21
- data/spec/shared_behaviours/documentation_on_faces.rb +3 -3
- data/spec/shared_behaviours/file_server_terminus.rb +2 -2
- data/spec/shared_contexts/platform.rb +1 -0
- data/spec/spec_helper.rb +13 -1
- data/spec/unit/agent_spec.rb +0 -12
- data/spec/unit/application/agent_spec.rb +4 -4
- data/spec/unit/application/apply_spec.rb +18 -2
- data/spec/unit/application/cert_spec.rb +8 -6
- data/spec/unit/application/device_spec.rb +1 -1
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application/inspect_spec.rb +1 -1
- data/spec/unit/application_spec.rb +24 -0
- data/spec/unit/configurer/downloader_spec.rb +8 -7
- data/spec/unit/configurer/fact_handler_spec.rb +23 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +7 -2
- data/spec/unit/configurer_spec.rb +15 -5
- data/spec/unit/{provider/confine → confine}/exists_spec.rb +12 -12
- data/spec/unit/{provider/confine → confine}/false_spec.rb +9 -9
- data/spec/unit/{provider/confine → confine}/feature_spec.rb +10 -10
- data/spec/unit/{provider/confine → confine}/true_spec.rb +7 -7
- data/spec/unit/{provider/confine → confine}/variable_spec.rb +16 -16
- data/spec/unit/{provider/confine_collection_spec.rb → confine_collection_spec.rb} +30 -30
- data/spec/unit/{provider/confine_spec.rb → confine_spec.rb} +11 -11
- data/spec/unit/{provider/confiner_spec.rb → confiner_spec.rb} +4 -4
- data/spec/unit/face/parser_spec.rb +54 -0
- data/spec/unit/file_bucket/dipper_spec.rb +2 -2
- data/spec/unit/file_serving/base_spec.rb +32 -9
- data/spec/unit/file_serving/configuration_spec.rb +7 -7
- data/spec/unit/file_serving/content_spec.rb +12 -7
- data/spec/unit/file_serving/fileset_spec.rb +57 -27
- data/spec/unit/file_serving/metadata_spec.rb +74 -12
- data/spec/unit/file_serving/mount/file_spec.rb +10 -10
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +73 -0
- data/spec/unit/file_system/file_spec.rb +486 -0
- data/spec/unit/file_system/tempfile_spec.rb +48 -0
- data/spec/unit/graph/relationship_graph_spec.rb +0 -6
- data/spec/unit/hiera_puppet_spec.rb +2 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +15 -19
- data/spec/unit/indirector/certificate_status/file_spec.rb +30 -40
- data/spec/unit/indirector/data_binding/hiera_spec.rb +95 -2
- data/spec/unit/indirector/direct_file_server_spec.rb +6 -6
- data/spec/unit/indirector/facts/facter_spec.rb +33 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +61 -52
- data/spec/unit/indirector/file_metadata/file_spec.rb +2 -2
- data/spec/unit/indirector/file_server_spec.rb +4 -4
- data/spec/unit/indirector/json_spec.rb +4 -4
- data/spec/unit/indirector/key/file_spec.rb +13 -14
- data/spec/unit/indirector/resource/ral_spec.rb +7 -0
- data/spec/unit/indirector/resource/store_configs_spec.rb +11 -0
- data/spec/unit/indirector/rest_spec.rb +7 -3
- data/spec/unit/indirector/ssl_file_spec.rb +14 -17
- data/spec/unit/indirector/yaml_spec.rb +4 -4
- data/spec/unit/module_spec.rb +43 -15
- data/spec/unit/module_tool/tar/gnu_spec.rb +2 -2
- data/spec/unit/module_tool/tar/solaris_spec.rb +2 -2
- data/spec/unit/module_tool/tar_spec.rb +45 -0
- data/spec/unit/network/authconfig_spec.rb +2 -1
- data/spec/unit/network/authentication_spec.rb +2 -2
- data/spec/unit/network/format_handler_spec.rb +2 -2
- data/spec/unit/network/formats_spec.rb +24 -0
- data/spec/unit/network/http/connection_spec.rb +76 -199
- data/spec/unit/network/http/handler_spec.rb +33 -34
- data/spec/unit/network/http_pool_spec.rb +8 -5
- data/spec/unit/node/environment_spec.rb +76 -90
- data/spec/unit/node/facts_spec.rb +20 -3
- data/spec/unit/node_spec.rb +43 -0
- data/spec/unit/parameter/boolean_spec.rb +22 -12
- data/spec/unit/parser/ast/resourceparam_spec.rb +51 -0
- data/spec/unit/parser/compiler_spec.rb +103 -35
- data/spec/unit/parser/eparser_adapter_spec.rb +12 -12
- data/spec/unit/parser/files_spec.rb +11 -11
- data/spec/unit/parser/functions/contain_spec.rb +185 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +13 -5
- data/spec/unit/parser/functions/generate_spec.rb +1 -1
- data/spec/unit/parser/functions_spec.rb +2 -2
- data/spec/unit/parser/lexer_spec.rb +1 -1
- data/spec/unit/parser/methods/each_spec.rb +1 -1
- data/spec/unit/parser/methods/{select_spec.rb → filter_spec.rb} +11 -11
- data/spec/unit/parser/methods/map_spec.rb +95 -0
- data/spec/unit/parser/methods/reduce_spec.rb +12 -11
- data/spec/unit/parser/methods/shared.rb +5 -5
- data/spec/unit/parser/methods/slice_spec.rb +13 -13
- data/spec/unit/parser/parser_spec.rb +1 -1
- data/spec/unit/parser/resource/param_spec.rb +44 -0
- data/spec/unit/parser/resource_spec.rb +16 -15
- data/spec/unit/pops/model/ast_transformer_spec.rb +18 -4
- data/spec/unit/pops/parser/lexer_spec.rb +22 -5
- data/spec/unit/pops/parser/parse_calls_spec.rb +5 -5
- data/spec/unit/pops/transformer/transform_calls_spec.rb +6 -6
- data/spec/unit/pops/transformer/transform_containers_spec.rb +2 -2
- data/spec/unit/pops/validator/validator_spec.rb +31 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +57 -2
- data/spec/unit/provider/exec/posix_spec.rb +8 -3
- data/spec/unit/provider/file/posix_spec.rb +2 -2
- data/spec/unit/provider/group/windows_adsi_spec.rb +70 -3
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +3 -3
- data/spec/unit/provider/package/apt_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +15 -42
- data/spec/unit/provider/package/openbsd_spec.rb +3 -3
- data/spec/unit/provider/package/rpm_spec.rb +56 -13
- data/spec/unit/provider/package/windows_spec.rb +15 -19
- data/spec/unit/provider/service/base_spec.rb +1 -1
- data/spec/unit/provider/service/daemontools_spec.rb +18 -8
- data/spec/unit/provider/service/freebsd_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_spec.rb +5 -2
- data/spec/unit/provider/service/init_spec.rb +17 -17
- data/spec/unit/provider/service/launchd_spec.rb +76 -23
- data/spec/unit/provider/service/openbsd_spec.rb +125 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/runit_spec.rb +12 -5
- data/spec/unit/provider/service/upstart_spec.rb +4 -4
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -5
- data/spec/unit/provider/user/directoryservice_spec.rb +4 -4
- data/spec/unit/provider/zone/solaris_spec.rb +1 -1
- data/spec/unit/provider_spec.rb +2 -2
- data/spec/unit/reports/http_spec.rb +19 -34
- data/spec/unit/reports/store_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +81 -11
- data/spec/unit/resource/status_spec.rb +11 -1
- data/spec/unit/resource/type_spec.rb +30 -1
- data/spec/unit/resource_spec.rb +40 -4
- data/spec/unit/settings/file_setting_spec.rb +2 -2
- data/spec/unit/settings/path_setting_spec.rb +2 -2
- data/spec/unit/settings/priority_setting_spec.rb +66 -0
- data/spec/unit/settings_spec.rb +16 -31
- data/spec/unit/ssl/certificate_authority/autosign_command_spec.rb +30 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +129 -134
- data/spec/unit/ssl/certificate_factory_spec.rb +18 -0
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +61 -0
- data/spec/unit/ssl/certificate_request_spec.rb +103 -0
- data/spec/unit/ssl/certificate_spec.rb +31 -18
- data/spec/unit/ssl/host_spec.rb +34 -8
- data/spec/unit/ssl/inventory_spec.rb +27 -62
- data/spec/unit/ssl/key_spec.rb +4 -4
- data/spec/unit/ssl/oids_spec.rb +48 -0
- data/spec/unit/ssl/validator_spec.rb +49 -6
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/transaction/event_spec.rb +1 -9
- data/spec/unit/transaction/report_spec.rb +20 -1
- data/spec/unit/transaction/resource_harness_spec.rb +60 -210
- data/spec/unit/transaction_spec.rb +54 -8
- data/spec/unit/type/component_spec.rb +2 -2
- data/spec/unit/type/exec_spec.rb +14 -7
- data/spec/unit/type/file/content_spec.rb +13 -2
- data/spec/unit/type/file/ctime_spec.rb +1 -1
- data/spec/unit/type/file/mode_spec.rb +48 -2
- data/spec/unit/type/file/mtime_spec.rb +1 -1
- data/spec/unit/type/file/source_spec.rb +177 -7
- data/spec/unit/type/file_spec.rb +63 -71
- data/spec/unit/type/group_spec.rb +20 -0
- data/spec/unit/type/k5login_spec.rb +3 -3
- data/spec/unit/type/mount_spec.rb +53 -0
- data/spec/unit/type/nagios_spec.rb +216 -0
- data/spec/unit/type/package_spec.rb +7 -1
- data/spec/unit/type/schedule_spec.rb +6 -0
- data/spec/unit/type/service_spec.rb +3 -3
- data/spec/unit/type/tidy_spec.rb +14 -14
- data/spec/unit/type/user_spec.rb +9 -0
- data/spec/unit/type_spec.rb +86 -4
- data/spec/unit/util/adsi_spec.rb +120 -12
- data/spec/unit/util/autoload_spec.rb +14 -14
- data/spec/unit/util/backups_spec.rb +29 -21
- data/spec/unit/util/checksums_spec.rb +2 -1
- data/spec/unit/util/command_line_spec.rb +41 -0
- data/spec/unit/util/docs_spec.rb +91 -0
- data/spec/unit/util/execution_spec.rb +26 -2
- data/spec/unit/util/filetype_spec.rb +7 -7
- data/spec/unit/util/lockfile_spec.rb +2 -2
- data/spec/unit/util/log/destinations_spec.rb +32 -0
- data/spec/unit/util/monkey_patches_spec.rb +41 -0
- data/spec/unit/util/pidlock_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +15 -13
- data/spec/unit/util/rdoc_spec.rb +18 -24
- data/spec/unit/util/resource_template_spec.rb +3 -3
- data/spec/unit/util/selinux_spec.rb +4 -2
- data/spec/unit/util/storage_spec.rb +4 -4
- data/spec/unit/util/suidmanager_spec.rb +7 -0
- data/spec/unit/util/tag_set_spec.rb +46 -0
- data/spec/unit/util/tagging_spec.rb +82 -45
- data/spec/unit/util/watcher_spec.rb +4 -1
- data/spec/unit/util/windows/access_control_entry_spec.rb +67 -0
- data/spec/unit/util/windows/access_control_list_spec.rb +133 -0
- data/spec/unit/util/windows/root_certs_spec.rb +10 -8
- data/spec/unit/util/windows/security_descriptor_spec.rb +117 -0
- data/spec/unit/util/windows/sid_spec.rb +69 -0
- data/spec/unit/util_spec.rb +7 -7
- data/tasks/ci.rake +17 -36
- metadata +2811 -2746
- checksums.yaml +0 -7
- data/examples/mac_automount.pp +0 -16
- data/examples/mcx_dock_absent.pp +0 -4
- data/examples/mcx_dock_default.pp +0 -118
- data/examples/mcx_dock_full.pp +0 -125
- data/examples/mcx_dock_invalid.pp +0 -9
- data/examples/mcx_nogroup.pp +0 -118
- data/examples/mcx_notexists_absent.pp +0 -4
- data/ext/rack/README +0 -58
- data/ext/rack/manifest.pp +0 -59
- data/lib/puppet/external/lock.rb +0 -63
- data/lib/puppet/indirector/hiera.rb +0 -39
- data/lib/puppet/parser/functions/foreach.rb +0 -95
- data/spec/integration/network/server/webrick_spec.rb +0 -76
- data/spec/integration/parser/functions_spec.rb +0 -16
- data/spec/unit/indirector/hiera_spec.rb +0 -154
- data/spec/unit/parser/methods/collect_spec.rb +0 -153
- data/spec/unit/parser/methods/foreach_spec.rb +0 -91
- data/spec/unit/parser/methods/reject_spec.rb +0 -73
- data/spec/unit/resource/resource_type.json +0 -34
@@ -59,7 +59,9 @@ describe Puppet::Resource::Status do
|
|
59
59
|
|
60
60
|
it "should copy the resource's tags" do
|
61
61
|
@resource.expects(:tags).returns %w{foo bar}
|
62
|
-
Puppet::Resource::Status.new(@resource)
|
62
|
+
status = Puppet::Resource::Status.new(@resource)
|
63
|
+
status.should be_tagged("foo")
|
64
|
+
status.should be_tagged("bar")
|
63
65
|
end
|
64
66
|
|
65
67
|
it "should always convert the resource to a string" do
|
@@ -113,6 +115,14 @@ describe Puppet::Resource::Status do
|
|
113
115
|
@status.events.should == [event]
|
114
116
|
end
|
115
117
|
|
118
|
+
it "records an event for a failure caused by an error" do
|
119
|
+
@status.failed_because(StandardError.new("the message"))
|
120
|
+
|
121
|
+
expect(@status.events[0].message).to eq("the message")
|
122
|
+
expect(@status.events[0].status).to eq("failure")
|
123
|
+
expect(@status.events[0].name).to eq(:resource_error)
|
124
|
+
end
|
125
|
+
|
116
126
|
it "should count the number of successful events and set changed" do
|
117
127
|
3.times{ @status << Puppet::Transaction::Event.new(:status => 'success') }
|
118
128
|
@status.change_count.should == 3
|
@@ -1,8 +1,19 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'spec_helper'
|
3
|
-
|
4
3
|
require 'puppet/resource/type'
|
5
4
|
|
5
|
+
# the json-schema gem doesn't support windows
|
6
|
+
if not Puppet.features.microsoft_windows?
|
7
|
+
RESOURCE_TYPE_SCHEMA = JSON.parse(File.read(File.join(File.dirname(__FILE__), '../../../api/schemas/resource_type.json')))
|
8
|
+
|
9
|
+
describe "resource type schema" do
|
10
|
+
it "should validate against the json meta-schema" do
|
11
|
+
JSON::Validator.validate!(JSON_META_SCHEMA, RESOURCE_TYPE_SCHEMA)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
6
17
|
describe Puppet::Resource::Type do
|
7
18
|
it "should have a 'name' attribute" do
|
8
19
|
Puppet::Resource::Type.new(:hostclass, "foo").name.should == "foo"
|
@@ -31,6 +42,10 @@ describe Puppet::Resource::Type do
|
|
31
42
|
end
|
32
43
|
|
33
44
|
describe "when converting to json" do
|
45
|
+
def validate_json_for_type(type)
|
46
|
+
JSON::Validator.validate!(RESOURCE_TYPE_SCHEMA, type.to_pson)
|
47
|
+
end
|
48
|
+
|
34
49
|
before do
|
35
50
|
@type = Puppet::Resource::Type.new(:hostclass, "foo")
|
36
51
|
end
|
@@ -48,6 +63,20 @@ describe Puppet::Resource::Type do
|
|
48
63
|
double_convert.type.should == @type.type
|
49
64
|
end
|
50
65
|
|
66
|
+
it "should validate with only name and kind", :unless => Puppet.features.microsoft_windows? do
|
67
|
+
validate_json_for_type(@type)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should validate with all fields set", :unless => Puppet.features.microsoft_windows? do
|
71
|
+
@type.set_arguments("one" => nil, "two" => "foo")
|
72
|
+
@type.line = 100
|
73
|
+
@type.doc = "A weird type"
|
74
|
+
@type.file = "/etc/manifests/thing.pp"
|
75
|
+
@type.parent = "one::two"
|
76
|
+
|
77
|
+
validate_json_for_type(@type)
|
78
|
+
end
|
79
|
+
|
51
80
|
it "should include any arguments" do
|
52
81
|
@type.set_arguments("one" => nil, "two" => "foo")
|
53
82
|
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -339,8 +339,11 @@ describe Puppet::Resource do
|
|
339
339
|
end
|
340
340
|
|
341
341
|
it "should query the injector using a namespaced key" do
|
342
|
-
compiler.injector.expects(:lookup).with(scope, 'apache::port')
|
342
|
+
compiler.injector.expects(:lookup).with(scope, 'apache::port').returns("8081")
|
343
|
+
|
343
344
|
resource.set_default_parameters(scope)
|
345
|
+
|
346
|
+
resource[:port].should == "8081"
|
344
347
|
end
|
345
348
|
|
346
349
|
it "should use the value from the data_binding terminus" do
|
@@ -376,8 +379,16 @@ describe Puppet::Resource do
|
|
376
379
|
resource[:port].should == '80'
|
377
380
|
end
|
378
381
|
|
382
|
+
it "should fail with error message about data binding on a hiera failure" do
|
383
|
+
Puppet::DataBinding.indirection.expects(:find).raises(Puppet::DataBinding::LookupError, 'Forgettabotit')
|
384
|
+
expect {
|
385
|
+
resource.set_default_parameters(scope)
|
386
|
+
}.to raise_error(Puppet::Error, /Error from DataBinding 'hiera' while looking up 'apache::port':.*Forgettabotit/)
|
387
|
+
end
|
388
|
+
|
379
389
|
it "should use the default value if the injector returns nil" do
|
380
390
|
compiler.injector.expects(:lookup).returns(nil)
|
391
|
+
Puppet::DataBinding.indirection.expects(:find).returns(nil)
|
381
392
|
|
382
393
|
resource.set_default_parameters(scope)
|
383
394
|
|
@@ -607,7 +618,7 @@ describe Puppet::Resource do
|
|
607
618
|
end
|
608
619
|
end
|
609
620
|
|
610
|
-
describe "when serializing" do
|
621
|
+
describe "when serializing a native type" do
|
611
622
|
before do
|
612
623
|
@resource = Puppet::Resource.new("file", "/my/file")
|
613
624
|
@resource["one"] = "test"
|
@@ -622,6 +633,31 @@ describe Puppet::Resource do
|
|
622
633
|
end
|
623
634
|
end
|
624
635
|
|
636
|
+
describe "when serializing a defined type" do
|
637
|
+
before do
|
638
|
+
type = Puppet::Resource::Type.new(:definition, "foo::bar")
|
639
|
+
Puppet::Node::Environment.new.known_resource_types.add type
|
640
|
+
end
|
641
|
+
|
642
|
+
before :each do
|
643
|
+
@resource = Puppet::Resource.new('foo::bar', 'xyzzy')
|
644
|
+
@resource['one'] = 'test'
|
645
|
+
@resource['two'] = 'other'
|
646
|
+
@resource.resource_type
|
647
|
+
end
|
648
|
+
|
649
|
+
it "doesn't include transient instance variables (#4506)" do
|
650
|
+
expect(@resource.to_yaml_properties).to_not include :@rstype
|
651
|
+
end
|
652
|
+
|
653
|
+
it "produces an equivalent yaml object" do
|
654
|
+
text = @resource.render('yaml')
|
655
|
+
|
656
|
+
newresource = Puppet::Resource.convert_from('yaml', text)
|
657
|
+
newresource.should equal_attributes_of @resource
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
625
661
|
describe "when converting to a RAL resource" do
|
626
662
|
it "should use the resource type's :new method to create the resource if the resource is of a builtin type" do
|
627
663
|
resource = Puppet::Resource.new("file", basepath+"/my/file")
|
@@ -810,9 +846,9 @@ describe Puppet::Resource do
|
|
810
846
|
end
|
811
847
|
end
|
812
848
|
|
813
|
-
describe "it should implement
|
849
|
+
describe "it should implement copy_as_resource" do
|
814
850
|
resource = Puppet::Resource.new("file", "/my/file")
|
815
|
-
resource.
|
851
|
+
resource.copy_as_resource.should == resource
|
816
852
|
end
|
817
853
|
|
818
854
|
describe "because it is an indirector model" do
|
@@ -139,14 +139,14 @@ describe Puppet::Settings::FileSetting do
|
|
139
139
|
it "should skip non-existent files if 'create_files' is not enabled" do
|
140
140
|
@file.expects(:create_files?).returns false
|
141
141
|
@file.expects(:type).returns :file
|
142
|
-
File.expects(:exist?).with(@basepath).returns false
|
142
|
+
Puppet::FileSystem::File.expects(:exist?).with(@basepath).returns false
|
143
143
|
@file.to_resource.should be_nil
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should manage existent files even if 'create_files' is not enabled" do
|
147
147
|
@file.expects(:create_files?).returns false
|
148
148
|
@file.expects(:type).returns :file
|
149
|
-
File.expects(:exist?).with(@basepath).returns true
|
149
|
+
Puppet::FileSystem::File.expects(:exist?).with(@basepath).returns true
|
150
150
|
@file.to_resource.should be_instance_of(Puppet::Resource)
|
151
151
|
end
|
152
152
|
|
@@ -22,8 +22,8 @@ describe Puppet::Settings::PathSetting do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should work with UNC paths" do
|
25
|
-
subject.munge('//
|
26
|
-
subject.munge('\\\\
|
25
|
+
subject.munge('//localhost/some/path').should == '//localhost/some/path'
|
26
|
+
subject.munge('\\\\localhost\some\path').should == '//localhost/some/path'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'puppet/settings'
|
5
|
+
require 'puppet/settings/priority_setting'
|
6
|
+
require 'puppet/util/platform'
|
7
|
+
|
8
|
+
describe Puppet::Settings::PrioritySetting do
|
9
|
+
let(:setting) { described_class.new(:settings => mock('settings'), :desc => "test") }
|
10
|
+
|
11
|
+
it "is of type :priority" do
|
12
|
+
setting.type.should == :priority
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "when munging the setting" do
|
16
|
+
it "passes nil through" do
|
17
|
+
setting.munge(nil).should be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns the same value if given an integer" do
|
21
|
+
setting.munge(5).should == 5
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns an integer if given a decimal string" do
|
25
|
+
setting.munge('12').should == 12
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns a negative integer if given a negative integer string" do
|
29
|
+
setting.munge('-5').should == -5
|
30
|
+
end
|
31
|
+
|
32
|
+
it "fails if given anything else" do
|
33
|
+
[ 'foo', 'realtime', true, 8.3, [] ].each do |value|
|
34
|
+
expect {
|
35
|
+
setting.munge(value)
|
36
|
+
}.to raise_error(Puppet::Settings::ValidationError)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "on a Unix-like platform it", :unless => Puppet::Util::Platform.windows? do
|
41
|
+
it "parses high, normal, low, and idle priorities" do
|
42
|
+
{
|
43
|
+
'high' => -10,
|
44
|
+
'normal' => 0,
|
45
|
+
'low' => 10,
|
46
|
+
'idle' => 19
|
47
|
+
}.each do |value, converted_value|
|
48
|
+
setting.munge(value).should == converted_value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "on a Windows-like platform it", :if => Puppet::Util::Platform.windows? do
|
54
|
+
it "parses high, normal, low, and idle priorities" do
|
55
|
+
{
|
56
|
+
'high' => Process::HIGH_PRIORITY_CLASS,
|
57
|
+
'normal' => Process::NORMAL_PRIORITY_CLASS,
|
58
|
+
'low' => Process::BELOW_NORMAL_PRIORITY_CLASS,
|
59
|
+
'idle' => Process::IDLE_PRIORITY_CLASS
|
60
|
+
}.each do |value, converted_value|
|
61
|
+
setting.munge(value).should == converted_value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/unit/settings_spec.rb
CHANGED
@@ -485,7 +485,7 @@ describe Puppet::Settings do
|
|
485
485
|
:three => { :default => "$one $two THREE", :desc => "c"},
|
486
486
|
:four => { :default => "$two $three FOUR", :desc => "d"},
|
487
487
|
:five => { :default => nil, :desc => "e" }
|
488
|
-
|
488
|
+
Puppet::FileSystem::File.stubs(:exist?).returns true
|
489
489
|
end
|
490
490
|
|
491
491
|
describe "call_on_define" do
|
@@ -589,7 +589,7 @@ describe Puppet::Settings do
|
|
589
589
|
:config => { :type => :file, :default => "/my/file", :desc => "a" },
|
590
590
|
:one => { :default => "ONE", :desc => "a" },
|
591
591
|
:two => { :default => "TWO", :desc => "b" }
|
592
|
-
|
592
|
+
Puppet::FileSystem::File.stubs(:exist?).returns true
|
593
593
|
@settings.preferred_run_mode = :agent
|
594
594
|
end
|
595
595
|
|
@@ -666,8 +666,8 @@ describe Puppet::Settings do
|
|
666
666
|
describe "when root" do
|
667
667
|
it "should look for the main config file default location config settings haven't been overridden'" do
|
668
668
|
Puppet.features.stubs(:root?).returns(true)
|
669
|
-
|
670
|
-
|
669
|
+
Puppet::FileSystem::File.expects(:exist?).with(main_config_file_default_location).returns(false)
|
670
|
+
Puppet::FileSystem::File.expects(:exist?).with(user_config_file_default_location).never
|
671
671
|
|
672
672
|
@settings.send(:parse_config_files)
|
673
673
|
end
|
@@ -678,7 +678,7 @@ describe Puppet::Settings do
|
|
678
678
|
Puppet.features.stubs(:root?).returns(false)
|
679
679
|
|
680
680
|
seq = sequence "load config files"
|
681
|
-
|
681
|
+
Puppet::FileSystem::File.expects(:exist?).with(user_config_file_default_location).returns(false).in_sequence(seq)
|
682
682
|
|
683
683
|
@settings.send(:parse_config_files)
|
684
684
|
end
|
@@ -699,8 +699,8 @@ describe Puppet::Settings do
|
|
699
699
|
:two => { :default => "$one TWO", :desc => "b" },
|
700
700
|
:three => { :default => "$one $two THREE", :desc => "c" }
|
701
701
|
@settings.stubs(:user_config_file).returns(@userconfig)
|
702
|
-
|
703
|
-
|
702
|
+
Puppet::FileSystem::File.stubs(:exist?).with(@file).returns true
|
703
|
+
Puppet::FileSystem::File.stubs(:exist?).with(@userconfig).returns false
|
704
704
|
end
|
705
705
|
|
706
706
|
it "should not ignore the report setting" do
|
@@ -712,7 +712,7 @@ describe Puppet::Settings do
|
|
712
712
|
[puppetd]
|
713
713
|
report=true
|
714
714
|
CONF
|
715
|
-
|
715
|
+
Puppet::FileSystem::File.expects(:exist?).with(myfile).returns(true)
|
716
716
|
@settings.expects(:read_file).returns(text)
|
717
717
|
@settings.send(:parse_config_files)
|
718
718
|
@settings[:report].should be_true
|
@@ -722,7 +722,7 @@ describe Puppet::Settings do
|
|
722
722
|
myfile = make_absolute("/my/file") # do not stub expand_path here, as this leads to a stack overflow, when mocha tries to use it
|
723
723
|
@settings[:config] = myfile
|
724
724
|
|
725
|
-
|
725
|
+
Puppet::FileSystem::File.expects(:exist?).with(myfile).returns(true)
|
726
726
|
|
727
727
|
File.expects(:read).with(myfile).returns "[main]"
|
728
728
|
|
@@ -730,7 +730,7 @@ describe Puppet::Settings do
|
|
730
730
|
end
|
731
731
|
|
732
732
|
it "should not try to parse non-existent files" do
|
733
|
-
|
733
|
+
Puppet::FileSystem::File.expects(:exist?).with(@file).returns false
|
734
734
|
|
735
735
|
File.expects(:read).with(@file).never
|
736
736
|
|
@@ -925,7 +925,7 @@ describe Puppet::Settings do
|
|
925
925
|
context "running non-root without explicit config file" do
|
926
926
|
before :each do
|
927
927
|
Puppet.features.stubs(:root?).returns(false)
|
928
|
-
|
928
|
+
Puppet::FileSystem::File.expects(:exist?).
|
929
929
|
with(user_config_file_default_location).
|
930
930
|
returns(true).in_sequence(seq)
|
931
931
|
@settings.expects(:read_file).
|
@@ -947,7 +947,7 @@ describe Puppet::Settings do
|
|
947
947
|
context "running as root without explicit config file" do
|
948
948
|
before :each do
|
949
949
|
Puppet.features.stubs(:root?).returns(true)
|
950
|
-
|
950
|
+
Puppet::FileSystem::File.expects(:exist?).
|
951
951
|
with(main_config_file_default_location).
|
952
952
|
returns(true).in_sequence(seq)
|
953
953
|
@settings.expects(:read_file).
|
@@ -970,7 +970,7 @@ describe Puppet::Settings do
|
|
970
970
|
before :each do
|
971
971
|
Puppet.features.stubs(:root?).returns(false)
|
972
972
|
@settings[:confdir] = File.dirname(main_config_file_default_location)
|
973
|
-
|
973
|
+
Puppet::FileSystem::File.expects(:exist?).
|
974
974
|
with(main_config_file_default_location).
|
975
975
|
returns(true).in_sequence(seq)
|
976
976
|
@settings.expects(:read_file).
|
@@ -1000,13 +1000,13 @@ describe Puppet::Settings do
|
|
1000
1000
|
:one => { :default => "ONE", :desc => "a" },
|
1001
1001
|
:two => { :default => "$one TWO", :desc => "b" },
|
1002
1002
|
:three => { :default => "$one $two THREE", :desc => "c" }
|
1003
|
-
|
1004
|
-
|
1003
|
+
Puppet::FileSystem::File.stubs(:exist?).with(@file).returns true
|
1004
|
+
Puppet::FileSystem::File.stubs(:exist?).with(@userconfig).returns false
|
1005
1005
|
@settings.stubs(:user_config_file).returns(@userconfig)
|
1006
1006
|
end
|
1007
1007
|
|
1008
1008
|
it "does not create the WatchedFile instance and should not parse if the file does not exist" do
|
1009
|
-
|
1009
|
+
Puppet::FileSystem::File.expects(:exist?).with(@file).returns false
|
1010
1010
|
Puppet::Util::WatchedFile.expects(:new).never
|
1011
1011
|
|
1012
1012
|
@settings.expects(:parse_config_files).never
|
@@ -1285,10 +1285,6 @@ describe Puppet::Settings do
|
|
1285
1285
|
@settings.define_settings :files, :myfile => {:type => :file, :default => make_absolute("/myfile"), :desc => "a", :mode => 0755}
|
1286
1286
|
end
|
1287
1287
|
|
1288
|
-
it "should provide a method that writes files with the correct modes" do
|
1289
|
-
@settings.should respond_to(:write)
|
1290
|
-
end
|
1291
|
-
|
1292
1288
|
it "should provide a method that creates directories with the correct modes" do
|
1293
1289
|
Puppet::Util::SUIDManager.expects(:asuser).with("suser", "sgroup").yields
|
1294
1290
|
Dir.expects(:mkdir).with(make_absolute("/otherdir"), 0755)
|
@@ -1567,17 +1563,6 @@ describe Puppet::Settings do
|
|
1567
1563
|
end
|
1568
1564
|
end
|
1569
1565
|
|
1570
|
-
describe "#writesub" do
|
1571
|
-
it "should only pass valid arguments to File.open" do
|
1572
|
-
settings = Puppet::Settings.new
|
1573
|
-
settings.stubs(:get_config_file_default).with(:privatekeydir).returns(OpenStruct.new(:mode => "750"))
|
1574
|
-
|
1575
|
-
File.expects(:open).with("/path/to/keydir", "w", 750).returns true
|
1576
|
-
settings.writesub(:privatekeydir, "/path/to/keydir")
|
1577
|
-
end
|
1578
|
-
end
|
1579
|
-
|
1580
|
-
|
1581
1566
|
describe "when dealing with command-line options" do
|
1582
1567
|
let(:settings) { Puppet::Settings.new }
|
1583
1568
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'puppet/ssl/certificate_authority/autosign_command'
|
4
|
+
|
5
|
+
describe Puppet::SSL::CertificateAuthority::AutosignCommand do
|
6
|
+
|
7
|
+
let(:csr) { stub 'csr', :name => 'host', :to_s => 'CSR PEM goes here' }
|
8
|
+
let(:decider) { Puppet::SSL::CertificateAuthority::AutosignCommand.new('/autosign/command') }
|
9
|
+
|
10
|
+
it "returns true if the command succeeded" do
|
11
|
+
executes_the_command_resulting_in(0)
|
12
|
+
|
13
|
+
decider.allowed?(csr).should == true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns false if the command failed" do
|
17
|
+
executes_the_command_resulting_in(1)
|
18
|
+
|
19
|
+
decider.allowed?(csr).should == false
|
20
|
+
end
|
21
|
+
|
22
|
+
def executes_the_command_resulting_in(exitstatus)
|
23
|
+
Puppet::Util::Execution.expects(:execute).
|
24
|
+
with(['/autosign/command', 'host'],
|
25
|
+
has_entries(:stdinfile => anything,
|
26
|
+
:combine => true,
|
27
|
+
:failonfail => false)).
|
28
|
+
returns(Puppet::Util::Execution::ProcessOutput.new('', exitstatus))
|
29
|
+
end
|
30
|
+
end
|
@@ -92,12 +92,6 @@ describe Puppet::SSL::CertificateAuthority do
|
|
92
92
|
Puppet::SSL::CertificateAuthority.new
|
93
93
|
end
|
94
94
|
|
95
|
-
it "should create an inventory instance" do
|
96
|
-
Puppet::SSL::Inventory.expects(:new).returns "inventory"
|
97
|
-
|
98
|
-
Puppet::SSL::CertificateAuthority.new.inventory.should == "inventory"
|
99
|
-
end
|
100
|
-
|
101
95
|
it "should make sure the CA is set up" do
|
102
96
|
Puppet::SSL::CertificateAuthority.any_instance.expects(:setup)
|
103
97
|
|
@@ -171,16 +165,16 @@ describe Puppet::SSL::CertificateAuthority do
|
|
171
165
|
it "should create and store a password at :capass" do
|
172
166
|
Puppet[:capass] = File.expand_path("/path/to/pass")
|
173
167
|
|
174
|
-
|
168
|
+
Puppet::FileSystem::File.expects(:exist?).with(Puppet[:capass]).returns false
|
175
169
|
|
176
|
-
fh =
|
177
|
-
Puppet.settings.expects(:
|
178
|
-
|
179
|
-
fh.expects(:print).with { |s| s.length > 18 }
|
170
|
+
fh = StringIO.new
|
171
|
+
Puppet.settings.setting(:capass).expects(:open).with('w').yields fh
|
180
172
|
|
181
173
|
@ca.stubs(:sign)
|
182
174
|
|
183
175
|
@ca.generate_ca_certificate
|
176
|
+
|
177
|
+
expect(fh.string.length).to be > 18
|
184
178
|
end
|
185
179
|
|
186
180
|
it "should generate a key if one does not exist" do
|
@@ -238,11 +232,10 @@ describe Puppet::SSL::CertificateAuthority do
|
|
238
232
|
|
239
233
|
Puppet::SSL::Certificate.stubs(:new).returns @cert
|
240
234
|
|
241
|
-
@cert.stubs(:content=)
|
242
235
|
Puppet::SSL::Certificate.indirection.stubs(:save)
|
243
236
|
|
244
237
|
# Stub out the factory
|
245
|
-
Puppet::SSL::CertificateFactory.stubs(:build).returns
|
238
|
+
Puppet::SSL::CertificateFactory.stubs(:build).returns @cert.content
|
246
239
|
|
247
240
|
@request_content = stub "request content stub", :subject => OpenSSL::X509::Name.new([['CN', @name]]), :public_key => stub('public_key')
|
248
241
|
@request = stub 'request', :name => @name, :request_extensions => [], :subject_alt_names => [], :content => @request_content
|
@@ -255,39 +248,6 @@ describe Puppet::SSL::CertificateAuthority do
|
|
255
248
|
Puppet::SSL::CertificateRequest.indirection.stubs(:destroy)
|
256
249
|
end
|
257
250
|
|
258
|
-
describe "and calculating the next certificate serial number" do
|
259
|
-
before do
|
260
|
-
@path = File.expand_path("/path/to/serial")
|
261
|
-
Puppet[:serial] = @path
|
262
|
-
|
263
|
-
@filehandle = stub 'filehandle', :<< => @filehandle
|
264
|
-
Puppet.settings.stubs(:readwritelock).with(:serial).yields @filehandle
|
265
|
-
end
|
266
|
-
|
267
|
-
it "should default to 0x1 for the first serial number" do
|
268
|
-
@ca.next_serial.should == 0x1
|
269
|
-
end
|
270
|
-
|
271
|
-
it "should return the current content of the serial file" do
|
272
|
-
FileTest.stubs(:exist?).with(@path).returns true
|
273
|
-
File.expects(:read).with(@path).returns "0002"
|
274
|
-
|
275
|
-
@ca.next_serial.should == 2
|
276
|
-
end
|
277
|
-
|
278
|
-
it "should write the next serial number to the serial file as hex" do
|
279
|
-
@filehandle.expects(:<<).with("0002")
|
280
|
-
|
281
|
-
@ca.next_serial
|
282
|
-
end
|
283
|
-
|
284
|
-
it "should lock the serial file while writing" do
|
285
|
-
Puppet.settings.expects(:readwritelock).with(:serial)
|
286
|
-
|
287
|
-
@ca.next_serial
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
251
|
describe "its own certificate" do
|
292
252
|
before do
|
293
253
|
@serial = 10
|
@@ -303,28 +263,28 @@ describe Puppet::SSL::CertificateAuthority do
|
|
303
263
|
it "should use a certificate type of :ca" do
|
304
264
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
305
265
|
args[0].should == :ca
|
306
|
-
end.returns
|
266
|
+
end.returns @cert.content
|
307
267
|
@ca.sign(@name, :ca, @request)
|
308
268
|
end
|
309
269
|
|
310
270
|
it "should pass the provided CSR as the CSR" do
|
311
271
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
312
272
|
args[1].should == @request
|
313
|
-
end.returns
|
273
|
+
end.returns @cert.content
|
314
274
|
@ca.sign(@name, :ca, @request)
|
315
275
|
end
|
316
276
|
|
317
277
|
it "should use the provided CSR's content as the issuer" do
|
318
278
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
319
279
|
args[2].subject.to_s.should == "/CN=myhost"
|
320
|
-
end.returns
|
280
|
+
end.returns @cert.content
|
321
281
|
@ca.sign(@name, :ca, @request)
|
322
282
|
end
|
323
283
|
|
324
284
|
it "should pass the next serial as the serial number" do
|
325
285
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
326
286
|
args[3].should == @serial
|
327
|
-
end.returns
|
287
|
+
end.returns @cert.content
|
328
288
|
@ca.sign(@name, :ca, @request)
|
329
289
|
end
|
330
290
|
|
@@ -355,7 +315,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
355
315
|
it "should use a certificate type of :server" do
|
356
316
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
357
317
|
args[0] == :server
|
358
|
-
end.returns
|
318
|
+
end.returns @cert.content
|
359
319
|
|
360
320
|
@ca.sign(@name)
|
361
321
|
end
|
@@ -404,14 +364,14 @@ describe Puppet::SSL::CertificateAuthority do
|
|
404
364
|
it "should use the CA certificate as the issuer" do
|
405
365
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
406
366
|
args[2] == @cacert.content
|
407
|
-
end.returns
|
408
|
-
@ca.sign(@name)
|
367
|
+
end.returns @cert.content
|
368
|
+
signed = @ca.sign(@name)
|
409
369
|
end
|
410
370
|
|
411
371
|
it "should pass the next serial as the serial number" do
|
412
372
|
Puppet::SSL::CertificateFactory.expects(:build).with do |*args|
|
413
373
|
args[3] == @serial
|
414
|
-
end.returns
|
374
|
+
end.returns @cert.content
|
415
375
|
@ca.sign(@name)
|
416
376
|
end
|
417
377
|
|
@@ -518,6 +478,40 @@ describe Puppet::SSL::CertificateAuthority do
|
|
518
478
|
end
|
519
479
|
end
|
520
480
|
|
481
|
+
it "accepts numeric OIDs under the ppRegCertExt subtree" do
|
482
|
+
exts = [{ 'oid' => '1.3.6.1.4.1.34380.1.1.1',
|
483
|
+
'value' => '657e4780-4cf5-11e3-8f96-0800200c9a66'}]
|
484
|
+
|
485
|
+
@request.stubs(:request_extensions).returns exts
|
486
|
+
|
487
|
+
expect {
|
488
|
+
@ca.check_internal_signing_policies(@name, @request, false)
|
489
|
+
}.to_not raise_error
|
490
|
+
end
|
491
|
+
|
492
|
+
it "accepts short name OIDs under the ppRegCertExt subtree" do
|
493
|
+
exts = [{ 'oid' => 'pp_uuid',
|
494
|
+
'value' => '657e4780-4cf5-11e3-8f96-0800200c9a66'}]
|
495
|
+
|
496
|
+
@request.stubs(:request_extensions).returns exts
|
497
|
+
|
498
|
+
expect {
|
499
|
+
@ca.check_internal_signing_policies(@name, @request, false)
|
500
|
+
}.to_not raise_error
|
501
|
+
end
|
502
|
+
|
503
|
+
it "accepts OIDs under the ppPrivCertAttrs subtree" do
|
504
|
+
exts = [{ 'oid' => '1.3.6.1.4.1.34380.1.2.1',
|
505
|
+
'value' => 'private extension'}]
|
506
|
+
|
507
|
+
@request.stubs(:request_extensions).returns exts
|
508
|
+
|
509
|
+
expect {
|
510
|
+
@ca.check_internal_signing_policies(@name, @request, false)
|
511
|
+
}.to_not raise_error
|
512
|
+
end
|
513
|
+
|
514
|
+
|
521
515
|
it "should reject a critical extension that isn't on the whitelist" do
|
522
516
|
@request.stubs(:request_extensions).returns [{ "oid" => "banana",
|
523
517
|
"value" => "yumm",
|
@@ -610,76 +604,104 @@ describe Puppet::SSL::CertificateAuthority do
|
|
610
604
|
end
|
611
605
|
|
612
606
|
describe "when autosigning certificates" do
|
613
|
-
let(:
|
614
|
-
it "should do nothing if autosign is disabled" do
|
615
|
-
Puppet[:autosign] = 'false'
|
607
|
+
let(:csr) { Puppet::SSL::CertificateRequest.new("host") }
|
616
608
|
|
617
|
-
|
618
|
-
|
619
|
-
end
|
609
|
+
describe "using the autosign setting" do
|
610
|
+
let(:autosign) { File.expand_path("/auto/sign") }
|
620
611
|
|
621
|
-
|
622
|
-
|
623
|
-
FileTest.expects(:exist?).with(autosign).returns false
|
612
|
+
it "should do nothing if autosign is disabled" do
|
613
|
+
Puppet[:autosign] = false
|
624
614
|
|
625
|
-
|
626
|
-
|
627
|
-
|
615
|
+
@ca.expects(:sign).never
|
616
|
+
@ca.autosign(csr)
|
617
|
+
end
|
628
618
|
|
629
|
-
|
630
|
-
before do
|
619
|
+
it "should do nothing if no autosign.conf exists" do
|
631
620
|
Puppet[:autosign] = autosign
|
632
|
-
|
633
|
-
File.
|
621
|
+
non_existent_file = Puppet::FileSystem::MemoryFile.a_missing_file(autosign)
|
622
|
+
Puppet::FileSystem::File.overlay(non_existent_file) do
|
623
|
+
@ca.expects(:sign).never
|
624
|
+
@ca.autosign(csr)
|
625
|
+
end
|
626
|
+
end
|
634
627
|
|
635
|
-
|
628
|
+
describe "and autosign is enabled and the autosign.conf file exists" do
|
629
|
+
let(:store) { stub 'store', :allow => nil, :allowed? => false }
|
636
630
|
|
637
|
-
|
638
|
-
|
639
|
-
|
631
|
+
before do
|
632
|
+
Puppet[:autosign] = autosign
|
633
|
+
end
|
640
634
|
|
641
|
-
|
642
|
-
|
643
|
-
|
635
|
+
describe "when creating the AuthStore instance to verify autosigning" do
|
636
|
+
it "should create an AuthStore with each line in the configuration file allowed to be autosigned" do
|
637
|
+
Puppet::FileSystem::File.overlay(Puppet::FileSystem::MemoryFile.a_regular_file_containing(autosign, "one\ntwo\n")) do
|
638
|
+
Puppet::Network::AuthStore.stubs(:new).returns store
|
644
639
|
|
645
|
-
|
646
|
-
|
640
|
+
store.expects(:allow).with("one")
|
641
|
+
store.expects(:allow).with("two")
|
647
642
|
|
648
|
-
|
649
|
-
|
643
|
+
@ca.autosign(csr)
|
644
|
+
end
|
645
|
+
end
|
650
646
|
|
651
|
-
|
652
|
-
|
647
|
+
it "should reparse the autosign configuration on each call" do
|
648
|
+
Puppet::FileSystem::File.overlay(Puppet::FileSystem::MemoryFile.a_regular_file_containing(autosign, "one")) do
|
649
|
+
Puppet::Network::AuthStore.stubs(:new).times(2).returns store
|
653
650
|
|
654
|
-
|
655
|
-
|
656
|
-
|
651
|
+
@ca.autosign(csr)
|
652
|
+
@ca.autosign(csr)
|
653
|
+
end
|
654
|
+
end
|
657
655
|
|
658
|
-
|
659
|
-
|
656
|
+
it "should ignore comments" do
|
657
|
+
Puppet::FileSystem::File.overlay(Puppet::FileSystem::MemoryFile.a_regular_file_containing(autosign, "one\n#two\n")) do
|
658
|
+
Puppet::Network::AuthStore.stubs(:new).returns store
|
660
659
|
|
661
|
-
|
662
|
-
@ca.autosign
|
663
|
-
end
|
660
|
+
store.expects(:allow).with("one")
|
664
661
|
|
665
|
-
|
666
|
-
|
662
|
+
@ca.autosign(csr)
|
663
|
+
end
|
664
|
+
end
|
667
665
|
|
668
|
-
|
669
|
-
|
666
|
+
it "should ignore blank lines" do
|
667
|
+
Puppet::FileSystem::File.overlay(Puppet::FileSystem::MemoryFile.a_regular_file_containing(autosign, "one\n\n")) do
|
668
|
+
Puppet::Network::AuthStore.stubs(:new).returns store
|
669
|
+
|
670
|
+
store.expects(:allow).with("one")
|
671
|
+
@ca.autosign(csr)
|
672
|
+
end
|
673
|
+
end
|
670
674
|
end
|
671
675
|
end
|
676
|
+
end
|
677
|
+
|
678
|
+
describe "using the autosign command setting" do
|
679
|
+
let(:cmd) { File.expand_path('/autosign_cmd') }
|
680
|
+
let(:autosign_cmd) { mock 'autosign_command' }
|
681
|
+
let(:autosign_executable) { Puppet::FileSystem::MemoryFile.an_executable(cmd) }
|
682
|
+
|
683
|
+
before do
|
684
|
+
Puppet[:autosign] = cmd
|
685
|
+
|
686
|
+
Puppet::SSL::CertificateAuthority::AutosignCommand.stubs(:new).returns autosign_cmd
|
687
|
+
end
|
672
688
|
|
673
|
-
it "
|
674
|
-
|
675
|
-
|
676
|
-
|
689
|
+
it "autosigns the CSR if the autosign command returned true" do
|
690
|
+
Puppet::FileSystem::File.overlay(autosign_executable) do
|
691
|
+
autosign_cmd.expects(:allowed?).with(csr).returns true
|
692
|
+
|
693
|
+
@ca.expects(:sign).with('host')
|
694
|
+
@ca.autosign(csr)
|
695
|
+
end
|
677
696
|
end
|
678
697
|
|
679
|
-
it "
|
680
|
-
|
681
|
-
|
682
|
-
|
698
|
+
it "doesn't autosign the CSR if the autosign_command returned false" do
|
699
|
+
Puppet::FileSystem::File.overlay(autosign_executable) do
|
700
|
+
autosign_cmd.expects(:allowed?).with(csr).returns false
|
701
|
+
|
702
|
+
@ca.expects(:sign).never
|
703
|
+
@ca.autosign(csr)
|
704
|
+
end
|
683
705
|
end
|
684
706
|
end
|
685
707
|
end
|
@@ -701,28 +723,6 @@ describe Puppet::SSL::CertificateAuthority do
|
|
701
723
|
@ca = Puppet::SSL::CertificateAuthority.new
|
702
724
|
end
|
703
725
|
|
704
|
-
it "should have a method for acting on the SSL files" do
|
705
|
-
@ca.should respond_to(:apply)
|
706
|
-
end
|
707
|
-
|
708
|
-
describe "when applying a method to a set of hosts" do
|
709
|
-
it "should fail if no subjects have been specified" do
|
710
|
-
expect { @ca.apply(:generate) }.to raise_error(ArgumentError)
|
711
|
-
end
|
712
|
-
|
713
|
-
it "should create an Interface instance with the specified method and the options" do
|
714
|
-
Puppet::SSL::CertificateAuthority::Interface.expects(:new).with(:generate, :to => :host).returns(stub('applier', :apply => nil))
|
715
|
-
@ca.apply(:generate, :to => :host)
|
716
|
-
end
|
717
|
-
|
718
|
-
it "should apply the Interface with itself as the argument" do
|
719
|
-
applier = stub('applier')
|
720
|
-
applier.expects(:apply).with(@ca)
|
721
|
-
Puppet::SSL::CertificateAuthority::Interface.expects(:new).returns applier
|
722
|
-
@ca.apply(:generate, :to => :ca_testing)
|
723
|
-
end
|
724
|
-
end
|
725
|
-
|
726
726
|
it "should be able to list waiting certificate requests" do
|
727
727
|
req1 = stub 'req1', :name => "one"
|
728
728
|
req2 = stub 'req2', :name => "two"
|
@@ -979,16 +979,15 @@ require 'puppet/indirector/memory'
|
|
979
979
|
describe "CertificateAuthority.generate" do
|
980
980
|
|
981
981
|
def expect_to_increment_serial_file
|
982
|
-
Puppet.settings.
|
982
|
+
Puppet.settings.setting(:serial).expects(:exclusive_open)
|
983
983
|
end
|
984
984
|
|
985
985
|
def expect_to_sign_a_cert
|
986
986
|
expect_to_increment_serial_file
|
987
|
-
Puppet.settings.expects(:write).with(:cert_inventory, "a")
|
988
987
|
end
|
989
988
|
|
990
989
|
def expect_to_write_the_ca_password
|
991
|
-
Puppet.settings.expects(:
|
990
|
+
Puppet.settings.setting(:capass).expects(:open).with('w')
|
992
991
|
end
|
993
992
|
|
994
993
|
def expect_ca_initialization
|
@@ -996,10 +995,6 @@ describe "CertificateAuthority.generate" do
|
|
996
995
|
expect_to_sign_a_cert
|
997
996
|
end
|
998
997
|
|
999
|
-
def avoid_rebuilding_inventory_for_every_cert
|
1000
|
-
Puppet::SSL::Inventory.any_instance.stubs(:rebuild)
|
1001
|
-
end
|
1002
|
-
|
1003
998
|
INDIRECTED_CLASSES = [
|
1004
999
|
Puppet::SSL::Certificate,
|
1005
1000
|
Puppet::SSL::CertificateRequest,
|
@@ -1021,7 +1016,7 @@ describe "CertificateAuthority.generate" do
|
|
1021
1016
|
end
|
1022
1017
|
|
1023
1018
|
before do
|
1024
|
-
|
1019
|
+
Puppet::SSL::Inventory.stubs(:new).returns(stub("Inventory", :add => nil))
|
1025
1020
|
INDIRECTED_CLASSES.each { |const| const.indirection.terminus_class = :memory }
|
1026
1021
|
end
|
1027
1022
|
|
@@ -1036,7 +1031,7 @@ describe "CertificateAuthority.generate" do
|
|
1036
1031
|
let(:ca) { Puppet::SSL::CertificateAuthority.new }
|
1037
1032
|
|
1038
1033
|
before do
|
1039
|
-
expect_ca_initialization
|
1034
|
+
expect_ca_initialization
|
1040
1035
|
end
|
1041
1036
|
|
1042
1037
|
it "should fail if a certificate already exists for the host" do
|