puppet 6.24.0-x86-mingw32 → 6.25.0-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.

Files changed (279) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +12 -12
  4. data/{ext → examples/enc}/regexp_nodes/classes/databases +0 -0
  5. data/{ext → examples/enc}/regexp_nodes/classes/webservers +0 -0
  6. data/{ext → examples/enc}/regexp_nodes/environment/development +0 -0
  7. data/{ext → examples/enc}/regexp_nodes/parameters/service/prod +0 -0
  8. data/{ext → examples/enc}/regexp_nodes/parameters/service/qa +0 -0
  9. data/{ext → examples/enc}/regexp_nodes/parameters/service/sandbox +0 -0
  10. data/{ext → examples/enc}/regexp_nodes/regexp_nodes.rb +0 -0
  11. data/{ext → examples}/nagios/check_puppet.rb +2 -2
  12. data/ext/README.md +13 -0
  13. data/lib/puppet/application/agent.rb +4 -0
  14. data/lib/puppet/application/apply.rb +20 -2
  15. data/lib/puppet/application/resource.rb +15 -13
  16. data/lib/puppet/concurrent/thread_local_singleton.rb +1 -0
  17. data/lib/puppet/configurer.rb +85 -57
  18. data/lib/puppet/confine/variable.rb +1 -1
  19. data/lib/puppet/defaults.rb +36 -30
  20. data/lib/puppet/environments.rb +66 -26
  21. data/lib/puppet/face/facts.rb +1 -1
  22. data/lib/puppet/facter_impl.rb +96 -0
  23. data/lib/puppet/file_serving/configuration/parser.rb +2 -0
  24. data/lib/puppet/file_serving/configuration.rb +3 -0
  25. data/lib/puppet/file_serving/mount/file.rb +4 -4
  26. data/lib/puppet/file_serving/mount/scripts.rb +24 -0
  27. data/lib/puppet/file_system/file_impl.rb +3 -1
  28. data/lib/puppet/forge.rb +1 -1
  29. data/lib/puppet/functions/find_template.rb +2 -2
  30. data/lib/puppet/http/service/compiler.rb +6 -1
  31. data/lib/puppet/indirector/catalog/compiler.rb +24 -6
  32. data/lib/puppet/indirector/catalog/rest.rb +1 -0
  33. data/lib/puppet/indirector/facts/facter.rb +6 -6
  34. data/lib/puppet/indirector/indirection.rb +1 -1
  35. data/lib/puppet/indirector/terminus.rb +4 -0
  36. data/lib/puppet/module/plan.rb +0 -1
  37. data/lib/puppet/module/task.rb +1 -1
  38. data/lib/puppet/module.rb +1 -0
  39. data/lib/puppet/module_tool/applications/installer.rb +8 -4
  40. data/lib/puppet/module_tool/applications/uninstaller.rb +1 -1
  41. data/lib/puppet/module_tool/applications/upgrader.rb +1 -1
  42. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  43. data/lib/puppet/node/environment.rb +10 -11
  44. data/lib/puppet/pal/pal_impl.rb +1 -1
  45. data/lib/puppet/parser/scope.rb +1 -0
  46. data/lib/puppet/parser/templatewrapper.rb +1 -0
  47. data/lib/puppet/pops/lookup/lookup_adapter.rb +3 -2
  48. data/lib/puppet/pops/model/ast.rb +1 -0
  49. data/lib/puppet/pops/model/factory.rb +2 -1
  50. data/lib/puppet/pops/parser/eparser.rb +201 -201
  51. data/lib/puppet/pops/parser/lexer2.rb +92 -91
  52. data/lib/puppet/pops/parser/slurp_support.rb +1 -0
  53. data/lib/puppet/pops/serialization/to_data_converter.rb +18 -6
  54. data/lib/puppet/pops/serialization/to_stringified_converter.rb +1 -1
  55. data/lib/puppet/pops/types/type_formatter.rb +4 -3
  56. data/lib/puppet/pops/types/types.rb +1 -1
  57. data/lib/puppet/provider/aix_object.rb +1 -1
  58. data/lib/puppet/provider/group/groupadd.rb +5 -2
  59. data/lib/puppet/provider/package/pkg.rb +19 -2
  60. data/lib/puppet/provider/package/puppetserver_gem.rb +1 -1
  61. data/lib/puppet/provider/package/yum.rb +1 -1
  62. data/lib/puppet/provider/service/base.rb +1 -1
  63. data/lib/puppet/provider/service/init.rb +5 -5
  64. data/lib/puppet/provider/service/launchd.rb +2 -2
  65. data/lib/puppet/provider/service/redhat.rb +1 -1
  66. data/lib/puppet/provider/service/smf.rb +3 -3
  67. data/lib/puppet/provider/service/systemd.rb +2 -2
  68. data/lib/puppet/provider/service/upstart.rb +5 -5
  69. data/lib/puppet/provider/user/aix.rb +44 -1
  70. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  71. data/lib/puppet/provider/user/useradd.rb +72 -16
  72. data/lib/puppet/provider.rb +1 -1
  73. data/lib/puppet/reference/providers.rb +2 -2
  74. data/lib/puppet/resource/type_collection.rb +1 -0
  75. data/lib/puppet/runtime.rb +11 -1
  76. data/lib/puppet/settings.rb +2 -2
  77. data/lib/puppet/test/test_helper.rb +4 -1
  78. data/lib/puppet/transaction/persistence.rb +11 -1
  79. data/lib/puppet/transaction/report.rb +15 -1
  80. data/lib/puppet/type/exec.rb +19 -2
  81. data/lib/puppet/type/file.rb +6 -6
  82. data/lib/puppet/type/filebucket.rb +3 -3
  83. data/lib/puppet/type/group.rb +0 -1
  84. data/lib/puppet/type/resources.rb +1 -1
  85. data/lib/puppet/type/service.rb +8 -3
  86. data/lib/puppet/type/user.rb +0 -1
  87. data/lib/puppet/type.rb +1 -1
  88. data/lib/puppet/util/command_line.rb +1 -1
  89. data/lib/puppet/util/filetype.rb +2 -2
  90. data/lib/puppet/util/json.rb +3 -0
  91. data/lib/puppet/util/log.rb +1 -2
  92. data/lib/puppet/util/logging.rb +1 -25
  93. data/lib/puppet/util/pidlock.rb +1 -1
  94. data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
  95. data/lib/puppet/util/suidmanager.rb +1 -2
  96. data/lib/puppet/util/tagging.rb +1 -0
  97. data/lib/puppet/util/windows/user.rb +0 -2
  98. data/lib/puppet/util.rb +4 -3
  99. data/lib/puppet/version.rb +1 -1
  100. data/lib/puppet.rb +2 -6
  101. data/locales/puppet.pot +246 -230
  102. data/man/man5/puppet.conf.5 +33 -25
  103. data/man/man8/puppet-agent.8 +4 -1
  104. data/man/man8/puppet-apply.8 +1 -1
  105. data/man/man8/puppet-catalog.8 +1 -1
  106. data/man/man8/puppet-config.8 +1 -1
  107. data/man/man8/puppet-describe.8 +1 -1
  108. data/man/man8/puppet-device.8 +1 -1
  109. data/man/man8/puppet-doc.8 +1 -1
  110. data/man/man8/puppet-epp.8 +1 -1
  111. data/man/man8/puppet-facts.8 +1 -1
  112. data/man/man8/puppet-filebucket.8 +1 -1
  113. data/man/man8/puppet-generate.8 +1 -1
  114. data/man/man8/puppet-help.8 +1 -1
  115. data/man/man8/puppet-key.8 +1 -1
  116. data/man/man8/puppet-lookup.8 +1 -1
  117. data/man/man8/puppet-man.8 +1 -1
  118. data/man/man8/puppet-module.8 +3 -3
  119. data/man/man8/puppet-node.8 +1 -1
  120. data/man/man8/puppet-parser.8 +1 -1
  121. data/man/man8/puppet-plugin.8 +1 -1
  122. data/man/man8/puppet-report.8 +1 -1
  123. data/man/man8/puppet-resource.8 +1 -1
  124. data/man/man8/puppet-script.8 +1 -1
  125. data/man/man8/puppet-ssl.8 +1 -1
  126. data/man/man8/puppet-status.8 +1 -1
  127. data/man/man8/puppet.8 +2 -2
  128. data/spec/fixtures/integration/application/agent/lib/facter/agent_spec_role.rb +3 -0
  129. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Gemfile +4 -0
  130. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/Rakefile +3 -0
  131. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/lib/puppet/functions/l10n.rb +8 -0
  132. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/config.yaml +25 -0
  133. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/ja/puppet-l10n.po +19 -0
  134. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/locales/puppet-l10n.pot +20 -0
  135. data/spec/fixtures/integration/l10n/envs/prod/modules/demo/metadata.json +8 -0
  136. data/spec/integration/application/agent_spec.rb +113 -37
  137. data/spec/integration/application/filebucket_spec.rb +5 -0
  138. data/spec/integration/configurer_spec.rb +18 -2
  139. data/spec/integration/indirector/facts/facter_spec.rb +3 -3
  140. data/spec/integration/l10n/compiler_spec.rb +37 -0
  141. data/spec/integration/transaction/report_spec.rb +1 -1
  142. data/spec/integration/type/file_spec.rb +2 -2
  143. data/spec/integration/type/package_spec.rb +6 -6
  144. data/spec/integration/util/rdoc/parser_spec.rb +1 -1
  145. data/spec/integration/util/windows/process_spec.rb +1 -9
  146. data/spec/lib/puppet_spec/modules.rb +13 -2
  147. data/spec/lib/puppet_spec/puppetserver.rb +15 -0
  148. data/spec/shared_behaviours/documentation_on_faces.rb +0 -2
  149. data/spec/shared_contexts/l10n.rb +27 -0
  150. data/spec/spec_helper.rb +1 -10
  151. data/spec/unit/application/apply_spec.rb +76 -56
  152. data/spec/unit/application/resource_spec.rb +29 -0
  153. data/spec/unit/configurer_spec.rb +171 -56
  154. data/spec/unit/defaults_spec.rb +1 -0
  155. data/spec/unit/environments_spec.rb +150 -1
  156. data/spec/unit/facter_impl_spec.rb +31 -0
  157. data/spec/unit/file_bucket/dipper_spec.rb +2 -2
  158. data/spec/unit/file_serving/configuration/parser_spec.rb +23 -0
  159. data/spec/unit/file_serving/configuration_spec.rb +14 -4
  160. data/spec/unit/file_serving/mount/scripts_spec.rb +69 -0
  161. data/spec/unit/file_system_spec.rb +7 -0
  162. data/spec/unit/functions/logging_spec.rb +1 -0
  163. data/spec/unit/functions/lookup_spec.rb +64 -0
  164. data/spec/unit/http/service/compiler_spec.rb +8 -0
  165. data/spec/unit/indirector/catalog/compiler_spec.rb +87 -0
  166. data/spec/unit/indirector/catalog/rest_spec.rb +8 -0
  167. data/spec/unit/indirector/indirection_spec.rb +10 -3
  168. data/spec/unit/interface/action_spec.rb +0 -9
  169. data/spec/unit/module_spec.rb +15 -1
  170. data/spec/unit/module_tool/applications/installer_spec.rb +39 -12
  171. data/spec/unit/network/authstore_spec.rb +0 -15
  172. data/spec/unit/network/formats_spec.rb +6 -0
  173. data/spec/unit/pops/parser/parse_containers_spec.rb +0 -11
  174. data/spec/unit/pops/serialization/to_from_hr_spec.rb +58 -0
  175. data/spec/unit/pops/serialization/to_stringified_spec.rb +5 -0
  176. data/spec/unit/pops/types/type_calculator_spec.rb +6 -0
  177. data/spec/unit/provider/package/gem_spec.rb +1 -1
  178. data/spec/unit/provider/package/pip2_spec.rb +1 -1
  179. data/spec/unit/provider/package/pip3_spec.rb +1 -1
  180. data/spec/unit/provider/package/pip_spec.rb +1 -1
  181. data/spec/unit/provider/package/pkg_spec.rb +29 -4
  182. data/spec/unit/provider/package/puppet_gem_spec.rb +1 -1
  183. data/spec/unit/provider/package/puppetserver_gem_spec.rb +1 -1
  184. data/spec/unit/provider/service/launchd_spec.rb +11 -0
  185. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  186. data/spec/unit/provider/user/aix_spec.rb +100 -0
  187. data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
  188. data/spec/unit/provider/user/useradd_spec.rb +43 -2
  189. data/spec/unit/provider_spec.rb +4 -4
  190. data/spec/unit/puppet_spec.rb +12 -4
  191. data/spec/unit/ssl/certificate_request_spec.rb +8 -14
  192. data/spec/unit/type/service_spec.rb +27 -0
  193. data/spec/unit/type_spec.rb +2 -2
  194. data/spec/unit/util/logging_spec.rb +2 -0
  195. data/tasks/parallel.rake +3 -3
  196. metadata +37 -94
  197. data/ext/README.environment +0 -8
  198. data/ext/dbfix.sql +0 -132
  199. data/ext/debian/README.Debian +0 -8
  200. data/ext/debian/README.source +0 -2
  201. data/ext/debian/TODO.Debian +0 -1
  202. data/ext/debian/changelog.erb +0 -1122
  203. data/ext/debian/compat +0 -1
  204. data/ext/debian/control +0 -144
  205. data/ext/debian/copyright +0 -339
  206. data/ext/debian/docs +0 -1
  207. data/ext/debian/fileserver.conf +0 -41
  208. data/ext/debian/puppet-common.dirs +0 -13
  209. data/ext/debian/puppet-common.install +0 -3
  210. data/ext/debian/puppet-common.lintian-overrides +0 -5
  211. data/ext/debian/puppet-common.manpages +0 -28
  212. data/ext/debian/puppet-common.postinst +0 -35
  213. data/ext/debian/puppet-common.postrm +0 -33
  214. data/ext/debian/puppet-el.dirs +0 -1
  215. data/ext/debian/puppet-el.emacsen-install +0 -25
  216. data/ext/debian/puppet-el.emacsen-remove +0 -11
  217. data/ext/debian/puppet-el.emacsen-startup +0 -9
  218. data/ext/debian/puppet-el.install +0 -1
  219. data/ext/debian/puppet-testsuite.install +0 -2
  220. data/ext/debian/puppet-testsuite.lintian-overrides +0 -4
  221. data/ext/debian/puppet.lintian-overrides +0 -3
  222. data/ext/debian/puppet.logrotate +0 -20
  223. data/ext/debian/puppet.postinst +0 -20
  224. data/ext/debian/puppet.postrm +0 -20
  225. data/ext/debian/puppet.preinst +0 -20
  226. data/ext/debian/puppetmaster-common.install +0 -2
  227. data/ext/debian/puppetmaster-common.manpages +0 -2
  228. data/ext/debian/puppetmaster-common.postinst +0 -6
  229. data/ext/debian/puppetmaster-passenger.dirs +0 -4
  230. data/ext/debian/puppetmaster-passenger.postinst +0 -162
  231. data/ext/debian/puppetmaster-passenger.postrm +0 -61
  232. data/ext/debian/puppetmaster.README.debian +0 -17
  233. data/ext/debian/puppetmaster.default +0 -14
  234. data/ext/debian/puppetmaster.init +0 -137
  235. data/ext/debian/puppetmaster.lintian-overrides +0 -3
  236. data/ext/debian/puppetmaster.postinst +0 -20
  237. data/ext/debian/puppetmaster.postrm +0 -5
  238. data/ext/debian/puppetmaster.preinst +0 -22
  239. data/ext/debian/rules +0 -132
  240. data/ext/debian/source/format +0 -1
  241. data/ext/debian/source/options +0 -1
  242. data/ext/debian/vim-puppet.README.Debian +0 -13
  243. data/ext/debian/vim-puppet.dirs +0 -5
  244. data/ext/debian/vim-puppet.yaml +0 -7
  245. data/ext/debian/watch +0 -2
  246. data/ext/freebsd/puppetd +0 -26
  247. data/ext/freebsd/puppetmasterd +0 -26
  248. data/ext/gentoo/conf.d/puppet +0 -5
  249. data/ext/gentoo/conf.d/puppetmaster +0 -12
  250. data/ext/gentoo/init.d/puppet +0 -38
  251. data/ext/gentoo/init.d/puppetmaster +0 -51
  252. data/ext/gentoo/puppet/fileserver.conf +0 -41
  253. data/ext/ips/puppet-agent +0 -44
  254. data/ext/ips/puppet-master +0 -44
  255. data/ext/ips/puppet.p5m.erb +0 -12
  256. data/ext/ips/puppetagent.xml +0 -42
  257. data/ext/ips/puppetmaster.xml +0 -42
  258. data/ext/ips/rules +0 -19
  259. data/ext/ips/transforms +0 -34
  260. data/ext/ldap/puppet.schema +0 -24
  261. data/ext/logcheck/puppet +0 -23
  262. data/ext/osx/file_mapping.yaml +0 -33
  263. data/ext/osx/postflight.erb +0 -109
  264. data/ext/osx/preflight.erb +0 -52
  265. data/ext/osx/prototype.plist.erb +0 -38
  266. data/ext/redhat/fileserver.conf +0 -41
  267. data/ext/redhat/logrotate +0 -21
  268. data/ext/redhat/puppet.spec.erb +0 -842
  269. data/ext/redhat/server.init +0 -128
  270. data/ext/redhat/server.sysconfig +0 -13
  271. data/ext/solaris/pkginfo +0 -6
  272. data/ext/solaris/smf/puppetd.xml +0 -77
  273. data/ext/solaris/smf/puppetmasterd.xml +0 -77
  274. data/ext/solaris/smf/svc-puppetd +0 -71
  275. data/ext/solaris/smf/svc-puppetmasterd +0 -67
  276. data/ext/suse/puppet.spec +0 -310
  277. data/ext/suse/server.init +0 -173
  278. data/ext/yaml_nodes.rb +0 -105
  279. data/spec/unit/indirector/store_configs_spec.rb +0 -7
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+ require 'puppet/file_serving/mount/scripts'
3
+
4
+ describe Puppet::FileServing::Mount::Scripts do
5
+ before do
6
+ @mount = Puppet::FileServing::Mount::Scripts.new("scripts")
7
+
8
+ @environment = double('environment', :module => nil)
9
+ @request = double('request', :environment => @environment)
10
+ end
11
+
12
+ describe "when finding files" do
13
+ it "should fail if no module is specified" do
14
+ expect { @mount.find("", @request) }.to raise_error(/No module specified/)
15
+ end
16
+
17
+ it "should use the provided environment to find the module" do
18
+ expect(@environment).to receive(:module)
19
+
20
+ @mount.find("foo", @request)
21
+ end
22
+
23
+ it "should treat the first field of the relative path as the module name" do
24
+ expect(@environment).to receive(:module).with("foo")
25
+ @mount.find("foo/bar/baz", @request)
26
+ end
27
+
28
+ it "should return nil if the specified module does not exist" do
29
+ expect(@environment).to receive(:module).with("foo")
30
+ @mount.find("foo/bar/baz", @request)
31
+ end
32
+
33
+ it "should return the file path from the module" do
34
+ mod = double('module')
35
+ expect(mod).to receive(:script).with("bar/baz").and_return("eh")
36
+ expect(@environment).to receive(:module).with("foo").and_return(mod)
37
+ expect(@mount.find("foo/bar/baz", @request)).to eq("eh")
38
+ end
39
+ end
40
+
41
+ describe "when searching for files" do
42
+ it "should fail if no module is specified" do
43
+ expect { @mount.search("", @request) }.to raise_error(/No module specified/)
44
+ end
45
+
46
+ it "should use the node's environment to search the module" do
47
+ expect(@environment).to receive(:module)
48
+
49
+ @mount.search("foo", @request)
50
+ end
51
+
52
+ it "should treat the first field of the relative path as the module name" do
53
+ expect(@environment).to receive(:module).with("foo")
54
+ @mount.search("foo/bar/baz", @request)
55
+ end
56
+
57
+ it "should return nil if the specified module does not exist" do
58
+ expect(@environment).to receive(:module).with("foo").and_return(nil)
59
+ @mount.search("foo/bar/baz", @request)
60
+ end
61
+
62
+ it "should return the script path as an array from the module" do
63
+ mod = double('module')
64
+ expect(mod).to receive(:script).with("bar/baz").and_return("eh")
65
+ expect(@environment).to receive(:module).with("foo").and_return(mod)
66
+ expect(@mount.search("foo/bar/baz", @request)).to eq(["eh"])
67
+ end
68
+ end
69
+ end
@@ -296,6 +296,13 @@ describe "Puppet::FileSystem" do
296
296
  expect(Puppet::FileSystem.read_preserve_line_endings(file)).to eq("file content \n")
297
297
  end
298
298
  end
299
+
300
+ it "should not warn about misusage of BOM with non-UTF encoding" do
301
+ allow(Encoding).to receive(:default_external).and_return(Encoding::US_ASCII)
302
+ with_file_content("file content \n") do |file|
303
+ expect{ Puppet::FileSystem.read_preserve_line_endings(file) }.not_to output(/BOM with non-UTF encoding US-ASCII is nonsense/).to_stderr
304
+ end
305
+ end
299
306
  end
300
307
 
301
308
  context "read without an encoding specified" do
@@ -6,6 +6,7 @@ describe 'the log function' do
6
6
 
7
7
  def collect_logs(code)
8
8
  Puppet[:code] = code
9
+ Puppet[:environment_timeout] = 10
9
10
  node = Puppet::Node.new('logtest')
10
11
  compiler = Puppet::Parser::Compiler.new(node)
11
12
  node.environment.check_for_reparse
@@ -870,6 +870,46 @@ describe "The lookup function" do
870
870
  end
871
871
  end
872
872
 
873
+ context 'with lookup_options' do
874
+ let(:environment_files) do
875
+ {
876
+ env_name => {
877
+ 'hiera.yaml' => <<-YAML.unindent,
878
+ ---
879
+ version: 5
880
+ YAML
881
+ 'data' => {
882
+ 'common.yaml' => common_yaml
883
+ }
884
+ }
885
+ }
886
+ end
887
+
888
+ context 'that are empty' do
889
+ let(:common_yaml) { <<-YAML.unindent }
890
+ lookup_options:
891
+ a: b
892
+ YAML
893
+
894
+ it 'ignores empty options' do
895
+ expect(lookup('a')).to eq("b")
896
+ end
897
+ end
898
+
899
+ context 'that contains a legal yaml hash with unexpected types' do
900
+ let(:common_yaml) { <<-YAML.unindent }
901
+ lookup_options:
902
+ :invalid_symbol
903
+ YAML
904
+
905
+ it 'fails lookup and reports a type mismatch' do
906
+ expect {
907
+ lookup('a')
908
+ }.to raise_error(Puppet::DataBinding::LookupError, /has wrong type, expects Puppet::LookupValue, got Runtime\[ruby, 'Symbol'\]/)
909
+ end
910
+ end
911
+ end
912
+
873
913
  context 'with lookup_options configured using patterns' do
874
914
  let(:mod_common) {
875
915
  <<-YAML.unindent
@@ -1019,6 +1059,30 @@ describe "The lookup function" do
1019
1059
  })
1020
1060
  end
1021
1061
 
1062
+ context 'and lookup_options is empty' do
1063
+ let(:mod_common) { <<-YAML.unindent }
1064
+ lookup_options:
1065
+ mod::a: b
1066
+ YAML
1067
+
1068
+ it 'ignores empty options' do
1069
+ expect(lookup('mod::a')).to eq("b")
1070
+ end
1071
+ end
1072
+
1073
+ context 'and lookup_options contains a legal hash with unexpected types' do
1074
+ let(:mod_common) { <<-YAML.unindent }
1075
+ lookup_options:
1076
+ :invalid_symbol
1077
+ YAML
1078
+
1079
+ it 'fails lookup and reports a type mismatch' do
1080
+ expect {
1081
+ lookup('mod::a')
1082
+ }.to raise_error(Puppet::DataBinding::LookupError, /has wrong type, expects Puppet::LookupValue, got Runtime\[ruby, 'Symbol'\]/)
1083
+ end
1084
+ end
1085
+
1022
1086
  context 'and patterns in module are not limited to module keys' do
1023
1087
  let(:mod_common) {
1024
1088
  <<-YAML.unindent
@@ -96,6 +96,14 @@ describe Puppet::HTTP::Service::Compiler do
96
96
  subject.post_catalog(certname, environment: 'production', facts: facts, configured_environment: 'agent_specified')
97
97
  end
98
98
 
99
+ it 'includes check_environment' do
100
+ stub_request(:post, uri)
101
+ .with(body: hash_including('check_environment' => 'false'))
102
+ .to_return(**catalog_response)
103
+
104
+ subject.post_catalog(certname, environment: 'production', facts: facts)
105
+ end
106
+
99
107
  it 'includes transaction_uuid' do
100
108
  uuid = "ec3d2844-b236-4287-b0ad-632fbb4d1ff0"
101
109
 
@@ -11,6 +11,9 @@ def set_facts(fact_hash)
11
11
  end
12
12
 
13
13
  describe Puppet::Resource::Catalog::Compiler do
14
+ include Matchers::Resource
15
+ include PuppetSpec::Files
16
+
14
17
  let(:compiler) { described_class.new }
15
18
  let(:node_name) { "foo" }
16
19
  let(:node) { Puppet::Node.new(node_name)}
@@ -236,6 +239,46 @@ describe Puppet::Resource::Catalog::Compiler do
236
239
  expect { compiler.find(@request) }.to raise_error Puppet::Error,
237
240
  "Unable to find a common checksum type between agent '' and master '[:sha256, :sha256lite, :md5, :md5lite, :sha1, :sha1lite, :sha512, :sha384, :sha224, :mtime, :ctime, :none]'."
238
241
  end
242
+
243
+ it "prevents the environment from being evicted during compilation" do
244
+ Puppet[:environment_timeout] = 0
245
+
246
+ envs = Puppet.lookup(:environments)
247
+
248
+ expect(compiler).to receive(:compile) do
249
+ # we should get the same object
250
+ expect(envs.get!(:production)).to equal(envs.get!(:production))
251
+ end
252
+
253
+ compiler.find(@request)
254
+ end
255
+
256
+ context 'when checking agent and server specified environments' do
257
+ before :each do
258
+ FileUtils.mkdir_p(File.join(Puppet[:environmentpath], 'env_server'))
259
+ FileUtils.mkdir_p(File.join(Puppet[:environmentpath], 'env_agent'))
260
+
261
+ node.environment = 'env_server'
262
+ allow(Puppet::Node.indirection).to receive(:find).and_return(node)
263
+
264
+ @request.environment = 'env_agent'
265
+ end
266
+
267
+ it 'ignores mismatched environments by default' do
268
+ catalog = compiler.find(@request)
269
+
270
+ expect(catalog.environment).to eq('env_server')
271
+ expect(catalog).to have_resource('Stage[main]')
272
+ end
273
+
274
+ it 'returns an empty catalog if asked to check the environment and they are mismatched' do
275
+ @request.options[:check_environment] = "true"
276
+ catalog = compiler.find(@request)
277
+
278
+ expect(catalog.environment).to eq('env_server')
279
+ expect(catalog.resources).to be_empty
280
+ end
281
+ end
239
282
  end
240
283
 
241
284
  describe "when handling a request with facts" do
@@ -564,6 +607,50 @@ describe Puppet::Resource::Catalog::Compiler do
564
607
  metadata
565
608
  end
566
609
 
610
+ describe "and the environment is a symlink and versioned_environment_dirs is true" do
611
+
612
+ let(:tmpdir) { Dir.mktmpdir }
613
+
614
+ before(:each) do
615
+ Puppet[:versioned_environment_dirs] = true
616
+ prod_path = File.join(Puppet[:environmentpath], 'production')
617
+ FileUtils.rm_rf(prod_path)
618
+ FileUtils.symlink(tmpdir, prod_path)
619
+ end
620
+
621
+ it "inlines metadata for a file" do
622
+ catalog = compile_to_catalog(<<-MANIFEST, node)
623
+ file { '#{path}':
624
+ ensure => file,
625
+ source => '#{source}'
626
+ }
627
+ MANIFEST
628
+
629
+ module_relative_path = 'modules/mymodule/files/config_file.txt'
630
+ metadata = stubs_file_metadata(checksum_type,
631
+ checksum_value,
632
+ module_relative_path,
633
+ File.join(tmpdir, module_relative_path) )
634
+ expect(metadata).to receive(:source=).with(source)
635
+ expect(metadata).to receive(:content_uri=).with("puppet:///#{module_relative_path}")
636
+
637
+ options = {
638
+ :environment => catalog.environment_instance,
639
+ :links => :manage,
640
+ :checksum_type => checksum_type.to_sym,
641
+ :source_permissions => :ignore
642
+ }
643
+ expect(Puppet::FileServing::Metadata.indirection).to receive(:find).with(source, options).and_return(metadata)
644
+
645
+ compiler.send(:inline_metadata, catalog, checksum_type)
646
+
647
+
648
+ expect(catalog.metadata[path]).to eq(metadata)
649
+ expect(catalog.recursive_metadata).to be_empty
650
+
651
+ end
652
+ end
653
+
567
654
  it "inlines metadata for a file" do
568
655
  catalog = compile_to_catalog(<<-MANIFEST, node)
569
656
  file { '#{path}':
@@ -33,6 +33,14 @@ describe Puppet::Resource::Catalog::Rest do
33
33
  described_class.indirection.find(certname, environment: Puppet::Node::Environment.remote('outerspace'))
34
34
  end
35
35
 
36
+ it "passes 'check_environment'" do
37
+ stub_request(:post, uri)
38
+ .with(body: hash_including('check_environment' => 'true'))
39
+ .to_return(**catalog_response(catalog))
40
+
41
+ described_class.indirection.find(certname, check_environment: true)
42
+ end
43
+
36
44
  it 'constructs a catalog environment_instance' do
37
45
  env = Puppet::Node::Environment.remote('outerspace')
38
46
  catalog = Puppet::Resource::Catalog.new(certname, env)
@@ -499,7 +499,7 @@ describe Puppet::Indirector::Indirection do
499
499
  end
500
500
 
501
501
  it "should return the result of saving to the terminus" do
502
- request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false)
502
+ request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false, :ignore_terminus? => false)
503
503
 
504
504
  expect(@indirection).to receive(:request).and_return(request)
505
505
 
@@ -509,7 +509,7 @@ describe Puppet::Indirector::Indirection do
509
509
  end
510
510
 
511
511
  it "should use a request to save the object to the cache" do
512
- request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false)
512
+ request = double('request', :instance => @instance, :node => nil, :ignore_cache_save? => false, :ignore_terminus? => false)
513
513
 
514
514
  expect(@indirection).to receive(:request).and_return(request)
515
515
 
@@ -519,7 +519,7 @@ describe Puppet::Indirector::Indirection do
519
519
  end
520
520
 
521
521
  it "should not save to the cache if the normal save fails" do
522
- request = double('request', :instance => @instance, :node => nil)
522
+ request = double('request', :instance => @instance, :node => nil, :ignore_terminus? => false)
523
523
 
524
524
  expect(@indirection).to receive(:request).and_return(request)
525
525
 
@@ -534,6 +534,13 @@ describe Puppet::Indirector::Indirection do
534
534
 
535
535
  @indirection.save(@instance, '/my/key', :ignore_cache_save => true)
536
536
  end
537
+
538
+ it "should only save to the cache if the request specifies not to use the terminus" do
539
+ expect(@terminus).not_to receive(:save)
540
+ expect(@cache).to receive(:save)
541
+
542
+ @indirection.save(@instance, "/my/key", :ignore_terminus => true)
543
+ end
537
544
  end
538
545
  end
539
546
 
@@ -537,15 +537,6 @@ describe Puppet::Interface::Action do
537
537
  end
538
538
  end
539
539
 
540
- context "#when_rendering" do
541
- it "should fail if no type is given when_rendering"
542
- it "should accept a when_rendering block"
543
- it "should accept multiple when_rendering blocks"
544
- it "should fail if when_rendering gets a non-symbol identifier"
545
- it "should fail if a second block is given for the same type"
546
- it "should return the block if asked"
547
- end
548
-
549
540
  context "#validate_and_clean" do
550
541
  subject do
551
542
  Puppet::Interface.new(:validate_args, '1.0.0') do
@@ -478,7 +478,7 @@ describe Puppet::Module do
478
478
  end
479
479
  end
480
480
 
481
- [:plugins, :pluginfacts, :templates, :files, :manifests].each do |filetype|
481
+ [:plugins, :pluginfacts, :templates, :files, :manifests, :scripts].each do |filetype|
482
482
  case filetype
483
483
  when :plugins
484
484
  dirname = "lib"
@@ -567,6 +567,20 @@ describe Puppet::Module do
567
567
  expect(mod.task_file(task_exe)).to eq("#{mod.path}/tasks/#{task_exe}")
568
568
  end
569
569
 
570
+ it "should list files from the scripts directory if required by the task" do
571
+ mod = 'loads_scripts'
572
+ task_dep = 'myscript.sh'
573
+ script_ref = "#{mod}/scripts/#{task_dep}"
574
+ task_json = JSON.generate({'files' => [script_ref]})
575
+ task = [['task', { name: 'task.json', content: task_json }]]
576
+ mod = PuppetSpec::Modules.create(mod, @modpath, {:environment => env,
577
+ :scripts => [task_dep],
578
+ :tasks => task})
579
+
580
+ expect(mod.tasks.first.files).to include({'name' => script_ref,
581
+ 'path' => /#{script_ref}/})
582
+ end
583
+
570
584
  it "should return nil when asked for an individual task file if it does not exist" do
571
585
  mod = PuppetSpec::Modules.create('task_file_neg', @modpath, {:environment => env,
572
586
  :tasks => []})
@@ -285,18 +285,45 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
285
285
  expect(subject).to include :result => :failure
286
286
  end
287
287
 
288
- it 'prints a detailed error containing the modules that would not be satisfied' do
289
- graph = double(SemanticPuppet::Dependency::Graph, :modules => ['pmtacceptance-mysql'])
290
- exception = SemanticPuppet::Dependency::UnsatisfiableGraph.new(graph)
291
- allow(exception).to receive(:respond_to?).and_return(true)
292
- allow(exception).to receive(:unsatisfied).and_return('pmtacceptance-mysql')
293
- allow(SemanticPuppet::Dependency).to receive(:resolve).and_raise(exception)
294
-
295
- expect(subject[:error]).to include(:multiline)
296
- expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (> 1.0.0)")
297
- expect(subject[:error][:multiline]).to include("The requested version cannot satisfy one or more of the following installed modules:")
298
- expect(subject[:error][:multiline]).to include("pmtacceptance-keystone, expects 'pmtacceptance-mysql': >=0.6.1 <1.0.0")
299
- expect(subject[:error][:multiline]).to include("Use `puppet module install 'pmtacceptance-mysql' --ignore-dependencies` to install only this module")
288
+ context 'with unsatisfiable dependencies' do
289
+ let(:graph) { double(SemanticPuppet::Dependency::Graph, :modules => ['pmtacceptance-mysql']) }
290
+ let(:exception) { SemanticPuppet::Dependency::UnsatisfiableGraph.new(graph, constraint) }
291
+
292
+ before do
293
+ allow(SemanticPuppet::Dependency).to receive(:resolve).and_raise(exception)
294
+ end
295
+
296
+ context 'with known constraint' do
297
+ let(:constraint) { 'pmtacceptance-mysql' }
298
+
299
+ it 'prints a detailed error containing the modules that would not be satisfied' do
300
+ expect(subject[:error]).to include(:multiline)
301
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (> 1.0.0)")
302
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy one or more of the following installed modules:")
303
+ expect(subject[:error][:multiline]).to include("pmtacceptance-keystone, expects 'pmtacceptance-mysql': >=0.6.1 <1.0.0")
304
+ expect(subject[:error][:multiline]).to include("Use `puppet module install 'pmtacceptance-mysql' --ignore-dependencies` to install only this module")
305
+ end
306
+ end
307
+
308
+ context 'with missing constraint' do
309
+ let(:constraint) { nil }
310
+
311
+ it 'prints the generic error message' do
312
+ expect(subject[:error]).to include(:multiline)
313
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (> 1.0.0)")
314
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy all dependencies")
315
+ end
316
+ end
317
+
318
+ context 'with unknown constraint' do
319
+ let(:constraint) { 'another' }
320
+
321
+ it 'prints the generic error message' do
322
+ expect(subject[:error]).to include(:multiline)
323
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (> 1.0.0)")
324
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy all dependencies")
325
+ end
326
+ end
300
327
  end
301
328
 
302
329
  context 'with --ignore-dependencies' do
@@ -101,21 +101,6 @@ describe Puppet::Network::AuthStore::Declaration do
101
101
  }
102
102
  }
103
103
 
104
- describe "when the pattern is a numeric IP with a back reference" do
105
- pending("implementation of backreferences for IP") do
106
- before :each do
107
- @ip = '100.101.$1'
108
- @declaration = Puppet::Network::AuthStore::Declaration.new(:allow_ip,@ip).interpolate('12.34'.match(/(.*)/))
109
- end
110
- it "should match an IP with the appropriate interpolation" do
111
- @declaration.should be_match('www.testsite.org',@ip.sub(/\$1/,'12.34'))
112
- end
113
- it "should not match other IPs" do
114
- @declaration.should_not be_match('www.testsite.org',@ip.sub(/\$1/,'66.34'))
115
- end
116
- end
117
- end
118
-
119
104
  [
120
105
  "02001:0000:1234:0000:0000:C1C0:ABCD:0876",
121
106
  "2001:0000:1234:0000:00001:C1C0:ABCD:0876",
@@ -368,6 +368,12 @@ describe "Puppet Network Format" do
368
368
  expect(json.render_multiple(instances)).to eq([{"string" => "foo"}].to_json)
369
369
  end
370
370
 
371
+ it "should render multiple instances as a JSON array of hashes when multi_json is not present" do
372
+ hide_const("MultiJson") if defined?(MultiJson)
373
+ instances = [FormatsTest.new("foo")]
374
+ expect(json.render_multiple(instances)).to eq([{"string" => "foo"}].to_json)
375
+ end
376
+
371
377
  it "should intern an instance from a JSON hash" do
372
378
  text = Puppet::Util::Json.dump({"string" => "parsed_json"})
373
379
  instance = json.intern(FormatsTest, text)
@@ -95,18 +95,7 @@ describe "egrammar parsing containers" do
95
95
  expect(dump(parse("class foo::default {}"))).to eq("(class foo::default ())")
96
96
  end
97
97
 
98
- it "class class inherits default {} # inherits default", :broken => true do
99
- expect {
100
- parse("class class inherits default {}")
101
- }.to raise_error(/not a valid classname/)
102
- end
103
-
104
98
  it "class class inherits default {} # inherits default" do
105
- # TODO: See previous test marked as :broken=>true, it is actually this test (result) that is wacky,
106
- # this because a class is named at parse time (since class evaluation is lazy, the model must have the
107
- # full class name for nested classes - only, it gets this wrong when a class is named "class" - or at least
108
- # I think it is wrong.)
109
- #
110
99
  expect { parse("class class inherits default {}") }.to raise_error(/'class' keyword not allowed at this location/)
111
100
  end
112
101
 
@@ -559,6 +559,29 @@ module Serialization
559
559
  expect(warnings).to eql(["['key'] contains the special value default. It will be converted to the String 'default'"])
560
560
  end
561
561
  end
562
+ context 'and force_symbol set to true' do
563
+ let(:to_converter) { ToDataConverter.new(:rich_data => false, :force_symbol => true) }
564
+
565
+ it 'A Hash with Symbol values is converted to hash with Symbol values' do
566
+ val = { 'one' => :one, 'two' => :two }
567
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
568
+
569
+ # write and read methods does not work here as we cannot force Symbols in Json.
570
+ # and a hash with symbol values cannot be an instance of Types::TypeFactory.data.
571
+ # Using YAML for this instead
572
+ io.reopen
573
+ value = to_converter.convert(val)
574
+ io << [value].to_yaml
575
+ io.rewind
576
+
577
+ val2 = from_converter.convert(YAML::load(io.read)[0])
578
+
579
+ expect(val2).to be_a(Hash)
580
+ expect(val2).to eql({ 'one' => :one, 'two' => :two })
581
+ end
582
+ expect(warnings).to be_empty
583
+ end
584
+ end
562
585
  end
563
586
 
564
587
  context 'with rich_data is set to true' do
@@ -632,6 +655,41 @@ module Serialization
632
655
  end.to raise_error(/Cannot create a Pcore::TimestampType from a (Fixnum|Integer)/)
633
656
  end
634
657
  end
658
+
659
+ context 'when data is unknown' do
660
+ let(:to_converter) { ToDataConverter.new(:message_prefix => 'Test Hash') }
661
+ let(:logs) { [] }
662
+ let(:warnings) { logs.select { |log| log.level == :warning }.map { |log| log.message } }
663
+ let(:val) { Class.new }
664
+
665
+ context 'and :silence_warnings undefined or set to false' do
666
+ it 'convert the unknown data to string with warnings' do
667
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
668
+ write(val)
669
+ val2 = read
670
+ expect(val2).to be_a(String)
671
+ expect(val2).to match(/Class/)
672
+ end
673
+ expect(warnings).to eql([
674
+ "Test Hash contains a #{val.class} value. It will be converted to the String '#{val.to_s}'"])
675
+ end
676
+ end
677
+
678
+ context 'and :silence_warnings undefined or set to true' do
679
+ let(:to_converter) { ToDataConverter.new(:message_prefix => 'Test Hash', :silence_warnings => true) }
680
+
681
+ it 'convert the unknown data to string without warnings if silence_warnings set to true' do
682
+ val = Class.new
683
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
684
+ write(val)
685
+ val2 = read
686
+ expect(val2).to be_a(String)
687
+ expect(val2).to match(/Class/)
688
+ end
689
+ expect(warnings).to be_empty
690
+ end
691
+ end
692
+ end
635
693
  end
636
694
  end
637
695
  end
@@ -154,4 +154,9 @@ describe 'ToStringifiedConverter' do
154
154
  unassigned = [243, 176, 128, 128].pack("C*").force_encoding(Encoding::UTF_8)
155
155
  expect(transform(unassigned)).to eq("󰀀")
156
156
  end
157
+
158
+ it 'converts ProcessOutput objects to string' do
159
+ object = Puppet::Util::Execution::ProcessOutput.new('object', 0)
160
+ expect(transform(object)).to be_instance_of(String)
161
+ end
157
162
  end
@@ -1980,6 +1980,12 @@ describe 'The type calculator' do
1980
1980
  expect(calculator.instance?(tuple, [1, 'a', 1])).to eq(false)
1981
1981
  end
1982
1982
 
1983
+ it 'should not consider ProcessOutput objects as instanceof PScalarDataType' do
1984
+ object = Puppet::Util::Execution::ProcessOutput.new('object', 0)
1985
+
1986
+ expect(calculator.instance?(PScalarDataType::DEFAULT, object)).to eq(false)
1987
+ end
1988
+
1983
1989
  context 'and t is Struct' do
1984
1990
  it 'should consider hash[cont] as instance of Struct[cont-t]' do
1985
1991
  struct = struct_t({'a'=>Integer, 'b'=>String, 'c'=>Float})
@@ -442,7 +442,7 @@ context Puppet::Type.type(:package).provider(:gem) do
442
442
  end
443
443
 
444
444
  context 'when is defaultfor' do
445
- let(:os) { Facter.value(:operatingsystem) }
445
+ let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
446
446
  subject do
447
447
  described_class.defaultfor(operatingsystem: os)
448
448
  described_class.specificity
@@ -24,7 +24,7 @@ describe Puppet::Type.type(:package).provider(:pip2) do
24
24
  end
25
25
 
26
26
  context 'when is defaultfor' do
27
- let(:os) { Facter.value(:operatingsystem) }
27
+ let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
28
28
  subject do
29
29
  described_class.defaultfor(operatingsystem: os)
30
30
  described_class.specificity
@@ -24,7 +24,7 @@ describe Puppet::Type.type(:package).provider(:pip3) do
24
24
  end
25
25
 
26
26
  context 'when is defaultfor' do
27
- let(:os) { Facter.value(:operatingsystem) }
27
+ let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
28
28
  subject do
29
29
  described_class.defaultfor(operatingsystem: os)
30
30
  described_class.specificity
@@ -491,7 +491,7 @@ describe Puppet::Type.type(:package).provider(:pip) do
491
491
  end
492
492
 
493
493
  context 'when is defaultfor' do
494
- let(:os) { Facter.value(:operatingsystem) }
494
+ let(:os) { Puppet.runtime[:facter].value(:operatingsystem) }
495
495
  subject do
496
496
  described_class.defaultfor(operatingsystem: os)
497
497
  described_class.specificity