puppet 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +20 -20
  4. data/Guardfile.example +76 -0
  5. data/LICENSE +189 -4
  6. data/README.md +3 -3
  7. data/Rakefile +5 -2
  8. data/ext/solaris/smf/svc-puppetd +8 -1
  9. data/ext/solaris/smf/svc-puppetmasterd +8 -1
  10. data/lib/puppet/application/apply.rb +100 -59
  11. data/lib/puppet/application/cert.rb +4 -114
  12. data/lib/puppet/application/device.rb +48 -32
  13. data/lib/puppet/application/script.rb +1 -1
  14. data/lib/puppet/application/ssl.rb +135 -51
  15. data/lib/puppet/application.rb +5 -0
  16. data/lib/puppet/configurer.rb +2 -3
  17. data/lib/puppet/defaults.rb +33 -49
  18. data/lib/puppet/etc.rb +20 -0
  19. data/lib/puppet/face/config.rb +3 -3
  20. data/lib/puppet/face/key.rb +1 -1
  21. data/lib/puppet/face/node/clean.rb +0 -1
  22. data/lib/puppet/feature/base.rb +1 -1
  23. data/lib/puppet/file_bucket/dipper.rb +1 -1
  24. data/lib/puppet/file_serving/fileset.rb +1 -1
  25. data/lib/puppet/functions/abs.rb +1 -1
  26. data/lib/puppet/functions/new.rb +1 -1
  27. data/lib/puppet/module/task.rb +29 -38
  28. data/lib/puppet/pal/catalog_compiler.rb +96 -0
  29. data/lib/puppet/pal/compiler.rb +221 -0
  30. data/lib/puppet/pal/function_signature.rb +52 -0
  31. data/lib/puppet/pal/json_catalog_encoder.rb +67 -0
  32. data/lib/puppet/pal/pal_api.rb +15 -0
  33. data/lib/puppet/pal/pal_impl.rb +523 -0
  34. data/lib/puppet/pal/plan_signature.rb +71 -0
  35. data/lib/puppet/pal/script_compiler.rb +71 -0
  36. data/lib/puppet/pal/task_signature.rb +58 -0
  37. data/lib/puppet/parser/catalog_compiler.rb +24 -0
  38. data/lib/puppet/parser/compiler.rb +3 -1
  39. data/lib/puppet/parser/functions/generate.rb +7 -6
  40. data/lib/puppet/plugins/configuration.rb +5 -1
  41. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
  42. data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -1
  44. data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -3
  45. data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
  46. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +19 -10
  47. data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
  48. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  49. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  50. data/lib/puppet/pops/pcore.rb +10 -33
  51. data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
  52. data/lib/puppet/pops/serialization.rb +1 -0
  53. data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
  54. data/lib/puppet/pops/types/string_converter.rb +18 -4
  55. data/lib/puppet/pops/validation/checker4_0.rb +17 -2
  56. data/lib/puppet/provider/exec.rb +59 -57
  57. data/lib/puppet/provider/group/aix.rb +18 -2
  58. data/lib/puppet/provider/group/windows_adsi.rb +7 -3
  59. data/lib/puppet/provider/nameservice.rb +1 -25
  60. data/lib/puppet/provider/package/dnf.rb +2 -0
  61. data/lib/puppet/provider/package/pkgng.rb +37 -21
  62. data/lib/puppet/provider/package/portage.rb +2 -2
  63. data/lib/puppet/provider/package/windows/exe_package.rb +16 -10
  64. data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
  65. data/lib/puppet/provider/package/windows/package.rb +9 -1
  66. data/lib/puppet/provider/package/windows.rb +2 -2
  67. data/lib/puppet/provider/package/yum.rb +1 -1
  68. data/lib/puppet/provider/parsedfile.rb +25 -4
  69. data/lib/puppet/provider/service/launchd.rb +19 -3
  70. data/lib/puppet/provider/service/smf.rb +54 -0
  71. data/lib/puppet/provider/service/systemd.rb +19 -0
  72. data/lib/puppet/provider/service/upstart.rb +1 -0
  73. data/lib/puppet/provider/service/windows.rb +22 -5
  74. data/lib/puppet/provider/user/aix.rb +48 -2
  75. data/lib/puppet/provider/user/useradd.rb +2 -10
  76. data/lib/puppet/provider/user/windows_adsi.rb +9 -1
  77. data/lib/puppet/resource/catalog.rb +1 -5
  78. data/lib/puppet/resource.rb +3 -1
  79. data/lib/puppet/ssl/host.rb +26 -16
  80. data/lib/puppet/syntax_checkers/epp.rb +34 -0
  81. data/lib/puppet/syntax_checkers/pp.rb +34 -0
  82. data/lib/puppet/transaction/event_manager.rb +13 -1
  83. data/lib/puppet/transaction/persistence.rb +1 -1
  84. data/lib/puppet/transaction/resource_harness.rb +3 -1
  85. data/lib/puppet/type/group.rb +29 -1
  86. data/lib/puppet/type/package.rb +5 -1
  87. data/lib/puppet/type/resources.rb +12 -2
  88. data/lib/puppet/type/schedule.rb +7 -0
  89. data/lib/puppet/type/service.rb +12 -0
  90. data/lib/puppet/type/user.rb +5 -2
  91. data/lib/puppet/type.rb +6 -0
  92. data/lib/puppet/util/command_line.rb +2 -3
  93. data/lib/puppet/util/execution.rb +15 -1
  94. data/lib/puppet/util/filetype.rb +56 -8
  95. data/lib/puppet/util/log/destinations.rb +3 -2
  96. data/lib/puppet/util/logging.rb +3 -2
  97. data/lib/puppet/util/posix.rb +15 -0
  98. data/lib/puppet/util/selinux.rb +1 -1
  99. data/lib/puppet/util/storage.rb +12 -0
  100. data/lib/puppet/util/windows/adsi.rb +79 -2
  101. data/lib/puppet/util/windows/api_types.rb +1 -1
  102. data/lib/puppet/util/windows/process.rb +23 -3
  103. data/lib/puppet/util/windows/registry.rb +29 -5
  104. data/lib/puppet/util/windows/security.rb +14 -0
  105. data/lib/puppet/util/windows/service.rb +294 -74
  106. data/lib/puppet/util/windows/user.rb +3 -5
  107. data/lib/puppet/util.rb +7 -3
  108. data/lib/puppet/version.rb +1 -1
  109. data/lib/puppet.rb +1 -0
  110. data/lib/puppet_pal.rb +5 -1099
  111. data/locales/ja/puppet.po +952 -986
  112. data/locales/puppet.pot +592 -347
  113. data/man/man5/puppet.conf.5 +26 -31
  114. data/man/man8/puppet-agent.8 +1 -1
  115. data/man/man8/puppet-apply.8 +1 -1
  116. data/man/man8/puppet-catalog.8 +1 -1
  117. data/man/man8/puppet-config.8 +4 -4
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +23 -19
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-filebucket.8 +1 -1
  124. data/man/man8/puppet-generate.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-key.8 +2 -2
  127. data/man/man8/puppet-lookup.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-module.8 +1 -1
  130. data/man/man8/puppet-node.8 +1 -1
  131. data/man/man8/puppet-parser.8 +1 -1
  132. data/man/man8/puppet-plugin.8 +1 -1
  133. data/man/man8/puppet-report.8 +1 -1
  134. data/man/man8/puppet-resource.8 +1 -1
  135. data/man/man8/puppet-script.8 +1 -1
  136. data/man/man8/puppet-ssl.8 +26 -3
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +2 -2
  139. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/bad_func_load.rb +11 -0
  140. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +7 -1
  141. data/spec/fixtures/unit/provider/package/pkgng/pkg.query.zsh +1 -0
  142. data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
  143. data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
  144. data/spec/integration/application/apply_spec.rb +4 -1
  145. data/spec/integration/parser/collection_spec.rb +4 -8
  146. data/spec/integration/provider/service/windows_spec.rb +5 -5
  147. data/spec/integration/ssl/key_spec.rb +0 -4
  148. data/spec/integration/transaction_spec.rb +559 -0
  149. data/spec/integration/type/file_spec.rb +6 -6
  150. data/spec/integration/util/windows/registry_spec.rb +39 -0
  151. data/spec/integration/util/windows/security_spec.rb +10 -7
  152. data/spec/integration/util/windows/user_spec.rb +37 -17
  153. data/spec/lib/puppet/test_ca.rb +1 -1
  154. data/spec/spec_helper.rb +1 -1
  155. data/spec/unit/agent_spec.rb +2 -2
  156. data/spec/unit/application/apply_spec.rb +55 -2
  157. data/spec/unit/application/device_spec.rb +10 -7
  158. data/spec/unit/application/face_base_spec.rb +1 -1
  159. data/spec/unit/application/lookup_spec.rb +2 -1
  160. data/spec/unit/application/ssl_spec.rb +178 -109
  161. data/spec/unit/application_spec.rb +29 -11
  162. data/spec/unit/configurer/downloader_spec.rb +1 -1
  163. data/spec/unit/configurer_spec.rb +16 -5
  164. data/spec/unit/etc_spec.rb +25 -0
  165. data/spec/unit/face/node_spec.rb +1 -3
  166. data/spec/unit/face/parser_spec.rb +15 -0
  167. data/spec/unit/file_serving/fileset_spec.rb +11 -11
  168. data/spec/unit/functions/logging_spec.rb +10 -3
  169. data/spec/unit/indirector/catalog/json_spec.rb +9 -3
  170. data/spec/unit/indirector/yaml_spec.rb +1 -1
  171. data/spec/unit/network/http/connection_spec.rb +2 -2
  172. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +36 -0
  173. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
  174. data/spec/unit/pops/loaders/loader_spec.rb +9 -17
  175. data/spec/unit/pops/loaders/loaders_spec.rb +48 -0
  176. data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
  177. data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
  178. data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -0
  179. data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
  180. data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
  181. data/spec/unit/pops/types/string_converter_spec.rb +25 -1
  182. data/spec/unit/pops/types/task_spec.rb +42 -116
  183. data/spec/unit/pops/validator/validator_spec.rb +24 -10
  184. data/spec/unit/provider/exec/posix_spec.rb +24 -0
  185. data/spec/unit/provider/group/aix_spec.rb +20 -6
  186. data/spec/unit/provider/group/ldap_spec.rb +22 -25
  187. data/spec/unit/provider/group/pw_spec.rb +7 -10
  188. data/spec/unit/provider/group/windows_adsi_spec.rb +42 -33
  189. data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
  190. data/spec/unit/provider/package/aix_spec.rb +5 -8
  191. data/spec/unit/provider/package/apt_spec.rb +3 -6
  192. data/spec/unit/provider/package/dnf_spec.rb +38 -25
  193. data/spec/unit/provider/package/dpkg_spec.rb +18 -21
  194. data/spec/unit/provider/package/freebsd_spec.rb +4 -7
  195. data/spec/unit/provider/package/gem_spec.rb +41 -41
  196. data/spec/unit/provider/package/hpux_spec.rb +7 -10
  197. data/spec/unit/provider/package/macports_spec.rb +13 -15
  198. data/spec/unit/provider/package/nim_spec.rb +3 -10
  199. data/spec/unit/provider/package/openbsd_spec.rb +14 -17
  200. data/spec/unit/provider/package/pip3_spec.rb +3 -6
  201. data/spec/unit/provider/package/pip_spec.rb +45 -49
  202. data/spec/unit/provider/package/pkgin_spec.rb +13 -18
  203. data/spec/unit/provider/package/pkgng_spec.rb +32 -27
  204. data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
  205. data/spec/unit/provider/package/tdnf_spec.rb +9 -12
  206. data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
  207. data/spec/unit/provider/package/windows_spec.rb +4 -4
  208. data/spec/unit/provider/package/yum_spec.rb +30 -16
  209. data/spec/unit/provider/package/zypper_spec.rb +17 -19
  210. data/spec/unit/provider/service/bsd_spec.rb +7 -9
  211. data/spec/unit/provider/service/daemontools_spec.rb +12 -16
  212. data/spec/unit/provider/service/debian_spec.rb +6 -10
  213. data/spec/unit/provider/service/freebsd_spec.rb +2 -2
  214. data/spec/unit/provider/service/launchd_spec.rb +19 -0
  215. data/spec/unit/provider/service/openbsd_spec.rb +13 -17
  216. data/spec/unit/provider/service/rcng_spec.rb +2 -4
  217. data/spec/unit/provider/service/redhat_spec.rb +12 -11
  218. data/spec/unit/provider/service/runit_spec.rb +7 -14
  219. data/spec/unit/provider/service/smf_spec.rb +77 -13
  220. data/spec/unit/provider/service/src_spec.rb +11 -16
  221. data/spec/unit/provider/service/systemd_spec.rb +39 -1
  222. data/spec/unit/provider/service/windows_spec.rb +39 -7
  223. data/spec/unit/provider/user/aix_spec.rb +43 -2
  224. data/spec/unit/provider/user/hpux_spec.rb +3 -5
  225. data/spec/unit/provider/user/ldap_spec.rb +29 -32
  226. data/spec/unit/provider/user/pw_spec.rb +10 -13
  227. data/spec/unit/provider/user/useradd_spec.rb +2 -2
  228. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  229. data/spec/unit/puppet_pal_2pec.rb +6 -6
  230. data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
  231. data/spec/unit/resource/catalog_spec.rb +2 -2
  232. data/spec/unit/resource_spec.rb +31 -0
  233. data/spec/unit/ssl/host_spec.rb +22 -1
  234. data/spec/unit/ssl/key_spec.rb +2 -4
  235. data/spec/unit/task_spec.rb +50 -5
  236. data/spec/unit/transaction/event_manager_spec.rb +12 -1
  237. data/spec/unit/transaction/persistence_spec.rb +4 -4
  238. data/spec/unit/transaction/resource_harness_spec.rb +18 -0
  239. data/spec/unit/type/group_spec.rb +11 -3
  240. data/spec/unit/type/resources_spec.rb +18 -0
  241. data/spec/unit/type/service_spec.rb +27 -1
  242. data/spec/unit/util/execution_spec.rb +77 -0
  243. data/spec/unit/util/filetype_spec.rb +13 -5
  244. data/spec/unit/util/log/destinations_spec.rb +10 -0
  245. data/spec/unit/util/logging_spec.rb +58 -41
  246. data/spec/unit/util/monkey_patches_spec.rb +18 -5
  247. data/spec/unit/util/posix_spec.rb +28 -0
  248. data/spec/unit/util/selinux_spec.rb +4 -0
  249. data/spec/unit/util/storage_spec.rb +107 -0
  250. data/spec/unit/util/suidmanager_spec.rb +1 -3
  251. data/spec/unit/util/windows/adsi_spec.rb +95 -0
  252. data/spec/unit/util/windows/service_spec.rb +377 -131
  253. metadata +24 -11
  254. data/ext/autotest/Rakefile +0 -8
  255. data/ext/autotest/config +0 -43
  256. data/ext/autotest/readme.rst +0 -16
  257. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -7
  258. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +0 -1
  259. data/spec/watchr.rb +0 -137
@@ -1,17 +1,15 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:package).provider(:yum)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:package).provider(:yum) do
7
4
  include PuppetSpec::Fixtures
8
- it_behaves_like 'RHEL package provider', provider_class, 'yum'
5
+
6
+ it_behaves_like 'RHEL package provider', described_class, 'yum'
9
7
 
10
8
  it "should have lower specificity" do
11
9
  Facter.stubs(:value).with(:osfamily).returns(:redhat)
12
10
  Facter.stubs(:value).with(:operatingsystem).returns(:fedora)
13
11
  Facter.stubs(:value).with(:operatingsystemmajrelease).returns("22")
14
- expect(provider_class.specificity).to be < 200
12
+ expect(described_class.specificity).to be < 200
15
13
  end
16
14
 
17
15
  describe "when supplied the source param" do
@@ -25,12 +23,12 @@ describe provider_class do
25
23
  end
26
24
 
27
25
  let(:provider) do
28
- provider = provider_class.new
26
+ provider = described_class.new
29
27
  provider.resource = resource
30
28
  provider
31
29
  end
32
30
 
33
- before { provider_class.stubs(:command).with(:cmd).returns("/usr/bin/yum") }
31
+ before { described_class.stubs(:command).with(:cmd).returns("/usr/bin/yum") }
34
32
 
35
33
  context "when installing" do
36
34
  it "should use the supplied source as the explicit path to a package to install" do
@@ -58,16 +56,18 @@ describe provider_class do
58
56
  end
59
57
  end
60
58
 
61
- describe "parsing the output of check-update" do
62
- describe "with no multiline entries" do
59
+ context "parsing the output of check-update" do
60
+ context "with no multiline entries" do
63
61
  let(:check_update) { File.read(my_fixture("yum-check-update-simple.txt")) }
64
62
  let(:output) { described_class.parse_updates(check_update) }
63
+
65
64
  it 'creates an entry for each package keyed on the package name' do
66
65
  expect(output['curl']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'i686'}, {:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'x86_64'}])
67
66
  expect(output['gawk']).to eq([{:name => 'gawk', :epoch => '0', :version => '4.1.0', :release => '3.fc20', :arch => 'i686'}])
68
67
  expect(output['dhclient']).to eq([{:name => 'dhclient', :epoch => '12', :version => '4.1.1', :release => '38.P1.fc20', :arch => 'i686'}])
69
68
  expect(output['selinux-policy']).to eq([{:name => 'selinux-policy', :epoch => '0', :version => '3.12.1', :release => '163.fc20', :arch => 'noarch'}])
70
69
  end
70
+
71
71
  it 'creates an entry for each package keyed on the package name and package architecture' do
72
72
  expect(output['curl.i686']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'i686'}])
73
73
  expect(output['curl.x86_64']).to eq([{:name => 'curl', :epoch => '0', :version => '7.32.0', :release => '10.fc20', :arch => 'x86_64'}])
@@ -77,55 +77,69 @@ describe provider_class do
77
77
  expect(output['java-1.8.0-openjdk.x86_64']).to eq([{:name => 'java-1.8.0-openjdk', :epoch => '1', :version => '1.8.0.131', :release => '2.b11.el7_3', :arch => 'x86_64'}])
78
78
  end
79
79
  end
80
- describe "with multiline entries" do
80
+
81
+ context "with multiline entries" do
81
82
  let(:check_update) { File.read(my_fixture("yum-check-update-multiline.txt")) }
82
83
  let(:output) { described_class.parse_updates(check_update) }
84
+
83
85
  it "parses multi-line values as a single package tuple" do
84
86
  expect(output['libpcap']).to eq([{:name => 'libpcap', :epoch => '14', :version => '1.4.0', :release => '1.20130826git2dbcaa1.el6', :arch => 'x86_64'}])
85
87
  end
86
88
  end
87
- describe "with obsoleted packages" do
89
+
90
+ context "with obsoleted packages" do
88
91
  let(:check_update) { File.read(my_fixture("yum-check-update-obsoletes.txt")) }
89
92
  let(:output) { described_class.parse_updates(check_update) }
93
+
90
94
  it "ignores all entries including and after 'Obsoleting Packages'" do
91
95
  expect(output).not_to include("Obsoleting")
92
96
  expect(output).not_to include("NetworkManager-bluetooth.x86_64")
93
97
  expect(output).not_to include("1:1.0.0-14.git20150121.b4ea599c.el7")
94
98
  end
95
99
  end
96
- describe "with security notifications" do
100
+
101
+ context "with security notifications" do
97
102
  let(:check_update) { File.read(my_fixture("yum-check-update-security.txt")) }
98
103
  let(:output) { described_class.parse_updates(check_update) }
104
+
99
105
  it "ignores all entries including and after 'Security'" do
100
106
  expect(output).not_to include("Security")
101
107
  end
108
+
102
109
  it "includes updates before 'Security'" do
103
110
  expect(output).to include("yum-plugin-fastestmirror.noarch")
104
111
  end
105
112
  end
106
- describe "with broken update notices" do
113
+
114
+ context "with broken update notices" do
107
115
  let(:check_update) { File.read(my_fixture("yum-check-update-broken-notices.txt")) }
108
116
  let(:output) { described_class.parse_updates(check_update) }
117
+
109
118
  it "ignores all entries including and after 'Update'" do
110
119
  expect(output).not_to include("Update")
111
120
  end
121
+
112
122
  it "includes updates before 'Update'" do
113
123
  expect(output).to include("yum-plugin-fastestmirror.noarch")
114
124
  end
115
125
  end
116
- describe "with improper package names in output" do
126
+
127
+ context "with improper package names in output" do
117
128
  it "raises an exception parsing package name" do
118
129
  expect {
119
130
  described_class.update_to_hash('badpackagename', '1')
120
131
  }.to raise_exception(Exception, /Failed to parse/)
121
132
  end
122
133
  end
123
- describe "with trailing plugin output" do
134
+
135
+ context "with trailing plugin output" do
124
136
  let(:check_update) { File.read(my_fixture("yum-check-update-plugin-output.txt")) }
125
137
  let(:output) { described_class.parse_updates(check_update) }
138
+
126
139
  it "parses correctly formatted entries" do
127
140
  expect(output['bash']).to eq([{:name => 'bash', :epoch => '0', :version => '4.2.46', :release => '12.el7', :arch => 'x86_64'}])
128
141
  end
142
+
129
143
  it "ignores all mentions of plugin output" do
130
144
  expect(output).not_to include("Random plugin")
131
145
  end
@@ -1,9 +1,6 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- provider_class = Puppet::Type.type(:package).provider(:zypper)
5
-
6
- describe provider_class do
3
+ describe Puppet::Type.type(:package).provider(:zypper) do
7
4
  before(:each) do
8
5
  # Create a mock resource
9
6
  @resource = stub 'resource'
@@ -16,35 +13,35 @@ describe provider_class do
16
13
  @resource.stubs(:[]).with(:ensure).returns :installed
17
14
  @resource.stubs(:command).with(:zypper).returns "/usr/bin/zypper"
18
15
 
19
- @provider = provider_class.new(@resource)
16
+ @provider = described_class.new(@resource)
20
17
  end
21
18
 
22
19
  it "should have an install method" do
23
- @provider = provider_class.new
20
+ @provider = described_class.new
24
21
  expect(@provider).to respond_to(:install)
25
22
  end
26
23
 
27
24
  it "should have an uninstall method" do
28
- @provider = provider_class.new
25
+ @provider = described_class.new
29
26
  expect(@provider).to respond_to(:uninstall)
30
27
  end
31
28
 
32
29
  it "should have an update method" do
33
- @provider = provider_class.new
30
+ @provider = described_class.new
34
31
  expect(@provider).to respond_to(:update)
35
32
  end
36
33
 
37
34
  it "should have a latest method" do
38
- @provider = provider_class.new
35
+ @provider = described_class.new
39
36
  expect(@provider).to respond_to(:latest)
40
37
  end
41
38
 
42
39
  it "should have a install_options method" do
43
- @provider = provider_class.new
40
+ @provider = described_class.new
44
41
  expect(@provider).to respond_to(:install_options)
45
42
  end
46
43
 
47
- describe "when installing with zypper version >= 1.0" do
44
+ context "when installing with zypper version >= 1.0" do
48
45
  it "should use a command-line with versioned package'" do
49
46
  @resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
50
47
  @resource.stubs(:allow_virtual?).returns false
@@ -65,7 +62,7 @@ describe provider_class do
65
62
  end
66
63
  end
67
64
 
68
- describe "when installing with zypper version = 0.6.104" do
65
+ context "when installing with zypper version = 0.6.104" do
69
66
  it "should use a command-line with versioned package'" do
70
67
  @resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
71
68
  @resource.stubs(:allow_virtual?).returns false
@@ -86,7 +83,7 @@ describe provider_class do
86
83
  end
87
84
  end
88
85
 
89
- describe "when installing with zypper version = 0.6.13" do
86
+ context "when installing with zypper version = 0.6.13" do
90
87
  it "should use a command-line with versioned package'" do
91
88
  @resource.stubs(:should).with(:ensure).returns "1.2.3-4.5.6"
92
89
  @resource.stubs(:allow_virtual?).returns false
@@ -107,15 +104,16 @@ describe provider_class do
107
104
  end
108
105
  end
109
106
 
110
- describe "when updating" do
107
+ context "when updating" do
111
108
  it "should call install method of instance" do
112
109
  @provider.expects(:install)
113
110
  @provider.update
114
111
  end
115
112
  end
116
113
 
117
- describe "when getting latest version" do
118
- after do described_class.reset! end
114
+ context "when getting latest version" do
115
+ after { described_class.reset! }
116
+
119
117
  context "when the package has available update" do
120
118
  it "should return a version string with valid list-updates data from SLES11sp1" do
121
119
  fake_data = File.read(my_fixture('zypper-list-updates-SLES11sp1.out'))
@@ -144,7 +142,7 @@ describe provider_class do
144
142
  end
145
143
  end
146
144
 
147
- describe "should install a virtual package" do
145
+ context "should install a virtual package" do
148
146
  it "when zypper version = 0.6.13" do
149
147
  @resource.stubs(:should).with(:ensure).returns :installed
150
148
  @resource.stubs(:allow_virtual?).returns true
@@ -164,7 +162,7 @@ describe provider_class do
164
162
  end
165
163
  end
166
164
 
167
- describe "when installing with zypper install options" do
165
+ context "when installing with zypper install options" do
168
166
  it "should install the package without checking keys" do
169
167
  @resource.stubs(:[]).with(:name).returns "php5"
170
168
  @resource.stubs(:[]).with(:install_options).returns ['--no-gpg-check', {'-p' => '/vagrant/files/localrepo/'}]
@@ -215,7 +213,7 @@ describe provider_class do
215
213
  end
216
214
  end
217
215
 
218
- describe 'when uninstalling' do
216
+ context 'when uninstalling' do
219
217
  it 'should use remove to uninstall on zypper version 1.6 and above' do
220
218
  @provider.stubs(:zypper_version).returns '1.6.308'
221
219
  @provider.expects(:zypper).with(:remove, '--no-confirm', 'mypackage')
@@ -1,11 +1,9 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'spec_helper'
4
2
 
5
3
  describe 'Puppet::Type::Service::Provider::Bsd',
6
4
  :unless => Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
7
-
8
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:bsd) }
6
+
9
7
  before :each do
10
8
  Puppet::Type.type(:service).stubs(:defaultprovider).returns provider_class
11
9
  Facter.stubs(:value).with(:operatingsystem).returns :netbsd
@@ -15,7 +13,7 @@ describe 'Puppet::Type::Service::Provider::Bsd',
15
13
  @provider.stubs(:initscript)
16
14
  end
17
15
 
18
- describe "#instances" do
16
+ context "#instances" do
19
17
  it "should have an instances method" do
20
18
  expect(provider_class).to respond_to :instances
21
19
  end
@@ -25,7 +23,7 @@ describe 'Puppet::Type::Service::Provider::Bsd',
25
23
  end
26
24
  end
27
25
 
28
- describe "#disable" do
26
+ context "#disable" do
29
27
  it "should have a disable method" do
30
28
  expect(@provider).to respond_to(:disable)
31
29
  end
@@ -46,7 +44,7 @@ describe 'Puppet::Type::Service::Provider::Bsd',
46
44
  end
47
45
  end
48
46
 
49
- describe "#enable" do
47
+ context "#enable" do
50
48
  it "should have an enable method" do
51
49
  expect(@provider).to respond_to(:enable)
52
50
  end
@@ -71,7 +69,7 @@ describe 'Puppet::Type::Service::Provider::Bsd',
71
69
  end
72
70
  end
73
71
 
74
- describe "#enabled?" do
72
+ context "#enabled?" do
75
73
  it "should have an enabled? method" do
76
74
  expect(@provider).to respond_to(:enabled?)
77
75
  end
@@ -91,7 +89,7 @@ describe 'Puppet::Type::Service::Provider::Bsd',
91
89
  end
92
90
  end
93
91
 
94
- describe "#startcmd" do
92
+ context "#startcmd" do
95
93
  it "should have a startcmd method" do
96
94
  expect(@provider).to respond_to(:startcmd)
97
95
  end
@@ -110,7 +108,7 @@ describe 'Puppet::Type::Service::Provider::Bsd',
110
108
  end
111
109
  end
112
110
 
113
- describe "#stopcmd" do
111
+ context "#stopcmd" do
114
112
  it "should have a stopcmd method" do
115
113
  expect(@provider).to respond_to(:stopcmd)
116
114
  end
@@ -1,12 +1,7 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the Daemontools service Provider
4
- #
5
- # author Brice Figureau
6
- #
7
1
  require 'spec_helper'
8
2
 
9
- describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::Platform.jruby? do
3
+ describe 'Puppet::Type::Service::Provider::Daemontools',
4
+ unless: Puppet::Util::Platform.jruby? do
10
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:daemontools) }
11
6
 
12
7
  before(:each) do
@@ -62,7 +57,7 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
62
57
  expect(@provider).to respond_to(:disable)
63
58
  end
64
59
 
65
- describe "when starting" do
60
+ context "when starting" do
66
61
  it "should use 'svc' to start the service" do
67
62
  @provider.stubs(:enabled?).returns :true
68
63
  @provider.expects(:svc).with("-u", "/etc/service/myservice")
@@ -80,7 +75,7 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
80
75
  end
81
76
  end
82
77
 
83
- describe "when stopping" do
78
+ context "when stopping" do
84
79
  it "should use 'svc' to stop the service" do
85
80
  @provider.stubs(:disable)
86
81
  @provider.expects(:svc).with("-d", "/etc/service/myservice")
@@ -89,7 +84,7 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
89
84
  end
90
85
  end
91
86
 
92
- describe "when restarting" do
87
+ context "when restarting" do
93
88
  it "should use 'svc' to restart the service" do
94
89
  @provider.expects(:svc).with("-t", "/etc/service/myservice")
95
90
 
@@ -97,7 +92,7 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
97
92
  end
98
93
  end
99
94
 
100
- describe "when enabling" do
95
+ context "when enabling" do
101
96
  it "should create a symlink between daemon dir and service dir", :if => Puppet.features.manages_symlinks? do
102
97
  daemon_path = File.join(@daemondir, "myservice")
103
98
  service_path = File.join(@servicedir, "myservice")
@@ -108,7 +103,7 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
108
103
  end
109
104
  end
110
105
 
111
- describe "when disabling" do
106
+ context "when disabling" do
112
107
  it "should remove the symlink between daemon dir and service dir" do
113
108
  FileTest.stubs(:directory?).returns(false)
114
109
  path = File.join(@servicedir,"myservice")
@@ -127,7 +122,7 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
127
122
  end
128
123
  end
129
124
 
130
- describe "when checking if the service is enabled?" do
125
+ context "when checking if the service is enabled?" do
131
126
  it "should return true if it is running" do
132
127
  @provider.stubs(:status).returns(:running)
133
128
 
@@ -145,26 +140,27 @@ describe 'Puppet::Type::Service::Provider::Daemontools', unless: Puppet::Util::P
145
140
  end
146
141
  end
147
142
 
148
- describe "when checking status" do
143
+ context "when checking status" do
149
144
  it "should call the external command 'svstat /etc/service/myservice'" do
150
145
  @provider.expects(:svstat).with(File.join(@servicedir,"myservice"))
151
146
  @provider.status
152
147
  end
153
148
  end
154
149
 
155
- describe "when checking status" do
150
+ context "when checking status" do
156
151
  it "and svstat fails, properly raise a Puppet::Error" do
157
152
  @provider.expects(:svstat).with(File.join(@servicedir,"myservice")).raises(Puppet::ExecutionFailure, "failure")
158
153
  expect { @provider.status }.to raise_error(Puppet::Error, 'Could not get status for service Service[myservice]: failure')
159
154
  end
155
+
160
156
  it "and svstat returns up, then return :running" do
161
157
  @provider.expects(:svstat).with(File.join(@servicedir,"myservice")).returns("/etc/service/myservice: up (pid 454) 954326 seconds")
162
158
  expect(@provider.status).to eq(:running)
163
159
  end
160
+
164
161
  it "and svstat returns not running, then return :stopped" do
165
162
  @provider.expects(:svstat).with(File.join(@servicedir,"myservice")).returns("/etc/service/myservice: supervise not running")
166
163
  expect(@provider.status).to eq(:stopped)
167
164
  end
168
165
  end
169
-
170
166
  end
@@ -1,11 +1,7 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # Unit testing for the debian service provider
4
- #
5
-
6
1
  require 'spec_helper'
7
2
 
8
- describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platform.jruby? do
3
+ describe 'Puppet::Type::Service::Provider::Debian',
4
+ unless: Puppet::Util::Platform.jruby? do
9
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:debian) }
10
6
 
11
7
  if Puppet::Util::Platform.windows?
@@ -69,14 +65,14 @@ describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platfo
69
65
  expect(@provider).to respond_to(:disable)
70
66
  end
71
67
 
72
- describe "when enabling" do
68
+ context "when enabling" do
73
69
  it "should call update-rc.d twice" do
74
70
  @provider.expects(:update_rc).twice
75
71
  @provider.enable
76
72
  end
77
73
  end
78
74
 
79
- describe "when disabling" do
75
+ context "when disabling" do
80
76
  it "should be able to disable services with newer sysv-rc versions" do
81
77
  @provider.stubs(:`).with("dpkg --compare-versions $(dpkg-query -W --showformat '${Version}' sysv-rc) ge 2.88 ; echo $?").returns "0"
82
78
 
@@ -95,7 +91,7 @@ describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platfo
95
91
  end
96
92
  end
97
93
 
98
- describe "when checking whether it is enabled" do
94
+ context "when checking whether it is enabled" do
99
95
  it "should call Kernel.system() with the appropriate parameters" do
100
96
  @provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
101
97
  $CHILD_STATUS.stubs(:exitstatus).returns(0)
@@ -155,7 +151,7 @@ describe 'Puppet::Type::Service::Provider::Debian', unless: Puppet::Util::Platfo
155
151
  end
156
152
  end
157
153
 
158
- describe "when checking service status" do
154
+ context "when checking service status" do
159
155
  it "should use the service command" do
160
156
  Facter.stubs(:value).with(:operatingsystem).returns('Debian')
161
157
  Facter.stubs(:value).with(:operatingsystemmajrelease).returns('8')
@@ -1,7 +1,7 @@
1
- #! /usr/bin/env ruby
2
1
  require 'spec_helper'
3
2
 
4
- describe 'Puppet::Type::Service::Provider::Freebsd', unless: Puppet::Util::Platform.jruby? do
3
+ describe 'Puppet::Type::Service::Provider::Freebsd',
4
+ unless: Puppet::Util::Platform.jruby? do
5
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:freebsd) }
6
6
 
7
7
  before :each do
@@ -345,4 +345,23 @@ describe 'Puppet::Type::Service::Provider::Launchd', unless: Puppet::Util::Platf
345
345
  expect { provider.jobsearch("NOSUCH") }.to raise_error(Puppet::Error)
346
346
  end
347
347
  end
348
+
349
+ describe "read_overrides" do
350
+ before do
351
+ Kernel.stubs(:sleep)
352
+ end
353
+ it "should read overrides" do
354
+ provider.expects(:read_plist).once.returns({})
355
+ expect(provider.read_overrides).to eq({})
356
+ end
357
+ it "should retry if read_plist fails" do
358
+ provider.expects(:read_plist).once.returns({})
359
+ provider.expects(:read_plist).once.returns(nil)
360
+ expect(provider.read_overrides).to eq({})
361
+ end
362
+ it "raises Puppet::Error after 20 attempts" do
363
+ provider.expects(:read_plist).times(20).returns(nil)
364
+ expect { provider.read_overrides }.to raise_error(Puppet::Error)
365
+ end
366
+ end
348
367
  end
@@ -1,11 +1,7 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Unit testing for the OpenBSD service provider
4
-
5
1
  require 'spec_helper'
6
2
 
7
3
  describe 'Puppet::Type::Service::Provider::Openbsd',
8
- unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
4
+ unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
9
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:openbsd) }
10
6
 
11
7
  before :each do
@@ -16,7 +12,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
16
12
  FileTest.stubs(:executable?).with('/usr/sbin/rcctl').returns true
17
13
  end
18
14
 
19
- describe "#instances" do
15
+ context "#instances" do
20
16
  it "should have an instances method" do
21
17
  expect(provider_class).to respond_to :instances
22
18
  end
@@ -29,7 +25,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
29
25
  end
30
26
  end
31
27
 
32
- describe "#start" do
28
+ context "#start" do
33
29
  it "should use the supplied start command if specified" do
34
30
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :start => '/bin/foo'))
35
31
  provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
@@ -43,7 +39,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
43
39
  end
44
40
  end
45
41
 
46
- describe "#stop" do
42
+ context "#stop" do
47
43
  it "should use the supplied stop command if specified" do
48
44
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :stop => '/bin/foo'))
49
45
  provider.expects(:execute).with(['/bin/foo'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true)
@@ -57,7 +53,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
57
53
  end
58
54
  end
59
55
 
60
- describe "#status" do
56
+ context "#status" do
61
57
  it "should use the status command from the resource" do
62
58
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :status => '/bin/foo'))
63
59
  provider.expects(:execute).with(['/usr/sbin/rcctl', :get, 'sshd', :status], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
@@ -82,7 +78,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
82
78
  end
83
79
  end
84
80
 
85
- describe "#restart" do
81
+ context "#restart" do
86
82
  it "should use the supplied restart command if specified" do
87
83
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :restart => '/bin/foo'))
88
84
  provider.expects(:execute).with(['/usr/sbin/rcctl', '-f', :restart, 'sshd'], :failonfail => true, :override_locale => false, :squelch => false, :combine => true).never
@@ -105,7 +101,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
105
101
  end
106
102
  end
107
103
 
108
- describe "#enabled?" do
104
+ context "#enabled?" do
109
105
  it "should return :true if the service is enabled" do
110
106
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
111
107
  provider_class.stubs(:rcctl).with(:get, 'sshd', :status)
@@ -121,7 +117,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
121
117
  end
122
118
  end
123
119
 
124
- describe "#enable" do
120
+ context "#enable" do
125
121
  it "should run rcctl enable to enable the service" do
126
122
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
127
123
  provider_class.stubs(:rcctl).with(:enable, 'sshd').returns('')
@@ -139,7 +135,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
139
135
  end
140
136
  end
141
137
 
142
- describe "#disable" do
138
+ context "#disable" do
143
139
  it "should run rcctl disable to disable the service" do
144
140
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
145
141
  provider_class.stubs(:rcctl).with(:disable, 'sshd').returns('')
@@ -148,7 +144,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
148
144
  end
149
145
  end
150
146
 
151
- describe "#running?" do
147
+ context "#running?" do
152
148
  it "should run rcctl check to check the service" do
153
149
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
154
150
  provider_class.stubs(:rcctl).with(:check, 'sshd').returns('sshd(ok)')
@@ -171,7 +167,7 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
171
167
  end
172
168
  end
173
169
 
174
- describe "#flags" do
170
+ context "#flags" do
175
171
  it "should return flags when set" do
176
172
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd', :flags => '-6'))
177
173
  provider_class.stubs(:rcctl).with('get', 'sshd', 'flags').returns('-6')
@@ -194,8 +190,8 @@ describe 'Puppet::Type::Service::Provider::Openbsd',
194
190
  end
195
191
  end
196
192
 
197
- describe "#flags=" do
198
- it "should run rcctl to set flags", :unless => Puppet::Util::Platform.windows? || RUBY_PLATFORM == 'java' do
193
+ context "#flags=" do
194
+ it "should run rcctl to set flags", unless: Puppet::Util::Platform.windows? || RUBY_PLATFORM == 'java' do
199
195
  provider = provider_class.new(Puppet::Type.type(:service).new(:name => 'sshd'))
200
196
  provider_class.stubs(:rcctl).with(:set, 'sshd', :flags, '-4').returns('')
201
197
  provider.expects(:rcctl).with(:set, 'sshd', :flags, '-4')
@@ -1,9 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require 'spec_helper'
4
2
 
5
3
  describe 'Puppet::Type::Service::Provider::Rcng',
6
- :unless => Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
4
+ unless: Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do
7
5
  let(:provider_class) { Puppet::Type.type(:service).provider(:rcng) }
8
6
 
9
7
  before :each do
@@ -15,7 +13,7 @@ describe 'Puppet::Type::Service::Provider::Rcng',
15
13
  @provider.stubs(:initscript)
16
14
  end
17
15
 
18
- describe "#enable" do
16
+ context "#enable" do
19
17
  it "should have an enable method" do
20
18
  expect(@provider).to respond_to(:enable)
21
19
  end