puppet 6.19.1-x64-mingw32 → 6.20.0-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 (171) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -16
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +30 -25
  5. data/lib/puppet/application.rb +10 -6
  6. data/lib/puppet/application/agent.rb +1 -0
  7. data/lib/puppet/application/apply.rb +3 -2
  8. data/lib/puppet/application/device.rb +1 -0
  9. data/lib/puppet/application/filebucket.rb +2 -2
  10. data/lib/puppet/application/script.rb +1 -0
  11. data/lib/puppet/application_support.rb +7 -0
  12. data/lib/puppet/configurer.rb +28 -18
  13. data/lib/puppet/defaults.rb +24 -18
  14. data/lib/puppet/environments.rb +38 -54
  15. data/lib/puppet/face/config.rb +10 -0
  16. data/lib/puppet/face/epp.rb +12 -2
  17. data/lib/puppet/face/facts.rb +60 -0
  18. data/lib/puppet/ffi/posix.rb +10 -0
  19. data/lib/puppet/ffi/posix/constants.rb +14 -0
  20. data/lib/puppet/ffi/posix/functions.rb +24 -0
  21. data/lib/puppet/functions/epp.rb +1 -0
  22. data/lib/puppet/functions/inline_epp.rb +1 -0
  23. data/lib/puppet/indirector/fact_search.rb +60 -0
  24. data/lib/puppet/indirector/facts/json.rb +27 -0
  25. data/lib/puppet/indirector/facts/yaml.rb +3 -58
  26. data/lib/puppet/indirector/json.rb +5 -1
  27. data/lib/puppet/indirector/node/json.rb +8 -0
  28. data/lib/puppet/indirector/report/json.rb +34 -0
  29. data/lib/puppet/module_tool/applications/installer.rb +48 -2
  30. data/lib/puppet/module_tool/errors/shared.rb +17 -2
  31. data/lib/puppet/network/formats.rb +2 -1
  32. data/lib/puppet/pal/pal_impl.rb +70 -17
  33. data/lib/puppet/parser/ast/leaf.rb +3 -2
  34. data/lib/puppet/parser/templatewrapper.rb +1 -1
  35. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  36. data/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -3
  37. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  38. data/lib/puppet/provider/package/apt.rb +4 -0
  39. data/lib/puppet/provider/user/aix.rb +2 -2
  40. data/lib/puppet/reference/configuration.rb +6 -5
  41. data/lib/puppet/settings.rb +33 -28
  42. data/lib/puppet/settings/alias_setting.rb +37 -0
  43. data/lib/puppet/settings/base_setting.rb +26 -2
  44. data/lib/puppet/util/autoload.rb +1 -8
  45. data/lib/puppet/util/fact_dif.rb +62 -0
  46. data/lib/puppet/util/posix.rb +54 -5
  47. data/lib/puppet/util/rubygems.rb +5 -1
  48. data/lib/puppet/version.rb +1 -1
  49. data/locales/puppet.pot +188 -164
  50. data/man/man5/puppet.conf.5 +6 -6
  51. data/man/man8/puppet-agent.8 +2 -2
  52. data/man/man8/puppet-apply.8 +2 -2
  53. data/man/man8/puppet-catalog.8 +1 -1
  54. data/man/man8/puppet-config.8 +1 -1
  55. data/man/man8/puppet-describe.8 +1 -1
  56. data/man/man8/puppet-device.8 +2 -2
  57. data/man/man8/puppet-doc.8 +1 -1
  58. data/man/man8/puppet-epp.8 +1 -1
  59. data/man/man8/puppet-facts.8 +32 -1
  60. data/man/man8/puppet-filebucket.8 +3 -3
  61. data/man/man8/puppet-generate.8 +1 -1
  62. data/man/man8/puppet-help.8 +1 -1
  63. data/man/man8/puppet-key.8 +1 -1
  64. data/man/man8/puppet-lookup.8 +1 -1
  65. data/man/man8/puppet-man.8 +1 -1
  66. data/man/man8/puppet-module.8 +1 -1
  67. data/man/man8/puppet-node.8 +4 -1
  68. data/man/man8/puppet-parser.8 +1 -1
  69. data/man/man8/puppet-plugin.8 +1 -1
  70. data/man/man8/puppet-report.8 +4 -1
  71. data/man/man8/puppet-resource.8 +1 -1
  72. data/man/man8/puppet-script.8 +2 -2
  73. data/man/man8/puppet-ssl.8 +1 -1
  74. data/man/man8/puppet-status.8 +1 -1
  75. data/man/man8/puppet.8 +2 -2
  76. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  77. data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
  78. data/spec/integration/application/agent_spec.rb +127 -3
  79. data/spec/integration/application/apply_spec.rb +19 -0
  80. data/spec/integration/defaults_spec.rb +0 -7
  81. data/spec/integration/environments/setting_hooks_spec.rb +1 -1
  82. data/spec/integration/resource/type_collection_spec.rb +2 -6
  83. data/spec/integration/transaction_spec.rb +4 -9
  84. data/spec/integration/util/windows/adsi_spec.rb +3 -1
  85. data/spec/integration/util/windows/registry_spec.rb +0 -10
  86. data/spec/lib/puppet_spec/settings.rb +6 -1
  87. data/spec/spec_helper.rb +1 -4
  88. data/spec/unit/agent_spec.rb +8 -6
  89. data/spec/unit/application/agent_spec.rb +0 -1
  90. data/spec/unit/application/config_spec.rb +224 -4
  91. data/spec/unit/application/filebucket_spec.rb +0 -2
  92. data/spec/unit/application_spec.rb +51 -9
  93. data/spec/unit/confine/feature_spec.rb +1 -1
  94. data/spec/unit/confine_spec.rb +8 -2
  95. data/spec/unit/defaults_spec.rb +20 -1
  96. data/spec/unit/environments_spec.rb +96 -19
  97. data/spec/unit/face/config_spec.rb +27 -32
  98. data/spec/unit/face/node_spec.rb +0 -11
  99. data/spec/unit/file_serving/configuration/parser_spec.rb +0 -1
  100. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  101. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  102. data/spec/unit/forge/module_release_spec.rb +2 -7
  103. data/spec/unit/functions/inline_epp_spec.rb +26 -1
  104. data/spec/unit/http/service/compiler_spec.rb +49 -0
  105. data/spec/unit/http/service_spec.rb +1 -1
  106. data/spec/unit/indirector/face_spec.rb +0 -1
  107. data/spec/unit/indirector/facts/facter_spec.rb +0 -1
  108. data/spec/unit/indirector/facts/json_spec.rb +255 -0
  109. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  110. data/spec/unit/indirector/indirection_spec.rb +8 -12
  111. data/spec/unit/indirector/key/file_spec.rb +0 -1
  112. data/spec/unit/indirector/node/json_spec.rb +33 -0
  113. data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
  114. data/spec/unit/indirector/report/yaml_spec.rb +72 -8
  115. data/spec/unit/indirector_spec.rb +2 -2
  116. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  117. data/spec/unit/network/authconfig_spec.rb +0 -3
  118. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -9
  119. data/spec/unit/network/http/handler_spec.rb +0 -5
  120. data/spec/unit/parser/compiler_spec.rb +3 -19
  121. data/spec/unit/parser/resource_spec.rb +14 -8
  122. data/spec/unit/parser/templatewrapper_spec.rb +4 -3
  123. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  124. data/spec/unit/property_spec.rb +1 -0
  125. data/spec/unit/provider/nameservice_spec.rb +66 -65
  126. data/spec/unit/provider/package/apt_spec.rb +4 -8
  127. data/spec/unit/provider/package/base_spec.rb +6 -5
  128. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  129. data/spec/unit/provider/package/pip_spec.rb +6 -11
  130. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  131. data/spec/unit/provider/user/aix_spec.rb +5 -0
  132. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  133. data/spec/unit/provider/user/pw_spec.rb +2 -0
  134. data/spec/unit/provider/user/useradd_spec.rb +1 -0
  135. data/spec/unit/provider_spec.rb +8 -10
  136. data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
  137. data/spec/unit/resource/capability_finder_spec.rb +6 -1
  138. data/spec/unit/resource/type_spec.rb +1 -1
  139. data/spec/unit/resource_spec.rb +11 -10
  140. data/spec/unit/settings_spec.rb +419 -242
  141. data/spec/unit/ssl/base_spec.rb +0 -1
  142. data/spec/unit/ssl/host_spec.rb +0 -5
  143. data/spec/unit/ssl/ssl_provider_spec.rb +14 -8
  144. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  145. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  146. data/spec/unit/transaction_spec.rb +13 -4
  147. data/spec/unit/type/file/content_spec.rb +0 -1
  148. data/spec/unit/type/file/selinux_spec.rb +0 -2
  149. data/spec/unit/type/file_spec.rb +0 -6
  150. data/spec/unit/type/group_spec.rb +13 -6
  151. data/spec/unit/type/resources_spec.rb +7 -7
  152. data/spec/unit/type/service_spec.rb +1 -1
  153. data/spec/unit/type/tidy_spec.rb +0 -1
  154. data/spec/unit/type_spec.rb +2 -2
  155. data/spec/unit/util/at_fork_spec.rb +2 -2
  156. data/spec/unit/util/autoload_spec.rb +5 -1
  157. data/spec/unit/util/backups_spec.rb +1 -2
  158. data/spec/unit/util/execution_spec.rb +15 -11
  159. data/spec/unit/util/inifile_spec.rb +6 -14
  160. data/spec/unit/util/log_spec.rb +8 -7
  161. data/spec/unit/util/logging_spec.rb +3 -3
  162. data/spec/unit/util/posix_spec.rb +363 -15
  163. data/spec/unit/util/rubygems_spec.rb +2 -2
  164. data/spec/unit/util/selinux_spec.rb +76 -52
  165. data/spec/unit/util/storage_spec.rb +3 -1
  166. data/spec/unit/util/suidmanager_spec.rb +44 -41
  167. data/spec/unit/util_spec.rb +13 -6
  168. metadata +21 -10
  169. data/spec/integration/application/config_spec.rb +0 -74
  170. data/spec/unit/face/catalog_spec.rb +0 -6
  171. data/spec/unit/face/module_spec.rb +0 -3
@@ -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
 
@@ -19,7 +19,6 @@ describe Puppet::SSL::Key::File do
19
19
  allow(Puppet.settings).to receive(:use)
20
20
 
21
21
  @searcher = Puppet::SSL::Key::File.new
22
- allow(@searcher).to receive(:ca?).and_return(false)
23
22
  expect(@searcher.public_key_path("whatever")).to eq(File.expand_path("/public/key/dir/whatever.pem"))
24
23
  end
25
24
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'puppet/node'
3
+ require 'puppet/indirector/node/json'
4
+
5
+ describe Puppet::Node::Json do
6
+ describe '#save' do
7
+ subject(:indirection) { described_class.indirection }
8
+
9
+ let(:env) { Puppet::Node::Environment.create(:testing, []) }
10
+ let(:node) { Puppet::Node.new('node_name', :environment => env) }
11
+ let(:file) { File.join(Puppet[:client_datadir], "node", "node_name.json") }
12
+
13
+ before do
14
+ indirection.terminus_class = :json
15
+ end
16
+
17
+ it 'saves the instance of the node as JSON to disk' do
18
+ indirection.save(node)
19
+ json = Puppet::FileSystem.read(file, :encoding => 'bom|utf-8')
20
+ content = Puppet::Util::Json.load(json)
21
+ expect(content["name"]).to eq('node_name')
22
+ end
23
+
24
+ context 'when node cannot be saved' do
25
+ it 'raises Errno::EISDIR' do
26
+ FileUtils.mkdir_p(file)
27
+ expect {
28
+ indirection.save(node)
29
+ }.to raise_error(Errno::EISDIR, /node_name.json/)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  require 'puppet/transaction/report'
4
- require 'puppet/indirector/report/yaml'
4
+ require 'puppet/indirector/report/json'
5
5
 
6
- describe Puppet::Transaction::Report::Yaml do
6
+ describe Puppet::Transaction::Report::Json do
7
+ include PuppetSpec::Files
7
8
  describe '#save' do
8
9
  subject(:indirection) { described_class.indirection }
9
10
 
@@ -17,19 +18,17 @@ describe Puppet::Transaction::Report::Yaml do
17
18
  let(:file) { request.path(:me) }
18
19
 
19
20
  before do
20
- indirection.terminus_class = :yaml
21
- end
21
+ Puppet[:lastrunreport] = File.join(Puppet[:statedir], "last_run_report.json")
22
22
 
23
- it 'is saves a report' do
24
- indirection.save(report)
23
+ indirection.terminus_class = :json
25
24
  end
26
25
 
27
- it 'saves the instance of the report as YAML to disk' do
26
+ it 'saves the instance of the report as JSON to disk' do
27
+
28
28
  indirection.save(report)
29
- content = Puppet::Util::Yaml.safe_load_file(
30
- Puppet[:lastrunreport], [Puppet::Transaction::Report]
31
- )
32
- expect(content.host).to eq(certname)
29
+ json = Puppet::FileSystem.read(Puppet[:lastrunreport], :encoding => 'bom|utf-8')
30
+ content = Puppet::Util::Json.load(json)
31
+ expect(content["host"]).to eq(certname)
33
32
  end
34
33
 
35
34
  it 'allows mode overwrite' do
@@ -37,8 +36,7 @@ describe Puppet::Transaction::Report::Yaml do
37
36
  indirection.save(report)
38
37
 
39
38
  if Puppet::Util::Platform.windows?
40
- require 'puppet/util/windows/security'
41
- mode = Puppet::Util::Windows::Security.get_mode(file)
39
+ mode = File.stat(file).mode
42
40
  else
43
41
  mode = Puppet::FileSystem.stat(file).mode
44
42
  end
@@ -62,21 +60,12 @@ describe Puppet::Transaction::Report::Yaml do
62
60
  end
63
61
  end
64
62
 
65
- context 'when repport is invalid' do
66
- it 'logs error' do
67
- expect(Puppet).to receive(:send_log).with(:err, /Could not save yaml ziggy: can't dump anonymous class/)
68
-
69
- report.configuration_version = Class.new
70
- indirection.save(report)
71
- end
72
- end
73
-
74
63
  context 'when report cannot be saved' do
75
- it 'raises Errno::EISDIR' do
64
+ it 'raises Error' do
76
65
  FileUtils.mkdir_p(file)
77
66
  expect {
78
67
  indirection.save(report)
79
- }.to raise_error(Errno::EISDIR, /last_run_report.yaml/)
68
+ }.to raise_error(Errno::EISDIR, /last_run_report.json/)
80
69
  end
81
70
  end
82
71
  end
@@ -4,14 +4,6 @@ require 'puppet/transaction/report'
4
4
  require 'puppet/indirector/report/yaml'
5
5
 
6
6
  describe Puppet::Transaction::Report::Yaml do
7
- it "should be a subclass of the Yaml terminus" do
8
- expect(Puppet::Transaction::Report::Yaml.superclass).to equal(Puppet::Indirector::Yaml)
9
- end
10
-
11
- it "should have documentation" do
12
- expect(Puppet::Transaction::Report::Yaml.doc).not_to be_nil
13
- end
14
-
15
7
  it "should be registered with the report indirection" do
16
8
  indirection = Puppet::Indirector::Indirection.instance(:report)
17
9
  expect(Puppet::Transaction::Report::Yaml.indirection).to equal(indirection)
@@ -24,4 +16,76 @@ describe Puppet::Transaction::Report::Yaml do
24
16
  it "should unconditionally save/load from the --lastrunreport setting" do
25
17
  expect(subject.path(:me)).to eq(Puppet[:lastrunreport])
26
18
  end
19
+
20
+ describe '#save' do
21
+ subject(:indirection) { described_class.indirection }
22
+
23
+ let(:request) { described_class.new }
24
+ let(:certname) { 'ziggy' }
25
+ let(:report) do
26
+ report = Puppet::Transaction::Report.new
27
+ report.host = certname
28
+ report
29
+ end
30
+ let(:file) { request.path(:me) }
31
+
32
+ before do
33
+ indirection.terminus_class = :yaml
34
+ end
35
+
36
+ it 'saves the instance of the report as YAML to disk' do
37
+ indirection.save(report)
38
+ content = Puppet::Util::Yaml.safe_load_file(
39
+ Puppet[:lastrunreport], [Puppet::Transaction::Report]
40
+ )
41
+ expect(content.host).to eq(certname)
42
+ end
43
+
44
+ it 'allows mode overwrite' do
45
+ Puppet.settings.setting(:lastrunreport).mode = '0644'
46
+ indirection.save(report)
47
+
48
+ if Puppet::Util::Platform.windows?
49
+ mode = File.stat(file).mode
50
+ else
51
+ mode = Puppet::FileSystem.stat(file).mode
52
+ end
53
+
54
+ expect(mode & 07777).to eq(0644)
55
+ end
56
+
57
+ context 'when mode is invalid' do
58
+ before do
59
+ Puppet.settings.setting(:lastrunreport).mode = '9999'
60
+ end
61
+
62
+ after do
63
+ Puppet.settings.setting(:lastrunreport).mode = '0644'
64
+ end
65
+
66
+ it 'raises Puppet::DevError ' do
67
+ expect{
68
+ indirection.save(report)
69
+ }.to raise_error(Puppet::DevError, "replace_file mode: 9999 is invalid")
70
+ end
71
+ end
72
+
73
+ context 'when repport is invalid' do
74
+ it 'logs error' do
75
+ expect(Puppet).to receive(:send_log).with(:err, /Could not save yaml ziggy: can't dump anonymous class/)
76
+
77
+ report.configuration_version = Class.new
78
+ indirection.save(report)
79
+ end
80
+ end
81
+
82
+ context 'when report cannot be saved' do
83
+ it 'raises Error' do
84
+ FileUtils.mkdir_p(file)
85
+ expect {
86
+ indirection.save(report)
87
+ }.to raise_error(Errno::EISDIR, /last_run_report.yaml/)
88
+ end
89
+ end
90
+ end
27
91
  end
@@ -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
@@ -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
 
@@ -6,9 +6,6 @@ describe Puppet::Network::DefaultAuthProvider do
6
6
  before :each do
7
7
  allow(Puppet::FileSystem).to receive(:stat).and_return(double('stat', :ctime => :now))
8
8
  allow(Time).to receive(:now).and_return(Time.now)
9
-
10
- allow_any_instance_of(Puppet::Network::DefaultAuthProvider).to receive(:exists?).and_return(true)
11
- # FIXME @authprovider = Puppet::Network::DefaultAuthProvider.new("dummy")
12
9
  end
13
10
 
14
11
  describe "when initializing" do
@@ -17,7 +17,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
17
17
  before do
18
18
  Puppet::IndirectorTesting.indirection.terminus_class = :memory
19
19
  Puppet::IndirectorTesting.indirection.terminus.clear
20
- allow(handler).to receive(:warn_if_near_expiration)
21
20
  end
22
21
 
23
22
  describe "when converting a URI into a request" do
@@ -25,10 +24,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
25
24
  let(:env_loaders) { Puppet::Environments::Static.new(environment) }
26
25
  let(:params) { { :environment => "env" } }
27
26
 
28
- before do
29
- allow(handler).to receive(:handler).and_return("foo")
30
- end
31
-
32
27
  around do |example|
33
28
  Puppet.override(:environments => env_loaders) do
34
29
  example.run
@@ -180,10 +175,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
180
175
  let(:environment) { Puppet::Node::Environment.create(:myenv, []) }
181
176
  let(:request) { Puppet::Indirector::Request.new(:foo, :find, "with spaces", nil, :foo => :bar, :environment => environment) }
182
177
 
183
- before do
184
- allow(handler).to receive(:handler).and_return("foo")
185
- end
186
-
187
178
  it "should include the environment in the query string of the URI" do
188
179
  expect(handler.class.request_to_uri(request)).to eq("#{master_url_prefix}/foo/with%20spaces?environment=myenv&foo=bar")
189
180
  end
@@ -102,11 +102,6 @@ describe Puppet::Network::HTTP::Handler do
102
102
  { :status => 200 }
103
103
  end
104
104
 
105
- before do
106
- allow(handler).to receive(:check_authorization)
107
- allow(handler).to receive(:warn_if_near_expiration)
108
- end
109
-
110
105
  it "should setup a profiler when the puppet-profiling header exists" do
111
106
  request = a_request
112
107
  request[:headers][Puppet::Network::HTTP::HEADER_ENABLE_PROFILING.downcase] = "true"