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
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
+ require 'pathname'
4
5
  require 'puppet/util/selinux'
5
6
  include Puppet::Util::SELinux
6
7
 
@@ -33,7 +34,7 @@ describe Puppet::Util::SELinux do
33
34
  end
34
35
  end
35
36
 
36
- describe "filesystem detection" do
37
+ describe "read_mounts" do
37
38
  before :each do
38
39
  fh = stub 'fh', :close => nil
39
40
  File.stubs(:open).with("/proc/mounts").returns fh
@@ -48,6 +49,17 @@ describe Puppet::Util::SELinux do
48
49
  '/proc' => 'proc',
49
50
  '/dev' => 'tmpfs' }
50
51
  end
52
+ end
53
+
54
+ describe "filesystem detection" do
55
+ before :each do
56
+ self.stubs(:read_mounts).returns({
57
+ '/' => 'ext3',
58
+ '/sys' => 'sysfs',
59
+ '/mnt/nfs' => 'nfs',
60
+ '/proc' => 'proc',
61
+ '/dev' => 'tmpfs' })
62
+ end
51
63
 
52
64
  it "should match a path on / to ext3" do
53
65
  find_fs('/etc/puppet/testfile').should == "ext3"
@@ -65,41 +77,21 @@ describe Puppet::Util::SELinux do
65
77
  selinux_label_support?('/mnt/nfs/testfile').should be_false
66
78
  end
67
79
 
68
- it "should follow symlinks when determining file systems" do
69
- self.stubs(:realpath).with('/mnt/symlink/testfile').returns('/mnt/nfs/dest/testfile')
80
+ it "(#8714) don't follow symlinks when determining file systems", :unless => Puppet.features.microsoft_windows? do
81
+ scratch = Pathname(PuppetSpec::Files.tmpdir('selinux'))
70
82
 
71
- selinux_label_support?('/mnt/symlink/testfile').should be_false
72
- end
83
+ self.stubs(:read_mounts).returns({
84
+ '/' => 'ext3',
85
+ scratch + 'nfs' => 'nfs',
86
+ })
73
87
 
74
- end
88
+ (scratch + 'foo').make_symlink('nfs/bar')
89
+ selinux_label_support?(scratch + 'foo').should be_true
90
+ end
75
91
 
76
- describe "realpath" do
77
92
  it "should handle files that don't exist" do
78
-
79
- # Since I'm stubbing Pathname.new for this test,
80
- # I need to also stub the internal calls to Pathname.new,
81
- # which happen in Pathname.dirname and Parthname.basename
82
- # I want those to return real Pathname objects,
83
- # so I'm creating them before the stub is in place.
84
- realpaths = Hash.new {|hash, path| hash[path] = Pathname.new(path) }
85
- paths = ['symlink', '/mnt']
86
- paths.each { |path| realpaths[path] }
87
-
88
- realpaths['/mnt/symlink'] = stubs "Pathname"
89
- realpaths['/mnt/symlink'].stubs(:realpath).returns(realpaths['/mnt/nfs/dest'])
90
- realpaths['/mnt/symlink'].stubs(:exist?).returns(true)
91
-
92
- realpaths['/mnt/symlink/nonexistant'] = stubs "Pathname"
93
- realpaths['/mnt/symlink/nonexistant'].stubs(:realpath).raises(Errno::ENOENT)
94
- realpaths['/mnt/symlink/nonexistant'].stubs(:exist?).returns(false)
95
- realpaths['/mnt/symlink/nonexistant'].stubs(:dirname).returns(realpaths['/mnt/symlink'])
96
- realpaths['/mnt/symlink/nonexistant'].stubs(:basename).returns(realpaths['nonexistant'])
97
-
98
- realpaths.each do |path, value|
99
- Pathname.stubs(:new).with(path).returns(value)
100
- end
101
-
102
- realpath('/mnt/symlink/nonexistant').should == '/mnt/nfs/dest/nonexistant'
93
+ scratch = Pathname(PuppetSpec::Files.tmpdir('selinux'))
94
+ selinux_label_support?(scratch + 'nonesuch').should be_true
103
95
  end
104
96
  end
105
97
 
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+ require 'spec_helper'
3
+
4
+ describe "Puppet::Util::Windows::SID", :if => Puppet.features.microsoft_windows? do
5
+ if Puppet.features.microsoft_windows?
6
+ require 'puppet/util/windows'
7
+ class SIDTester
8
+ include Puppet::Util::Windows::SID
9
+ end
10
+ end
11
+
12
+ let(:subject) { SIDTester.new }
13
+ let(:sid) { Win32::Security::SID::LocalSystem }
14
+ let(:invalid_sid) { 'bogus' }
15
+ let(:unknown_sid) { 'S-0-0-0' }
16
+ let(:unknown_name) { 'chewbacca' }
17
+
18
+ context "#name_to_sid" do
19
+ it "should return nil if the account does not exist" do
20
+ subject.name_to_sid(unknown_name).should be_nil
21
+ end
22
+
23
+ it "should accept unqualified account name" do
24
+ subject.name_to_sid('SYSTEM').should == sid
25
+ end
26
+
27
+ it "should be case-insensitive" do
28
+ subject.name_to_sid('SYSTEM').should == subject.name_to_sid('system')
29
+ end
30
+
31
+ it "should accept domain qualified account names" do
32
+ subject.name_to_sid('NT AUTHORITY\SYSTEM').should == sid
33
+ end
34
+
35
+ it "should be the identity function for any sid" do
36
+ subject.name_to_sid(sid).should == sid
37
+ end
38
+ end
39
+
40
+ context "#sid_to_name" do
41
+ it "should return nil if given a sid for an account that doesn't exist" do
42
+ subject.sid_to_name(unknown_sid).should be_nil
43
+ end
44
+
45
+ it "should accept a sid" do
46
+ subject.sid_to_name(sid).should == "NT AUTHORITY\\SYSTEM"
47
+ end
48
+ end
49
+
50
+ context "#sid_ptr_to_string" do
51
+ it "should raise if given an invalid sid" do
52
+ expect {
53
+ subject.sid_ptr_to_string(nil)
54
+ }.to raise_error(Puppet::Error, /Invalid SID/)
55
+ end
56
+
57
+ it "should yield a valid sid pointer" do
58
+ string = nil
59
+ subject.string_to_sid_ptr(sid) do |ptr|
60
+ string = subject.sid_ptr_to_string(ptr)
61
+ end
62
+ string.should == sid
63
+ end
64
+ end
65
+
66
+ context "#string_to_sid_ptr" do
67
+ it "should yield sid_ptr" do
68
+ ptr = nil
69
+ subject.string_to_sid_ptr(sid) do |p|
70
+ ptr = p
71
+ end
72
+ ptr.should_not be_nil
73
+ end
74
+
75
+ it "should raise on an invalid sid" do
76
+ expect {
77
+ subject.string_to_sid_ptr(invalid_sid)
78
+ }.to raise_error(Puppet::Error, /Failed to convert string SID/)
79
+ end
80
+ end
81
+
82
+ context "#valid_sid?" do
83
+ it "should return true for a valid SID" do
84
+ subject.valid_sid?(sid).should be_true
85
+ end
86
+
87
+ it "should return false for an invalid SID" do
88
+ subject.valid_sid?(invalid_sid).should be_false
89
+ end
90
+
91
+ it "should raise if the conversion fails" do
92
+ subject.expects(:string_to_sid_ptr).with(sid).
93
+ raises(Puppet::Util::Windows::Error.new("Failed to convert string SID: #{sid}", Windows::Error::ERROR_ACCESS_DENIED))
94
+
95
+ expect {
96
+ subject.string_to_sid_ptr(sid) {|ptr| }
97
+ }.to raise_error(Puppet::Util::Windows::Error, /Failed to convert string SID: #{sid}/)
98
+ end
99
+ end
100
+ end
@@ -16,43 +16,71 @@ require 'spec_helper'
16
16
  require 'puppet/util/monkey_patches'
17
17
 
18
18
  describe "Pure ruby yaml implementation" do
19
+ def can_round_trip(value)
20
+ YAML.load(value.to_yaml).should == value
21
+ end
22
+
19
23
  {
20
- 7 => "--- 7",
21
- 3.14159 => "--- 3.14159",
22
- "3.14159" => '--- "3.14159"',
23
- "+3.14159" => '--- "+3.14159"',
24
- "0x123abc" => '--- "0x123abc"',
25
- "-0x123abc" => '--- "-0x123abc"',
26
- "-0x123" => '--- "-0x123"',
27
- "+0x123" => '--- "+0x123"',
28
- "0x123.456" => "--- 0x123.456",
29
- 'test' => "--- test",
30
- [] => "--- []",
31
- :symbol => "--- !ruby/sym symbol",
32
- {:a => "A"} => "--- \n !ruby/sym a: A",
33
- {:a => "x\ny"} => "--- \n !ruby/sym a: |-\n x\n y"
34
- }.each { |o,y|
35
- it "should convert the #{o.class} #{o.inspect} to yaml" do
36
- o.to_yaml.should == y
24
+ 7 => "--- 7",
25
+ 3.14159 => "--- 3.14159",
26
+ "3.14159" => '--- "3.14159"',
27
+ "+3.14159" => '--- "+3.14159"',
28
+ "0x123abc" => '--- "0x123abc"',
29
+ "-0x123abc" => '--- "-0x123abc"',
30
+ "-0x123" => '--- "-0x123"',
31
+ "+0x123" => '--- "+0x123"',
32
+ "0x123.456" => '--- "0x123.456"',
33
+ 'test' => "--- test",
34
+ [] => "--- []",
35
+ :symbol => "--- !ruby/sym symbol",
36
+ {:a => "A"} => "--- \n !ruby/sym a: A",
37
+ {:a => "x\ny"} => "--- \n !ruby/sym a: |-\n x\n y"
38
+ }.each do |data, serialized|
39
+ it "should convert the #{data.class} #{data.inspect} to yaml" do
40
+ data.to_yaml.should == serialized
37
41
  end
38
- it "should produce yaml for the #{o.class} #{o.inspect} that can be reconstituted" do
39
- YAML.load(o.to_yaml).should == o
42
+
43
+ it "should produce yaml for the #{data.class} #{data.inspect} that can be reconstituted" do
44
+ can_round_trip data
45
+ end
46
+ end
47
+
48
+ [
49
+ { :a => "a:" },
50
+ { :a => "a:", :b => "b:" },
51
+ ["a:", "b:"],
52
+ { :a => "/:", :b => "/:" },
53
+ { :a => "a/:", :b => "a/:" },
54
+ { :a => "\"" },
55
+ { :a => {}.to_yaml },
56
+ { :a => [].to_yaml },
57
+ { :a => "".to_yaml },
58
+ { :a => :a.to_yaml },
59
+
60
+ { "a:" => "b" },
61
+ { :a.to_yaml => "b" },
62
+ { [1, 2, 3] => "b" },
63
+ { "b:" => { "a" => [] } }
64
+ ].each do |value|
65
+ it "properly escapes #{value.inspect}, which contains YAML characters" do
66
+ can_round_trip value
40
67
  end
41
- }
68
+ end
69
+
42
70
  #
43
71
  # Can't test for equality on raw objects
44
72
  {
45
- Object.new => "--- !ruby/object {}",
46
- [Object.new] => "--- \n - !ruby/object {}",
47
- {Object.new => Object.new} => "--- \n ? !ruby/object {}\n : !ruby/object {}"
48
- }.each { |o,y|
73
+ Object.new => "--- !ruby/object {}",
74
+ [Object.new] => "--- \n - !ruby/object {}",
75
+ {Object.new => Object.new} => "--- \n ? !ruby/object {}\n : !ruby/object {}"
76
+ }.each do |o,y|
49
77
  it "should convert the #{o.class} #{o.inspect} to yaml" do
50
78
  o.to_yaml.should == y
51
79
  end
52
80
  it "should produce yaml for the #{o.class} #{o.inspect} that can be reconstituted" do
53
81
  lambda { YAML.load(o.to_yaml) }.should_not raise_error
54
82
  end
55
- }
83
+ end
56
84
 
57
85
  it "should emit proper labels and backreferences for common objects" do
58
86
  # Note: this test makes assumptions about the names ZAML chooses
@@ -104,3 +132,115 @@ describe "UTF-8 encoded String#to_yaml (Bug #11246)" do
104
132
  end
105
133
  end
106
134
  end
135
+
136
+ describe "binary data" do
137
+ subject { "M\xC0\xDF\xE5tt\xF6" }
138
+
139
+ if String.method_defined?(:encoding)
140
+ def binary(str)
141
+ str.force_encoding('binary')
142
+ end
143
+ else
144
+ def binary(str)
145
+ str
146
+ end
147
+ end
148
+
149
+ it "should not explode encoding binary data" do
150
+ expect { subject.to_yaml }.not_to raise_error
151
+ end
152
+
153
+ it "should mark the binary data as binary" do
154
+ subject.to_yaml.should =~ /!binary/
155
+ end
156
+
157
+ it "should round-trip the data" do
158
+ yaml = subject.to_yaml
159
+ read = YAML.load(yaml)
160
+ binary(read).should == binary(subject)
161
+ end
162
+
163
+ [
164
+ "\xC0\xAE", # over-long UTF-8 '.' character
165
+ "\xC0\x80", # over-long NULL byte
166
+ "\xC0\xFF",
167
+ "\xC1\xAE",
168
+ "\xC1\x80",
169
+ "\xC1\xFF",
170
+ "\x80", # first continuation byte
171
+ "\xbf", # last continuation byte
172
+ # all possible continuation bytes in one shot
173
+ "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F" +
174
+ "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F" +
175
+ "\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF" +
176
+ "\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF",
177
+ # lonely start characters - first, all possible two byte sequences
178
+ "\xC0 \xC1 \xC2 \xC3 \xC4 \xC5 \xC6 \xC7 \xC8 \xC9 \xCA \xCB \xCC \xCD \xCE \xCF " +
179
+ "\xD0 \xD1 \xD2 \xD3 \xD4 \xD5 \xD6 \xD7 \xD8 \xD9 \xDA \xDB \xDC \xDD \xDE \xDF ",
180
+ # and so for three byte sequences, four, five, and six, as follow.
181
+ "\xE0 \xE1 \xE2 \xE3 \xE4 \xE5 \xE6 \xE7 \xE8 \xE9 \xEA \xEB \xEC \xED \xEE \xEF ",
182
+ "\xF0 \xF1 \xF2 \xF3 \xF4 \xF5 \xF6 \xF7 ",
183
+ "\xF8 \xF9 \xFA \xFB ",
184
+ "\xFC \xFD ",
185
+ # sequences with the last byte missing
186
+ "\xC0", "\xE0", "\xF0\x80\x80", "\xF8\x80\x80\x80", "\xFC\x80\x80\x80\x80",
187
+ "\xDF", "\xEF\xBF", "\xF7\xBF\xBF", "\xFB\xBF\xBF\xBF", "\xFD\xBF\xBF\xBF\xBF",
188
+ # impossible bytes
189
+ "\xFE", "\xFF", "\xFE\xFE\xFF\xFF",
190
+ # over-long '/' character
191
+ "\xC0\xAF",
192
+ "\xE0\x80\xAF",
193
+ "\xF0\x80\x80\xAF",
194
+ "\xF8\x80\x80\x80\xAF",
195
+ "\xFC\x80\x80\x80\x80\xAF",
196
+ # maximum overlong sequences
197
+ "\xc1\xbf",
198
+ "\xe0\x9f\xbf",
199
+ "\xf0\x8f\xbf\xbf",
200
+ "\xf8\x87\xbf\xbf\xbf",
201
+ "\xfc\x83\xbf\xbf\xbf\xbf",
202
+ # overlong NUL
203
+ "\xc0\x80",
204
+ "\xe0\x80\x80",
205
+ "\xf0\x80\x80\x80",
206
+ "\xf8\x80\x80\x80\x80",
207
+ "\xfc\x80\x80\x80\x80\x80",
208
+ ].each do |input|
209
+ # It might seem like we should more correctly reject these sequences in
210
+ # the encoder, and I would personally agree, but the sad reality is that
211
+ # we do not distinguish binary and textual data in our language, and so we
212
+ # wind up with the same thing - a string - containing both.
213
+ #
214
+ # That leads to the position where we must treat these invalid sequences,
215
+ # which are both legitimate binary content, and illegitimate potential
216
+ # attacks on the system, as something that passes through correctly in
217
+ # a string. --daniel 2012-07-14
218
+ it "binary encode highly dubious non-compliant UTF-8 input #{input.inspect}" do
219
+ encoded = ZAML.dump(binary(input))
220
+ encoded.should =~ /!binary/
221
+ YAML.load(encoded).should == input
222
+ end
223
+ end
224
+ end
225
+
226
+ describe "multi-line values" do
227
+ [
228
+ "none",
229
+ "one\n",
230
+ "two\n\n",
231
+ ["one\n", "two"],
232
+ ["two\n\n", "three"],
233
+ { "\nkey" => "value" },
234
+ { "key\n" => "value" },
235
+ { "\nkey\n" => "value" },
236
+ { "key\nkey" => "value" },
237
+ { "\nkey\nkey" => "value" },
238
+ { "key\nkey\n" => "value" },
239
+ { "\nkey\nkey\n" => "value" },
240
+ ].each do |input|
241
+ it "handles #{input.inspect} without corruption" do
242
+ zaml = ZAML.dump(input)
243
+ YAML.load(zaml).should == input
244
+ end
245
+ end
246
+ end
@@ -394,7 +394,9 @@ describe Puppet::Util do
394
394
  Process.expects(:CloseHandle).with(thread_handle)
395
395
  Process.expects(:CloseHandle).with(process_handle)
396
396
 
397
- expect { Puppet::Util.execute('test command') }.should raise_error(RuntimeError)
397
+ expect {
398
+ Puppet::Util.execute('test command')
399
+ }.to raise_error(RuntimeError)
398
400
  end
399
401
  end
400
402
  end
@@ -691,14 +693,6 @@ describe Puppet::Util do
691
693
  newhash.should == resulthash
692
694
  end
693
695
  end
694
-
695
- describe "#symbolizehash!" do
696
- it "should symbolize the hash in place" do
697
- localhash = myhash
698
- Puppet::Util.symbolizehash!(localhash)
699
- localhash.should == resulthash
700
- end
701
- end
702
696
  end
703
697
 
704
698
  context "#replace_file" do
@@ -80,13 +80,9 @@ end
80
80
  def run_spec_files(files)
81
81
  files = Array(files)
82
82
  return if files.empty?
83
- if File.exist?(File.expand_path("~/.rspec")) then
84
- opts = '' # use the user defaults
85
- else
86
- opts = File.readlines('spec/spec.opts').collect { |l| l.chomp }.join(" ")
87
- end
88
83
  begin
89
- run_spec("rspec #{opts} --tty #{files.join(' ')}")
84
+ # End users can put additional options into ~/.rspec
85
+ run_spec("rspec --tty #{files.join(' ')}")
90
86
  rescue => detail
91
87
  puts "Failed to load #{files}: #{detail}"
92
88
  end
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'puppet/version'
2
3
 
3
4
  GEM_FILES = FileList[
4
5
  '[A-Z]*',
@@ -20,13 +21,14 @@ EXECUTABLES = FileList[
20
21
  ]
21
22
 
22
23
  SBIN = Dir.glob("sbin/*")
24
+ GEMVERSION = Puppet.version.gsub('-','.')
23
25
 
24
26
  spec = Gem::Specification.new do |spec|
25
27
  spec.platform = Gem::Platform::RUBY
26
28
  spec.name = 'puppet'
27
29
  spec.files = GEM_FILES.to_a
28
30
  spec.executables = EXECUTABLES.gsub(/sbin\/|bin\//, '').to_a
29
- spec.version = Puppet::PUPPETVERSION
31
+ spec.version = GEMVERSION
30
32
  spec.add_dependency('facter', '~> 1.5')
31
33
  spec.summary = 'Puppet, an automated configuration management tool'
32
34
  spec.description = 'Puppet, an automated configuration management tool'
@@ -52,7 +54,7 @@ desc "Create the gem"
52
54
  task :create_gem => :prepare_gem do
53
55
  Dir.mkdir("pkg") rescue nil
54
56
  Gem::Builder.new(spec).build
55
- FileUtils.move("puppet-#{Puppet::PUPPETVERSION}.gem", "pkg")
57
+ FileUtils.move("puppet-#{GEMVERSION}.gem", "pkg")
56
58
  SBIN.each do |f|
57
59
  fn = f.gsub(/sbin\/(.*)/, '\1')
58
60
  FileUtils.rm_r "bin/" + fn