puppet 7.0.0-universal-darwin → 7.5.0-universal-darwin

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 (191) hide show
  1. checksums.yaml +4 -4
  2. data/CODEOWNERS +2 -16
  3. data/Gemfile +2 -3
  4. data/Gemfile.lock +45 -33
  5. data/ext/build_defaults.yaml +0 -1
  6. data/ext/project_data.yaml +1 -0
  7. data/lib/puppet/application.rb +10 -6
  8. data/lib/puppet/application/agent.rb +1 -0
  9. data/lib/puppet/application/apply.rb +3 -2
  10. data/lib/puppet/application/device.rb +1 -0
  11. data/lib/puppet/application/script.rb +1 -0
  12. data/lib/puppet/application/ssl.rb +11 -0
  13. data/lib/puppet/application_support.rb +7 -0
  14. data/lib/puppet/configurer.rb +16 -3
  15. data/lib/puppet/defaults.rb +14 -41
  16. data/lib/puppet/environments.rb +54 -55
  17. data/lib/puppet/face/facts.rb +26 -2
  18. data/lib/puppet/face/node/clean.rb +8 -0
  19. data/lib/puppet/ffi/posix.rb +10 -0
  20. data/lib/puppet/ffi/posix/constants.rb +14 -0
  21. data/lib/puppet/ffi/posix/functions.rb +24 -0
  22. data/lib/puppet/ffi/windows/api_types.rb +1 -1
  23. data/lib/puppet/ffi/windows/constants.rb +1 -1
  24. data/lib/puppet/file_serving/configuration/parser.rb +5 -2
  25. data/lib/puppet/file_system/memory_file.rb +8 -1
  26. data/lib/puppet/file_system/windows.rb +2 -0
  27. data/lib/puppet/http/factory.rb +4 -0
  28. data/lib/puppet/indirector/facts/facter.rb +1 -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 +67 -0
  32. data/lib/puppet/network/http.rb +5 -2
  33. data/lib/puppet/network/http/api.rb +10 -6
  34. data/lib/puppet/network/http/api/master.rb +3 -2
  35. data/lib/puppet/network/http/api/master/v3.rb +2 -25
  36. data/lib/puppet/network/http/api/master/v3/environments.rb +2 -33
  37. data/lib/puppet/network/http/api/server.rb +10 -0
  38. data/lib/puppet/network/http/api/server/v3.rb +39 -0
  39. data/lib/puppet/network/http/api/server/v3/environments.rb +48 -0
  40. data/lib/puppet/parser/ast/leaf.rb +3 -2
  41. data/lib/puppet/parser/templatewrapper.rb +1 -1
  42. data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
  43. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  44. data/lib/puppet/pops/parser/lexer2.rb +0 -4
  45. data/lib/puppet/pops/validation/checker4_0.rb +0 -1
  46. data/lib/puppet/property/list.rb +1 -1
  47. data/lib/puppet/provider/group/groupadd.rb +13 -8
  48. data/lib/puppet/provider/package/apt.rb +34 -2
  49. data/lib/puppet/provider/package/aptitude.rb +6 -0
  50. data/lib/puppet/provider/service/debian.rb +2 -0
  51. data/lib/puppet/provider/user/aix.rb +2 -2
  52. data/lib/puppet/provider/user/useradd.rb +62 -8
  53. data/lib/puppet/reference/configuration.rb +6 -5
  54. data/lib/puppet/settings.rb +33 -28
  55. data/lib/puppet/settings/alias_setting.rb +37 -0
  56. data/lib/puppet/settings/environment_conf.rb +1 -0
  57. data/lib/puppet/type/package.rb +3 -3
  58. data/lib/puppet/type/user.rb +1 -1
  59. data/lib/puppet/util/autoload.rb +1 -8
  60. data/lib/puppet/util/monkey_patches.rb +7 -0
  61. data/lib/puppet/util/posix.rb +54 -5
  62. data/lib/puppet/util/windows/adsi.rb +46 -0
  63. data/lib/puppet/util/windows/principal.rb +9 -2
  64. data/lib/puppet/util/windows/sid.rb +4 -2
  65. data/lib/puppet/version.rb +1 -1
  66. data/locales/puppet.pot +166 -146
  67. data/man/man5/puppet.conf.5 +14 -6
  68. data/man/man8/puppet-agent.8 +2 -2
  69. data/man/man8/puppet-apply.8 +2 -2
  70. data/man/man8/puppet-catalog.8 +1 -1
  71. data/man/man8/puppet-config.8 +1 -1
  72. data/man/man8/puppet-describe.8 +1 -1
  73. data/man/man8/puppet-device.8 +2 -2
  74. data/man/man8/puppet-doc.8 +1 -1
  75. data/man/man8/puppet-epp.8 +1 -1
  76. data/man/man8/puppet-facts.8 +8 -2
  77. data/man/man8/puppet-filebucket.8 +1 -1
  78. data/man/man8/puppet-generate.8 +1 -1
  79. data/man/man8/puppet-help.8 +1 -1
  80. data/man/man8/puppet-lookup.8 +1 -1
  81. data/man/man8/puppet-module.8 +1 -1
  82. data/man/man8/puppet-node.8 +1 -1
  83. data/man/man8/puppet-parser.8 +1 -1
  84. data/man/man8/puppet-plugin.8 +1 -1
  85. data/man/man8/puppet-report.8 +1 -1
  86. data/man/man8/puppet-resource.8 +1 -1
  87. data/man/man8/puppet-script.8 +2 -2
  88. data/man/man8/puppet-ssl.8 +5 -1
  89. data/man/man8/puppet.8 +2 -2
  90. data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
  91. data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
  92. data/spec/integration/application/agent_spec.rb +160 -3
  93. data/spec/integration/application/apply_spec.rb +19 -0
  94. data/spec/integration/application/plugin_spec.rb +1 -1
  95. data/spec/integration/defaults_spec.rb +0 -7
  96. data/spec/integration/http/client_spec.rb +12 -0
  97. data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
  98. data/spec/integration/indirector/file_content/file_server_spec.rb +0 -2
  99. data/spec/integration/indirector/file_metadata/file_server_spec.rb +0 -2
  100. data/spec/integration/parser/collection_spec.rb +10 -0
  101. data/spec/integration/resource/type_collection_spec.rb +2 -6
  102. data/spec/integration/transaction_spec.rb +4 -9
  103. data/spec/integration/util/windows/adsi_spec.rb +21 -1
  104. data/spec/integration/util/windows/principal_spec.rb +21 -0
  105. data/spec/integration/util/windows/registry_spec.rb +6 -10
  106. data/spec/spec_helper.rb +1 -4
  107. data/spec/unit/agent_spec.rb +8 -6
  108. data/spec/unit/application/agent_spec.rb +0 -1
  109. data/spec/unit/application/facts_spec.rb +58 -7
  110. data/spec/unit/application/filebucket_spec.rb +0 -2
  111. data/spec/unit/application/ssl_spec.rb +23 -0
  112. data/spec/unit/application_spec.rb +51 -9
  113. data/spec/unit/confine/feature_spec.rb +1 -1
  114. data/spec/unit/confine_spec.rb +8 -2
  115. data/spec/unit/defaults_spec.rb +1 -56
  116. data/spec/unit/environments_spec.rb +221 -68
  117. data/spec/unit/face/node_spec.rb +14 -13
  118. data/spec/unit/file_serving/configuration/parser_spec.rb +8 -1
  119. data/spec/unit/file_serving/metadata_spec.rb +3 -3
  120. data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
  121. data/spec/unit/file_system_spec.rb +9 -0
  122. data/spec/unit/forge/module_release_spec.rb +2 -7
  123. data/spec/unit/http/factory_spec.rb +19 -0
  124. data/spec/unit/indirector/face_spec.rb +0 -1
  125. data/spec/unit/indirector/facts/facter_spec.rb +20 -5
  126. data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
  127. data/spec/unit/indirector/indirection_spec.rb +8 -12
  128. data/spec/unit/indirector_spec.rb +2 -2
  129. data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
  130. data/spec/unit/network/formats_spec.rb +41 -0
  131. data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -4
  132. data/spec/unit/network/http/api/master_spec.rb +38 -0
  133. data/spec/unit/network/http/api/{master → server}/v3/environments_spec.rb +2 -2
  134. data/spec/unit/network/http/api/{master → server}/v3_spec.rb +19 -19
  135. data/spec/unit/network/http/api_spec.rb +11 -11
  136. data/spec/unit/parser/compiler_spec.rb +3 -19
  137. data/spec/unit/parser/resource_spec.rb +14 -8
  138. data/spec/unit/parser/templatewrapper_spec.rb +4 -3
  139. data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
  140. data/spec/unit/pops/parser/lexer2_spec.rb +0 -4
  141. data/spec/unit/pops/validator/validator_spec.rb +20 -43
  142. data/spec/unit/property_spec.rb +1 -0
  143. data/spec/unit/provider/group/groupadd_spec.rb +5 -2
  144. data/spec/unit/provider/nameservice_spec.rb +66 -65
  145. data/spec/unit/provider/package/apt_spec.rb +28 -23
  146. data/spec/unit/provider/package/aptitude_spec.rb +1 -1
  147. data/spec/unit/provider/package/base_spec.rb +6 -5
  148. data/spec/unit/provider/package/pacman_spec.rb +18 -12
  149. data/spec/unit/provider/package/pip_spec.rb +6 -11
  150. data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
  151. data/spec/unit/provider/user/aix_spec.rb +5 -0
  152. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  153. data/spec/unit/provider/user/pw_spec.rb +2 -0
  154. data/spec/unit/provider/user/useradd_spec.rb +56 -3
  155. data/spec/unit/provider_spec.rb +6 -8
  156. data/spec/unit/resource/type_spec.rb +1 -1
  157. data/spec/unit/resource_spec.rb +11 -10
  158. data/spec/unit/settings_spec.rb +13 -6
  159. data/spec/unit/ssl/base_spec.rb +0 -1
  160. data/spec/unit/ssl/certificate_request_spec.rb +4 -10
  161. data/spec/unit/ssl/ssl_provider_spec.rb +5 -2
  162. data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
  163. data/spec/unit/transaction/event_manager_spec.rb +14 -11
  164. data/spec/unit/transaction_spec.rb +13 -4
  165. data/spec/unit/type/file/content_spec.rb +0 -1
  166. data/spec/unit/type/file/selinux_spec.rb +0 -2
  167. data/spec/unit/type/file_spec.rb +0 -6
  168. data/spec/unit/type/group_spec.rb +13 -6
  169. data/spec/unit/type/resources_spec.rb +7 -7
  170. data/spec/unit/type/service_spec.rb +1 -1
  171. data/spec/unit/type/tidy_spec.rb +0 -1
  172. data/spec/unit/type_spec.rb +2 -2
  173. data/spec/unit/util/at_fork_spec.rb +2 -2
  174. data/spec/unit/util/autoload_spec.rb +5 -1
  175. data/spec/unit/util/backups_spec.rb +1 -2
  176. data/spec/unit/util/execution_spec.rb +15 -11
  177. data/spec/unit/util/inifile_spec.rb +6 -14
  178. data/spec/unit/util/log_spec.rb +8 -7
  179. data/spec/unit/util/logging_spec.rb +3 -3
  180. data/spec/unit/util/posix_spec.rb +363 -15
  181. data/spec/unit/util/selinux_spec.rb +76 -52
  182. data/spec/unit/util/storage_spec.rb +3 -1
  183. data/spec/unit/util/suidmanager_spec.rb +44 -41
  184. data/spec/unit/util/windows/sid_spec.rb +6 -0
  185. data/spec/unit/util_spec.rb +13 -6
  186. metadata +33 -16
  187. data/spec/lib/matchers/include.rb +0 -27
  188. data/spec/lib/matchers/include_spec.rb +0 -32
  189. data/spec/unit/pops/parser/parse_application_spec.rb +0 -13
  190. data/spec/unit/pops/parser/parse_capabilities_spec.rb +0 -23
  191. data/spec/unit/pops/parser/parse_site_spec.rb +0 -43
@@ -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
@@ -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
@@ -24,10 +24,6 @@ describe Puppet::Network::HTTP::API::IndirectedRoutes do
24
24
  let(:env_loaders) { Puppet::Environments::Static.new(environment) }
25
25
  let(:params) { { :environment => "env" } }
26
26
 
27
- before do
28
- allow(handler).to receive(:handler).and_return("foo")
29
- end
30
-
31
27
  around do |example|
32
28
  Puppet.override(:environments => env_loaders) do
33
29
  example.run
@@ -0,0 +1,38 @@
1
+ # Tests the backwards compatibility of our master -> server changes
2
+ # in the HTTP API
3
+ # This may be removed in Puppet 8
4
+ require 'spec_helper'
5
+
6
+ require 'puppet/network/http'
7
+ require 'puppet_spec/network'
8
+
9
+ describe Puppet::Network::HTTP::API::Master::V3 do
10
+ include PuppetSpec::Network
11
+
12
+ let(:response) { Puppet::Network::HTTP::MemoryResponse.new }
13
+ let(:server_url_prefix) { "#{Puppet::Network::HTTP::MASTER_URL_PREFIX}/v3" }
14
+ let(:server_routes) {
15
+ Puppet::Network::HTTP::Route.
16
+ path(Regexp.new("#{Puppet::Network::HTTP::MASTER_URL_PREFIX}/")).
17
+ any.
18
+ chain(Puppet::Network::HTTP::API::Master::V3.routes)
19
+ }
20
+
21
+ # simulate puppetserver registering its authconfigloader class
22
+ around :each do |example|
23
+ Puppet::Network::Authorization.authconfigloader_class = Object
24
+ begin
25
+ example.run
26
+ ensure
27
+ Puppet::Network::Authorization.authconfigloader_class = nil
28
+ end
29
+ end
30
+
31
+ it "mounts the environments endpoint" do
32
+ request = Puppet::Network::HTTP::Request.from_hash(:path => "#{server_url_prefix}/environments")
33
+ server_routes.process(request, response)
34
+
35
+ expect(response.code).to eq(200)
36
+ end
37
+ end
38
+