puppet 7.1.0-x64-mingw32 → 7.6.1-x64-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 (198) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +38 -30
  3. data/ext/build_defaults.yaml +0 -1
  4. data/lib/puppet/application.rb +10 -6
  5. data/lib/puppet/application/agent.rb +1 -0
  6. data/lib/puppet/application/apply.rb +3 -2
  7. data/lib/puppet/application/device.rb +1 -0
  8. data/lib/puppet/application/script.rb +1 -0
  9. data/lib/puppet/application/ssl.rb +11 -0
  10. data/lib/puppet/configurer.rb +16 -3
  11. data/lib/puppet/defaults.rb +14 -19
  12. data/lib/puppet/environments.rb +16 -1
  13. data/lib/puppet/face/facts.rb +26 -2
  14. data/lib/puppet/ffi/windows/api_types.rb +1 -1
  15. data/lib/puppet/ffi/windows/constants.rb +1 -1
  16. data/lib/puppet/file_serving/configuration/parser.rb +5 -2
  17. data/lib/puppet/file_system/memory_file.rb +8 -1
  18. data/lib/puppet/file_system/windows.rb +2 -0
  19. data/lib/puppet/functions.rb +1 -1
  20. data/lib/puppet/functions/partition.rb +8 -0
  21. data/lib/puppet/http/factory.rb +4 -0
  22. data/lib/puppet/indirector/facts/facter.rb +1 -0
  23. data/lib/puppet/loaders.rb +0 -4
  24. data/lib/puppet/module.rb +1 -0
  25. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  26. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  27. data/lib/puppet/network/formats.rb +67 -0
  28. data/lib/puppet/network/http.rb +5 -2
  29. data/lib/puppet/network/http/api.rb +10 -6
  30. data/lib/puppet/network/http/api/master.rb +3 -2
  31. data/lib/puppet/network/http/api/master/v3.rb +2 -25
  32. data/lib/puppet/network/http/api/master/v3/environments.rb +2 -33
  33. data/lib/puppet/network/http/api/server.rb +10 -0
  34. data/lib/puppet/network/http/api/server/v3.rb +39 -0
  35. data/lib/puppet/network/http/api/server/v3/environments.rb +48 -0
  36. data/lib/puppet/node/environment.rb +12 -5
  37. data/lib/puppet/parser/ast/leaf.rb +3 -2
  38. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  39. data/lib/puppet/pops/loader/base_loader.rb +42 -32
  40. data/lib/puppet/pops/loader/dependency_loader.rb +2 -2
  41. data/lib/puppet/pops/loader/loader.rb +15 -5
  42. data/lib/puppet/pops/loader/module_loaders.rb +8 -8
  43. data/lib/puppet/pops/loader/predefined_loader.rb +4 -0
  44. data/lib/puppet/pops/loader/runtime3_type_loader.rb +1 -1
  45. data/lib/puppet/pops/loader/static_loader.rb +4 -0
  46. data/lib/puppet/pops/loaders.rb +4 -4
  47. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  48. data/lib/puppet/pops/parser/lexer2.rb +0 -4
  49. data/lib/puppet/pops/types/p_type_set_type.rb +1 -1
  50. data/lib/puppet/pops/validation/checker4_0.rb +0 -1
  51. data/lib/puppet/property/list.rb +1 -1
  52. data/lib/puppet/provider/group/groupadd.rb +13 -8
  53. data/lib/puppet/provider/package/apt.rb +34 -2
  54. data/lib/puppet/provider/package/aptitude.rb +6 -0
  55. data/lib/puppet/provider/package/dnfmodule.rb +1 -1
  56. data/lib/puppet/provider/package/puppet_gem.rb +12 -1
  57. data/lib/puppet/provider/service/debian.rb +2 -0
  58. data/lib/puppet/provider/service/systemd.rb +1 -1
  59. data/lib/puppet/provider/user/useradd.rb +62 -8
  60. data/lib/puppet/reference/configuration.rb +6 -5
  61. data/lib/puppet/settings.rb +36 -30
  62. data/lib/puppet/settings/alias_setting.rb +37 -0
  63. data/lib/puppet/settings/environment_conf.rb +1 -0
  64. data/lib/puppet/type/package.rb +3 -3
  65. data/lib/puppet/util/autoload.rb +1 -8
  66. data/lib/puppet/util/monkey_patches.rb +7 -0
  67. data/lib/puppet/util/posix.rb +1 -1
  68. data/lib/puppet/util/windows/adsi.rb +46 -0
  69. data/lib/puppet/util/windows/principal.rb +9 -2
  70. data/lib/puppet/util/windows/sid.rb +4 -2
  71. data/lib/puppet/version.rb +1 -1
  72. data/locales/puppet.pot +166 -146
  73. data/man/man5/puppet.conf.5 +14 -6
  74. data/man/man8/puppet-agent.8 +2 -2
  75. data/man/man8/puppet-apply.8 +2 -2
  76. data/man/man8/puppet-catalog.8 +1 -1
  77. data/man/man8/puppet-config.8 +1 -1
  78. data/man/man8/puppet-describe.8 +1 -1
  79. data/man/man8/puppet-device.8 +2 -2
  80. data/man/man8/puppet-doc.8 +1 -1
  81. data/man/man8/puppet-epp.8 +1 -1
  82. data/man/man8/puppet-facts.8 +8 -2
  83. data/man/man8/puppet-filebucket.8 +1 -1
  84. data/man/man8/puppet-generate.8 +1 -1
  85. data/man/man8/puppet-help.8 +1 -1
  86. data/man/man8/puppet-lookup.8 +1 -1
  87. data/man/man8/puppet-module.8 +1 -1
  88. data/man/man8/puppet-node.8 +1 -1
  89. data/man/man8/puppet-parser.8 +1 -1
  90. data/man/man8/puppet-plugin.8 +1 -1
  91. data/man/man8/puppet-report.8 +1 -1
  92. data/man/man8/puppet-resource.8 +1 -1
  93. data/man/man8/puppet-script.8 +2 -2
  94. data/man/man8/puppet-ssl.8 +5 -1
  95. data/man/man8/puppet.8 +2 -2
  96. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  97. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
  98. data/spec/integration/application/agent_spec.rb +160 -3
  99. data/spec/integration/application/apply_spec.rb +19 -0
  100. data/spec/integration/application/plugin_spec.rb +1 -1
  101. data/spec/integration/defaults_spec.rb +0 -7
  102. data/spec/integration/http/client_spec.rb +12 -0
  103. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  104. data/spec/integration/indirector/file_content/file_server_spec.rb +0 -2
  105. data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -2
  106. data/spec/integration/parser/collection_spec.rb +10 -0
  107. data/spec/integration/resource/type_collection_spec.rb +2 -6
  108. data/spec/integration/transaction_spec.rb +4 -9
  109. data/spec/integration/util/windows/adsi_spec.rb +21 -1
  110. data/spec/integration/util/windows/principal_spec.rb +21 -0
  111. data/spec/integration/util/windows/registry_spec.rb +6 -10
  112. data/spec/spec_helper.rb +12 -5
  113. data/spec/unit/agent_spec.rb +8 -6
  114. data/spec/unit/application/agent_spec.rb +0 -1
  115. data/spec/unit/application/facts_spec.rb +58 -7
  116. data/spec/unit/application/filebucket_spec.rb +0 -2
  117. data/spec/unit/application/ssl_spec.rb +23 -0
  118. data/spec/unit/application_spec.rb +17 -9
  119. data/spec/unit/confine/feature_spec.rb +1 -1
  120. data/spec/unit/confine_spec.rb +8 -2
  121. data/spec/unit/environments_spec.rb +164 -88
  122. data/spec/unit/face/node_spec.rb +0 -11
  123. data/spec/unit/file_serving/configuration/parser_spec.rb +8 -1
  124. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  125. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  126. data/spec/unit/file_system_spec.rb +9 -0
  127. data/spec/unit/forge/module_release_spec.rb +2 -7
  128. data/spec/unit/http/factory_spec.rb +19 -0
  129. data/spec/unit/indirector/face_spec.rb +0 -1
  130. data/spec/unit/indirector/facts/facter_spec.rb +20 -5
  131. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  132. data/spec/unit/indirector/indirection_spec.rb +8 -12
  133. data/spec/unit/indirector_spec.rb +2 -2
  134. data/spec/unit/module_spec.rb +1 -1
  135. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  136. data/spec/unit/network/formats_spec.rb +41 -0
  137. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -4
  138. data/spec/unit/network/http/api/master_spec.rb +38 -0
  139. data/spec/unit/network/http/api/{master → server}/v3/environments_spec.rb +2 -2
  140. data/spec/unit/network/http/api/{master → server}/v3_spec.rb +19 -19
  141. data/spec/unit/network/http/api_spec.rb +11 -11
  142. data/spec/unit/parser/compiler_spec.rb +3 -19
  143. data/spec/unit/parser/resource_spec.rb +14 -8
  144. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  145. data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
  146. data/spec/unit/pops/parser/lexer2_spec.rb +0 -4
  147. data/spec/unit/pops/types/type_parser_spec.rb +2 -1
  148. data/spec/unit/pops/validator/validator_spec.rb +20 -43
  149. data/spec/unit/property_spec.rb +1 -0
  150. data/spec/unit/provider/group/groupadd_spec.rb +5 -2
  151. data/spec/unit/provider/nameservice_spec.rb +66 -65
  152. data/spec/unit/provider/package/apt_spec.rb +28 -23
  153. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  154. data/spec/unit/provider/package/base_spec.rb +6 -5
  155. data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
  156. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  157. data/spec/unit/provider/package/pip_spec.rb +6 -11
  158. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  159. data/spec/unit/provider/package/puppet_gem_spec.rb +28 -0
  160. data/spec/unit/provider/service/systemd_spec.rb +11 -0
  161. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  162. data/spec/unit/provider/user/useradd_spec.rb +70 -3
  163. data/spec/unit/provider_spec.rb +6 -8
  164. data/spec/unit/resource/type_spec.rb +1 -1
  165. data/spec/unit/resource_spec.rb +11 -10
  166. data/spec/unit/settings_spec.rb +13 -6
  167. data/spec/unit/ssl/base_spec.rb +0 -1
  168. data/spec/unit/ssl/certificate_request_spec.rb +4 -10
  169. data/spec/unit/ssl/ssl_provider_spec.rb +5 -2
  170. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  171. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  172. data/spec/unit/transaction_spec.rb +13 -4
  173. data/spec/unit/type/file/content_spec.rb +0 -1
  174. data/spec/unit/type/file/selinux_spec.rb +0 -2
  175. data/spec/unit/type/file_spec.rb +0 -6
  176. data/spec/unit/type/group_spec.rb +13 -6
  177. data/spec/unit/type/resources_spec.rb +7 -7
  178. data/spec/unit/type/service_spec.rb +1 -1
  179. data/spec/unit/type/tidy_spec.rb +0 -1
  180. data/spec/unit/type_spec.rb +2 -2
  181. data/spec/unit/util/at_fork_spec.rb +2 -2
  182. data/spec/unit/util/autoload_spec.rb +5 -1
  183. data/spec/unit/util/backups_spec.rb +1 -2
  184. data/spec/unit/util/execution_spec.rb +15 -11
  185. data/spec/unit/util/inifile_spec.rb +6 -14
  186. data/spec/unit/util/log_spec.rb +8 -7
  187. data/spec/unit/util/logging_spec.rb +3 -3
  188. data/spec/unit/util/posix_spec.rb +16 -10
  189. data/spec/unit/util/selinux_spec.rb +76 -52
  190. data/spec/unit/util/suidmanager_spec.rb +44 -41
  191. data/spec/unit/util/windows/sid_spec.rb +6 -0
  192. data/spec/unit/util_spec.rb +13 -6
  193. metadata +18 -16
  194. data/spec/lib/matchers/include.rb +0 -27
  195. data/spec/lib/matchers/include_spec.rb +0 -32
  196. data/spec/unit/pops/parser/parse_application_spec.rb +0 -13
  197. data/spec/unit/pops/parser/parse_capabilities_spec.rb +0 -23
  198. data/spec/unit/pops/parser/parse_site_spec.rb +0 -43
@@ -15,13 +15,6 @@ describe Puppet::Face[:node, '0.0.1'] do
15
15
  end
16
16
 
17
17
  describe 'when running #clean' do
18
- before :each do
19
- allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
20
- allow(Puppet::Node::Facts.indirection).to receive(:cache_class=)
21
- allow(Puppet::Node).to receive(:terminus_class=)
22
- allow(Puppet::Node).to receive(:cache_class=)
23
- end
24
-
25
18
  it 'should invoke #cleanup' do
26
19
  expect(subject).to receive(:cleanup).with('hostname')
27
20
  subject.clean('hostname')
@@ -30,10 +23,6 @@ describe Puppet::Face[:node, '0.0.1'] do
30
23
 
31
24
  describe "clean action" do
32
25
  before :each do
33
- allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
34
- allow(Puppet::Node::Facts.indirection).to receive(:cache_class=)
35
- allow(Puppet::Node).to receive(:terminus_class=)
36
- allow(Puppet::Node).to receive(:cache_class=)
37
26
  allow(subject).to receive(:cleanup)
38
27
  end
39
28
 
@@ -87,7 +87,6 @@ describe Puppet::FileServing::Configuration::Parser do
87
87
  before do
88
88
  @mount = double('testmount', :name => "one", :validate => true)
89
89
  expect(Puppet::FileServing::Mount::File).to receive(:new).with("one").and_return(@mount)
90
- allow(@parser).to receive(:add_modules_mount)
91
90
  end
92
91
 
93
92
  it "should set the mount path to the path attribute from that section" do
@@ -122,6 +121,14 @@ describe Puppet::FileServing::Configuration::Parser do
122
121
  end
123
122
  }
124
123
 
124
+ it "should not generate an error when parsing 'allow *'" do
125
+ write_config_file "[one]\nallow *\n"
126
+
127
+ expect(Puppet).to receive(:err).never
128
+
129
+ @parser.parse
130
+ end
131
+
125
132
  it "should return comprehensible error message, if failed on invalid attribute" do
126
133
  write_config_file "[one]\ndo something\n"
127
134
 
@@ -266,9 +266,9 @@ describe Puppet::FileServing::Metadata, :uses_checksums => true do
266
266
  path = tmpfile('bar')
267
267
  FileUtils.touch(path)
268
268
 
269
- allow(Puppet::Util::Windows::Security).to receive(:get_owner).with(path, :use).and_raise(invalid_error)
270
- allow(Puppet::Util::Windows::Security).to receive(:get_group).with(path, :use).and_raise(invalid_error)
271
- allow(Puppet::Util::Windows::Security).to receive(:get_mode).with(path, :use).and_raise(invalid_error)
269
+ allow(Puppet::Util::Windows::Security).to receive(:get_owner).with(path).and_raise(invalid_error)
270
+ allow(Puppet::Util::Windows::Security).to receive(:get_group).with(path).and_raise(invalid_error)
271
+ allow(Puppet::Util::Windows::Security).to receive(:get_mode).with(path).and_raise(invalid_error)
272
272
 
273
273
  stat = Puppet::FileSystem.stat(path)
274
274
 
@@ -2,13 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  require 'puppet/file_serving/terminus_helper'
4
4
 
5
+ class Puppet::FileServing::TestHelper
6
+ include Puppet::FileServing::TerminusHelper
7
+
8
+ attr_reader :model
9
+
10
+ def initialize(model)
11
+ @model = model
12
+ end
13
+ end
14
+
5
15
  describe Puppet::FileServing::TerminusHelper do
6
16
  before do
7
- @helper = Object.new
8
- @helper.extend(Puppet::FileServing::TerminusHelper)
9
-
10
17
  @model = double('model')
11
- allow(@helper).to receive(:model).and_return(@model)
18
+ @helper = Puppet::FileServing::TestHelper.new(@model)
12
19
 
13
20
  @request = double('request', :key => "url", :options => {})
14
21
 
@@ -999,6 +999,15 @@ describe "Puppet::FileSystem" do
999
999
  Puppet::FileSystem.replace_file(dest, 0755) { |_| }
1000
1000
  }.to raise_error(ArgumentError, /Only modes 0644, 0640, 0660, and 0440 are allowed/)
1001
1001
  end
1002
+
1003
+ it 'falls back to fully qualified user name when sid retrieval fails' do
1004
+ current_user_sid = Puppet::Util::Windows::SID.name_to_sid(Puppet::Util::Windows::ADSI::User.current_user_name)
1005
+ allow(Puppet::Util::Windows::SID).to receive(:name_to_sid).with(Puppet::Util::Windows::ADSI::User.current_user_name).and_return(nil, current_user_sid)
1006
+ allow(Puppet::Util::Windows::SID).to receive(:name_to_sid).with(Puppet::Util::Windows::ADSI::User.current_sam_compatible_user_name).and_call_original
1007
+
1008
+ Puppet::FileSystem.replace_file(dest, 0644) { |f| f.write(content) }
1009
+ expects_public_file(dest)
1010
+ end
1002
1011
  end
1003
1012
  end
1004
1013
 
@@ -22,13 +22,8 @@ describe Puppet::Forge::ModuleRelease do
22
22
  let(:uri) { " "}
23
23
  let(:release) { Puppet::Forge::ModuleRelease.new(ssl_repository, JSON.parse(release_json)) }
24
24
 
25
- let(:mock_file) {
26
- mock_io = StringIO.new
27
- allow(mock_io).to receive(:path).and_return('/dev/null')
28
- mock_io
29
- }
30
-
31
- let(:mock_dir) { '/tmp' }
25
+ let(:mock_file) { double('file', path: '/dev/null') }
26
+ let(:mock_dir) { tmpdir('dir') }
32
27
 
33
28
  let(:destination) { tmpfile('forge_module_release') }
34
29
 
@@ -138,4 +138,23 @@ describe Puppet::HTTP::Factory do
138
138
  expect(conn.local_host).to eq('127.0.0.1')
139
139
  end
140
140
  end
141
+
142
+ context 'tls' do
143
+ it "sets the minimum version to TLS 1.0", if: RUBY_VERSION.to_f >= 2.5 do
144
+ conn = create_connection(site)
145
+ expect(conn.min_version).to eq(OpenSSL::SSL::TLS1_VERSION)
146
+ end
147
+
148
+ it "defaults to ciphersuites providing 128 bits of security or greater" do
149
+ conn = create_connection(site)
150
+ expect(conn.ciphers).to eq("ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256")
151
+ end
152
+
153
+ it "can be restricted to TLSv1.3 ciphers" do
154
+ tls13_ciphers = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256"
155
+ Puppet[:ciphers] = tls13_ciphers
156
+ conn = create_connection(site)
157
+ expect(conn.ciphers).to eq(tls13_ciphers)
158
+ end
159
+ end
141
160
  end
@@ -33,7 +33,6 @@ describe Puppet::Indirector::Face do
33
33
  describe "as an instance" do
34
34
  it "should be able to determine its indirection" do
35
35
  # Loading actions here can get, um, complicated
36
- allow(Puppet::Face).to receive(:load_actions)
37
36
  expect(Puppet::Indirector::Face.new(:catalog, '0.0.1').indirection).to equal(Puppet::Resource::Catalog.indirection)
38
37
  end
39
38
  end
@@ -22,7 +22,6 @@ describe Puppet::Node::Facts::Facter do
22
22
  end
23
23
 
24
24
  before :each do
25
- allow(Puppet::Node::Facts::Facter).to receive(:reload_facter)
26
25
  @facter = Puppet::Node::Facts::Facter.new
27
26
  allow(Facter).to receive(:to_hash).and_return({})
28
27
  @name = "me"
@@ -154,19 +153,17 @@ describe Puppet::Node::Facts::Facter do
154
153
  end
155
154
 
156
155
  describe 'when :resolve_options is true' do
157
- let(:options) { { resolve_options: true, user_query: ["os", "timezone"], show_legacy: true } }
156
+ let(:options) { { resolve_options: true, user_query: ["os", "timezone"] } }
158
157
  let(:facts) { Puppet::Node::Facts.new("foo") }
159
158
 
160
159
  before :each do
161
160
  allow(@request).to receive(:options).and_return(options)
162
161
  allow(Puppet::Node::Facts).to receive(:new).and_return(facts)
163
- allow(Facter).to receive(:respond_to?).and_return(false)
164
- allow(Facter).to receive(:respond_to?).with(:resolve).and_return(true)
165
162
  allow(facts).to receive(:add_local_facts)
166
163
  end
167
164
 
168
165
  it 'should call Facter.resolve method' do
169
- expect(Facter).to receive(:resolve).with("os timezone --show-legacy")
166
+ expect(Facter).to receive(:resolve).with("os timezone")
170
167
  @facter.find(@request)
171
168
  end
172
169
 
@@ -176,6 +173,24 @@ describe Puppet::Node::Facts::Facter do
176
173
  @facter.find(@request)
177
174
  end
178
175
 
176
+ context 'when --show-legacy flag is present' do
177
+ let(:options) { { resolve_options: true, user_query: ["os", "timezone"], show_legacy: true } }
178
+
179
+ it 'should call Facter.resolve method with show-legacy' do
180
+ expect(Facter).to receive(:resolve).with("os timezone --show-legacy")
181
+ @facter.find(@request)
182
+ end
183
+ end
184
+
185
+ context 'when --timing flag is present' do
186
+ let(:options) { { resolve_options: true, user_query: ["os", "timezone"], timing: true } }
187
+
188
+ it 'calls Facter.resolve with --timing' do
189
+ expect(Facter).to receive(:resolve).with("os timezone --timing")
190
+ @facter.find(@request)
191
+ end
192
+ end
193
+
179
194
  describe 'when Facter version is lower than 4.0.40' do
180
195
  before :each do
181
196
  allow(Facter).to receive(:respond_to?).and_return(false)
@@ -5,22 +5,40 @@ require 'puppet/indirector/file_bucket_file/file'
5
5
  require 'puppet/indirector/file_bucket_file/rest'
6
6
 
7
7
  describe Puppet::FileBucketFile::Selector do
8
+ let(:model) { Puppet::FileBucket::File.new('') }
9
+ let(:indirection) { Puppet::FileBucket::File.indirection }
10
+ let(:terminus) { indirection.terminus(:selector) }
11
+
8
12
  %w[head find save search destroy].each do |method|
9
13
  describe "##{method}" do
10
14
  it "should proxy to rest terminus for https requests" do
11
- request = double('request', :protocol => 'https')
15
+ key = "https://example.com/path/to/file"
12
16
 
13
- expect_any_instance_of(Puppet::FileBucketFile::Rest).to receive(method).with(request)
17
+ expect(indirection.terminus(:rest)).to receive(method)
14
18
 
15
- subject.send(method, request)
19
+ if method == 'save'
20
+ terminus.send(method, indirection.request(method, key, model))
21
+ else
22
+ terminus.send(method, indirection.request(method, key, nil))
23
+ end
16
24
  end
17
25
 
18
26
  it "should proxy to file terminus for other requests" do
19
- request = double('request', :protocol => 'file')
20
-
21
- expect_any_instance_of(Puppet::FileBucketFile::File).to receive(method).with(request)
22
-
23
- subject.send(method, request)
27
+ key = "file:///path/to/file"
28
+
29
+ case method
30
+ when 'save'
31
+ expect(indirection.terminus(:file)).to receive(method)
32
+ terminus.send(method, indirection.request(method, key, model))
33
+ when 'find', 'head'
34
+ expect(indirection.terminus(:file)).to receive(method)
35
+ terminus.send(method, indirection.request(method, key, nil))
36
+ else
37
+ # file terminus doesn't implement search or destroy
38
+ expect {
39
+ terminus.send(method, indirection.request(method, key, nil))
40
+ }.to raise_error(NoMethodError)
41
+ end
24
42
  end
25
43
  end
26
44
  end
@@ -178,29 +178,25 @@ describe Puppet::Indirector::Indirection do
178
178
 
179
179
  describe "creates a request" do
180
180
  it "should create it with its name as the request's indirection name" do
181
- expect(Puppet::Indirector::Request).to receive(:new).with(@indirection.name, anything, anything)
182
- @indirection.request(:funtest, "yayness")
181
+ expect(@indirection.request(:funtest, "yayness", nil).indirection_name).to eq(@indirection.name)
183
182
  end
184
183
 
185
184
  it "should require a method and key" do
186
- expect(Puppet::Indirector::Request).to receive(:new).with(anything, :funtest, "yayness")
187
- @indirection.request(:funtest, "yayness")
185
+ request = @indirection.request(:funtest, "yayness", nil)
186
+ expect(request.method).to eq(:funtest)
187
+ expect(request.key).to eq("yayness")
188
188
  end
189
189
 
190
190
  it "should support optional arguments" do
191
- expect(Puppet::Indirector::Request).to receive(:new).with(anything, anything, anything, {:one => :two})
192
- @indirection.request(:funtest, "yayness", :one => :two)
191
+ expect(@indirection.request(:funtest, "yayness", nil, :one => :two).options).to eq(:one => :two)
193
192
  end
194
193
 
195
194
  it "should not pass options if none are supplied" do
196
- expect(Puppet::Indirector::Request).to receive(:new).with(anything, anything, anything)
197
- @indirection.request(:funtest, "yayness")
195
+ expect(@indirection.request(:funtest, "yayness", nil).options).to eq({})
198
196
  end
199
197
 
200
198
  it "should return the request" do
201
- request = double('request')
202
- expect(Puppet::Indirector::Request).to receive(:new).and_return(request)
203
- expect(@indirection.request(:funtest, "yayness")).to equal(request)
199
+ expect(@indirection.request(:funtest, "yayness", nil)).to be_a(Puppet::Indirector::Request)
204
200
  end
205
201
  end
206
202
 
@@ -833,7 +829,7 @@ describe Puppet::Indirector::Indirection do
833
829
  end
834
830
 
835
831
  it "should not create a terminus instance until one is actually needed" do
836
- expect(Puppet::Indirector).not_to receive(:terminus)
832
+ expect(@indirection).not_to receive(:terminus)
837
833
  Puppet::Indirector::Indirection.new(double('model'), :lazytest)
838
834
  end
839
835
 
@@ -112,8 +112,8 @@ describe Puppet::Indirector, "when registering an indirection" do
112
112
  end
113
113
 
114
114
  it "should pass any provided options to the indirection during initialization" do
115
- expect(Puppet::Indirector::Indirection).to receive(:new).with(@thingie, :first, {:some => :options, :indirected_class => 'Thingie'})
116
- @indirection = @thingie.indirects :first, :some => :options
115
+ expect(Puppet::Indirector::Indirection).to receive(:new).with(@thingie, :first, {:doc => 'some docs', :indirected_class => 'Thingie'})
116
+ @indirection = @thingie.indirects :first, :doc => 'some docs'
117
117
  end
118
118
 
119
119
  it "should extend the class to handle serialization" do
@@ -478,7 +478,7 @@ describe Puppet::Module do
478
478
  end
479
479
  end
480
480
 
481
- [:plugins, :pluginfacts, :templates, :files, :manifests].each do |filetype|
481
+ [:plugins, :pluginfacts, :templates, :files, :manifests, :scripts].each do |filetype|
482
482
  case filetype
483
483
  when :plugins
484
484
  dirname = "lib"
@@ -247,6 +247,21 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
247
247
  expect(subject).to include :result => :success
248
248
  graph_should_include 'pmtacceptance-mysql', nil => v('0.8.0')
249
249
  end
250
+
251
+ context 'with an already installed dependency' do
252
+ before { preinstall('pmtacceptance-stdlib', '2.6.0') }
253
+
254
+ def options
255
+ super.merge(:version => '0.7.0')
256
+ end
257
+
258
+ it 'installs given version without errors and does not change version of dependency' do
259
+ expect(subject).to include :result => :success
260
+ graph_should_include 'pmtacceptance-mysql', nil => v('0.7.0')
261
+ expect(subject[:error]).to be_nil
262
+ graph_should_include 'pmtacceptance-stdlib', v('2.6.0') => v('2.6.0')
263
+ end
264
+ end
250
265
  end
251
266
 
252
267
  context 'with a --version that cannot satisfy' do
@@ -258,6 +273,20 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
258
273
  expect(subject).to include :result => :failure
259
274
  end
260
275
 
276
+ it 'prints a detailed error containing the modules that would not be satisfied' do
277
+ graph = double(SemanticPuppet::Dependency::Graph, :modules => ['pmtacceptance-mysql'])
278
+ exception = SemanticPuppet::Dependency::UnsatisfiableGraph.new(graph)
279
+ allow(exception).to receive(:respond_to?).and_return(true)
280
+ allow(exception).to receive(:unsatisfied).and_return('pmtacceptance-mysql')
281
+ allow(SemanticPuppet::Dependency).to receive(:resolve).and_raise(exception)
282
+
283
+ expect(subject[:error]).to include(:multiline)
284
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (> 1.0.0)")
285
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy one or more of the following installed modules:")
286
+ expect(subject[:error][:multiline]).to include("pmtacceptance-keystone, expects 'pmtacceptance-mysql': >=0.6.1 <1.0.0")
287
+ expect(subject[:error][:multiline]).to include("Use `puppet module install 'pmtacceptance-mysql' --ignore-dependencies` to install only this module")
288
+ end
289
+
261
290
  context 'with --ignore-dependencies' do
262
291
  def options
263
292
  super.merge(:ignore_dependencies => true)
@@ -278,6 +307,43 @@ describe Puppet::ModuleTool::Applications::Installer, :unless => RUBY_PLATFORM =
278
307
  graph_should_include 'pmtacceptance-mysql', nil => v('2.1.0')
279
308
  end
280
309
  end
310
+
311
+ context 'with an already installed dependency' do
312
+ let(:graph) {
313
+ double(SemanticPuppet::Dependency::Graph,
314
+ :dependencies => {
315
+ 'pmtacceptance-mysql' => {
316
+ :version => '2.1.0'
317
+ }
318
+ },
319
+ :modules => ['pmtacceptance-mysql'],
320
+ :unsatisfied => 'pmtacceptance-stdlib'
321
+ )
322
+ }
323
+
324
+ let(:unsatisfiable_graph_exception) { SemanticPuppet::Dependency::UnsatisfiableGraph.new(graph) }
325
+
326
+ before do
327
+ allow(SemanticPuppet::Dependency).to receive(:resolve).and_raise(unsatisfiable_graph_exception)
328
+ allow(unsatisfiable_graph_exception).to receive(:respond_to?).and_return(true)
329
+ allow(unsatisfiable_graph_exception).to receive(:unsatisfied).and_return(graph.unsatisfied)
330
+
331
+ preinstall('pmtacceptance-stdlib', '2.6.0')
332
+ end
333
+
334
+ def options
335
+ super.merge(:version => '2.1.0')
336
+ end
337
+
338
+ it 'fails to install and outputs a multiline error containing the versions, expectations and workaround' do
339
+ expect(subject).to include :result => :failure
340
+ expect(subject[:error]).to include(:multiline)
341
+ expect(subject[:error][:multiline]).to include("Could not install module 'pmtacceptance-mysql' (v2.1.0)")
342
+ expect(subject[:error][:multiline]).to include("The requested version cannot satisfy one or more of the following installed modules:")
343
+ expect(subject[:error][:multiline]).to include("pmtacceptance-stdlib, installed: 2.6.0, expected: >= 2.2.1")
344
+ expect(subject[:error][:multiline]).to include("Use `puppet module install 'pmtacceptance-mysql' --ignore-dependencies` to install only this module")
345
+ end
346
+ end
281
347
  end
282
348
  end
283
349
 
@@ -534,4 +534,45 @@ EOT
534
534
  end
535
535
  end
536
536
  end
537
+
538
+ describe ":flat format" do
539
+ let(:flat) { Puppet::Network::FormatHandler.format(:flat) }
540
+
541
+ it "should include a flat format" do
542
+ expect(flat).to be_an_instance_of Puppet::Network::Format
543
+ end
544
+
545
+ [:intern, :intern_multiple].each do |method|
546
+ it "should not implement #{method}" do
547
+ expect { flat.send(method, String, 'blah') }.to raise_error NotImplementedError
548
+ end
549
+ end
550
+
551
+ context "when rendering arrays" do
552
+ {
553
+ [] => "",
554
+ [1, 2] => "0=1\n1=2\n",
555
+ ["one"] => "0=one\n",
556
+ [{"one" => 1}, {"two" => 2}] => "0.one=1\n1.two=2\n",
557
+ [['something', 'for'], ['the', 'test']] => "0=[\"something\", \"for\"]\n1=[\"the\", \"test\"]\n"
558
+ }.each_pair do |input, output|
559
+ it "should render #{input.inspect} as one item per line" do
560
+ expect(flat.render(input)).to eq(output)
561
+ end
562
+ end
563
+ end
564
+
565
+ context "when rendering hashes" do
566
+ {
567
+ {} => "",
568
+ {1 => 2} => "1=2\n",
569
+ {"one" => "two"} => "one=two\n",
570
+ {[1,2] => 3, [2,3] => 5, [3,4] => 7} => "[1, 2]=3\n[2, 3]=5\n[3, 4]=7\n",
571
+ }.each_pair do |input, output|
572
+ it "should render #{input.inspect}" do
573
+ expect(flat.render(input)).to eq(output)
574
+ end
575
+ end
576
+ end
577
+ end
537
578
  end