puppet 4.0.0-x86-mingw32 → 4.1.0-x86-mingw32

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

Potentially problematic release.


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

Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +8 -35
  3. data/ext/debian/puppet.default +0 -5
  4. data/ext/debian/puppet.init +1 -15
  5. data/lib/hiera/puppet_function.rb +15 -4
  6. data/lib/puppet/application/agent.rb +5 -0
  7. data/lib/puppet/application/apply.rb +23 -2
  8. data/lib/puppet/application/device.rb +8 -3
  9. data/lib/puppet/application/master.rb +16 -5
  10. data/lib/puppet/configurer.rb +7 -5
  11. data/lib/puppet/defaults.rb +18 -0
  12. data/lib/puppet/environments.rb +1 -1
  13. data/lib/puppet/error.rb +27 -1
  14. data/lib/puppet/file_serving/metadata.rb +13 -8
  15. data/lib/puppet/file_serving/terminus_helper.rb +7 -8
  16. data/lib/puppet/file_system.rb +13 -0
  17. data/lib/puppet/file_system/file_impl.rb +4 -0
  18. data/lib/puppet/file_system/memory_impl.rb +4 -0
  19. data/lib/puppet/file_system/windows.rb +8 -0
  20. data/lib/puppet/functions.rb +33 -3
  21. data/lib/puppet/functions/defined.rb +130 -0
  22. data/lib/puppet/functions/regsubst.rb +1 -1
  23. data/lib/puppet/functions/split.rb +1 -1
  24. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  25. data/lib/puppet/indirector/facts/facter.rb +11 -0
  26. data/lib/puppet/loaders.rb +1 -0
  27. data/lib/puppet/node.rb +17 -1
  28. data/lib/puppet/node/environment.rb +4 -0
  29. data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
  30. data/lib/puppet/parser/compiler.rb +9 -0
  31. data/lib/puppet/parser/functions/defined.rb +25 -1
  32. data/lib/puppet/parser/functions/file.rb +3 -1
  33. data/lib/puppet/parser/scope.rb +11 -2
  34. data/lib/puppet/parser/templatewrapper.rb +2 -1
  35. data/lib/puppet/pops.rb +4 -0
  36. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  37. data/lib/puppet/pops/evaluator/closure.rb +28 -2
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
  41. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  42. data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
  44. data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
  45. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  46. data/lib/puppet/pops/functions/dispatcher.rb +7 -1
  47. data/lib/puppet/pops/issue_reporter.rb +42 -16
  48. data/lib/puppet/pops/issues.rb +116 -2
  49. data/lib/puppet/pops/loader/loader.rb +11 -0
  50. data/lib/puppet/pops/loader/loader_paths.rb +67 -6
  51. data/lib/puppet/pops/loader/module_loaders.rb +19 -8
  52. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
  53. data/lib/puppet/pops/loaders.rb +6 -4
  54. data/lib/puppet/pops/migration/migration_checker.rb +54 -0
  55. data/lib/puppet/pops/model/factory.rb +5 -1
  56. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  57. data/lib/puppet/pops/model/model_meta.rb +5 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +9 -10
  59. data/lib/puppet/pops/parser/eparser.rb +1061 -1047
  60. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  61. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  62. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  63. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  64. data/lib/puppet/pops/parser/lexer2.rb +29 -12
  65. data/lib/puppet/pops/parser/lexer_support.rb +52 -23
  66. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  67. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  68. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  69. data/lib/puppet/pops/types/type_factory.rb +66 -13
  70. data/lib/puppet/pops/types/type_parser.rb +22 -13
  71. data/lib/puppet/pops/types/types.rb +23 -4
  72. data/lib/puppet/pops/types/types_meta.rb +13 -2
  73. data/lib/puppet/pops/validation.rb +25 -2
  74. data/lib/puppet/pops/validation/checker4_0.rb +63 -31
  75. data/lib/puppet/provider/group/windows_adsi.rb +8 -4
  76. data/lib/puppet/provider/mount/parsed.rb +145 -2
  77. data/lib/puppet/provider/package/apt.rb +1 -1
  78. data/lib/puppet/provider/package/pip.rb +11 -2
  79. data/lib/puppet/provider/package/pkgng.rb +134 -0
  80. data/lib/puppet/provider/package/portage.rb +1 -1
  81. data/lib/puppet/provider/package/ports.rb +0 -3
  82. data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
  83. data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
  84. data/lib/puppet/provider/package/zypper.rb +50 -15
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
  86. data/lib/puppet/provider/service/debian.rb +1 -1
  87. data/lib/puppet/provider/service/init.rb +7 -0
  88. data/lib/puppet/provider/user/openbsd.rb +1 -0
  89. data/lib/puppet/provider/user/windows_adsi.rb +45 -2
  90. data/lib/puppet/reference/indirection.rb +1 -1
  91. data/lib/puppet/resource.rb +1 -1
  92. data/lib/puppet/resource/catalog.rb +0 -4
  93. data/lib/puppet/settings.rb +19 -0
  94. data/lib/puppet/type/file.rb +1 -0
  95. data/lib/puppet/type/file/ensure.rb +1 -1
  96. data/lib/puppet/type/mount.rb +9 -1
  97. data/lib/puppet/type/scheduled_task.rb +13 -0
  98. data/lib/puppet/type/tidy.rb +3 -1
  99. data/lib/puppet/type/user.rb +32 -0
  100. data/lib/puppet/type/yumrepo.rb +5 -5
  101. data/lib/puppet/util/log.rb +50 -8
  102. data/lib/puppet/util/log/destinations.rb +23 -2
  103. data/lib/puppet/util/logging.rb +37 -1
  104. data/lib/puppet/util/run_mode.rb +1 -14
  105. data/lib/puppet/util/windows/adsi.rb +130 -58
  106. data/lib/puppet/version.rb +1 -1
  107. data/man/man5/puppet.conf.5 +48 -6
  108. data/man/man8/extlookup2hiera.8 +1 -1
  109. data/man/man8/puppet-agent.8 +4 -1
  110. data/man/man8/puppet-apply.8 +4 -1
  111. data/man/man8/puppet-ca.8 +1 -1
  112. data/man/man8/puppet-catalog.8 +1 -1
  113. data/man/man8/puppet-cert.8 +1 -1
  114. data/man/man8/puppet-certificate.8 +1 -1
  115. data/man/man8/puppet-certificate_request.8 +1 -1
  116. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  117. data/man/man8/puppet-config.8 +1 -1
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +6 -3
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-file.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-inspect.8 +1 -1
  127. data/man/man8/puppet-key.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-master.8 +4 -1
  130. data/man/man8/puppet-module.8 +1 -1
  131. data/man/man8/puppet-node.8 +1 -1
  132. data/man/man8/puppet-parser.8 +1 -1
  133. data/man/man8/puppet-plugin.8 +1 -1
  134. data/man/man8/puppet-report.8 +1 -1
  135. data/man/man8/puppet-resource.8 +1 -1
  136. data/man/man8/puppet-resource_type.8 +1 -1
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +1 -1
  139. data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
  140. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
  141. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
  142. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
  143. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
  144. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
  145. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
  146. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
  147. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
  148. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
  149. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
  150. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
  151. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
  152. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
  153. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  154. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  155. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
  156. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
  157. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
  158. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
  159. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
  160. data/spec/integration/application/apply_spec.rb +49 -0
  161. data/spec/integration/faces/plugin_spec.rb +0 -4
  162. data/spec/integration/indirector/facts/facter_spec.rb +59 -0
  163. data/spec/integration/parser/compiler_spec.rb +850 -0
  164. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  165. data/spec/integration/parser/scope_spec.rb +26 -5
  166. data/spec/integration/transaction_spec.rb +1 -1
  167. data/spec/integration/type/file_spec.rb +318 -41
  168. data/spec/integration/util/windows/security_spec.rb +14 -5
  169. data/spec/lib/matchers/resource.rb +22 -1
  170. data/spec/lib/puppet_spec/matchers.rb +6 -4
  171. data/spec/unit/application/master_spec.rb +33 -7
  172. data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
  173. data/spec/unit/file_serving/metadata_spec.rb +1 -1
  174. data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
  175. data/spec/unit/file_system_spec.rb +38 -0
  176. data/spec/unit/functions/defined_spec.rb +289 -0
  177. data/spec/unit/functions/hiera_spec.rb +8 -6
  178. data/spec/unit/functions/regsubst_spec.rb +4 -0
  179. data/spec/unit/functions/split_spec.rb +8 -0
  180. data/spec/unit/functions4_spec.rb +97 -2
  181. data/spec/unit/indirector/facts/facter_spec.rb +7 -0
  182. data/spec/unit/node_spec.rb +6 -0
  183. data/spec/unit/parser/functions/file_spec.rb +7 -1
  184. data/spec/unit/parser/functions/template_spec.rb +1 -1
  185. data/spec/unit/parser/scope_spec.rb +2 -2
  186. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  187. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  188. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
  189. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  190. data/spec/unit/pops/issues_spec.rb +16 -16
  191. data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
  192. data/spec/unit/pops/migration_spec.rb +53 -0
  193. data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
  194. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  195. data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
  196. data/spec/unit/pops/validation_spec.rb +66 -0
  197. data/spec/unit/pops/validator/validator_spec.rb +1 -1
  198. data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
  199. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  200. data/spec/unit/provider/package/apt_spec.rb +5 -0
  201. data/spec/unit/provider/package/pip_spec.rb +9 -0
  202. data/spec/unit/provider/package/pkgng_spec.rb +172 -0
  203. data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
  204. data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
  205. data/spec/unit/provider/package/zypper_spec.rb +50 -19
  206. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  207. data/spec/unit/provider/service/base_spec.rb +38 -27
  208. data/spec/unit/provider/service/debian_spec.rb +8 -0
  209. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  210. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  211. data/spec/unit/provider/service/init_spec.rb +18 -0
  212. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  213. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  214. data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
  215. data/spec/unit/settings_spec.rb +11 -0
  216. data/spec/unit/util/log_spec.rb +113 -0
  217. data/spec/unit/util/windows/adsi_spec.rb +135 -41
  218. data/spec/unit/util/windows/sid_spec.rb +0 -10
  219. metadata +48 -2
@@ -111,7 +111,7 @@ describe "validating 4x" do
111
111
  end
112
112
 
113
113
  context 'for reserved words' do
114
- ['function', 'private', 'type', 'attr'].each do |word|
114
+ ['private', 'type', 'attr'].each do |word|
115
115
  it "produces an error for the word '#{word}'" do
116
116
  source = "$a = #{word}"
117
117
  expect(validate(parse(source))).to have_issue(Puppet::Pops::Issues::RESERVED_WORD)
@@ -43,14 +43,6 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
43
43
  end
44
44
 
45
45
  describe "#members_insync?" do
46
- it "should return false when current is nil" do
47
- expect(provider.members_insync?(nil, ['user2'])).to be_falsey
48
- end
49
-
50
- it "should return false when should is nil" do
51
- expect(provider.members_insync?(['user1'], nil)).to be_falsey
52
- end
53
-
54
46
  it "should return true for same lists of members" do
55
47
  expect(provider.members_insync?(['user1', 'user2'], ['user1', 'user2'])).to be_truthy
56
48
  end
@@ -63,11 +55,31 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
63
55
  expect(provider.members_insync?(['user1', 'user2', 'user2'], ['user2', 'user1', 'user1'])).to be_truthy
64
56
  end
65
57
 
58
+ it "should return true when current and should members are empty lists" do
59
+ expect(provider.members_insync?([], [])).to be_truthy
60
+ end
61
+
62
+ # invalid scenarios
63
+ #it "should return true when current and should members are nil lists" do
64
+ #it "should return true when current members is nil and should members is empty" do
65
+
66
+ it "should return true when current members is empty and should members is nil" do
67
+ expect(provider.members_insync?([], nil)).to be_truthy
68
+ end
69
+
66
70
  context "when auth_membership => true" do
67
71
  before :each do
68
72
  resource[:auth_membership] = true
69
73
  end
70
74
 
75
+ it "should return false when current is nil" do
76
+ expect(provider.members_insync?(nil, ['user2'])).to be_falsey
77
+ end
78
+
79
+ it "should return false when should is nil" do
80
+ expect(provider.members_insync?(['user1'], nil)).to be_falsey
81
+ end
82
+
71
83
  it "should return false when current contains different users than should" do
72
84
  expect(provider.members_insync?(['user1'], ['user2'])).to be_falsey
73
85
  end
@@ -83,6 +95,10 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
83
95
  it "should return false when should user(s) are not the only items in the current" do
84
96
  expect(provider.members_insync?(['user1', 'user2'], ['user1'])).to be_falsey
85
97
  end
98
+
99
+ it "should return false when current user(s) is not empty and should is an empty list" do
100
+ expect(provider.members_insync?(['user1','user2'], [])).to be_falsey
101
+ end
86
102
  end
87
103
 
88
104
  context "when auth_membership => false" do
@@ -91,6 +107,14 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
91
107
  resource[:auth_membership] = false
92
108
  end
93
109
 
110
+ it "should return false when current is nil" do
111
+ expect(provider.members_insync?(nil, ['user2'])).to be_falsey
112
+ end
113
+
114
+ it "should return true when should is nil" do
115
+ expect(provider.members_insync?(['user1'], nil)).to be_truthy
116
+ end
117
+
94
118
  it "should return false when current contains different users than should" do
95
119
  expect(provider.members_insync?(['user1'], ['user2'])).to be_falsey
96
120
  end
@@ -105,7 +129,11 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
105
129
 
106
130
  it "should return true when current user(s) contains at least the should list" do
107
131
  expect(provider.members_insync?(['user1','user2'], ['user1'])).to be_truthy
108
- end
132
+ end
133
+
134
+ it "should return true when current user(s) is not empty and should is an empty list" do
135
+ expect(provider.members_insync?(['user1','user2'], [])).to be_truthy
136
+ end
109
137
 
110
138
  it "should return true when current user(s) contains at least the should list, even unordered" do
111
139
  expect(provider.members_insync?(['user3','user1','user2'], ['user2','user1'])).to be_truthy
@@ -185,6 +213,18 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
185
213
  /Cannot create group if user 'testers' exists./ )
186
214
  end
187
215
 
216
+ it "should fail with an actionable message when trying to create an active directory group" do
217
+ resource[:name] = 'DOMAIN\testdomaingroup'
218
+ Puppet::Util::Windows::ADSI::User.expects(:exists?).with(resource[:name]).returns(false)
219
+ connection.expects(:Create)
220
+ connection.expects(:SetInfo).raises( WIN32OLERuntimeError.new("(in OLE method `SetInfo': )\n OLE error code:8007089A in Active Directory\n The specified username is invalid.\r\n\n HRESULT error code:0x80020009\n Exception occurred."))
221
+
222
+ expect{ provider.create }.to raise_error(
223
+ Puppet::Error,
224
+ /not able to create\/delete domain groups/
225
+ )
226
+ end
227
+
188
228
  it 'should commit a newly created group' do
189
229
  provider.group.expects( :commit )
190
230
 
@@ -207,6 +247,14 @@ describe Puppet::Type.type(:group).provider(:windows_adsi), :if => Puppet.featur
207
247
  provider.delete
208
248
  end
209
249
 
250
+ it 'should not run commit on a deleted group' do
251
+ connection.expects(:Delete).with('group', 'testers')
252
+ connection.expects(:SetInfo).never
253
+
254
+ provider.delete
255
+ provider.flush
256
+ end
257
+
210
258
  it "should report the group's SID as gid" do
211
259
  Puppet::Util::Windows::SID.expects(:name_to_sid).with('testers').returns('S-1-5-32-547')
212
260
  expect(provider.gid).to eq('S-1-5-32-547')
@@ -8,6 +8,9 @@ require 'shared_behaviours/all_parsedfile_providers'
8
8
  # restore Solaris spec tests.
9
9
 
10
10
  describe Puppet::Type.type(:mount).provider(:parsed), :unless => Puppet.features.microsoft_windows? do
11
+ before :each do
12
+ Facter.clear
13
+ end
11
14
 
12
15
  let :vfstab_sample do
13
16
  "/dev/dsk/c0d0s0 /dev/rdsk/c0d0s0 \t\t / \t ufs 1 no\t-"
@@ -26,6 +29,11 @@ describe Puppet::Type.type(:mount).provider(:parsed), :unless => Puppet.features
26
29
  end
27
30
  end
28
31
 
32
+ it "should default to /etc/vfstab on Solaris" do
33
+ pending "This test only works on AIX" unless Facter.value(:osfamily) == 'AIX'
34
+ expect(described_class.default_target).to eq('/etc/filesystems')
35
+ end
36
+
29
37
  it "should default to /etc/fstab on anything else" do
30
38
  if Facter.value(:osfamily) == 'Solaris'
31
39
  skip("This test only does not work on Solaris")
@@ -171,10 +179,14 @@ FSTAB
171
179
  described_class.stubs(:mountcmd).returns(File.read(my_fixture('aix.mount')))
172
180
  mounts = described_class.mountinstances
173
181
  expect(mounts[0]).to eq({ :name => '/', :mounted => :yes })
174
- expect(mounts[1]).to eq({ :name => '/tmp', :mounted => :yes })
175
- expect(mounts[2]).to eq({ :name => '/home', :mounted => :yes })
176
- expect(mounts[3]).to eq({ :name => '/usr', :mounted => :yes })
177
- expect(mounts[4]).to eq({ :name => '/usr/code', :mounted => :yes })
182
+ expect(mounts[1]).to eq({ :name => '/usr', :mounted => :yes })
183
+ expect(mounts[2]).to eq({ :name => '/var', :mounted => :yes })
184
+ expect(mounts[3]).to eq({ :name => '/tmp', :mounted => :yes })
185
+ expect(mounts[4]).to eq({ :name => '/home', :mounted => :yes })
186
+ expect(mounts[5]).to eq({ :name => '/admin', :mounted => :yes })
187
+ expect(mounts[6]).to eq({ :name => '/proc', :mounted => :yes })
188
+ expect(mounts[7]).to eq({ :name => '/opt', :mounted => :yes })
189
+ expect(mounts[8]).to eq({ :name => '/srv/aix', :mounted => :yes })
178
190
  end
179
191
 
180
192
  it "should raise an error if a line is not understandable" do
@@ -184,7 +196,21 @@ FSTAB
184
196
 
185
197
  end
186
198
 
187
- it "should support AIX's paragraph based /etc/filesystems"
199
+ it "should support AIX's paragraph based /etc/filesystems" do
200
+ pending "This test only works on AIX" unless Facter.value(:osfamily) == 'AIX'
201
+ Facter.stubs(:value).with(:osfamily).returns 'AIX'
202
+ described_class.stubs(:default_target).returns my_fixture('aix.filesystems')
203
+ described_class.stubs(:mountcmd).returns File.read(my_fixture('aix.mount'))
204
+ instances = described_class.instances
205
+ expect(instances[0].name).to eq("/")
206
+ expect(instances[0].device).to eq("/dev/hd4")
207
+ expect(instances[0].fstype).to eq("jfs2")
208
+ expect(instances[0].options).to eq("check=false,free=true,log=NULL,mount=automatic,quota=no,type=bootfs,vol=root")
209
+ expect(instances[11].name).to eq("/srv/aix")
210
+ expect(instances[11].device).to eq("mynode")
211
+ expect(instances[11].fstype).to eq("nfs")
212
+ expect(instances[11].options).to eq("vers=2,account=false,log=NULL,mount=true")
213
+ end
188
214
 
189
215
  my_fixtures('*.fstab').each do |fstab|
190
216
  platform = File.basename(fstab, '.fstab')
@@ -19,6 +19,11 @@ describe provider_class do
19
19
  provider
20
20
  end
21
21
 
22
+ it "should be the default provider on :osfamily => Debian" do
23
+ Facter.expects(:value).with(:osfamily).returns("Debian")
24
+ expect(described_class.default?).to be_truthy
25
+ end
26
+
22
27
  it "should be versionable" do
23
28
  expect(provider_class).to be_versionable
24
29
  end
@@ -193,6 +193,15 @@ describe provider_class do
193
193
  @provider.install
194
194
  end
195
195
 
196
+ it "should handle install options" do
197
+ @resource[:ensure] = :installed
198
+ @resource[:source] = nil
199
+ @resource[:install_options] = [{"--timeout" => "10"}, "--no-index"]
200
+ @provider.expects(:lazy_pip).
201
+ with("install", "-q", "--timeout=10", "--no-index", "fake_package")
202
+ @provider.install
203
+ end
204
+
196
205
  end
197
206
 
198
207
  describe "uninstall" do
@@ -0,0 +1,172 @@
1
+ #! /usr/bin/env ruby
2
+ require 'spec_helper'
3
+ require 'puppet/provider/package/pkgng'
4
+
5
+ provider_class = Puppet::Type.type(:package).provider(:pkgng)
6
+
7
+ describe provider_class do
8
+ let(:name) { 'bash' }
9
+ let(:installed_name) { 'zsh' }
10
+ let(:pkgng) { 'pkgng' }
11
+
12
+ let(:resource) do
13
+ # When bash is not present
14
+ Puppet::Type.type(:package).new(:name => name, :provider => pkgng)
15
+ end
16
+
17
+ let(:installed_resource) do
18
+ # When zsh is present
19
+ Puppet::Type.type(:package).new(:name => installed_name, :provider => pkgng)
20
+ end
21
+
22
+ let(:latest_resource) do
23
+ # When curl is installed but not the latest
24
+ Puppet::Type.type(:package).new(:name => 'ftp/curl', :provider => pkgng, :ensure => latest)
25
+ end
26
+
27
+ let (:provider) { resource.provider }
28
+ let (:installed_provider) { installed_resource.provider }
29
+
30
+ def run_in_catalog(*resources)
31
+ catalog = Puppet::Resource::Catalog.new
32
+ catalog.host_config = false
33
+ resources.each do |resource|
34
+ #resource.expects(:err).never
35
+ catalog.add_resource(resource)
36
+ end
37
+ catalog.apply
38
+ end
39
+
40
+ before do
41
+ provider_class.stubs(:command).with(:pkg) { '/usr/local/sbin/pkg' }
42
+
43
+ info = File.read(my_fixture('pkg.info'))
44
+ provider_class.stubs(:get_query).returns(info)
45
+
46
+ version_list = File.read(my_fixture('pkg.version'))
47
+ provider_class.stubs(:get_version_list).returns(version_list)
48
+ end
49
+
50
+ context "#instances" do
51
+ it "should return the empty set if no packages are listed" do
52
+ provider_class.stubs(:get_query).returns('')
53
+ provider_class.stubs(:get_version_list).returns('')
54
+ expect(provider_class.instances).to be_empty
55
+ end
56
+
57
+ it "should return all packages when invoked" do
58
+ expect(provider_class.instances.map(&:name).sort).to eq(
59
+ %w{ca_root_nss curl nmap pkg gnupg mcollective zsh tac_plus}.sort)
60
+ end
61
+
62
+ it "should set latest to current version when no upgrade available" do
63
+ nmap = provider_class.instances.find {|i| i.properties[:origin] == 'security/nmap' }
64
+
65
+ expect(nmap.properties[:version]).to eq(nmap.properties[:latest])
66
+ end
67
+
68
+ describe "version" do
69
+ it "should retrieve the correct version of the current package" do
70
+ zsh = provider_class.instances.find {|i| i.properties[:origin] == 'shells/zsh' }
71
+ expect( zsh.properties[:version]).to eq('5.0.2_1')
72
+ end
73
+ end
74
+ end
75
+
76
+ context "#install" do
77
+ it "should call pkg with the specified package version given an origin for package name" do
78
+ resource = Puppet::Type.type(:package).new(
79
+ :name => 'ftp/curl',
80
+ :provider => :pkgng,
81
+ :ensure => '7.33.1'
82
+ )
83
+ resource.provider.expects(:pkg) do |arg|
84
+ arg.should include('curl-7.33.1')
85
+ end
86
+ resource.provider.install
87
+ end
88
+
89
+ it "should call pkg with the specified package version" do
90
+ resource = Puppet::Type.type(:package).new(
91
+ :name => 'curl',
92
+ :provider => :pkgng,
93
+ :ensure => '7.33.1'
94
+ )
95
+ resource.provider.expects(:pkg) do |arg|
96
+ arg.should include('curl-7.33.1')
97
+ end
98
+ resource.provider.install
99
+ end
100
+
101
+ it "should call pkg with the specified package repo" do
102
+ resource = Puppet::Type.type(:package).new(
103
+ :name => 'curl',
104
+ :provider => :pkgng,
105
+ :source => 'urn:freebsd:repo:FreeBSD'
106
+ )
107
+ resource.provider.expects(:pkg) do |arg|
108
+ arg.should include('FreeBSD')
109
+ end
110
+ resource.provider.install
111
+ end
112
+ end
113
+
114
+ context "#query" do
115
+ it "should return the installed version if present" do
116
+ provider_class.prefetch({installed_name => installed_resource})
117
+ expect(installed_provider.query).to eq({:version=>'5.0.2_1'})
118
+ end
119
+
120
+ it "should return nil if not present" do
121
+ fixture = File.read(my_fixture('pkg.query_absent'))
122
+ provider_class.stubs(:get_resource_info).with('bash').returns(fixture)
123
+ expect(provider.query).to equal(nil)
124
+ end
125
+ end
126
+
127
+ describe "latest" do
128
+ it "should retrieve the correct version of the latest package" do
129
+ provider_class.prefetch( { installed_name => installed_resource })
130
+ expect(installed_provider.latest).not_to be_nil
131
+ end
132
+
133
+ it "should set latest to newer package version when available" do
134
+ instances = provider_class.instances
135
+ curl = instances.find {|i| i.properties[:origin] == 'ftp/curl' }
136
+ expect(curl.properties[:latest]).to eq('7.33.0_2')
137
+ end
138
+
139
+ it "should call update to upgrade the version" do
140
+ resource = Puppet::Type.type(:package).new(
141
+ :name => 'ftp/curl',
142
+ :provider => pkgng,
143
+ :ensure => :latest
144
+ )
145
+
146
+ resource.provider.expects(:update)
147
+
148
+ resource.property(:ensure).sync
149
+ end
150
+ end
151
+
152
+ describe "get_latest_version" do
153
+ it "should rereturn nil when the current package is the latest" do
154
+ nmap_latest_version = provider_class.get_latest_version('security/nmap')
155
+ expect(nmap_latest_version).to be_nil
156
+ end
157
+
158
+ it "should match the package name exactly" do
159
+ bash_comp_latest_version = provider_class.get_latest_version('shells/bash-completion')
160
+ expect(bash_comp_latest_version).to eq('2.1_3')
161
+ end
162
+ end
163
+
164
+ describe "confine" do
165
+ context "on FreeBSD" do
166
+ it "should be the default provider" do
167
+ Facter.expects(:value).with(:operatingsystem).at_least_once.returns :freebsd
168
+ expect(provider_class).to be_default
169
+ end
170
+ end
171
+ end
172
+ end
@@ -34,7 +34,6 @@ describe Puppet::Provider::Package::Windows::ExePackage do
34
34
  {
35
35
  'DisplayName' => ['My App', ''],
36
36
  'UninstallString' => ['E:\uninstall.exe', ''],
37
- 'SystemComponent' => [nil, 1],
38
37
  'WindowsInstaller' => [nil, 1],
39
38
  'ParentKeyName' => [nil, 'Uber Product'],
40
39
  'Security Update' => [nil, 'KB890830'],
@@ -48,7 +48,6 @@ describe Puppet::Provider::Package::Windows::MsiPackage do
48
48
 
49
49
  {
50
50
  'DisplayName' => ['My App', ''],
51
- 'SystemComponent' => [nil, 1],
52
51
  'WindowsInstaller' => [1, nil],
53
52
  }.each_pair do |k, arr|
54
53
  it "should accept '#{k}' with value '#{arr[0]}'" do
@@ -80,7 +80,7 @@ describe provider_class do
80
80
  @resource.stubs(:should).with(:ensure).returns :latest
81
81
  @resource.stubs(:allow_virtual?).returns false
82
82
  @provider.stubs(:zypper_version).returns "0.6.104"
83
- @provider.expects(:zypper).with('--terse', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', 'mypackage')
83
+ @provider.expects(:zypper).with('--terse', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage')
84
84
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
85
85
  @provider.install
86
86
  end
@@ -101,7 +101,7 @@ describe provider_class do
101
101
  @resource.stubs(:should).with(:ensure).returns :latest
102
102
  @resource.stubs(:allow_virtual?).returns false
103
103
  @provider.stubs(:zypper_version).returns "0.6.13"
104
- @provider.expects(:zypper).with('--terse', :install, '--no-confirm', '--name', 'mypackage')
104
+ @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
105
105
  @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
106
106
  @provider.install
107
107
  end
@@ -115,22 +115,53 @@ describe provider_class do
115
115
  end
116
116
 
117
117
  describe "when getting latest version" do
118
- it "should return a version string with valid list-updates data from SLES11sp1" do
119
- fake_data = File.read(my_fixture('zypper-list-updates-SLES11sp1.out'))
118
+ after do described_class.reset! end
119
+ context "when the package has available update" do
120
+ it "should return a version string with valid list-updates data from SLES11sp1" do
121
+ fake_data = File.read(my_fixture('zypper-list-updates-SLES11sp1.out'))
122
+ @resource.stubs(:[]).with(:name).returns "at"
123
+ described_class.expects(:zypper).with("list-updates").returns fake_data
124
+ expect(@provider.latest).to eq("3.1.8-1069.18.2")
125
+ end
126
+ end
127
+
128
+ context "when the package is in the latest version" do
129
+ it "should return nil with valid list-updates data from SLES11sp1" do
130
+ fake_data = File.read(my_fixture('zypper-list-updates-SLES11sp1.out'))
131
+ @resource.stubs(:[]).with(:name).returns "zypper-log"
132
+ described_class.expects(:zypper).with("list-updates").returns fake_data
133
+ expect(@provider.latest).to eq(nil)
134
+ end
135
+ end
120
136
 
121
- @resource.stubs(:[]).with(:name).returns "at"
122
- @provider.expects(:zypper).with("list-updates").returns fake_data
123
- expect(@provider.latest).to eq("3.1.8-1069.18.2")
137
+ context "when there are no updates available" do
138
+ it "should return nil" do
139
+ fake_data_empty = File.read(my_fixture('zypper-list-updates-empty.out'))
140
+ @resource.stubs(:[]).with(:name).returns "at"
141
+ described_class.expects(:zypper).with("list-updates").returns fake_data_empty
142
+ expect(@provider.latest).to eq(nil)
143
+ end
124
144
  end
125
145
  end
126
146
 
127
- it "should install a virtual package" do
128
- @resource.stubs(:should).with(:ensure).returns :installed
129
- @resource.stubs(:allow_virtual?).returns true
130
- @provider.stubs(:zypper_version).returns "0.6.13"
131
- @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
132
- @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
133
- @provider.install
147
+ describe "should install a virtual package" do
148
+ it "when zypper version = 0.6.13" do
149
+ @resource.stubs(:should).with(:ensure).returns :installed
150
+ @resource.stubs(:allow_virtual?).returns true
151
+ @provider.stubs(:zypper_version).returns "0.6.13"
152
+ @provider.expects(:zypper).with('--terse', :install, '--no-confirm', 'mypackage')
153
+ @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
154
+ @provider.install
155
+ end
156
+
157
+ it "when zypper version >= 1.0.0" do
158
+ @resource.stubs(:should).with(:ensure).returns :installed
159
+ @resource.stubs(:allow_virtual?).returns true
160
+ @provider.stubs(:zypper_version).returns "1.2.8"
161
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', 'mypackage')
162
+ @provider.expects(:query).returns "mypackage 0 1.2.3 4.5.6 x86_64"
163
+ @provider.install
164
+ end
134
165
  end
135
166
 
136
167
  describe "when installing with zypper install options" do
@@ -141,8 +172,8 @@ describe provider_class do
141
172
  @resource.stubs(:allow_virtual?).returns false
142
173
  @provider.stubs(:zypper_version).returns "1.2.8"
143
174
 
144
- @provider.expects(:zypper).with('--quiet', :install,
145
- '--auto-agree-with-licenses', '--no-confirm', '--no-gpg-check', '-p=/vagrant/files/localrepo/', 'php5-5.4.10-4.5.6')
175
+ @provider.expects(:zypper).with('--quiet', '--no-gpg-check', :install,
176
+ '--auto-agree-with-licenses', '--no-confirm', '-p=/vagrant/files/localrepo/', 'php5-5.4.10-4.5.6')
146
177
  @provider.expects(:query).returns "php5 0 5.4.10 4.5.6 x86_64"
147
178
  @provider.install
148
179
  end
@@ -154,7 +185,7 @@ describe provider_class do
154
185
  @resource.stubs(:allow_virtual?).returns false
155
186
 
156
187
  @provider.stubs(:zypper_version).returns '1.2.8'
157
- @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', '--a=foo', '--b="quoted bar"', 'vim')
188
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a=foo', '--b="quoted bar"', '--name', 'vim')
158
189
  @provider.expects(:query).returns 'package vim is not installed'
159
190
  @provider.install
160
191
  end
@@ -166,7 +197,7 @@ describe provider_class do
166
197
  @resource.stubs(:allow_virtual?).returns false
167
198
 
168
199
  @provider.stubs(:zypper_version).returns '1.2.8'
169
- @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', '--a', '--b', '--c', 'vim')
200
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a', '--b', '--c', '--name', 'vim')
170
201
  @provider.expects(:query).returns 'package vim is not installed'
171
202
  @provider.install
172
203
  end
@@ -178,7 +209,7 @@ describe provider_class do
178
209
  @resource.stubs(:allow_virtual?).returns false
179
210
 
180
211
  @provider.stubs(:zypper_version).returns '1.2.8'
181
- @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--name', '--a --b --c', 'vim')
212
+ @provider.expects(:zypper).with('--quiet', :install, '--auto-agree-with-licenses', '--no-confirm', '--a --b --c', '--name', 'vim')
182
213
  @provider.expects(:query).returns 'package vim is not installed'
183
214
  @provider.install
184
215
  end