puppet 2.7.19 → 2.7.20.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (324) hide show
  1. data/CONTRIBUTING.md +61 -238
  2. data/Gemfile +32 -0
  3. data/Gemfile.lock +44 -0
  4. data/LICENSE +1 -1
  5. data/README_DEVELOPER.md +300 -5
  6. data/Rakefile +41 -37
  7. data/ext/build_defaults.yaml +20 -0
  8. data/ext/debian/README.Debian +8 -0
  9. data/ext/debian/README.source +2 -0
  10. data/ext/debian/TODO.Debian +1 -0
  11. data/ext/debian/changelog.erb +1104 -0
  12. data/ext/debian/compat +1 -0
  13. data/ext/debian/control +142 -0
  14. data/ext/debian/copyright +361 -0
  15. data/ext/debian/docs +1 -0
  16. data/ext/debian/fileserver.conf +17 -0
  17. data/ext/debian/puppet-common.dirs +8 -0
  18. data/ext/debian/puppet-common.install +3 -0
  19. data/ext/debian/puppet-common.lintian-overrides +7 -0
  20. data/ext/debian/puppet-common.manpages +2 -0
  21. data/ext/debian/puppet-common.postinst +35 -0
  22. data/ext/debian/puppet-common.postrm +32 -0
  23. data/ext/debian/puppet-el.dirs +1 -0
  24. data/ext/debian/puppet-el.emacsen-install +25 -0
  25. data/ext/debian/puppet-el.emacsen-remove +11 -0
  26. data/ext/debian/puppet-el.emacsen-startup +9 -0
  27. data/ext/debian/puppet-el.install +1 -0
  28. data/ext/debian/puppet-testsuite.install +3 -0
  29. data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
  30. data/ext/debian/puppet.NEWS +86 -0
  31. data/ext/debian/puppet.conf +14 -0
  32. data/ext/debian/puppet.default +7 -0
  33. data/ext/debian/puppet.dirs +1 -0
  34. data/ext/debian/puppet.init +118 -0
  35. data/ext/debian/puppet.install +4 -0
  36. data/ext/debian/puppet.lintian-overrides +3 -0
  37. data/ext/debian/puppet.logrotate +11 -0
  38. data/ext/debian/puppet.manpages +36 -0
  39. data/ext/debian/puppet.postinst +20 -0
  40. data/ext/debian/puppet.postrm +20 -0
  41. data/ext/debian/puppet.preinst +20 -0
  42. data/ext/debian/puppetmaster-common.install +5 -0
  43. data/ext/debian/puppetmaster-common.manpages +5 -0
  44. data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
  45. data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
  46. data/ext/debian/puppetmaster-passenger.dirs +4 -0
  47. data/ext/debian/puppetmaster-passenger.postinst +66 -0
  48. data/ext/debian/puppetmaster-passenger.postrm +33 -0
  49. data/ext/debian/puppetmaster.NEWS +13 -0
  50. data/ext/debian/puppetmaster.README.debian +16 -0
  51. data/ext/debian/puppetmaster.default +38 -0
  52. data/ext/debian/puppetmaster.dirs +1 -0
  53. data/ext/debian/puppetmaster.init +158 -0
  54. data/ext/debian/puppetmaster.install +1 -0
  55. data/ext/debian/puppetmaster.lintian-overrides +3 -0
  56. data/ext/debian/puppetmaster.manpages +1 -0
  57. data/ext/debian/puppetmaster.postinst +20 -0
  58. data/ext/debian/puppetmaster.postrm +5 -0
  59. data/ext/debian/puppetmaster.preinst +22 -0
  60. data/ext/debian/rules +127 -0
  61. data/ext/debian/source/format +1 -0
  62. data/ext/debian/source/options +1 -0
  63. data/ext/debian/vim-puppet.README.Debian +13 -0
  64. data/ext/debian/vim-puppet.dirs +3 -0
  65. data/ext/debian/vim-puppet.yaml +5 -0
  66. data/ext/debian/watch +2 -0
  67. data/ext/emacs/puppet-mode.el +1 -0
  68. data/{conf → ext}/osx/PackageInfo.plist +0 -0
  69. data/{conf → ext}/osx/createpackage.sh +0 -0
  70. data/ext/osx/file_mapping.yaml +38 -0
  71. data/ext/osx/preflight.erb +37 -0
  72. data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
  73. data/ext/packaging/README-Solaris.md +117 -0
  74. data/ext/packaging/README.md +255 -0
  75. data/ext/packaging/spec/spec_helper.rb +12 -0
  76. data/ext/packaging/spec/tasks/00_utils_spec.rb +66 -0
  77. data/ext/packaging/tasks/00_utils.rake +382 -0
  78. data/ext/packaging/tasks/10_setupvars.rake +71 -0
  79. data/ext/packaging/tasks/20_setupextravars.rake +25 -0
  80. data/ext/packaging/tasks/apple.rake +201 -0
  81. data/ext/packaging/tasks/clean.rake +5 -0
  82. data/ext/packaging/tasks/deb.rake +108 -0
  83. data/ext/packaging/tasks/doc.rake +20 -0
  84. data/ext/packaging/tasks/fetch.rake +18 -0
  85. data/ext/packaging/tasks/gem.rake +68 -0
  86. data/ext/packaging/tasks/ips.rake +80 -0
  87. data/ext/packaging/tasks/mock.rake +126 -0
  88. data/ext/packaging/tasks/pe_deb.rake +9 -0
  89. data/ext/packaging/tasks/pe_remote.rake +45 -0
  90. data/ext/packaging/tasks/pe_rpm.rake +21 -0
  91. data/ext/packaging/tasks/pe_ship.rake +30 -0
  92. data/ext/packaging/tasks/pe_sign.rake +27 -0
  93. data/ext/packaging/tasks/pe_sles.rake +96 -0
  94. data/ext/packaging/tasks/release.rake +73 -0
  95. data/ext/packaging/tasks/remote_build.rake +78 -0
  96. data/ext/packaging/tasks/rpm.rake +52 -0
  97. data/ext/packaging/tasks/ship.rake +78 -0
  98. data/ext/packaging/tasks/sign.rake +82 -0
  99. data/ext/packaging/tasks/tag.rake +8 -0
  100. data/ext/packaging/tasks/tar.rake +68 -0
  101. data/ext/packaging/tasks/template.rake +13 -0
  102. data/ext/packaging/tasks/update.rake +16 -0
  103. data/ext/packaging/tasks/version.rake +21 -0
  104. data/ext/project_data.yaml +24 -0
  105. data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +18 -10
  106. data/install.rb +8 -8
  107. data/lib/puppet.rb +2 -6
  108. data/lib/puppet/agent/locker.rb +2 -0
  109. data/lib/puppet/application.rb +1 -1
  110. data/lib/puppet/application/agent.rb +1 -1
  111. data/lib/puppet/application/apply.rb +1 -1
  112. data/lib/puppet/application/cert.rb +5 -6
  113. data/lib/puppet/application/describe.rb +1 -1
  114. data/lib/puppet/application/device.rb +1 -1
  115. data/lib/puppet/application/doc.rb +1 -1
  116. data/lib/puppet/application/filebucket.rb +1 -1
  117. data/lib/puppet/application/inspect.rb +1 -1
  118. data/lib/puppet/application/kick.rb +1 -1
  119. data/lib/puppet/application/master.rb +1 -1
  120. data/lib/puppet/application/resource.rb +1 -1
  121. data/lib/puppet/defaults.rb +21 -3
  122. data/lib/puppet/external/dot.rb +1 -1
  123. data/lib/puppet/face/help/global.erb +1 -1
  124. data/lib/puppet/face/module/install.rb +1 -1
  125. data/lib/puppet/face/module/list.rb +1 -1
  126. data/lib/puppet/face/module/uninstall.rb +1 -1
  127. data/lib/puppet/face/node/clean.rb +23 -18
  128. data/lib/puppet/face/parser.rb +11 -2
  129. data/lib/puppet/file_collection.rb +16 -27
  130. data/lib/puppet/file_collection/lookup.rb +6 -16
  131. data/lib/puppet/file_serving/base.rb +4 -4
  132. data/lib/puppet/indirector/catalog/static_compiler.rb +3 -4
  133. data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
  134. data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
  135. data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
  136. data/lib/puppet/indirector/face.rb +2 -2
  137. data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
  138. data/lib/puppet/indirector/node/exec.rb +13 -1
  139. data/lib/puppet/indirector/request.rb +4 -0
  140. data/lib/puppet/metatype/manager.rb +17 -10
  141. data/lib/puppet/network/authstore.rb +1 -1
  142. data/lib/puppet/network/rights.rb +1 -2
  143. data/lib/puppet/node/environment.rb +1 -0
  144. data/lib/puppet/parameter/value.rb +9 -3
  145. data/lib/puppet/parser/ast.rb +1 -4
  146. data/lib/puppet/parser/files.rb +1 -1
  147. data/lib/puppet/parser/functions.rb +68 -22
  148. data/lib/puppet/parser/functions/create_resources.rb +2 -3
  149. data/lib/puppet/parser/functions/shellquote.rb +21 -25
  150. data/lib/puppet/parser/lexer.rb +40 -6
  151. data/lib/puppet/parser/relationship.rb +3 -1
  152. data/lib/puppet/parser/resource.rb +2 -3
  153. data/lib/puppet/parser/resource/param.rb +3 -5
  154. data/lib/puppet/parser/scope.rb +7 -4
  155. data/lib/puppet/property.rb +5 -3
  156. data/lib/puppet/provider.rb +5 -5
  157. data/lib/puppet/provider/aixobject.rb +1 -1
  158. data/lib/puppet/provider/augeas/augeas.rb +1 -1
  159. data/lib/puppet/provider/exec/windows.rb +1 -1
  160. data/lib/puppet/provider/file/windows.rb +10 -29
  161. data/lib/puppet/provider/group/groupadd.rb +2 -3
  162. data/lib/puppet/provider/group/ldap.rb +1 -1
  163. data/lib/puppet/provider/group/windows_adsi.rb +1 -1
  164. data/lib/puppet/provider/ldap.rb +5 -1
  165. data/lib/puppet/provider/nameservice.rb +3 -3
  166. data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
  167. data/lib/puppet/provider/package/gem.rb +6 -2
  168. data/lib/puppet/provider/package/portage.rb +4 -2
  169. data/lib/puppet/provider/parsedfile.rb +1 -1
  170. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  171. data/lib/puppet/provider/service/base.rb +2 -41
  172. data/lib/puppet/provider/service/daemontools.rb +1 -1
  173. data/lib/puppet/provider/service/launchd.rb +1 -1
  174. data/lib/puppet/provider/service/redhat.rb +6 -5
  175. data/lib/puppet/provider/service/runit.rb +1 -1
  176. data/lib/puppet/provider/service/service.rb +43 -0
  177. data/lib/puppet/provider/service/windows.rb +1 -8
  178. data/lib/puppet/provider/user/user_role_add.rb +2 -1
  179. data/lib/puppet/provider/user/useradd.rb +8 -3
  180. data/lib/puppet/provider/user/windows_adsi.rb +12 -1
  181. data/lib/puppet/provider/zone/solaris.rb +1 -1
  182. data/lib/puppet/rails/inventory_node.rb +26 -13
  183. data/lib/puppet/reports.rb +1 -1
  184. data/lib/puppet/resource.rb +20 -5
  185. data/lib/puppet/resource/status.rb +1 -1
  186. data/lib/puppet/ssl/certificate_authority.rb +2 -0
  187. data/lib/puppet/ssl/host.rb +31 -6
  188. data/lib/puppet/test/test_helper.rb +3 -1
  189. data/lib/puppet/transaction/event.rb +1 -1
  190. data/lib/puppet/transaction/report.rb +2 -2
  191. data/lib/puppet/type.rb +30 -25
  192. data/lib/puppet/type/augeas.rb +1 -1
  193. data/lib/puppet/type/cron.rb +2 -2
  194. data/lib/puppet/type/exec.rb +6 -6
  195. data/lib/puppet/type/file.rb +5 -15
  196. data/lib/puppet/type/file/content.rb +1 -1
  197. data/lib/puppet/type/file/ensure.rb +1 -1
  198. data/lib/puppet/type/file/mode.rb +1 -1
  199. data/lib/puppet/type/file/selcontext.rb +6 -2
  200. data/lib/puppet/type/file/source.rb +1 -1
  201. data/lib/puppet/type/mount.rb +1 -1
  202. data/lib/puppet/type/package.rb +1 -1
  203. data/lib/puppet/type/schedule.rb +1 -1
  204. data/lib/puppet/type/scheduled_task.rb +1 -1
  205. data/lib/puppet/type/tidy.rb +1 -1
  206. data/lib/puppet/type/whit.rb +16 -9
  207. data/lib/puppet/util.rb +27 -11
  208. data/lib/puppet/util/adsi.rb +25 -23
  209. data/lib/puppet/util/autoload.rb +1 -1
  210. data/lib/puppet/util/classgen.rb +1 -1
  211. data/lib/puppet/util/feature.rb +3 -1
  212. data/lib/puppet/util/fileparsing.rb +9 -9
  213. data/lib/puppet/util/filetype.rb +55 -40
  214. data/lib/puppet/util/instance_loader.rb +5 -5
  215. data/lib/puppet/util/instrumentation.rb +3 -5
  216. data/lib/puppet/util/log_paths.rb +1 -3
  217. data/lib/puppet/util/monkey_patches.rb +34 -8
  218. data/lib/puppet/util/platform.rb +7 -0
  219. data/lib/puppet/util/posix.rb +3 -3
  220. data/lib/puppet/util/provider_features.rb +2 -3
  221. data/lib/puppet/util/rdoc.rb +4 -3
  222. data/lib/puppet/util/reference.rb +1 -1
  223. data/lib/puppet/util/selinux.rb +31 -36
  224. data/lib/puppet/util/tagging.rb +28 -6
  225. data/lib/puppet/util/windows.rb +1 -0
  226. data/lib/puppet/util/windows/error.rb +1 -1
  227. data/lib/puppet/util/windows/process.rb +3 -3
  228. data/lib/puppet/util/windows/security.rb +9 -46
  229. data/lib/puppet/util/windows/sid.rb +96 -0
  230. data/lib/puppet/util/windows/user.rb +65 -2
  231. data/lib/puppet/util/zaml.rb +109 -59
  232. data/lib/puppet/version.rb +18 -0
  233. data/spec/fixtures/unit/util/filetype/aixtab_output +44 -0
  234. data/spec/fixtures/unit/util/filetype/suntab_output +9 -0
  235. data/spec/integration/defaults_spec.rb +26 -7
  236. data/spec/integration/parser/functions_spec.rb +0 -4
  237. data/spec/integration/util/file_locking_spec.rb +1 -1
  238. data/spec/integration/util/windows/security_spec.rb +3 -23
  239. data/spec/lib/puppet_spec/files.rb +3 -3
  240. data/spec/shared_contexts/platform.rb +8 -0
  241. data/spec/spec_helper.rb +6 -1
  242. data/spec/unit/application/queue_spec.rb +2 -1
  243. data/spec/unit/configurer_spec.rb +1 -1
  244. data/spec/unit/face/{instrumentation_data.rb → instrumentation_data_spec.rb} +0 -0
  245. data/spec/unit/face/{instrumentation_listener.rb → instrumentation_listener_spec.rb} +0 -0
  246. data/spec/unit/face/{instrumentation_probe.rb → instrumentation_probe_spec.rb} +0 -0
  247. data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
  248. data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
  249. data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
  250. data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
  251. data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
  252. data/spec/unit/indirector/request_spec.rb +22 -0
  253. data/spec/unit/network/http/webrick_spec.rb +0 -7
  254. data/spec/unit/node/environment_spec.rb +8 -8
  255. data/spec/unit/parser/ast_spec.rb +0 -5
  256. data/spec/unit/parser/collector_spec.rb +1 -0
  257. data/spec/unit/parser/files_spec.rb +2 -2
  258. data/spec/unit/parser/functions/create_resources_spec.rb +3 -4
  259. data/spec/unit/parser/functions/require_spec.rb +0 -6
  260. data/spec/unit/parser/functions/shellquote_spec.rb +0 -5
  261. data/spec/unit/parser/functions/template_spec.rb +6 -1
  262. data/spec/unit/parser/functions_spec.rb +73 -23
  263. data/spec/unit/parser/lexer_spec.rb +133 -8
  264. data/spec/unit/parser/relationship_spec.rb +24 -0
  265. data/spec/unit/parser/resource_spec.rb +0 -4
  266. data/spec/unit/parser/scope_spec.rb +2 -2
  267. data/spec/unit/property_spec.rb +21 -1
  268. data/spec/unit/provider/exec/posix_spec.rb +7 -6
  269. data/spec/unit/provider/file/windows_spec.rb +29 -29
  270. data/spec/unit/provider/group/groupadd_spec.rb +36 -30
  271. data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
  272. data/spec/unit/provider/package/gem_spec.rb +12 -0
  273. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
  274. data/spec/unit/provider/service/redhat_spec.rb +11 -1
  275. data/spec/unit/provider/service/windows_spec.rb +19 -0
  276. data/spec/unit/provider/user/ldap_spec.rb +22 -8
  277. data/spec/unit/provider/user/user_role_add_spec.rb +12 -0
  278. data/spec/unit/provider/user/useradd_spec.rb +146 -118
  279. data/spec/unit/provider/user/windows_adsi_spec.rb +24 -2
  280. data/spec/unit/puppet_spec.rb +10 -0
  281. data/spec/unit/resource/status_spec.rb +1 -1
  282. data/spec/unit/resource_spec.rb +73 -0
  283. data/spec/unit/ssl/certificate_authority_spec.rb +25 -1
  284. data/spec/unit/ssl/host_spec.rb +73 -27
  285. data/spec/unit/ssl/key_spec.rb +0 -4
  286. data/spec/unit/transaction/event_spec.rb +1 -1
  287. data/spec/unit/type/exec_spec.rb +1 -1
  288. data/spec/unit/type/file/content_spec.rb +6 -4
  289. data/spec/unit/type/file/{ctime.rb → ctime_spec.rb} +0 -0
  290. data/spec/unit/type/file/{mtime.rb → mtime_spec.rb} +0 -0
  291. data/spec/unit/type/file/{type.rb → type_spec.rb} +0 -0
  292. data/spec/unit/type/file_spec.rb +2 -12
  293. data/spec/unit/type/host_spec.rb +14 -5
  294. data/spec/unit/type/mount_spec.rb +8 -0
  295. data/spec/unit/type/scheduled_task_spec.rb +2 -2
  296. data/spec/unit/util/adsi_spec.rb +23 -8
  297. data/spec/unit/util/command_line_spec.rb +11 -2
  298. data/spec/unit/util/feature_spec.rb +12 -1
  299. data/spec/unit/util/filetype_spec.rb +161 -55
  300. data/spec/unit/util/log_spec.rb +1 -1
  301. data/spec/unit/util/monkey_patches_spec.rb +7 -0
  302. data/spec/unit/util/rdoc_spec.rb +8 -2
  303. data/spec/unit/util/selinux_spec.rb +24 -32
  304. data/spec/unit/util/windows/sid_spec.rb +100 -0
  305. data/spec/unit/util/zaml_spec.rb +165 -25
  306. data/spec/unit/util_spec.rb +3 -9
  307. data/spec/watchr.rb +2 -6
  308. data/tasks/rake/gem.rake +4 -2
  309. data/tasks/rake/sign.rake +1 -1
  310. data/test/language/parser.rb +1 -0
  311. data/test/language/scope.rb +0 -5
  312. data/test/language/snippets.rb +1 -2
  313. data/test/lib/puppettest.rb +16 -27
  314. data/test/lib/puppettest/parsertesting.rb +0 -1
  315. data/test/network/authstore.rb +2 -4
  316. data/test/puppet/defaults.rb +0 -4
  317. data/test/util/fileparsing.rb +2 -6
  318. metadata +1706 -1617
  319. data/conf/osx/preflight +0 -24
  320. data/spec/spec.opts +0 -4
  321. data/spec/unit/file_collection/lookup_spec.rb +0 -45
  322. data/spec/unit/file_collection_spec.rb +0 -52
  323. data/tasks/rake/apple.rake +0 -176
  324. data/test/puppet/errortest.rb +0 -19
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+ require 'puppet/indirector/certificate/disabled_ca'
4
+
5
+ describe Puppet::SSL::Certificate::DisabledCa do
6
+ def request(type, remote)
7
+ r = Puppet::Indirector::Request.new(:certificate, type, "foo.com", nil)
8
+ if remote
9
+ r.ip = '10.0.0.1'
10
+ r.node = 'agent.example.com'
11
+ end
12
+ r
13
+ end
14
+
15
+ context "when not a CA" do
16
+ before :each do
17
+ Puppet[:ca] = false
18
+ Puppet::SSL::Host.ca_location = :none
19
+ end
20
+
21
+ [:find, :head, :search, :save, :destroy].each do |name|
22
+ it "should fail remote #{name} requests" do
23
+ expect { subject.send(name, request(name, true)) }.
24
+ to raise_error Puppet::Error, /is not a CA/
25
+ end
26
+
27
+ it "should forward local #{name} requests" do
28
+ Puppet::SSL::Certificate.indirection.terminus(:file).expects(name)
29
+ subject.send(name, request(name, false))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+ require 'puppet/indirector/certificate_request/disabled_ca'
4
+
5
+ describe Puppet::SSL::CertificateRequest::DisabledCa do
6
+ def request(type, remote)
7
+ r = Puppet::Indirector::Request.new(:certificate_request, type, "foo.com", nil)
8
+ if remote
9
+ r.ip = '10.0.0.1'
10
+ r.node = 'agent.example.com'
11
+ end
12
+ r
13
+ end
14
+
15
+ context "when not a CA" do
16
+ before :each do
17
+ Puppet[:ca] = false
18
+ Puppet::SSL::Host.ca_location = :none
19
+ end
20
+
21
+ [:find, :head, :search, :save, :destroy].each do |name|
22
+ it "should fail remote #{name} requests" do
23
+ expect { subject.send(name, request(name, true)) }.
24
+ to raise_error Puppet::Error, /is not a CA/
25
+ end
26
+
27
+ it "should forward local #{name} requests" do
28
+ Puppet::SSL::CertificateRequest.indirection.terminus(:file).expects(name)
29
+ subject.send(name, request(name, false))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+ require 'puppet/indirector/certificate_revocation_list/disabled_ca'
4
+
5
+ describe Puppet::SSL::CertificateRevocationList::DisabledCa do
6
+ def request(type, remote)
7
+ r = Puppet::Indirector::Request.new(:certificate_revocation_list, type, "foo.com", nil)
8
+ if remote
9
+ r.ip = '10.0.0.1'
10
+ r.node = 'agent.example.com'
11
+ end
12
+ r
13
+ end
14
+
15
+ context "when not a CA" do
16
+ before :each do
17
+ Puppet[:ca] = false
18
+ Puppet::SSL::Host.ca_location = :none
19
+ end
20
+
21
+ [:find, :head, :search, :save, :destroy].each do |name|
22
+ it "should fail remote #{name} requests" do
23
+ expect { subject.send(name, request(name, true)) }.
24
+ to raise_error Puppet::Error, /is not a CA/
25
+ end
26
+
27
+ it "should forward local #{name} requests" do
28
+ Puppet::SSL::CertificateRevocationList.indirection.terminus(:file).expects(name)
29
+ subject.send(name, request(name, false))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ #! /usr/bin/env ruby -S rspec
2
+ require 'spec_helper'
3
+ require 'puppet/indirector/key/disabled_ca'
4
+
5
+ describe Puppet::SSL::Key::DisabledCa do
6
+ def request(type, remote)
7
+ r = Puppet::Indirector::Request.new(:key, type, "foo.com", nil)
8
+ if remote
9
+ r.ip = '10.0.0.1'
10
+ r.node = 'agent.example.com'
11
+ end
12
+ r
13
+ end
14
+
15
+ context "when not a CA" do
16
+ before :each do
17
+ Puppet[:ca] = false
18
+ Puppet::SSL::Host.ca_location = :none
19
+ end
20
+
21
+ [:find, :head, :search, :save, :destroy].each do |name|
22
+ it "should fail remote #{name} requests" do
23
+ expect { subject.send(name, request(name, true)) }.
24
+ to raise_error Puppet::Error, /is not a CA/
25
+ end
26
+
27
+ it "should forward local #{name} requests" do
28
+ Puppet::SSL::Key.indirection.terminus(:file).expects(name)
29
+ subject.send(name, request(name, false))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -311,4 +311,26 @@ describe Puppet::Indirector::Request do
311
311
  lambda { @request.query_string }.should raise_error(ArgumentError)
312
312
  end
313
313
  end
314
+
315
+ describe "#remote?" do
316
+ def request(options = {})
317
+ Puppet::Indirector::Request.new('node', 'find', 'localhost', options)
318
+ end
319
+
320
+ it "should not be unless node or ip is set" do
321
+ request.should_not be_remote
322
+ end
323
+
324
+ it "should be remote if node is set" do
325
+ request(:node => 'example.com').should be_remote
326
+ end
327
+
328
+ it "should be remote if ip is set" do
329
+ request(:ip => '127.0.0.1').should be_remote
330
+ end
331
+
332
+ it "should be remote if node and ip are set" do
333
+ request(:node => 'example.com', :ip => '127.0.0.1').should be_remote
334
+ end
335
+ end
314
336
  end
@@ -37,13 +37,6 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
37
37
  Proc.new { @server.listen(@listen_params.delete_if {|k,v| :port == k})}.should raise_error(ArgumentError)
38
38
  end
39
39
 
40
- it "should order a webrick server to start in a separate thread" do
41
- @mock_webrick.expects(:start)
42
- # If you remove this you'll sometimes get race condition problems
43
- Thread.expects(:new).yields
44
- @server.listen(@listen_params)
45
- end
46
-
47
40
  it "should tell webrick to listen on the specified address and port" do
48
41
  WEBrick::HTTPServer.expects(:new).with {|args|
49
42
  args[:Port] == 31337 and args[:BindAddress] == "127.0.0.1"
@@ -24,7 +24,7 @@ describe Puppet::Node::Environment do
24
24
  end
25
25
 
26
26
  it "should use the default environment if no name is provided while initializing an environment" do
27
- Puppet.settings.expects(:value).with(:environment).returns("one")
27
+ Puppet[:environment] = "one"
28
28
  Puppet::Node::Environment.new.name.should == :one
29
29
  end
30
30
 
@@ -80,15 +80,15 @@ describe Puppet::Node::Environment do
80
80
  end
81
81
 
82
82
  it "should give to all threads using the same environment the same collection if the collection isn't stale" do
83
- original_thread_type_collection = Puppet::Resource::TypeCollection.new(env)
84
- Puppet::Resource::TypeCollection.expects(:new).with(env).returns original_thread_type_collection
85
- env.known_resource_types.should equal(original_thread_type_collection)
83
+ @original_thread_type_collection = Puppet::Resource::TypeCollection.new(env)
84
+ Puppet::Resource::TypeCollection.expects(:new).with(env).returns @original_thread_type_collection
85
+ env.known_resource_types.should equal(@original_thread_type_collection)
86
86
 
87
- original_thread_type_collection.expects(:require_reparse?).returns(false)
87
+ @original_thread_type_collection.expects(:require_reparse?).returns(false)
88
88
  Puppet::Resource::TypeCollection.stubs(:new).with(env).returns @collection
89
89
 
90
90
  t = Thread.new {
91
- env.known_resource_types.should equal(original_thread_type_collection)
91
+ env.known_resource_types.should equal(@original_thread_type_collection)
92
92
  }
93
93
  t.join
94
94
  end
@@ -156,8 +156,8 @@ describe Puppet::Node::Environment do
156
156
  end
157
157
 
158
158
  it "should ask the Puppet settings instance for the setting qualified with the environment name" do
159
- Puppet.settings.expects(:value).with("myvar", :testing).returns("myval")
160
- env["myvar"].should == "myval"
159
+ Puppet.settings.set_value(:server, "myval", :testing)
160
+ env[:server].should == "myval"
161
161
  end
162
162
 
163
163
  it "should be able to return an individual module that exists in its module path" do
@@ -4,11 +4,6 @@ require 'spec_helper'
4
4
  require 'puppet/parser/ast'
5
5
 
6
6
  describe Puppet::Parser::AST do
7
-
8
- it "should use the file lookup module" do
9
- Puppet::Parser::AST.ancestors.should be_include(Puppet::FileCollection::Lookup)
10
- end
11
-
12
7
  it "should have a doc accessor" do
13
8
  ast = Puppet::Parser::AST.new({})
14
9
  ast.should respond_to(:doc)
@@ -53,6 +53,7 @@ describe Puppet::Parser::Collector, "when collecting specific virtual resources"
53
53
  @scope = mock 'scope'
54
54
  @vquery = mock 'vquery'
55
55
  @equery = mock 'equery'
56
+ @compiler = mock 'compiler'
56
57
 
57
58
  @collector = Puppet::Parser::Collector.new(@scope, "resource_type", @equery, @vquery, :virtual)
58
59
  end
@@ -33,11 +33,11 @@ describe Puppet::Parser::Files do
33
33
  end
34
34
 
35
35
  it "should return the file in the templatedir if it exists" do
36
- Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")
36
+ Puppet[:templatedir] = "/my/templates"
37
37
  Puppet[:modulepath] = "/one:/two"
38
38
  File.stubs(:directory?).returns(true)
39
39
  FileTest.stubs(:exist?).returns(true)
40
- Puppet::Parser::Files.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate"
40
+ Puppet::Parser::Files.find_template("mymod/mytemplate").should == File.join(Puppet[:templatedir], "mymod/mytemplate")
41
41
  end
42
42
 
43
43
  it "should not raise an error if no valid templatedir exists and the template exists in a module" do
@@ -6,10 +6,9 @@ describe 'function for dynamically creating resources' do
6
6
  include PuppetSpec::Compiler
7
7
 
8
8
  before :each do
9
- @scope = Puppet::Parser::Scope.new
10
- @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production'))
11
- @topscope = @scope.compiler.topscope
12
- @compiler = @scope.compiler
9
+ @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("floppy", :environment => 'production'))
10
+ @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
11
+ @topscope = @topscope
13
12
  @scope.parent = @topscope
14
13
  Puppet::Parser::Functions.function(:create_resources)
15
14
  end
@@ -39,12 +39,6 @@ describe "the require function" do
39
39
  @resource["require"][0].should be_instance_of(Puppet::Resource)
40
40
  end
41
41
 
42
- it "should verify the 'include' function is loaded" do
43
- Puppet::Parser::Functions.expects(:function).with(:include).returns(:function_include)
44
- @scope.stubs(:function_include)
45
- @scope.function_require("myclass")
46
- end
47
-
48
42
  it "should include the class but not add a dependency if used on a client not at least version 0.25" do
49
43
  @resource.expects(:metaparam_compatibility_mode?).returns true
50
44
  @scope.expects(:warning)
@@ -2,10 +2,6 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe "the shellquote function" do
5
- before :all do
6
- Puppet::Parser::Functions.autoloader.loadall
7
- end
8
-
9
5
  before :each do
10
6
  @scope = Puppet::Parser::Scope.new
11
7
  end
@@ -14,7 +10,6 @@ describe "the shellquote function" do
14
10
  Puppet::Parser::Functions.function("shellquote").should == "function_shellquote"
15
11
  end
16
12
 
17
-
18
13
  it "should handle no arguments" do
19
14
  result = @scope.function_shellquote([])
20
15
  result.should(eql(""))
@@ -7,7 +7,12 @@ describe "the template function", :'fails_on_ruby_1.9.2' => true do
7
7
  end
8
8
 
9
9
  before :each do
10
- @scope = Puppet::Parser::Scope.new
10
+ node = stub 'node'
11
+ node.stubs(:name).returns 'test_node'
12
+ node.stubs(:classes).returns []
13
+ env = Puppet::Node::Environment.new('production')
14
+ node.stubs(:environment).returns env
15
+ @scope = Puppet::Parser::Scope.new(:compiler => Puppet::Parser::Compiler.new(node))
11
16
  end
12
17
 
13
18
  it "should exist" do
@@ -3,22 +3,6 @@ require 'spec_helper'
3
3
 
4
4
  describe Puppet::Parser::Functions do
5
5
 
6
- after(:each) do
7
- # Rationale:
8
- # our various tests will almost all register to Pupet::Parser::Functions
9
- # a new function called "name". All tests are required to stub Puppet::Parser::Scope
10
- # so that +no+ new real ruby method are defined.
11
- # After each test, we want to leave the whole Puppet::Parser::Functions environment
12
- # as it was before we were called, hence we call rmfunction (which might not succeed
13
- # if the function hasn't been registered in the test). It is also important in this
14
- # section to stub +remove_method+ here so that we don't pollute the scope.
15
- Puppet::Parser::Scope.stubs(:remove_method)
16
- begin
17
- Puppet::Parser::Functions.rmfunction("name")
18
- rescue
19
- end
20
- end
21
-
22
6
  it "should have a method for returning an environment-specific module" do
23
7
  Puppet::Parser::Functions.environment_module("myenv").should be_instance_of(Module)
24
8
  end
@@ -39,13 +23,6 @@ describe Puppet::Parser::Functions do
39
23
  Puppet::Parser::Functions.newfunction("name", :type => :rvalue)
40
24
  end
41
25
 
42
- it "should raise an error if the function already exists" do
43
- @module.expects(:define_method).with { |name,block| name == "function_name" }.once
44
- Puppet::Parser::Functions.newfunction("name", :type => :rvalue)
45
-
46
- lambda { Puppet::Parser::Functions.newfunction("name", :type => :rvalue) }.should raise_error
47
- end
48
-
49
26
  it "should raise an error if the function type is not correct" do
50
27
  @module.expects(:define_method).with { |name,block| name == "function_name" }.never
51
28
 
@@ -98,4 +75,77 @@ describe Puppet::Parser::Functions do
98
75
  Puppet::Parser::Functions.function("name")
99
76
  end
100
77
  end
78
+
79
+ describe "::get_function" do
80
+ it "can retrieve a function defined on the *root* environment" do
81
+ Thread.current[:environment] = nil
82
+ function = Puppet::Parser::Functions.newfunction("atest", :type => :rvalue) do
83
+ nil
84
+ end
85
+
86
+ Puppet::Node::Environment.current = "test_env"
87
+ Puppet::Parser::Functions.send(:get_function, "atest").should equal(function)
88
+ end
89
+
90
+ it "can retrieve a function from the current environment" do
91
+ Puppet::Node::Environment.current = "test_env"
92
+ function = Puppet::Parser::Functions.newfunction("atest", :type => :rvalue) do
93
+ nil
94
+ end
95
+
96
+ Puppet::Parser::Functions.send(:get_function, "atest").should equal(function)
97
+ end
98
+
99
+ it "takes a function in the current environment over one in the root" do
100
+ root = Puppet::Node::Environment.root
101
+ env = Puppet::Node::Environment.current = "test_env"
102
+ func1 = {:type => :rvalue, :name => :testfunc, :extra => :func1}
103
+ func2 = {:type => :rvalue, :name => :testfunc, :extra => :func2}
104
+ Puppet::Parser::Functions.instance_eval do
105
+ @functions[Puppet::Node::Environment.root][:atest] = func1
106
+ @functions[Puppet::Node::Environment.current][:atest] = func2
107
+ end
108
+
109
+ Puppet::Parser::Functions.send(:get_function, "atest").should equal(func2)
110
+ end
111
+ end
112
+
113
+ describe "::merged_functions" do
114
+ it "returns functions in both the current and root environment" do
115
+ Thread.current[:environment] = nil
116
+ func_a = Puppet::Parser::Functions.newfunction("test_a", :type => :rvalue) do
117
+ nil
118
+ end
119
+ Puppet::Node::Environment.current = "test_env"
120
+ func_b = Puppet::Parser::Functions.newfunction("test_b", :type => :rvalue) do
121
+ nil
122
+ end
123
+
124
+ Puppet::Parser::Functions.send(:merged_functions).should include(:test_a, :test_b)
125
+ end
126
+
127
+ it "returns functions from the current environment over the root environment" do
128
+ root = Puppet::Node::Environment.root
129
+ env = Puppet::Node::Environment.current = "test_env"
130
+ func1 = {:type => :rvalue, :name => :testfunc, :extra => :func1}
131
+ func2 = {:type => :rvalue, :name => :testfunc, :extra => :func2}
132
+ Puppet::Parser::Functions.instance_eval do
133
+ @functions[Puppet::Node::Environment.root][:atest] = func1
134
+ @functions[Puppet::Node::Environment.current][:atest] = func2
135
+ end
136
+
137
+ Puppet::Parser::Functions.send(:merged_functions)[:atest].should equal(func2)
138
+ end
139
+ end
140
+
141
+ describe "::add_function" do
142
+ it "adds functions to the current environment" do
143
+ func = {:type => :rvalue, :name => :testfunc}
144
+ Puppet::Node::Environment.current = "add_function_test"
145
+ Puppet::Parser::Functions.send(:add_function, :testfunc, func)
146
+
147
+ Puppet::Parser::Functions.instance_variable_get(:@functions)[Puppet::Node::Environment.root].should_not include(:testfunc)
148
+ Puppet::Parser::Functions.instance_variable_get(:@functions)[Puppet::Node::Environment.current].should include(:testfunc)
149
+ end
150
+ end
101
151
  end
@@ -11,6 +11,13 @@ RSpec::Matchers.define :be_like do |*expected|
11
11
  end
12
12
  __ = nil
13
13
 
14
+ def tokens_scanned_from(s)
15
+ lexer = Puppet::Parser::Lexer.new
16
+ lexer.string = s
17
+ lexer.fullscan[0..-2]
18
+ end
19
+
20
+
14
21
  describe Puppet::Parser::Lexer do
15
22
  describe "when reading strings" do
16
23
  before { @lexer = Puppet::Parser::Lexer.new }
@@ -37,6 +44,18 @@ describe Puppet::Parser::Lexer do
37
44
 
38
45
  @lexer.line.should == 13
39
46
  end
47
+
48
+ {
49
+ 'r' => "\r",
50
+ 'n' => "\n",
51
+ 't' => "\t",
52
+ 's' => " "
53
+ }.each do |esc, expected_result|
54
+ it "should recognize \\#{esc} sequence" do
55
+ @lexer.string = "\\#{esc}'"
56
+ @lexer.slurpstring("'")[0].should == expected_result
57
+ end
58
+ end
40
59
  end
41
60
  end
42
61
 
@@ -406,7 +425,8 @@ describe Puppet::Parser::Lexer::TOKENS[:RETURN] do
406
425
  end
407
426
  end
408
427
 
409
- shared_examples_for "variable names in the lexer" do |prefix|
428
+
429
+ shared_examples_for "handling `-` in standard variable names" do |prefix|
410
430
  # Watch out - a regex might match a *prefix* on these, not just the whole
411
431
  # word, so make sure you don't have false positive or negative results based
412
432
  # on that.
@@ -423,7 +443,13 @@ shared_examples_for "variable names in the lexer" do |prefix|
423
443
 
424
444
  illegal.each do |name|
425
445
  var = prefix + global_scope + name
426
- it "should NOT accept #{var.inspect} as a valid variable name" do
446
+ it "when `variable_with_dash` is disabled it should NOT accept #{var.inspect} as a valid variable name" do
447
+ Puppet[:allow_variables_with_dashes] = false
448
+ (subject.regex.match(var) || [])[0].should_not == var
449
+ end
450
+
451
+ it "when `variable_with_dash` is enabled it should NOT accept #{var.inspect} as a valid variable name" do
452
+ Puppet[:allow_variables_with_dashes] = true
427
453
  (subject.regex.match(var) || [])[0].should_not == var
428
454
  end
429
455
  end
@@ -434,20 +460,118 @@ describe Puppet::Parser::Lexer::TOKENS[:DOLLAR_VAR] do
434
460
  its(:skip_text) { should be_false }
435
461
  its(:incr_line) { should be_false }
436
462
 
437
- it_should_behave_like "variable names in the lexer", '$'
463
+ it_should_behave_like "handling `-` in standard variable names", '$'
438
464
  end
439
465
 
440
466
  describe Puppet::Parser::Lexer::TOKENS[:VARIABLE] do
441
467
  its(:skip_text) { should be_false }
442
468
  its(:incr_line) { should be_false }
443
469
 
444
- it_should_behave_like "variable names in the lexer", ''
470
+ it_should_behave_like "handling `-` in standard variable names", ''
445
471
  end
446
472
 
447
- def tokens_scanned_from(s)
448
- lexer = Puppet::Parser::Lexer.new
449
- lexer.string = s
450
- lexer.fullscan[0..-2]
473
+ describe "the horrible deprecation / compatibility variables with dashes" do
474
+ NamesWithDashes = %w{f- f-o -f f::-o f::o- f::o-o}
475
+
476
+ { Puppet::Parser::Lexer::TOKENS[:DOLLAR_VAR_WITH_DASH] => '$',
477
+ Puppet::Parser::Lexer::TOKENS[:VARIABLE_WITH_DASH] => ''
478
+ }.each do |token, prefix|
479
+ describe token do
480
+ its(:skip_text) { should be_false }
481
+ its(:incr_line) { should be_false }
482
+
483
+ context "when compatibly is disabled" do
484
+ before :each do Puppet[:allow_variables_with_dashes] = false end
485
+ Puppet::Parser::Lexer::TOKENS.each do |name, value|
486
+ it "should be unacceptable after #{name}" do
487
+ token.acceptable?(:after => name).should be_false
488
+ end
489
+ end
490
+
491
+ # Yes, this should still *match*, just not be acceptable.
492
+ NamesWithDashes.each do |name|
493
+ ["", "::"].each do |global_scope|
494
+ var = prefix + global_scope + name
495
+ it "should match #{var.inspect}" do
496
+ subject.regex.match(var).to_a.should == [var]
497
+ end
498
+ end
499
+ end
500
+ end
501
+
502
+ context "when compatibility is enabled" do
503
+ before :each do Puppet[:allow_variables_with_dashes] = true end
504
+ it "should be acceptable after DQPRE" do
505
+ token.acceptable?(:after => :DQPRE).should be_true
506
+ end
507
+
508
+ NamesWithDashes.each do |name|
509
+ ["", "::"].each do |global_scope|
510
+ var = prefix + global_scope + name
511
+ it "should match #{var.inspect}" do
512
+ subject.regex.match(var).to_a.should == [var]
513
+ end
514
+ end
515
+ end
516
+ end
517
+ end
518
+ end
519
+
520
+ context "deprecation warnings" do
521
+ before :each do Puppet[:allow_variables_with_dashes] = true end
522
+
523
+ it "should match a top level variable" do
524
+ Puppet.expects(:deprecation_warning).once
525
+
526
+ tokens_scanned_from('$foo-bar').should == [
527
+ [:VARIABLE, { :value => 'foo-bar', :line => 1 }]
528
+ ]
529
+ end
530
+
531
+ it "does not warn about a variable without a dash" do
532
+ Puppet.expects(:deprecation_warning).never
533
+
534
+ tokens_scanned_from('$c').should == [
535
+ [:VARIABLE, { :value => "c", :line => 1 }]
536
+ ]
537
+ end
538
+
539
+ it "does not warn about referencing a class name that contains a dash" do
540
+ Puppet.expects(:deprecation_warning).never
541
+
542
+ tokens_scanned_from('foo-bar').should == [
543
+ [:NAME, { :value => "foo-bar", :line => 1 }]
544
+ ]
545
+ end
546
+
547
+ it "warns about reference to variable" do
548
+ Puppet.expects(:deprecation_warning).once
549
+
550
+ tokens_scanned_from('$::foo-bar::baz-quux').should == [
551
+ [:VARIABLE, { :value => "::foo-bar::baz-quux", :line => 1 }]
552
+ ]
553
+ end
554
+
555
+ it "warns about reference to variable interpolated in a string" do
556
+ Puppet.expects(:deprecation_warning).once
557
+
558
+ tokens_scanned_from('"$::foo-bar::baz-quux"').should == [
559
+ [:DQPRE, { :value => "", :line => 1 }],
560
+ [:VARIABLE, { :value => "::foo-bar::baz-quux", :line => 1 }],
561
+ [:DQPOST, { :value => "", :line => 1 }],
562
+ ]
563
+ end
564
+
565
+ it "warns about reference to variable interpolated in a string as an expression" do
566
+ Puppet.expects(:deprecation_warning).once
567
+
568
+ tokens_scanned_from('"${::foo-bar::baz-quux}"').should == [
569
+ [:DQPRE, { :value => "", :line => 1 }],
570
+ [:VARIABLE, { :value => "::foo-bar::baz-quux", :line => 1 }],
571
+ [:DQPOST, { :value => "", :line => 1 }],
572
+ ]
573
+ end
574
+ end
451
575
  end
452
576
 
453
577
  describe Puppet::Parser::Lexer,"when lexing strings" do
@@ -457,6 +581,7 @@ describe Puppet::Parser::Lexer,"when lexing strings" do
457
581
  %q{'single quoted string with an escaped "\\'"'} => [[:STRING,'single quoted string with an escaped "\'"']],
458
582
  %q{'single quoted string with an escaped "\$"'} => [[:STRING,'single quoted string with an escaped "\$"']],
459
583
  %q{'single quoted string with an escaped "\."'} => [[:STRING,'single quoted string with an escaped "\."']],
584
+ %q{'single quoted string with an escaped "\r\n"'} => [[:STRING,'single quoted string with an escaped "\r\n"']],
460
585
  %q{'single quoted string with an escaped "\n"'} => [[:STRING,'single quoted string with an escaped "\n"']],
461
586
  %q{'single quoted string with an escaped "\\\\"'} => [[:STRING,'single quoted string with an escaped "\\\\"']],
462
587
  %q{"string with an escaped '\\"'"} => [[:STRING,"string with an escaped '\"'"]],