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
@@ -83,6 +83,17 @@ describe Puppet::Type.type(:user).provider(:windows_adsi) do
83
83
  provider.create
84
84
  end
85
85
 
86
+ it "should load the profile if managehome is set", :if => Puppet.features.microsoft_windows? do
87
+ resource[:password] = '0xDeadBeef'
88
+ resource[:managehome] = true
89
+
90
+ user = stub_everything 'user'
91
+ Puppet::Util::ADSI::User.expects(:create).with('testuser').returns user
92
+ Puppet::Util::Windows::User.expects(:load_profile).with('testuser', '0xDeadBeef')
93
+
94
+ provider.create
95
+ end
96
+
86
97
  it "should set a user's password" do
87
98
  provider.user.expects(:password=).with('plaintextbad')
88
99
 
@@ -125,14 +136,25 @@ describe Puppet::Type.type(:user).provider(:windows_adsi) do
125
136
  provider.delete
126
137
  end
127
138
 
139
+ it 'should delete the profile if managehome is set', :if => Puppet.features.microsoft_windows? do
140
+ resource[:managehome] = true
141
+
142
+ sid = 'S-A-B-C'
143
+ Puppet::Util::Windows::Security.expects(:name_to_sid).with('testuser').returns(sid)
144
+ Puppet::Util::ADSI::UserProfile.expects(:delete).with(sid)
145
+ connection.expects(:Delete).with('user', 'testuser')
146
+
147
+ provider.delete
148
+ end
149
+
128
150
  it "should commit the user when flushed" do
129
151
  provider.user.expects(:commit)
130
152
 
131
153
  provider.flush
132
154
  end
133
155
 
134
- it "should return the user's SID as uid" do
135
- Puppet::Util::ADSI.expects(:sid_for_account).with('testuser').returns('S-1-5-21-1362942247-2130103807-3279964888-1111')
156
+ it "should return the user's SID as uid", :if => Puppet.features.microsoft_windows? do
157
+ Puppet::Util::Windows::Security.expects(:name_to_sid).with('testuser').returns('S-1-5-21-1362942247-2130103807-3279964888-1111')
136
158
 
137
159
  provider.uid.should == 'S-1-5-21-1362942247-2130103807-3279964888-1111'
138
160
  end
@@ -2,8 +2,18 @@
2
2
 
3
3
  require 'spec_helper'
4
4
  require 'puppet'
5
+ require 'puppet_spec/files'
6
+ require 'semver'
5
7
 
6
8
  describe Puppet do
9
+ include PuppetSpec::Files
10
+
11
+ context "#version" do
12
+ it "should be valid semver" do
13
+ SemVer.should be_valid Puppet.version
14
+ end
15
+ end
16
+
7
17
  Puppet::Util::Log.eachlevel do |level|
8
18
  it "should have a method for sending '#{level}' logs" do
9
19
  Puppet.should respond_to(level)
@@ -148,7 +148,7 @@ describe Puppet::Resource::Status do
148
148
  @status.line = 27
149
149
  @status.evaluation_time = 2.7
150
150
  @status.tags = %w{one two}
151
- @status.to_yaml_properties.should == Puppet::Resource::Status::YAML_ATTRIBUTES.sort
151
+ @status.to_yaml_properties.should =~ Puppet::Resource::Status::YAML_ATTRIBUTES
152
152
  end
153
153
  end
154
154
  end
@@ -799,6 +799,79 @@ type: File
799
799
  end
800
800
  end
801
801
 
802
+ describe '#parse_title' do
803
+ describe 'with a composite namevar' do
804
+ before do
805
+ Puppet::Type.newtype(:composite) do
806
+
807
+ newparam(:name)
808
+ newparam(:value)
809
+
810
+ # Configure two title patterns to match a title that is either
811
+ # separated with a colon or exclamation point. The first capture
812
+ # will be used for the :name param, and the second capture will be
813
+ # used for the :value param.
814
+ def self.title_patterns
815
+ identity = lambda {|x| x }
816
+ reverse = lambda {|x| x.reverse }
817
+ [
818
+ [
819
+ /^(.*?):(.*?)$/,
820
+ [
821
+ [:name, identity],
822
+ [:value, identity],
823
+ ]
824
+ ],
825
+ [
826
+ /^(.*?)!(.*?)$/,
827
+ [
828
+ [:name, reverse],
829
+ [:value, reverse],
830
+ ]
831
+ ],
832
+ ]
833
+ end
834
+ end
835
+ end
836
+
837
+ describe "with no matching title patterns" do
838
+ subject { Puppet::Resource.new(:composite, 'unmatching title')}
839
+
840
+ it "should raise an exception if no title patterns match" do
841
+ expect do
842
+ subject.to_hash
843
+ end.to raise_error(Puppet::Error, /No set of title patterns matched/)
844
+ end
845
+ end
846
+
847
+ describe "with a matching title pattern" do
848
+ subject { Puppet::Resource.new(:composite, 'matching:title') }
849
+
850
+ it "should not raise an exception if there was a match" do
851
+ expect do
852
+ subject.to_hash
853
+ end.to_not raise_error
854
+ end
855
+
856
+ it "should set the resource parameters from the parsed title values" do
857
+ h = subject.to_hash
858
+ h[:name].should == 'matching'
859
+ h[:value].should == 'title'
860
+ end
861
+ end
862
+
863
+ describe "and multiple title patterns" do
864
+ subject { Puppet::Resource.new(:composite, 'matching!title') }
865
+
866
+ it "should use the first title pattern that matches" do
867
+ h = subject.to_hash
868
+ h[:name].should == 'gnihctam'
869
+ h[:value].should == 'eltit'
870
+ end
871
+ end
872
+ end
873
+ end
874
+
802
875
  describe "#prune_parameters" do
803
876
  before do
804
877
  Puppet.newtype('blond') do
@@ -334,7 +334,7 @@ describe Puppet::SSL::CertificateAuthority do
334
334
 
335
335
  expect do
336
336
  @ca.sign(@name, false, @request)
337
- end.should_not raise_error(Puppet::SSL::CertificateAuthority::CertificateSigningError)
337
+ end.not_to raise_error(Puppet::SSL::CertificateAuthority::CertificateSigningError)
338
338
  end
339
339
 
340
340
  it "should save the resulting certificate" do
@@ -906,6 +906,30 @@ describe Puppet::SSL::CertificateAuthority do
906
906
  @ca.crl.expects(:revoke).with { |serial, key| serial == 16 }
907
907
  @ca.revoke('host')
908
908
  end
909
+
910
+ context "revocation by serial number (#16798)" do
911
+ it "revokes when given a lower case hexadecimal formatted string" do
912
+ @ca.crl.expects(:revoke).with { |serial, key| serial == 15 }
913
+ Puppet::SSL::Certificate.indirection.expects(:find).with("0xf").returns nil
914
+
915
+ @ca.revoke('0xf')
916
+ end
917
+
918
+ it "revokes when given an upper case hexadecimal formatted string" do
919
+ @ca.crl.expects(:revoke).with { |serial, key| serial == 15 }
920
+ Puppet::SSL::Certificate.indirection.expects(:find).with("0xF").returns nil
921
+
922
+ @ca.revoke('0xF')
923
+ end
924
+
925
+ it "handles very large serial numbers" do
926
+ bighex = '0x4000000000000000000000000000000000000000'
927
+ @ca.crl.expects(:revoke).with { |serial, key| serial == 2**(159-1) }
928
+ Puppet::SSL::Certificate.indirection.expects(:find).with(bighex).returns nil
929
+
930
+ @ca.revoke(bighex)
931
+ end
932
+ end
909
933
  end
910
934
 
911
935
  it "should be able to generate a complete new SSL host" do
@@ -3,6 +3,12 @@ require 'spec_helper'
3
3
 
4
4
  require 'puppet/ssl/host'
5
5
 
6
+ def base_pson_comparison(result, pson_hash)
7
+ result["fingerprint"].should == pson_hash["fingerprint"]
8
+ result["name"].should == pson_hash["name"]
9
+ result["state"].should == pson_hash["desired_state"]
10
+ end
11
+
6
12
  describe Puppet::SSL::Host do
7
13
  include PuppetSpec::Files
8
14
 
@@ -322,10 +328,10 @@ describe Puppet::SSL::Host do
322
328
  end
323
329
 
324
330
  it "should set the terminus class for Key, Certificate, CertificateRevocationList, and CertificateRequest as :file" do
325
- Puppet::SSL::Key.indirection.terminus_class.should == :file
326
- Puppet::SSL::Certificate.indirection.terminus_class.should == :file
327
- Puppet::SSL::CertificateRequest.indirection.terminus_class.should == :file
328
- Puppet::SSL::CertificateRevocationList.indirection.terminus_class.should == :file
331
+ Puppet::SSL::Key.indirection.terminus_class.should == :disabled_ca
332
+ Puppet::SSL::Certificate.indirection.terminus_class.should == :disabled_ca
333
+ Puppet::SSL::CertificateRequest.indirection.terminus_class.should == :disabled_ca
334
+ Puppet::SSL::CertificateRevocationList.indirection.terminus_class.should == :disabled_ca
329
335
  end
330
336
 
331
337
  it "should set the terminus class for Host to 'none'" do
@@ -797,23 +803,71 @@ describe Puppet::SSL::Host do
797
803
  end
798
804
 
799
805
  describe "when converting to PSON" do
806
+ let(:host) do
807
+ Puppet::SSL::Host.new("bazinga")
808
+ end
809
+
810
+ let(:pson_hash) do
811
+ {
812
+ "fingerprint" => host.certificate_request.fingerprint,
813
+ "desired_state" => 'requested',
814
+ "name" => host.name
815
+ }
816
+ end
817
+
800
818
  it "should be able to identify a host with an unsigned certificate request" do
801
- host = Puppet::SSL::Host.new("bazinga")
802
819
  host.generate_certificate_request
803
- pson_hash = {
804
- "fingerprint" => host.certificate_request.fingerprint,
805
- "desired_state" => 'requested',
806
- "name" => host.name
807
- }
808
820
 
809
821
  result = PSON.parse(Puppet::SSL::Host.new(host.name).to_pson)
810
- result["fingerprint"].should == pson_hash["fingerprint"]
811
- result["name"].should == pson_hash["name"]
812
- result["state"].should == pson_hash["desired_state"]
813
- end
822
+
823
+ base_pson_comparison result, pson_hash
824
+ end
825
+
826
+ describe "explicit fingerprints" do
827
+ [:SHA1, :SHA256, :SHA512].each do |md|
828
+ it "should include #{md}" do
829
+ mds = md.to_s
830
+ host.generate_certificate_request
831
+ pson_hash["fingerprints"] = {}
832
+ pson_hash["fingerprints"][mds] = host.certificate_request.fingerprint(md)
833
+
834
+ result = PSON.parse(Puppet::SSL::Host.new(host.name).to_pson)
835
+ base_pson_comparison result, pson_hash
836
+ result["fingerprints"][mds].should == pson_hash["fingerprints"][mds]
837
+ end
838
+ end
839
+ end
840
+
841
+ describe "dns_alt_names" do
842
+ describe "when not specified" do
843
+ it "should include the dns_alt_names associated with the certificate" do
844
+ host.generate_certificate_request
845
+ pson_hash["desired_alt_names"] = host.certificate_request.subject_alt_names
846
+
847
+ result = PSON.parse(Puppet::SSL::Host.new(host.name).to_pson)
848
+ base_pson_comparison result, pson_hash
849
+ result["dns_alt_names"].should == pson_hash["desired_alt_names"]
850
+ end
851
+ end
852
+
853
+ [ "",
854
+ "test, alt, names"
855
+ ].each do |alt_names|
856
+ describe "when #{alt_names}" do
857
+ it "should include the dns_alt_names associated with the certificate" do
858
+ host.generate_certificate_request :dns_alt_names => alt_names
859
+ pson_hash["desired_alt_names"] = host.certificate_request.subject_alt_names
860
+
861
+ result = PSON.parse(Puppet::SSL::Host.new(host.name).to_pson)
862
+ base_pson_comparison result, pson_hash
863
+ result["dns_alt_names"].should == pson_hash["desired_alt_names"]
864
+ end
865
+ end
866
+ end
867
+ end
868
+
814
869
 
815
870
  it "should be able to identify a host with a signed certificate" do
816
- host = Puppet::SSL::Host.new("bazinga")
817
871
  host.generate_certificate_request
818
872
  @ca.sign(host.name)
819
873
  pson_hash = {
@@ -823,26 +877,18 @@ describe Puppet::SSL::Host do
823
877
  }
824
878
 
825
879
  result = PSON.parse(Puppet::SSL::Host.new(host.name).to_pson)
826
- result["fingerprint"].should == pson_hash["fingerprint"]
827
- result["name"].should == pson_hash["name"]
828
- result["state"].should == pson_hash["desired_state"]
880
+ base_pson_comparison result, pson_hash
829
881
  end
830
882
 
831
883
  it "should be able to identify a host with a revoked certificate" do
832
- host = Puppet::SSL::Host.new("bazinga")
833
884
  host.generate_certificate_request
834
885
  @ca.sign(host.name)
835
886
  @ca.revoke(host.name)
836
- pson_hash = {
837
- "fingerprint" => Puppet::SSL::Certificate.indirection.find(host.name).fingerprint,
838
- "desired_state" => 'revoked',
839
- "name" => host.name,
840
- }
887
+ pson_hash["fingerprint"] = Puppet::SSL::Certificate.indirection.find(host.name).fingerprint
888
+ pson_hash["desired_state"] = 'revoked'
841
889
 
842
890
  result = PSON.parse(Puppet::SSL::Host.new(host.name).to_pson)
843
- result["fingerprint"].should == pson_hash["fingerprint"]
844
- result["name"].should == pson_hash["name"]
845
- result["state"].should == pson_hash["desired_state"]
891
+ base_pson_comparison result, pson_hash
846
892
  end
847
893
  end
848
894
 
@@ -16,10 +16,6 @@ describe Puppet::SSL::Key do
16
16
  @class.indirection.name.should == :key
17
17
  end
18
18
 
19
- it "should default to the :file terminus" do
20
- @class.indirection.terminus_class.should == :file
21
- end
22
-
23
19
  it "should only support the text format" do
24
20
  @class.supported_formats.should == [:s]
25
21
  end
@@ -122,7 +122,7 @@ describe Puppet::Transaction::Event do
122
122
  :message => "Help I'm trapped in a spec test",
123
123
  :name => :mode_changed, :previous_value => 6, :property => :mode,
124
124
  :status => 'success')
125
- event.to_yaml_properties.should == Puppet::Transaction::Event::YAML_ATTRIBUTES.sort
125
+ event.to_yaml_properties.should =~ Puppet::Transaction::Event::YAML_ATTRIBUTES
126
126
  end
127
127
  end
128
128
  end
@@ -274,7 +274,7 @@ describe Puppet::Type.type(:exec) do
274
274
 
275
275
  it "should fail if the provider calls the command invalid" do
276
276
  expect { test(command, false) }.
277
- to raise_error Puppet::Error, /Parameter #{@param} failed: from a stub/
277
+ to raise_error Puppet::Error, /Parameter #{@param} failed on Exec\[.*\]: from a stub/
278
278
  end
279
279
  end
280
280
  end
@@ -264,8 +264,9 @@ describe content do
264
264
  end
265
265
 
266
266
  it "should write to the given file handle" do
267
- @fh.expects(:print).with("this is content")
268
- @content.write(@fh)
267
+ fh = mock 'filehandle'
268
+ fh.expects(:print).with("this is content")
269
+ @content.write(fh)
269
270
  end
270
271
 
271
272
  it "should return the current checksum value" do
@@ -295,8 +296,9 @@ describe content do
295
296
  @content.resource.expects(:bucket).returns bucket
296
297
  bucket.expects(:getfile).with("foo").returns "mycontent"
297
298
 
298
- @fh.expects(:print).with("mycontent")
299
- @content.write(@fh)
299
+ fh = mock 'filehandle'
300
+ fh.expects(:print).with("mycontent")
301
+ @content.write(fh)
300
302
  end
301
303
  end
302
304
 
@@ -36,22 +36,12 @@ describe Puppet::Type.type(:file) do
36
36
  file[:path].should == "/"
37
37
  end
38
38
 
39
- it "should accept a double-slash at the start of the path" do
39
+ it "should accept and preserve a double-slash at the start of the path" do
40
40
  expect {
41
41
  file[:path] = "//tmp/xxx"
42
- # REVISIT: This should be wrong, later. See the next test.
43
- # --daniel 2011-01-31
44
- file[:path].should == '/tmp/xxx'
42
+ file[:path].should == '//tmp/xxx'
45
43
  }.to_not raise_error
46
44
  end
47
-
48
- # REVISIT: This is pending, because I don't want to try and audit the
49
- # entire codebase to make sure we get this right. POSIX treats two (and
50
- # exactly two) '/' characters at the start of the path specially.
51
- #
52
- # See sections 3.2 and 4.11, which allow DomainOS to be all special like
53
- # and still have the POSIX branding and all. --daniel 2011-01-31
54
- it "should preserve the double-slash at the start of the path"
55
45
  end
56
46
 
57
47
  describe "on Windows systems", :if => Puppet.features.microsoft_windows? do
@@ -4,10 +4,11 @@ require 'spec_helper'
4
4
  host = Puppet::Type.type(:host)
5
5
 
6
6
  describe host do
7
+ FakeHostProvider = Struct.new(:ip, :host_aliases, :comment)
7
8
  before do
8
9
  @class = host
9
10
  @catalog = Puppet::Resource::Catalog.new
10
- @provider = stub 'provider'
11
+ @provider = FakeHostProvider.new
11
12
  @resource = stub 'resource', :resource => nil, :provider => @provider
12
13
  end
13
14
 
@@ -618,27 +619,35 @@ describe host do
618
619
 
619
620
  it "should send the first value to the provider for ip property" do
620
621
  @ip = @class.attrclass(:ip).new(:resource => @resource, :should => %w{192.168.0.1 192.168.0.2})
621
- @provider.expects(:ip=).with '192.168.0.1'
622
+
622
623
  @ip.sync
624
+
625
+ @provider.ip.should == '192.168.0.1'
623
626
  end
624
627
 
625
628
  it "should send the first value to the provider for comment property" do
626
629
  @comment = @class.attrclass(:comment).new(:resource => @resource, :should => %w{Bazinga Notme})
627
- @provider.expects(:comment=).with 'Bazinga'
630
+
628
631
  @comment.sync
632
+
633
+ @provider.comment.should == 'Bazinga'
629
634
  end
630
635
 
631
636
  it "should send the joined array to the provider for host_alias" do
632
637
  @host_aliases = @class.attrclass(:host_aliases).new(:resource => @resource, :should => %w{foo bar})
633
- @provider.expects(:host_aliases=).with 'foo bar'
638
+
634
639
  @host_aliases.sync
640
+
641
+ @provider.host_aliases.should == 'foo bar'
635
642
  end
636
643
 
637
644
  it "should also use the specified delimiter for joining" do
638
645
  @host_aliases = @class.attrclass(:host_aliases).new(:resource => @resource, :should => %w{foo bar})
639
646
  @host_aliases.stubs(:delimiter).returns "\t"
640
- @provider.expects(:host_aliases=).with "foo\tbar"
647
+
641
648
  @host_aliases.sync
649
+
650
+ @provider.host_aliases.should == "foo\tbar"
642
651
  end
643
652
 
644
653
  it "should care about the order of host_aliases" do