puppet 2.7.19 → 2.7.20.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 +61 -238
- data/Gemfile +32 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +1 -1
- data/README_DEVELOPER.md +300 -5
- data/Rakefile +41 -37
- data/ext/build_defaults.yaml +20 -0
- data/ext/debian/README.Debian +8 -0
- data/ext/debian/README.source +2 -0
- data/ext/debian/TODO.Debian +1 -0
- data/ext/debian/changelog.erb +1104 -0
- data/ext/debian/compat +1 -0
- data/ext/debian/control +142 -0
- data/ext/debian/copyright +361 -0
- data/ext/debian/docs +1 -0
- data/ext/debian/fileserver.conf +17 -0
- data/ext/debian/puppet-common.dirs +8 -0
- data/ext/debian/puppet-common.install +3 -0
- data/ext/debian/puppet-common.lintian-overrides +7 -0
- data/ext/debian/puppet-common.manpages +2 -0
- data/ext/debian/puppet-common.postinst +35 -0
- data/ext/debian/puppet-common.postrm +32 -0
- data/ext/debian/puppet-el.dirs +1 -0
- data/ext/debian/puppet-el.emacsen-install +25 -0
- data/ext/debian/puppet-el.emacsen-remove +11 -0
- data/ext/debian/puppet-el.emacsen-startup +9 -0
- data/ext/debian/puppet-el.install +1 -0
- data/ext/debian/puppet-testsuite.install +3 -0
- data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
- data/ext/debian/puppet.NEWS +86 -0
- data/ext/debian/puppet.conf +14 -0
- data/ext/debian/puppet.default +7 -0
- data/ext/debian/puppet.dirs +1 -0
- data/ext/debian/puppet.init +118 -0
- data/ext/debian/puppet.install +4 -0
- data/ext/debian/puppet.lintian-overrides +3 -0
- data/ext/debian/puppet.logrotate +11 -0
- data/ext/debian/puppet.manpages +36 -0
- data/ext/debian/puppet.postinst +20 -0
- data/ext/debian/puppet.postrm +20 -0
- data/ext/debian/puppet.preinst +20 -0
- data/ext/debian/puppetmaster-common.install +5 -0
- data/ext/debian/puppetmaster-common.manpages +5 -0
- data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
- data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
- data/ext/debian/puppetmaster-passenger.dirs +4 -0
- data/ext/debian/puppetmaster-passenger.postinst +66 -0
- data/ext/debian/puppetmaster-passenger.postrm +33 -0
- data/ext/debian/puppetmaster.NEWS +13 -0
- data/ext/debian/puppetmaster.README.debian +16 -0
- data/ext/debian/puppetmaster.default +38 -0
- data/ext/debian/puppetmaster.dirs +1 -0
- data/ext/debian/puppetmaster.init +158 -0
- data/ext/debian/puppetmaster.install +1 -0
- data/ext/debian/puppetmaster.lintian-overrides +3 -0
- data/ext/debian/puppetmaster.manpages +1 -0
- data/ext/debian/puppetmaster.postinst +20 -0
- data/ext/debian/puppetmaster.postrm +5 -0
- data/ext/debian/puppetmaster.preinst +22 -0
- data/ext/debian/rules +127 -0
- data/ext/debian/source/format +1 -0
- data/ext/debian/source/options +1 -0
- data/ext/debian/vim-puppet.README.Debian +13 -0
- data/ext/debian/vim-puppet.dirs +3 -0
- data/ext/debian/vim-puppet.yaml +5 -0
- data/ext/debian/watch +2 -0
- data/ext/emacs/puppet-mode.el +1 -0
- data/{conf → ext}/osx/PackageInfo.plist +0 -0
- data/{conf → ext}/osx/createpackage.sh +0 -0
- data/ext/osx/file_mapping.yaml +38 -0
- data/ext/osx/preflight.erb +37 -0
- data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
- data/ext/packaging/README-Solaris.md +117 -0
- data/ext/packaging/README.md +255 -0
- data/ext/packaging/spec/spec_helper.rb +12 -0
- data/ext/packaging/spec/tasks/00_utils_spec.rb +66 -0
- data/ext/packaging/tasks/00_utils.rake +382 -0
- data/ext/packaging/tasks/10_setupvars.rake +71 -0
- data/ext/packaging/tasks/20_setupextravars.rake +25 -0
- data/ext/packaging/tasks/apple.rake +201 -0
- data/ext/packaging/tasks/clean.rake +5 -0
- data/ext/packaging/tasks/deb.rake +108 -0
- data/ext/packaging/tasks/doc.rake +20 -0
- data/ext/packaging/tasks/fetch.rake +18 -0
- data/ext/packaging/tasks/gem.rake +68 -0
- data/ext/packaging/tasks/ips.rake +80 -0
- data/ext/packaging/tasks/mock.rake +126 -0
- data/ext/packaging/tasks/pe_deb.rake +9 -0
- data/ext/packaging/tasks/pe_remote.rake +45 -0
- data/ext/packaging/tasks/pe_rpm.rake +21 -0
- data/ext/packaging/tasks/pe_ship.rake +30 -0
- data/ext/packaging/tasks/pe_sign.rake +27 -0
- data/ext/packaging/tasks/pe_sles.rake +96 -0
- data/ext/packaging/tasks/release.rake +73 -0
- data/ext/packaging/tasks/remote_build.rake +78 -0
- data/ext/packaging/tasks/rpm.rake +52 -0
- data/ext/packaging/tasks/ship.rake +78 -0
- data/ext/packaging/tasks/sign.rake +82 -0
- data/ext/packaging/tasks/tag.rake +8 -0
- data/ext/packaging/tasks/tar.rake +68 -0
- data/ext/packaging/tasks/template.rake +13 -0
- data/ext/packaging/tasks/update.rake +16 -0
- data/ext/packaging/tasks/version.rake +21 -0
- data/ext/project_data.yaml +24 -0
- data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +18 -10
- data/install.rb +8 -8
- data/lib/puppet.rb +2 -6
- data/lib/puppet/agent/locker.rb +2 -0
- data/lib/puppet/application.rb +1 -1
- data/lib/puppet/application/agent.rb +1 -1
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/cert.rb +5 -6
- data/lib/puppet/application/describe.rb +1 -1
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/kick.rb +1 -1
- data/lib/puppet/application/master.rb +1 -1
- data/lib/puppet/application/resource.rb +1 -1
- data/lib/puppet/defaults.rb +21 -3
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/help/global.erb +1 -1
- data/lib/puppet/face/module/install.rb +1 -1
- data/lib/puppet/face/module/list.rb +1 -1
- data/lib/puppet/face/module/uninstall.rb +1 -1
- data/lib/puppet/face/node/clean.rb +23 -18
- data/lib/puppet/face/parser.rb +11 -2
- data/lib/puppet/file_collection.rb +16 -27
- data/lib/puppet/file_collection/lookup.rb +6 -16
- data/lib/puppet/file_serving/base.rb +4 -4
- data/lib/puppet/indirector/catalog/static_compiler.rb +3 -4
- data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/face.rb +2 -2
- data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
- data/lib/puppet/indirector/node/exec.rb +13 -1
- data/lib/puppet/indirector/request.rb +4 -0
- data/lib/puppet/metatype/manager.rb +17 -10
- data/lib/puppet/network/authstore.rb +1 -1
- data/lib/puppet/network/rights.rb +1 -2
- data/lib/puppet/node/environment.rb +1 -0
- data/lib/puppet/parameter/value.rb +9 -3
- data/lib/puppet/parser/ast.rb +1 -4
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +68 -22
- data/lib/puppet/parser/functions/create_resources.rb +2 -3
- data/lib/puppet/parser/functions/shellquote.rb +21 -25
- data/lib/puppet/parser/lexer.rb +40 -6
- data/lib/puppet/parser/relationship.rb +3 -1
- data/lib/puppet/parser/resource.rb +2 -3
- data/lib/puppet/parser/resource/param.rb +3 -5
- data/lib/puppet/parser/scope.rb +7 -4
- data/lib/puppet/property.rb +5 -3
- data/lib/puppet/provider.rb +5 -5
- data/lib/puppet/provider/aixobject.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/file/windows.rb +10 -29
- data/lib/puppet/provider/group/groupadd.rb +2 -3
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/group/windows_adsi.rb +1 -1
- data/lib/puppet/provider/ldap.rb +5 -1
- data/lib/puppet/provider/nameservice.rb +3 -3
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/gem.rb +6 -2
- data/lib/puppet/provider/package/portage.rb +4 -2
- data/lib/puppet/provider/parsedfile.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/base.rb +2 -41
- data/lib/puppet/provider/service/daemontools.rb +1 -1
- data/lib/puppet/provider/service/launchd.rb +1 -1
- data/lib/puppet/provider/service/redhat.rb +6 -5
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/service/service.rb +43 -0
- data/lib/puppet/provider/service/windows.rb +1 -8
- data/lib/puppet/provider/user/user_role_add.rb +2 -1
- data/lib/puppet/provider/user/useradd.rb +8 -3
- data/lib/puppet/provider/user/windows_adsi.rb +12 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails/inventory_node.rb +26 -13
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource.rb +20 -5
- data/lib/puppet/resource/status.rb +1 -1
- data/lib/puppet/ssl/certificate_authority.rb +2 -0
- data/lib/puppet/ssl/host.rb +31 -6
- data/lib/puppet/test/test_helper.rb +3 -1
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/report.rb +2 -2
- data/lib/puppet/type.rb +30 -25
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/cron.rb +2 -2
- data/lib/puppet/type/exec.rb +6 -6
- data/lib/puppet/type/file.rb +5 -15
- data/lib/puppet/type/file/content.rb +1 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +1 -1
- data/lib/puppet/type/file/selcontext.rb +6 -2
- data/lib/puppet/type/file/source.rb +1 -1
- data/lib/puppet/type/mount.rb +1 -1
- data/lib/puppet/type/package.rb +1 -1
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/scheduled_task.rb +1 -1
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/whit.rb +16 -9
- data/lib/puppet/util.rb +27 -11
- data/lib/puppet/util/adsi.rb +25 -23
- data/lib/puppet/util/autoload.rb +1 -1
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/feature.rb +3 -1
- data/lib/puppet/util/fileparsing.rb +9 -9
- data/lib/puppet/util/filetype.rb +55 -40
- data/lib/puppet/util/instance_loader.rb +5 -5
- data/lib/puppet/util/instrumentation.rb +3 -5
- data/lib/puppet/util/log_paths.rb +1 -3
- data/lib/puppet/util/monkey_patches.rb +34 -8
- data/lib/puppet/util/platform.rb +7 -0
- data/lib/puppet/util/posix.rb +3 -3
- data/lib/puppet/util/provider_features.rb +2 -3
- data/lib/puppet/util/rdoc.rb +4 -3
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/selinux.rb +31 -36
- data/lib/puppet/util/tagging.rb +28 -6
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/process.rb +3 -3
- data/lib/puppet/util/windows/security.rb +9 -46
- data/lib/puppet/util/windows/sid.rb +96 -0
- data/lib/puppet/util/windows/user.rb +65 -2
- data/lib/puppet/util/zaml.rb +109 -59
- data/lib/puppet/version.rb +18 -0
- data/spec/fixtures/unit/util/filetype/aixtab_output +44 -0
- data/spec/fixtures/unit/util/filetype/suntab_output +9 -0
- data/spec/integration/defaults_spec.rb +26 -7
- data/spec/integration/parser/functions_spec.rb +0 -4
- data/spec/integration/util/file_locking_spec.rb +1 -1
- data/spec/integration/util/windows/security_spec.rb +3 -23
- data/spec/lib/puppet_spec/files.rb +3 -3
- data/spec/shared_contexts/platform.rb +8 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/application/queue_spec.rb +2 -1
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/face/{instrumentation_data.rb → instrumentation_data_spec.rb} +0 -0
- data/spec/unit/face/{instrumentation_listener.rb → instrumentation_listener_spec.rb} +0 -0
- data/spec/unit/face/{instrumentation_probe.rb → instrumentation_probe_spec.rb} +0 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
- data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
- data/spec/unit/indirector/request_spec.rb +22 -0
- data/spec/unit/network/http/webrick_spec.rb +0 -7
- data/spec/unit/node/environment_spec.rb +8 -8
- data/spec/unit/parser/ast_spec.rb +0 -5
- data/spec/unit/parser/collector_spec.rb +1 -0
- data/spec/unit/parser/files_spec.rb +2 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +3 -4
- data/spec/unit/parser/functions/require_spec.rb +0 -6
- data/spec/unit/parser/functions/shellquote_spec.rb +0 -5
- data/spec/unit/parser/functions/template_spec.rb +6 -1
- data/spec/unit/parser/functions_spec.rb +73 -23
- data/spec/unit/parser/lexer_spec.rb +133 -8
- data/spec/unit/parser/relationship_spec.rb +24 -0
- data/spec/unit/parser/resource_spec.rb +0 -4
- data/spec/unit/parser/scope_spec.rb +2 -2
- data/spec/unit/property_spec.rb +21 -1
- data/spec/unit/provider/exec/posix_spec.rb +7 -6
- data/spec/unit/provider/file/windows_spec.rb +29 -29
- data/spec/unit/provider/group/groupadd_spec.rb +36 -30
- data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +12 -0
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
- data/spec/unit/provider/service/redhat_spec.rb +11 -1
- data/spec/unit/provider/service/windows_spec.rb +19 -0
- data/spec/unit/provider/user/ldap_spec.rb +22 -8
- data/spec/unit/provider/user/user_role_add_spec.rb +12 -0
- data/spec/unit/provider/user/useradd_spec.rb +146 -118
- data/spec/unit/provider/user/windows_adsi_spec.rb +24 -2
- data/spec/unit/puppet_spec.rb +10 -0
- data/spec/unit/resource/status_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +73 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +25 -1
- data/spec/unit/ssl/host_spec.rb +73 -27
- data/spec/unit/ssl/key_spec.rb +0 -4
- data/spec/unit/transaction/event_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +1 -1
- data/spec/unit/type/file/content_spec.rb +6 -4
- data/spec/unit/type/file/{ctime.rb → ctime_spec.rb} +0 -0
- data/spec/unit/type/file/{mtime.rb → mtime_spec.rb} +0 -0
- data/spec/unit/type/file/{type.rb → type_spec.rb} +0 -0
- data/spec/unit/type/file_spec.rb +2 -12
- data/spec/unit/type/host_spec.rb +14 -5
- data/spec/unit/type/mount_spec.rb +8 -0
- data/spec/unit/type/scheduled_task_spec.rb +2 -2
- data/spec/unit/util/adsi_spec.rb +23 -8
- data/spec/unit/util/command_line_spec.rb +11 -2
- data/spec/unit/util/feature_spec.rb +12 -1
- data/spec/unit/util/filetype_spec.rb +161 -55
- data/spec/unit/util/log_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +7 -0
- data/spec/unit/util/rdoc_spec.rb +8 -2
- data/spec/unit/util/selinux_spec.rb +24 -32
- data/spec/unit/util/windows/sid_spec.rb +100 -0
- data/spec/unit/util/zaml_spec.rb +165 -25
- data/spec/unit/util_spec.rb +3 -9
- data/spec/watchr.rb +2 -6
- data/tasks/rake/gem.rake +4 -2
- data/tasks/rake/sign.rake +1 -1
- data/test/language/parser.rb +1 -0
- data/test/language/scope.rb +0 -5
- data/test/language/snippets.rb +1 -2
- data/test/lib/puppettest.rb +16 -27
- data/test/lib/puppettest/parsertesting.rb +0 -1
- data/test/network/authstore.rb +2 -4
- data/test/puppet/defaults.rb +0 -4
- data/test/util/fileparsing.rb +2 -6
- metadata +1706 -1617
- data/conf/osx/preflight +0 -24
- data/spec/spec.opts +0 -4
- data/spec/unit/file_collection/lookup_spec.rb +0 -45
- data/spec/unit/file_collection_spec.rb +0 -52
- data/tasks/rake/apple.rake +0 -176
- data/test/puppet/errortest.rb +0 -19
@@ -114,6 +114,25 @@ describe Puppet::Type.type(:service).provider(:windows), :if => Puppet.features.
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
describe "#restart" do
|
118
|
+
it "should use the supplied restart command if specified" do
|
119
|
+
resource[:restart] = 'c:/bin/foo'
|
120
|
+
|
121
|
+
provider.expects(:execute).never
|
122
|
+
provider.expects(:execute).with(['c:/bin/foo'], :failonfail => true, :squelch => true)
|
123
|
+
|
124
|
+
provider.restart
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should restart the service" do
|
128
|
+
seq = sequence("restarting")
|
129
|
+
provider.expects(:stop).in_sequence(seq)
|
130
|
+
provider.expects(:start).in_sequence(seq)
|
131
|
+
|
132
|
+
provider.restart
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
117
136
|
describe "#enabled?" do
|
118
137
|
it "should report a service with a startup type of manual as manual" do
|
119
138
|
config.start_type = Win32::Service.get_start_type(Win32::Service::SERVICE_DEMAND_START)
|
@@ -24,14 +24,6 @@ describe provider_class do
|
|
24
24
|
provider_class.should be_manages_passwords
|
25
25
|
end
|
26
26
|
|
27
|
-
it "should use the ldap group provider to convert group names to numbers" do
|
28
|
-
provider = provider_class.new(:name => "foo")
|
29
|
-
Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with("bar").returns 10
|
30
|
-
|
31
|
-
provider.gid = 'bar'
|
32
|
-
provider.gid.should == 10
|
33
|
-
end
|
34
|
-
|
35
27
|
{:name => "uid",
|
36
28
|
:password => "userPassword",
|
37
29
|
:comment => "cn",
|
@@ -53,10 +45,13 @@ describe provider_class do
|
|
53
45
|
end
|
54
46
|
|
55
47
|
it "should generate the sn as the last field of the cn" do
|
48
|
+
Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with(["whatever"]).returns [123]
|
49
|
+
|
56
50
|
resource = stub 'resource', :should => %w{whatever}
|
57
51
|
resource.stubs(:should).with(:comment).returns ["Luke Kanies"]
|
58
52
|
resource.stubs(:should).with(:ensure).returns :present
|
59
53
|
instance = provider_class.new(:name => "luke", :ensure => :absent)
|
54
|
+
|
60
55
|
instance.stubs(:resource).returns resource
|
61
56
|
|
62
57
|
@connection.expects(:add).with { |dn, attrs| attrs["sn"] == ["Kanies"] }
|
@@ -65,8 +60,25 @@ describe provider_class do
|
|
65
60
|
instance.flush
|
66
61
|
end
|
67
62
|
|
63
|
+
it "should translate a group name to the numeric id" do
|
64
|
+
Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with("bar").returns 101
|
65
|
+
|
66
|
+
resource = stub 'resource', :should => %w{whatever}
|
67
|
+
resource.stubs(:should).with(:gid).returns 'bar'
|
68
|
+
resource.stubs(:should).with(:ensure).returns :present
|
69
|
+
instance = provider_class.new(:name => "luke", :ensure => :absent)
|
70
|
+
instance.stubs(:resource).returns resource
|
71
|
+
|
72
|
+
@connection.expects(:add).with { |dn, attrs| attrs["gidNumber"] == ["101"] }
|
73
|
+
|
74
|
+
instance.create
|
75
|
+
instance.flush
|
76
|
+
end
|
77
|
+
|
68
78
|
describe "with no uid specified" do
|
69
79
|
it "should pick the first available UID after the largest existing UID" do
|
80
|
+
Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with(["whatever"]).returns [123]
|
81
|
+
|
70
82
|
low = {:name=>["luke"], :shell=>:absent, :uid=>["600"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["l k"]}
|
71
83
|
high = {:name=>["testing"], :shell=>:absent, :uid=>["640"], :home=>["/h"], :gid=>["1000"], :password=>["blah"], :comment=>["t u"]}
|
72
84
|
provider_class.manager.expects(:search).returns([low, high])
|
@@ -84,6 +96,8 @@ describe provider_class do
|
|
84
96
|
end
|
85
97
|
|
86
98
|
it "should pick 501 of no users exist" do
|
99
|
+
Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with(["whatever"]).returns [123]
|
100
|
+
|
87
101
|
provider_class.manager.expects(:search).returns nil
|
88
102
|
|
89
103
|
resource = stub 'resource', :should => %w{whatever}
|
@@ -300,4 +300,16 @@ FIXTURE
|
|
300
300
|
@provider.shadow_entry.should == ["fakeval", "*", "20", "10", "30", "7", "2"]
|
301
301
|
end
|
302
302
|
end
|
303
|
+
|
304
|
+
describe "#password_max_age" do
|
305
|
+
it "should return a maximum age number" do
|
306
|
+
File.stubs(:readlines).returns(["fakeval:NP:12345:0:50::::\n"])
|
307
|
+
@provider.password_max_age.should == "50"
|
308
|
+
end
|
309
|
+
|
310
|
+
it "should return -1 for no maximum" do
|
311
|
+
File.stubs(:readlines).returns(["fakeval:NP:12345::::::\n"])
|
312
|
+
@provider.password_max_age.should == -1
|
313
|
+
end
|
314
|
+
end
|
303
315
|
end
|
@@ -1,111 +1,140 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@provider = provider_class.new(@resource)
|
4
|
+
describe Puppet::Type.type(:user).provider(:useradd) do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
described_class.stubs(:command).with(:password).returns '/usr/bin/chage'
|
8
|
+
described_class.stubs(:command).with(:add).returns '/usr/sbin/useradd'
|
9
|
+
described_class.stubs(:command).with(:modify).returns '/usr/sbin/usermod'
|
10
|
+
described_class.stubs(:command).with(:delete).returns '/usr/sbin/userdel'
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
let(:resource) do
|
14
|
+
Puppet::Type.type(:user).new(
|
15
|
+
:name => 'myuser',
|
16
|
+
:managehome => :false,
|
17
|
+
:system => :false,
|
18
|
+
:provider => provider
|
19
|
+
)
|
21
20
|
end
|
22
21
|
|
23
|
-
|
24
|
-
@resource.expects(:allowdupe?).returns true
|
25
|
-
@provider.expects(:execute).with { |args| args.include?("-o") }
|
22
|
+
let(:provider) { described_class.new(:name => 'myuser') }
|
26
23
|
|
27
|
-
|
28
|
-
|
24
|
+
describe "#create" do
|
25
|
+
|
26
|
+
it "should add -o when allowdupe is enabled and the user is being created" do
|
27
|
+
resource[:allowdupe] = true
|
28
|
+
provider.expects(:execute).with(['/usr/sbin/useradd', '-o', 'myuser'])
|
29
|
+
provider.create
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "on systems that support has_system", :if => described_class.system_users? do
|
33
|
+
it "should add -r when system is enabled" do
|
34
|
+
resource[:system] = :true
|
35
|
+
provider.should be_system_users
|
36
|
+
provider.expects(:execute).with(['/usr/sbin/useradd', '-r', 'myuser'])
|
37
|
+
provider.create
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "on systems that do not support has_system", :unless => described_class.system_users? do
|
42
|
+
it "should not add -r when system is enabled" do
|
43
|
+
resource[:system] = :true
|
44
|
+
provider.should_not be_system_users
|
45
|
+
provider.expects(:execute).with(['/usr/sbin/useradd', 'myuser'])
|
46
|
+
provider.create
|
47
|
+
end
|
48
|
+
end
|
29
49
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
50
|
+
it "should set password age rules" do
|
51
|
+
described_class.has_feature :manages_password_age
|
52
|
+
resource[:password_min_age] = 5
|
53
|
+
resource[:password_max_age] = 10
|
54
|
+
provider.expects(:execute).with(['/usr/sbin/useradd', 'myuser'])
|
55
|
+
provider.expects(:execute).with(['/usr/bin/chage', '-m', 5, '-M', 10, 'myuser'])
|
56
|
+
provider.create
|
57
|
+
end
|
36
58
|
end
|
37
59
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@provider.create
|
60
|
+
describe "#uid=" do
|
61
|
+
it "should add -o when allowdupe is enabled and the uid is being modified" do
|
62
|
+
resource[:allowdupe] = :true
|
63
|
+
provider.expects(:execute).with(['/usr/sbin/usermod', '-u', 150, '-o', 'myuser'])
|
64
|
+
provider.uid = 150
|
65
|
+
end
|
45
66
|
end
|
46
67
|
|
47
|
-
describe "
|
68
|
+
describe "#check_allow_dup" do
|
48
69
|
it "should check allow dup" do
|
49
|
-
|
50
|
-
|
70
|
+
resource.expects(:allowdupe?)
|
71
|
+
provider.check_allow_dup
|
51
72
|
end
|
52
73
|
|
53
74
|
it "should return an array with a flag if dup is allowed" do
|
54
|
-
|
55
|
-
|
75
|
+
resource[:allowdupe] = :true
|
76
|
+
provider.check_allow_dup.must == ["-o"]
|
56
77
|
end
|
57
78
|
|
58
79
|
it "should return an empty array if no dup is allowed" do
|
59
|
-
|
60
|
-
|
80
|
+
resource[:allowdupe] = :false
|
81
|
+
provider.check_allow_dup.must == []
|
61
82
|
end
|
62
83
|
end
|
63
84
|
|
64
|
-
describe "
|
85
|
+
describe "#check_system_users" do
|
65
86
|
it "should check system users" do
|
66
|
-
|
67
|
-
|
87
|
+
described_class.expects(:system_users?).returns true
|
88
|
+
resource.expects(:system?)
|
89
|
+
provider.check_system_users
|
68
90
|
end
|
69
91
|
|
70
92
|
it "should return an array with a flag if it's a system user" do
|
71
|
-
|
72
|
-
|
93
|
+
described_class.expects(:system_users?).returns true
|
94
|
+
resource[:system] = :true
|
95
|
+
provider.check_system_users.must == ["-r"]
|
73
96
|
end
|
74
97
|
|
75
98
|
it "should return an empty array if it's not a system user" do
|
76
|
-
|
77
|
-
|
99
|
+
described_class.expects(:system_users?).returns true
|
100
|
+
resource[:system] = :false
|
101
|
+
provider.check_system_users.must == []
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return an empty array if system user is not featured" do
|
105
|
+
described_class.expects(:system_users?).returns false
|
106
|
+
resource[:system] = :true
|
107
|
+
provider.check_system_users.must == []
|
78
108
|
end
|
79
109
|
end
|
80
110
|
|
81
|
-
describe "
|
111
|
+
describe "#check_manage_home" do
|
82
112
|
it "should check manage home" do
|
83
|
-
|
84
|
-
|
113
|
+
resource.expects(:managehome?)
|
114
|
+
provider.check_manage_home
|
85
115
|
end
|
86
116
|
|
87
117
|
it "should return an array with -m flag if home is managed" do
|
88
|
-
|
89
|
-
|
118
|
+
resource[:managehome] = :true
|
119
|
+
provider.check_manage_home.must == ["-m"]
|
90
120
|
end
|
91
|
-
|
121
|
+
|
92
122
|
it "should return an array with -r flag if home is managed" do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
@provider.deletecmd.must == ["userdel", "-r", "fakeval"]
|
123
|
+
resource[:managehome] = :true
|
124
|
+
resource[:ensure] = :absent
|
125
|
+
provider.deletecmd.must == ['/usr/sbin/userdel', '-r', 'myuser']
|
97
126
|
end
|
98
127
|
|
99
128
|
it "should return an array with -M if home is not managed and on Redhat" do
|
100
|
-
Facter.stubs(:value).with(
|
101
|
-
|
102
|
-
|
129
|
+
Facter.stubs(:value).with(:operatingsystem).returns("RedHat")
|
130
|
+
resource[:managehome] = :false
|
131
|
+
provider.check_manage_home.must == ["-M"]
|
103
132
|
end
|
104
133
|
|
105
134
|
it "should return an empty array if home is not managed and not on Redhat" do
|
106
|
-
Facter.stubs(:value).with(
|
107
|
-
|
108
|
-
|
135
|
+
Facter.stubs(:value).with(:operatingsystem).returns("some OS")
|
136
|
+
resource[:managehome] = :false
|
137
|
+
provider.check_manage_home.must == []
|
109
138
|
end
|
110
139
|
end
|
111
140
|
|
@@ -116,107 +145,106 @@ describe provider_class do
|
|
116
145
|
it "should return and array of flags and values"
|
117
146
|
end
|
118
147
|
|
119
|
-
describe "
|
148
|
+
describe "#addcmd" do
|
120
149
|
before do
|
121
|
-
|
122
|
-
|
123
|
-
|
150
|
+
resource[:allowdupe] = :true
|
151
|
+
resource[:managehome] = :true
|
152
|
+
resource[:system] = :true
|
124
153
|
end
|
125
154
|
|
126
155
|
it "should call command with :add" do
|
127
|
-
|
128
|
-
|
156
|
+
provider.expects(:command).with(:add)
|
157
|
+
provider.addcmd
|
129
158
|
end
|
130
159
|
|
131
160
|
it "should add properties" do
|
132
|
-
|
133
|
-
|
161
|
+
provider.expects(:add_properties).returns(['-foo_add_properties'])
|
162
|
+
provider.addcmd.should include '-foo_add_properties'
|
134
163
|
end
|
135
164
|
|
136
165
|
it "should check and add if dup allowed" do
|
137
|
-
|
138
|
-
|
166
|
+
provider.expects(:check_allow_dup).returns(['-allow_dup_flag'])
|
167
|
+
provider.addcmd.should include '-allow_dup_flag'
|
139
168
|
end
|
140
169
|
|
141
170
|
it "should check and add if home is managed" do
|
142
|
-
|
143
|
-
|
171
|
+
provider.expects(:check_manage_home).returns(['-manage_home_flag'])
|
172
|
+
provider.addcmd.should include '-manage_home_flag'
|
144
173
|
end
|
145
174
|
|
146
175
|
it "should add the resource :name" do
|
147
|
-
|
148
|
-
@provider.addcmd
|
176
|
+
provider.addcmd.should include 'myuser'
|
149
177
|
end
|
150
178
|
|
151
|
-
|
152
|
-
|
179
|
+
describe "on systems featuring system_users", :if => described_class.system_users? do
|
180
|
+
it "should return an array with -r if system? is true" do
|
181
|
+
resource[:system] = :true
|
182
|
+
provider.addcmd.should include("-r")
|
183
|
+
end
|
153
184
|
|
154
|
-
|
185
|
+
it "should return an array without -r if system? is false" do
|
186
|
+
resource[:system] = :false
|
187
|
+
provider.addcmd.should_not include("-r")
|
188
|
+
end
|
155
189
|
end
|
156
190
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
191
|
+
describe "on systems not featuring system_users", :unless => described_class.system_users? do
|
192
|
+
[:false, :true].each do |system|
|
193
|
+
it "should return an array without -r if system? is #{system}" do
|
194
|
+
resource[:system] = system
|
195
|
+
provider.addcmd.should_not include("-r")
|
196
|
+
end
|
197
|
+
end
|
161
198
|
end
|
162
199
|
|
163
200
|
it "should return an array with full command" do
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
201
|
+
described_class.expects(:system_users?).returns true
|
202
|
+
provider.stubs(:add_properties).returns(["-G", "somegroup"])
|
203
|
+
resource[:expiry] = "2012-08-18"
|
204
|
+
|
205
|
+
provider.addcmd.must == ["/usr/sbin/useradd", "-G", "somegroup", "-o", "-m", '-e 2012-08-18', "-r", "myuser"]
|
169
206
|
end
|
170
207
|
|
171
208
|
it "should return an array without -e if expiry is undefined full command" do
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
@resource.stubs(:[]).with(:expiry).returns nil
|
176
|
-
@provider.addcmd.must == ["useradd", "-G", "somegroup", "-o", "-m", "-r", "someuser"]
|
209
|
+
described_class.expects(:system_users?).returns true
|
210
|
+
provider.stubs(:add_properties).returns(["-G", "somegroup"])
|
211
|
+
provider.addcmd.must == ["/usr/sbin/useradd", "-G", "somegroup", "-o", "-m", "-r", "myuser"]
|
177
212
|
end
|
178
213
|
end
|
179
214
|
|
180
|
-
describe "
|
215
|
+
describe "#passcmd" do
|
181
216
|
before do
|
182
|
-
|
183
|
-
|
184
|
-
|
217
|
+
resource[:allowdupe] = :true
|
218
|
+
resource[:managehome] = :true
|
219
|
+
resource[:system] = :true
|
185
220
|
end
|
186
221
|
|
187
222
|
it "should call command with :pass" do
|
188
|
-
|
189
|
-
|
223
|
+
# command(:password) is only called inside passcmd if
|
224
|
+
# password_min_age or password_max_age is set
|
225
|
+
resource[:password_min_age] = 123
|
226
|
+
provider.expects(:command).with(:password)
|
227
|
+
provider.passcmd
|
190
228
|
end
|
191
229
|
|
192
230
|
it "should return nil if neither min nor max is set" do
|
193
|
-
|
194
|
-
@resource.stubs(:should).with(:password_max_age).returns nil
|
195
|
-
@provider.passcmd.must == nil
|
231
|
+
provider.passcmd.must be_nil
|
196
232
|
end
|
197
233
|
|
198
234
|
it "should return a chage command array with -m <value> and the user name if password_min_age is set" do
|
199
|
-
|
200
|
-
|
201
|
-
@resource.stubs(:should).with(:password_min_age).returns 123
|
202
|
-
@resource.stubs(:should).with(:password_max_age).returns nil
|
203
|
-
@provider.passcmd.must == ['chage','-m',123,'someuser']
|
235
|
+
resource[:password_min_age] = 123
|
236
|
+
provider.passcmd.must == ['/usr/bin/chage','-m',123,'myuser']
|
204
237
|
end
|
205
238
|
|
206
239
|
it "should return a chage command array with -M <value> if password_max_age is set" do
|
207
|
-
|
208
|
-
|
209
|
-
@resource.stubs(:should).with(:password_min_age).returns nil
|
210
|
-
@resource.stubs(:should).with(:password_max_age).returns 999
|
211
|
-
@provider.passcmd.must == ['chage','-M',999,'someuser']
|
240
|
+
resource[:password_max_age] = 999
|
241
|
+
provider.passcmd.must == ['/usr/bin/chage','-M',999,'myuser']
|
212
242
|
end
|
213
243
|
|
214
244
|
it "should return a chage command array with -M <value> -m <value> if both password_min_age and password_max_age are set" do
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
@resource.stubs(:should).with(:password_max_age).returns 999
|
219
|
-
@provider.passcmd.must == ['chage','-m',123,'-M',999,'someuser']
|
245
|
+
resource[:password_min_age] = 123
|
246
|
+
resource[:password_max_age] = 999
|
247
|
+
provider.passcmd.must == ['/usr/bin/chage','-m',123,'-M',999,'myuser']
|
220
248
|
end
|
221
249
|
end
|
222
250
|
end
|