puppet 4.3.1-x86-mingw32 → 4.3.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/build_defaults.yaml +1 -1
- data/lib/hiera/scope.rb +1 -1
- data/lib/puppet/application/lookup.rb +41 -43
- data/lib/puppet/data_providers/lookup_adapter.rb +73 -26
- data/lib/puppet/functions/lookup.rb +126 -150
- data/lib/puppet/functions/match.rb +1 -0
- data/lib/puppet/indirector/hiera.rb +3 -1
- data/lib/puppet/indirector/indirection.rb +6 -2
- data/lib/puppet/indirector/json.rb +2 -2
- data/lib/puppet/module.rb +3 -2
- data/lib/puppet/node.rb +11 -2
- data/lib/puppet/parser/compiler.rb +1 -8
- data/lib/puppet/parser/functions/lookup.rb +128 -149
- data/lib/puppet/parser/functions/match.rb +1 -0
- data/lib/puppet/plugins/data_providers/data_provider.rb +3 -2
- data/lib/puppet/pops/adapters.rb +43 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +3 -3
- data/lib/puppet/pops/evaluator/closure.rb +51 -51
- data/lib/puppet/pops/evaluator/collector_transformer.rb +16 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +11 -2
- data/lib/puppet/pops/functions/function.rb +6 -2
- data/lib/puppet/pops/issues.rb +16 -0
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +3 -2
- data/lib/puppet/pops/lookup.rb +3 -0
- data/lib/puppet/pops/lookup/explainer.rb +73 -3
- data/lib/puppet/pops/lookup/invocation.rb +21 -19
- data/lib/puppet/pops/model/factory.rb +153 -155
- data/lib/puppet/pops/model/model.rb +9 -0
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/parser/evaluating_parser.rb +3 -3
- data/lib/puppet/pops/parser/lexer2.rb +411 -393
- data/lib/puppet/pops/parser/slurp_support.rb +5 -1
- data/lib/puppet/pops/types/type_calculator.rb +2 -6
- data/lib/puppet/pops/types/types.rb +3 -9
- data/lib/puppet/pops/validation/checker4_0.rb +36 -12
- data/lib/puppet/provider/group/windows_adsi.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +11 -1
- data/lib/puppet/provider/package/rpm.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +5 -18
- data/lib/puppet/provider/service/init.rb +7 -0
- data/lib/puppet/provider/service/launchd.rb +6 -0
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/user/windows_adsi.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +6 -3
- data/lib/puppet/resource/type.rb +2 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +17 -3
- data/lib/puppet/type/group.rb +6 -2
- data/lib/puppet/util/windows.rb +4 -0
- data/lib/puppet/util/windows/adsi.rb +61 -24
- data/lib/puppet/util/windows/principal.rb +181 -0
- data/lib/puppet/util/windows/registry.rb +21 -15
- data/lib/puppet/util/windows/sid.rb +42 -11
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +4 -0
- data/spec/fixtures/unit/application/environments/production/manifests/site.pp +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/environment.conf +1 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/data.pp +10 -0
- data/spec/fixtures/unit/application/environments/puppet_func_provider/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/data/specific.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/hiera.yaml +7 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/data/common.yaml +6 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/manifests/init.pp +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +4 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/manifests/init.pp +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/metadata.json +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/functions/usee_puppet.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{usee → modules/usee}/lib/puppet/functions/usee/callee.rb +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/functions/usee/usee_ruby.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee2/lib/puppet/functions/usee2/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_puppet_init.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/functions/puppet_calling_ruby.pp +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/lib/puppet/functions/user/caller.rb +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/caller2.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_puppet_init.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/lib/puppet/functions/user/ruby_calling_ruby.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +81 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/{user → modules/user}/metadata.json +2 -1
- data/spec/integration/parser/collection_spec.rb +8 -0
- data/spec/integration/util/windows/principal_spec.rb +115 -0
- data/spec/{unit → integration}/util/windows/registry_spec.rb +91 -1
- data/spec/integration/util/windows/security_spec.rb +2 -2
- data/spec/unit/application/lookup_spec.rb +138 -28
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +182 -5
- data/spec/unit/face/epp_face_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +6 -6
- data/spec/unit/functions/inline_epp_spec.rb +4 -4
- data/spec/unit/functions/lookup_spec.rb +30 -3
- data/spec/unit/functions4_spec.rb +1 -1
- data/spec/unit/hiera/scope_spec.rb +5 -2
- data/spec/unit/indirector/json_spec.rb +1 -1
- data/spec/unit/node_spec.rb +8 -0
- data/spec/unit/parser/compiler_spec.rb +0 -18
- data/spec/unit/pops/evaluator/access_ops_spec.rb +4 -4
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +84 -2
- data/spec/unit/pops/parser/lexer2_spec.rb +6 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +0 -17
- data/spec/unit/pops/validator/validator_spec.rb +87 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +8 -8
- data/spec/unit/provider/package/pip_spec.rb +41 -13
- data/spec/unit/provider/package/rpm_spec.rb +2 -25
- data/spec/unit/provider/package/yum_spec.rb +1 -1
- data/spec/unit/provider/service/debian_spec.rb +6 -24
- data/spec/unit/provider/service/init_spec.rb +11 -1
- data/spec/unit/provider/service/launchd_spec.rb +11 -0
- data/spec/unit/provider/service/systemd_spec.rb +18 -12
- data/spec/unit/provider/service/upstart_spec.rb +57 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +5 -5
- data/spec/unit/provider/yumrepo/inifile_spec.rb +16 -0
- data/spec/unit/resource_spec.rb +12 -2
- data/spec/unit/util/windows/adsi_spec.rb +44 -36
- data/spec/unit/util/windows/sid_spec.rb +47 -10
- metadata +77 -10
@@ -32,9 +32,9 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
|
|
32
32
|
|
33
33
|
describe "group type :members property helpers" do
|
34
34
|
|
35
|
-
let(:user1) { stub(:account => 'user1', :domain => '.', :
|
36
|
-
let(:user2) { stub(:account => 'user2', :domain => '.', :
|
37
|
-
let(:user3) { stub(:account => 'user3', :domain => '.', :
|
35
|
+
let(:user1) { stub(:account => 'user1', :domain => '.', :sid => 'user1sid') }
|
36
|
+
let(:user2) { stub(:account => 'user2', :domain => '.', :sid => 'user2sid') }
|
37
|
+
let(:user3) { stub(:account => 'user3', :domain => '.', :sid => 'user3sid') }
|
38
38
|
let(:invalid_user) { SecureRandom.uuid }
|
39
39
|
|
40
40
|
before :each do
|
@@ -183,9 +183,9 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
|
|
183
183
|
provider.group.stubs(:members).returns ['user1', 'user2']
|
184
184
|
|
185
185
|
member_sids = [
|
186
|
-
stub(:account => 'user1', :domain => 'testcomputername'),
|
187
|
-
stub(:account => 'user2', :domain => 'testcomputername'),
|
188
|
-
stub(:account => 'user3', :domain => 'testcomputername'),
|
186
|
+
stub(:account => 'user1', :domain => 'testcomputername', :sid => 1),
|
187
|
+
stub(:account => 'user2', :domain => 'testcomputername', :sid => 2),
|
188
|
+
stub(:account => 'user3', :domain => 'testcomputername', :sid => 3),
|
189
189
|
]
|
190
190
|
|
191
191
|
provider.group.stubs(:member_sids).returns(member_sids[0..1])
|
@@ -241,8 +241,8 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
|
|
241
241
|
end
|
242
242
|
|
243
243
|
it "should be able to test whether a group exists" do
|
244
|
-
Puppet::Util::Windows::
|
245
|
-
Puppet::Util::Windows::ADSI.stubs(:connect).returns stub('connection')
|
244
|
+
Puppet::Util::Windows::SID.stubs(:name_to_sid_object).returns(nil)
|
245
|
+
Puppet::Util::Windows::ADSI.stubs(:connect).returns stub('connection', :Class => 'Group')
|
246
246
|
expect(provider).to be_exists
|
247
247
|
|
248
248
|
Puppet::Util::Windows::ADSI.stubs(:connect).returns nil
|
@@ -12,7 +12,6 @@ describe provider_class do
|
|
12
12
|
@client = stub_everything('client')
|
13
13
|
@client.stubs(:call).with('package_releases', 'real_package').returns(["1.3", "1.2.5", "1.2.4"])
|
14
14
|
@client.stubs(:call).with('package_releases', 'fake_package').returns([])
|
15
|
-
XMLRPC::Client.stubs(:new2).returns(@client)
|
16
15
|
end
|
17
16
|
|
18
17
|
describe "parse" do
|
@@ -118,23 +117,52 @@ describe provider_class do
|
|
118
117
|
end
|
119
118
|
|
120
119
|
describe "latest" do
|
120
|
+
context "connecting directly" do
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
122
|
+
before :each do
|
123
|
+
XMLRPC::Client.expects(:new2).with("http://pypi.python.org/pypi", nil).returns(@client)
|
124
|
+
end
|
126
125
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
it "should find a version number for real_package" do
|
127
|
+
@resource[:name] = "real_package"
|
128
|
+
expect(@provider.latest).not_to eq(nil)
|
129
|
+
end
|
131
130
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
it "should not find a version number for fake_package" do
|
132
|
+
@resource[:name] = "fake_package"
|
133
|
+
expect(@provider.latest).to eq(nil)
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should handle a timeout gracefully" do
|
137
|
+
@resource[:name] = "fake_package"
|
138
|
+
@client.stubs(:call).raises(Timeout::Error)
|
139
|
+
expect { @provider.latest }.to raise_error(Puppet::Error)
|
140
|
+
end
|
136
141
|
end
|
137
142
|
|
143
|
+
context "connecting via a proxy" do
|
144
|
+
before :each do
|
145
|
+
Puppet::Util::HttpProxy.expects(:http_proxy_host).returns 'some_host'
|
146
|
+
Puppet::Util::HttpProxy.expects(:http_proxy_port).returns 'some_port'
|
147
|
+
XMLRPC::Client.expects(:new2).with("http://pypi.python.org/pypi", "some_host:some_port").returns(@client)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should find a version number for real_package" do
|
151
|
+
@resource[:name] = "real_package"
|
152
|
+
expect(@provider.latest).not_to eq(nil)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should not find a version number for fake_package" do
|
156
|
+
@resource[:name] = "fake_package"
|
157
|
+
expect(@provider.latest).to eq(nil)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should handle a timeout gracefully" do
|
161
|
+
@resource[:name] = "fake_package"
|
162
|
+
@client.stubs(:call).raises(Timeout::Error)
|
163
|
+
expect { @provider.latest }.to raise_error(Puppet::Error)
|
164
|
+
end
|
165
|
+
end
|
138
166
|
end
|
139
167
|
|
140
168
|
describe "install" do
|
@@ -12,7 +12,6 @@ describe provider_class do
|
|
12
12
|
chkconfig 0 1.3.30.2 2.el5 x86_64
|
13
13
|
myresource 0 1.2.3.4 5.el4 noarch
|
14
14
|
mysummaryless 0 1.2.3.4 5.el4 noarch
|
15
|
-
tomcat 1 1.2.3.4 5.fc22 noarch
|
16
15
|
RPM_OUTPUT
|
17
16
|
end
|
18
17
|
|
@@ -117,18 +116,7 @@ describe provider_class do
|
|
117
116
|
:ensure => "1.3.30.2-2.el5",
|
118
117
|
}
|
119
118
|
)
|
120
|
-
expect(installed_packages
|
121
|
-
{
|
122
|
-
:provider => :rpm,
|
123
|
-
:name => "myresource",
|
124
|
-
:epoch => "0",
|
125
|
-
:version => "1.2.3.4",
|
126
|
-
:release => "5.el4",
|
127
|
-
:arch => "noarch",
|
128
|
-
:ensure => "1.2.3.4-5.el4",
|
129
|
-
}
|
130
|
-
)
|
131
|
-
expect(installed_packages[4].properties).to eq(
|
119
|
+
expect(installed_packages.last.properties).to eq(
|
132
120
|
{
|
133
121
|
:provider => :rpm,
|
134
122
|
:name => "mysummaryless",
|
@@ -139,17 +127,6 @@ describe provider_class do
|
|
139
127
|
:ensure => "1.2.3.4-5.el4",
|
140
128
|
}
|
141
129
|
)
|
142
|
-
expect(installed_packages[5].properties).to eq(
|
143
|
-
{
|
144
|
-
:provider => :rpm,
|
145
|
-
:name => "tomcat",
|
146
|
-
:epoch => "1",
|
147
|
-
:version => "1.2.3.4",
|
148
|
-
:release => "5.fc22",
|
149
|
-
:arch => "noarch",
|
150
|
-
:ensure => "1:1.2.3.4-5.fc22",
|
151
|
-
}
|
152
|
-
)
|
153
130
|
end
|
154
131
|
end
|
155
132
|
|
@@ -292,7 +269,7 @@ describe provider_class do
|
|
292
269
|
line.gsub(field, delimiter),
|
293
270
|
package_hash.merge(
|
294
271
|
field.to_sym => delimiter,
|
295
|
-
:ensure => '
|
272
|
+
:ensure => 'version-release'.gsub(field, delimiter)
|
296
273
|
)
|
297
274
|
)
|
298
275
|
end
|
@@ -448,7 +448,7 @@ describe provider_class do
|
|
448
448
|
|
449
449
|
it "returns an empty hash if 'yum check-update' returned an exit code that was not 0 or 100" do
|
450
450
|
Puppet::Util::Execution.expects(:execute).returns(stub(:exitstatus => 1))
|
451
|
-
described_class.expects(:
|
451
|
+
described_class.expects(:warning).with('Could not check for updates, \'/usr/bin/yum check-update\' exited with 1')
|
452
452
|
expect(described_class.check_updates([], [], [])).to eq({})
|
453
453
|
end
|
454
454
|
end
|
@@ -27,6 +27,7 @@ describe provider_class do
|
|
27
27
|
|
28
28
|
@provider.stubs(:command).with(:update_rc).returns "update_rc"
|
29
29
|
@provider.stubs(:command).with(:invoke_rc).returns "invoke_rc"
|
30
|
+
@provider.stubs(:command).with(:service).returns "service"
|
30
31
|
|
31
32
|
@provider.stubs(:update_rc)
|
32
33
|
@provider.stubs(:invoke_rc)
|
@@ -142,30 +143,11 @@ describe provider_class do
|
|
142
143
|
end
|
143
144
|
|
144
145
|
describe "when checking service status" do
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
expect(@provider.statuscmd).to eq(["systemctl", "is-active", @resource[:name]])
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should call systemctl to determine running status in Ubuntu" do
|
154
|
-
Facter.stubs(:value).with(:operatingsystem).returns('Ubuntu')
|
155
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('15.04')
|
156
|
-
@resource.stubs(:[]).with(:hasstatus).returns(:true)
|
157
|
-
expect(@provider.statuscmd).to eq(["systemctl", "is-active", @resource[:name]])
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context "On systems which only use sysvinit" do
|
162
|
-
it "should use the service init script" do
|
163
|
-
Facter.stubs(:value).with(:operatingsystem).returns('Debian')
|
164
|
-
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('7')
|
165
|
-
@resource.stubs(:[]).with(:hasstatus).returns(:true)
|
166
|
-
@provider.stubs(:initscript).returns("/etc/init.d/script")
|
167
|
-
expect(@provider.statuscmd).to eq(["/etc/init.d/script", :status])
|
168
|
-
end
|
146
|
+
it "should use the service command" do
|
147
|
+
Facter.stubs(:value).with(:operatingsystem).returns('Debian')
|
148
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
|
149
|
+
@resource.stubs(:[]).with(:hasstatus).returns(:true)
|
150
|
+
expect(@provider.statuscmd).to eq(["service", @resource[:name], "status"])
|
169
151
|
end
|
170
152
|
end
|
171
153
|
end
|
@@ -39,7 +39,7 @@ describe Puppet::Type.type(:service).provider(:init) do
|
|
39
39
|
before :each do
|
40
40
|
described_class.stubs(:defpath).returns('tmp')
|
41
41
|
|
42
|
-
@services = ['one', 'two', 'three', 'four']
|
42
|
+
@services = ['one', 'two', 'three', 'four', 'umountfs']
|
43
43
|
Dir.stubs(:entries).with('tmp').returns @services
|
44
44
|
FileTest.expects(:directory?).with('tmp').returns(true)
|
45
45
|
FileTest.stubs(:executable?).returns(true)
|
@@ -59,6 +59,16 @@ describe Puppet::Type.type(:service).provider(:init) do
|
|
59
59
|
expect(described_class.get_services(described_class.defpath, exclude).map(&:name)).to eq(@services - [exclude])
|
60
60
|
end
|
61
61
|
|
62
|
+
it "should omit Yocto services on cisco-wrlinux" do
|
63
|
+
Facter.stubs(:value).with(:osfamily).returns 'cisco-wrlinux'
|
64
|
+
exclude = 'umountfs'
|
65
|
+
expect(described_class.get_services(described_class.defpath).map(&:name)).to eq(@services - [exclude])
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should not omit Yocto services on non cisco-wrlinux platforms" do
|
69
|
+
expect(described_class.get_services(described_class.defpath).map(&:name)).to eq(@services)
|
70
|
+
end
|
71
|
+
|
62
72
|
it "should use defpath" do
|
63
73
|
expect(described_class.instances).to be_all { |provider| provider.get(:path) == described_class.defpath }
|
64
74
|
end
|
@@ -254,6 +254,7 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
254
254
|
}
|
255
255
|
end
|
256
256
|
let(:busted_plist_path) { '/Library/LaunchAgents/org.busted.plist' }
|
257
|
+
let(:binary_plist_path) { '/Library/LaunchAgents/org.binary.plist' }
|
257
258
|
|
258
259
|
it "[17624] should warn that the plist in question is being skipped" do
|
259
260
|
provider.expects(:launchd_paths).returns(['/Library/LaunchAgents'])
|
@@ -264,6 +265,8 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
264
265
|
end
|
265
266
|
|
266
267
|
it "[15929] should skip plists that plutil cannot read" do
|
268
|
+
Plist.expects(:parse_xml).with(busted_plist_path).raises(ArgumentError, 'boom')
|
269
|
+
Puppet.expects(:debug).with("Error reading #{busted_plist_path}: boom. Retrying with plutil.")
|
267
270
|
provider.expects(:plutil).with('-convert', 'xml1', '-o', '/dev/stdout',
|
268
271
|
busted_plist_path).raises(Puppet::ExecutionFailure, 'boom')
|
269
272
|
Puppet.expects(:warning).with("Cannot read file #{busted_plist_path}; " +
|
@@ -271,6 +274,14 @@ describe Puppet::Type.type(:service).provider(:launchd) do
|
|
271
274
|
"Details: boom")
|
272
275
|
provider.read_plist(busted_plist_path)
|
273
276
|
end
|
277
|
+
|
278
|
+
it "should read binary plists with plutil" do
|
279
|
+
Plist.expects(:parse_xml).with(binary_plist_path).raises(ArgumentError, 'boom')
|
280
|
+
Puppet.expects(:debug).with("Error reading #{binary_plist_path}: boom. Retrying with plutil.")
|
281
|
+
provider.expects(:plutil).with('-convert', 'xml1', '-o', '/dev/stdout', binary_plist_path).returns('plist')
|
282
|
+
Plist.expects(:parse_xml).with('plist').returns('plist_map')
|
283
|
+
expect(provider.read_plist(binary_plist_path)).to eq('plist_map')
|
284
|
+
end
|
274
285
|
end
|
275
286
|
it "should return the cached value when available" do
|
276
287
|
provider.instance_variable_set(:@label_to_path_map, {'xx'=>'yy'})
|
@@ -19,14 +19,14 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
19
19
|
osfamily.each do |osfamily|
|
20
20
|
it "should be the default provider on #{osfamily}" do
|
21
21
|
Facter.stubs(:value).with(:osfamily).returns(osfamily)
|
22
|
-
expect(described_class
|
22
|
+
expect(described_class).to be_default
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should be the default provider on rhel7" do
|
27
27
|
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
28
28
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
|
29
|
-
expect(described_class
|
29
|
+
expect(described_class).to be_default
|
30
30
|
end
|
31
31
|
|
32
32
|
[ 4, 5, 6 ].each do |ver|
|
@@ -38,7 +38,7 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
38
38
|
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
39
39
|
Facter.stubs(:value).with(:operatingsystem).returns(:redhat)
|
40
40
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
|
41
|
-
expect(described_class
|
41
|
+
expect(described_class).not_to be_default
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -47,64 +47,70 @@ describe Puppet::Type.type(:service).provider(:systemd) do
|
|
47
47
|
Facter.stubs(:value).with(:osfamily).returns(:redhat)
|
48
48
|
Facter.stubs(:value).with(:operatingsystem).returns(:fedora)
|
49
49
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("#{ver}")
|
50
|
-
expect(described_class
|
50
|
+
expect(described_class).to be_default
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should be the default provider on sles12" do
|
55
55
|
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
56
56
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("12")
|
57
|
-
expect(described_class
|
57
|
+
expect(described_class).to be_default
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should be the default provider on opensuse13" do
|
61
61
|
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
62
62
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("13")
|
63
|
-
expect(described_class
|
63
|
+
expect(described_class).to be_default
|
64
64
|
end
|
65
65
|
|
66
66
|
# tumbleweed is a rolling release with date-based major version numbers
|
67
67
|
it "should be the default provider on tumbleweed" do
|
68
68
|
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
69
69
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("20150829")
|
70
|
-
expect(described_class
|
70
|
+
expect(described_class).to be_default
|
71
71
|
end
|
72
72
|
|
73
73
|
# leap is the next generation suse release
|
74
74
|
it "should be the default provider on leap" do
|
75
75
|
Facter.stubs(:value).with(:osfamily).returns(:suse)
|
76
76
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("42")
|
77
|
-
expect(described_class
|
77
|
+
expect(described_class).to be_default
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not be the default provider on debian7" do
|
81
81
|
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
82
82
|
Facter.stubs(:value).with(:operatingsystem).returns(:debian)
|
83
83
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("7")
|
84
|
-
expect(described_class
|
84
|
+
expect(described_class).not_to be_default
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should be the default provider on debian8" do
|
88
88
|
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
89
89
|
Facter.stubs(:value).with(:operatingsystem).returns(:debian)
|
90
90
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("8")
|
91
|
-
expect(described_class
|
91
|
+
expect(described_class).to be_default
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should not be the default provider on ubuntu14.04" do
|
95
95
|
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
96
96
|
Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
|
97
97
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("14.04")
|
98
|
-
expect(described_class
|
98
|
+
expect(described_class).not_to be_default
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should be the default provider on ubuntu15.04" do
|
102
102
|
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
103
103
|
Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
|
104
104
|
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("15.04")
|
105
|
-
expect(described_class
|
105
|
+
expect(described_class).to be_default
|
106
106
|
end
|
107
107
|
|
108
|
+
it "should be the default provider on ubuntu15.10" do
|
109
|
+
Facter.stubs(:value).with(:osfamily).returns(:debian)
|
110
|
+
Facter.stubs(:value).with(:operatingsystem).returns(:ubuntu)
|
111
|
+
Facter.stubs(:value).with(:operatingsystemmajrelease).returns("15.10")
|
112
|
+
expect(described_class).to be_default
|
113
|
+
end
|
108
114
|
|
109
115
|
[:enabled?, :enable, :disable, :start, :stop, :status, :restart].each do |method|
|
110
116
|
it "should have a #{method} method" do
|
@@ -158,6 +158,63 @@ describe Puppet::Type.type(:service).provider(:upstart) do
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
+
describe "when a special status command is specifed" do
|
162
|
+
it "should use the provided status command" do
|
163
|
+
resource = Puppet::Type.type(:service).new(:name => 'foo', :provider => :upstart, :status => '/bin/foo')
|
164
|
+
provider = provider_class.new(resource)
|
165
|
+
provider.stubs(:is_upstart?).returns(true)
|
166
|
+
|
167
|
+
provider.expects(:status_exec).with(['foo']).never
|
168
|
+
provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
|
169
|
+
Process::Status.any_instance.stubs(:exitstatus).returns(0)
|
170
|
+
provider.status
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should return :stopped when the provided status command return non-zero" do
|
174
|
+
resource = Puppet::Type.type(:service).new(:name => 'foo', :provider => :upstart, :status => '/bin/foo')
|
175
|
+
provider = provider_class.new(resource)
|
176
|
+
provider.stubs(:is_upstart?).returns(true)
|
177
|
+
|
178
|
+
provider.expects(:status_exec).with(['foo']).never
|
179
|
+
provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
|
180
|
+
$CHILD_STATUS.stubs(:exitstatus).returns 1
|
181
|
+
expect(provider.status).to eq(:stopped)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should return :running when the provided status command return zero" do
|
185
|
+
resource = Puppet::Type.type(:service).new(:name => 'foo', :provider => :upstart, :status => '/bin/foo')
|
186
|
+
provider = provider_class.new(resource)
|
187
|
+
provider.stubs(:is_upstart?).returns(true)
|
188
|
+
|
189
|
+
provider.expects(:status_exec).with(['foo']).never
|
190
|
+
provider.expects(:execute).with(['/bin/foo'], :failonfail => false, :override_locale => false, :squelch => false, :combine => true)
|
191
|
+
$CHILD_STATUS.stubs(:exitstatus).returns 0
|
192
|
+
expect(provider.status).to eq(:running)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "when :hasstatus is set to false" do
|
197
|
+
it "should return :stopped if the pid can not be found" do
|
198
|
+
resource = Puppet::Type.type(:service).new(:name => 'foo', :hasstatus => false, :provider => :upstart)
|
199
|
+
provider = provider_class.new(resource)
|
200
|
+
provider.stubs(:is_upstart?).returns(true)
|
201
|
+
|
202
|
+
provider.expects(:status_exec).with(['foo']).never
|
203
|
+
provider.expects(:getpid).returns nil
|
204
|
+
expect(provider.status).to eq(:stopped)
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should return :running if the pid can be found" do
|
208
|
+
resource = Puppet::Type.type(:service).new(:name => 'foo', :hasstatus => false, :provider => :upstart)
|
209
|
+
provider = provider_class.new(resource)
|
210
|
+
provider.stubs(:is_upstart?).returns(true)
|
211
|
+
|
212
|
+
provider.expects(:status_exec).with(['foo']).never
|
213
|
+
provider.expects(:getpid).returns 2706
|
214
|
+
expect(provider.status).to eq(:running)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
161
218
|
it "should properly handle services with 'start' in their name" do
|
162
219
|
resource = Puppet::Type.type(:service).new(:name => "foostartbar", :provider => :upstart)
|
163
220
|
provider = provider_class.new(resource)
|
@@ -64,9 +64,9 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
|
|
64
64
|
|
65
65
|
describe "#groups_insync?" do
|
66
66
|
|
67
|
-
let(:group1) { stub(:account => 'group1', :domain => '.', :
|
68
|
-
let(:group2) { stub(:account => 'group2', :domain => '.', :
|
69
|
-
let(:group3) { stub(:account => 'group3', :domain => '.', :
|
67
|
+
let(:group1) { stub(:account => 'group1', :domain => '.', :sid => 'group1sid') }
|
68
|
+
let(:group2) { stub(:account => 'group2', :domain => '.', :sid => 'group2sid') }
|
69
|
+
let(:group3) { stub(:account => 'group3', :domain => '.', :sid => 'group3sid') }
|
70
70
|
|
71
71
|
before :each do
|
72
72
|
Puppet::Util::Windows::SID.stubs(:name_to_sid_object).with('group1').returns(group1)
|
@@ -244,8 +244,8 @@ describe Puppet::Type.type(:user).provider(:windows_adsi), :if => Puppet.feature
|
|
244
244
|
end
|
245
245
|
|
246
246
|
it 'should be able to test whether a user exists' do
|
247
|
-
Puppet::Util::Windows::
|
248
|
-
Puppet::Util::Windows::ADSI.stubs(:connect).returns stub('connection')
|
247
|
+
Puppet::Util::Windows::SID.stubs(:name_to_sid_object).returns(nil)
|
248
|
+
Puppet::Util::Windows::ADSI.stubs(:connect).returns stub('connection', :Class => 'User')
|
249
249
|
expect(provider).to be_exists
|
250
250
|
|
251
251
|
Puppet::Util::Windows::ADSI.stubs(:connect).returns nil
|