puppet 7.0.0-x64-mingw32 → 7.5.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 (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
@@ -146,16 +146,6 @@ describe Puppet::Util::Windows::Registry do
146
146
  utf_8_bytes = ENDASH_UTF_8 + TM_UTF_8
147
147
  utf_8_str = utf_8_bytes.pack('c*').force_encoding(Encoding::UTF_8)
148
148
 
149
- # this problematic Ruby codepath triggers a conversion of UTF-16LE to
150
- # a local codepage which can totally break when that codepage has no
151
- # conversion from the given UTF-16LE characters to local codepage
152
- # a prime example is that IBM437 has no conversion from a Unicode en-dash
153
- expect(Win32::Registry).not_to receive(:export_string)
154
-
155
- # also, expect that we're using our variants of keys / values, not Rubys
156
- expect(Win32::Registry).not_to receive(:each_key)
157
- expect(Win32::Registry).not_to receive(:each_value)
158
-
159
149
  hklm.create("#{puppet_key}\\#{subkey_name}", Win32::Registry::KEY_ALL_ACCESS | regsam) do |reg|
160
150
  reg.write("#{guid}", Win32::Registry::REG_SZ, utf_16_str)
161
151
 
@@ -273,6 +263,12 @@ describe Puppet::Util::Windows::Registry do
273
263
  type: Win32::Registry::REG_EXPAND_SZ,
274
264
  value: "\0\0\0reg expand string",
275
265
  expected_value: ""
266
+ },
267
+ {
268
+ name: 'REG_EXPAND_SZ_2',
269
+ type: Win32::Registry::REG_EXPAND_SZ,
270
+ value: "1\x002\x003\x004\x00\x00\x00\x90\xD8UoY".force_encoding("UTF-16LE"),
271
+ expected_value: "1234"
276
272
  }
277
273
  ].each do |pair|
278
274
  it 'reads up to the first wide null' do
data/spec/spec_helper.rb CHANGED
@@ -84,10 +84,7 @@ RSpec.configure do |config|
84
84
  config.filter_run_when_matching :focus
85
85
 
86
86
  config.mock_with :rspec do |mocks|
87
- # We really should have this on, but it breaks a _lot_ of tests. We'll
88
- # need to go through and fix those tests first before it can be enabled
89
- # for real.
90
- mocks.verify_partial_doubles = false
87
+ mocks.verify_partial_doubles = true
91
88
  end
92
89
 
93
90
  tmpdir = Puppet::FileSystem.expand_path(Dir.mktmpdir("rspecrun"))
@@ -3,9 +3,13 @@ require 'puppet/agent'
3
3
  require 'puppet/configurer'
4
4
 
5
5
  class AgentTestClient
6
- def run
6
+ def initialize(transaction_uuid = nil, job_id = nil)
7
+ end
8
+
9
+ def run(client_args)
7
10
  # no-op
8
11
  end
12
+
9
13
  def stop
10
14
  # no-op
11
15
  end
@@ -49,11 +53,10 @@ describe Puppet::Agent do
49
53
 
50
54
  it "should create an instance of its client class and run it when asked to run" do
51
55
  client = double('client')
52
- expect(AgentTestClient).to receive(:new).and_return(client)
53
-
54
- expect(client).to receive(:run)
56
+ allow(AgentTestClient).to receive(:new).with(nil, nil).and_return(client)
55
57
 
56
58
  allow(@agent).to receive(:disabled?).and_return(false)
59
+ expect(client).to receive(:run)
57
60
  @agent.run
58
61
  end
59
62
 
@@ -90,7 +93,6 @@ describe Puppet::Agent do
90
93
 
91
94
  describe "when being run" do
92
95
  before do
93
- allow(AgentTestClient).to receive(:lockfile_path).and_return("/my/lock")
94
96
  allow(@agent).to receive(:disabled?).and_return(false)
95
97
  end
96
98
 
@@ -186,7 +188,7 @@ describe Puppet::Agent do
186
188
  allow(lockfile).to receive(:lock).and_return(false)
187
189
  end
188
190
 
189
- it "should notify that a run is already in progres" do
191
+ it "should notify that a run is already in progress" do
190
192
  client = AgentTestClient.new
191
193
  expect(AgentTestClient).to receive(:new).and_return(client)
192
194
  expect(Puppet).to receive(:notice).with(/Run of .* already in progress; skipping .* exists/)
@@ -202,7 +202,6 @@ describe Puppet::Application::Agent do
202
202
  allow(Puppet::Resource::Catalog.indirection).to receive(:terminus_class=)
203
203
  allow(Puppet::Resource::Catalog.indirection).to receive(:cache_class=)
204
204
  allow(Puppet::Node::Facts.indirection).to receive(:terminus_class=)
205
- allow(Puppet).to receive(:settraps)
206
205
  end
207
206
 
208
207
  it "should not run with extra arguments" do
@@ -3,7 +3,7 @@ require 'puppet/application/facts'
3
3
 
4
4
  describe Puppet::Application::Facts do
5
5
  let(:app) { Puppet::Application[:facts] }
6
- let(:values) { {"filesystems" => "apfs,autofs,devfs", "macaddress" => "64:52:11:22:03:25"} }
6
+ let(:values) { {"filesystems" => "apfs,autofs,devfs", "macaddress" => "64:52:11:22:03:2e"} }
7
7
 
8
8
  before :each do
9
9
  Puppet::Node::Facts.indirection.terminus_class = :memory
@@ -21,7 +21,7 @@ describe Puppet::Application::Facts do
21
21
  name: whatever
22
22
  values:
23
23
  filesystems: apfs,autofs,devfs
24
- macaddress: "64:52:11:22:03:25"
24
+ macaddress: "64:52:11:22:03:2e"
25
25
  END
26
26
 
27
27
  expect {
@@ -42,7 +42,7 @@ describe Puppet::Application::Facts do
42
42
  name: #{Puppet[:certname]}
43
43
  values:
44
44
  filesystems: apfs,autofs,devfs
45
- macaddress: "64:52:11:22:03:25"
45
+ macaddress: "64:52:11:22:03:2e"
46
46
  END
47
47
 
48
48
  expect {
@@ -52,7 +52,12 @@ describe Puppet::Application::Facts do
52
52
  end
53
53
 
54
54
  context 'when show action is called' do
55
- let(:expected) { "{\n \"filesystems\": \"apfs,autofs,devfs\",\n \"macaddress\": \"64:52:11:22:03:25\"\n}\n" }
55
+ let(:expected) { <<~END }
56
+ {
57
+ "filesystems": "apfs,autofs,devfs",
58
+ "macaddress": "64:52:11:22:03:2e"
59
+ }
60
+ END
56
61
 
57
62
  before :each do
58
63
  Puppet::Node::Facts.indirection.terminus_class = :facter
@@ -64,12 +69,58 @@ describe Puppet::Application::Facts do
64
69
  expect {
65
70
  app.run
66
71
  }.to exit_with(0)
67
- .and output(expected).to_stdout
72
+ .and output(expected).to_stdout
73
+ end
74
+
75
+ it 'displays a single fact value' do
76
+ app.command_line.args << 'filesystems' << '--value-only'
77
+ expect {
78
+ app.run
79
+ }.to exit_with(0)
80
+ .and output("apfs,autofs,devfs\n").to_stdout
81
+ end
82
+
83
+ it "warns and ignores value-only when multiple fact names are specified" do
84
+ app.command_line.args << 'filesystems' << 'macaddress' << '--value-only'
85
+ expect {
86
+ app.run
87
+ }.to exit_with(0)
88
+ .and output(expected).to_stdout
89
+ .and output(/it can only be used when querying for a single fact/).to_stderr
90
+ end
91
+
92
+ {
93
+ "type_hash" => [{'a' => 2}, "{\n \"a\": 2\n}"],
94
+ "type_array" => [[], "[\n\n]"],
95
+ "type_string" => ["str", "str"],
96
+ "type_int" => [1, "1"],
97
+ "type_float" => [1.0, "1.0"],
98
+ "type_true" => [true, "true"],
99
+ "type_false" => [false, "false"],
100
+ "type_nil" => [nil, ""],
101
+ "type_sym" => [:sym, "sym"]
102
+ }.each_pair do |name, values|
103
+ it "renders '#{name}' as '#{values.last}'" do
104
+ fact_value = values.first
105
+ fact_output = values.last
106
+
107
+ allow(Facter).to receive(:resolve).and_return({name => fact_value})
108
+
109
+ app.command_line.args << name << '--value-only'
110
+ expect {
111
+ app.run
112
+ }.to exit_with(0)
113
+ .and output("#{fact_output}\n").to_stdout
114
+ end
68
115
  end
69
116
  end
70
117
 
71
118
  context 'when default action is called' do
72
- let(:expected) { "---\nfilesystems: apfs,autofs,devfs\nmacaddress: 64:52:11:22:03:25\n" }
119
+ let(:expected) { <<~END }
120
+ ---
121
+ filesystems: apfs,autofs,devfs
122
+ macaddress: 64:52:11:22:03:2e
123
+ END
73
124
 
74
125
  before :each do
75
126
  Puppet::Node::Facts.indirection.terminus_class = :facter
@@ -81,7 +132,7 @@ describe Puppet::Application::Facts do
81
132
  expect {
82
133
  app.run
83
134
  }.to exit_with(0)
84
- .and output(expected).to_stdout
135
+ .and output(expected).to_stdout
85
136
  expect(app.action.name).to eq(:show)
86
137
  end
87
138
  end
@@ -42,7 +42,6 @@ describe Puppet::Application::Filebucket do
42
42
  describe "during setup" do
43
43
  before :each do
44
44
  allow(Puppet::Log).to receive(:newdestination)
45
- allow(Puppet).to receive(:settraps)
46
45
  allow(Puppet::FileBucket::Dipper).to receive(:new)
47
46
  allow(@filebucket.options).to receive(:[])
48
47
  end
@@ -159,7 +158,6 @@ describe Puppet::Application::Filebucket do
159
158
  describe "when running" do
160
159
  before :each do
161
160
  allow(Puppet::Log).to receive(:newdestination)
162
- allow(Puppet).to receive(:settraps)
163
161
  allow(Puppet::FileBucket::Dipper).to receive(:new)
164
162
  allow(@filebucket.options).to receive(:[])
165
163
 
@@ -432,4 +432,27 @@ describe Puppet::Application::Ssl, unless: Puppet::Util::Platform.jruby? do
432
432
  expects_command_to_pass
433
433
  end
434
434
  end
435
+
436
+ context 'when showing' do
437
+ before do
438
+ ssl.command_line.args << 'show'
439
+ File.write(Puppet[:hostcert], @host[:cert].to_pem)
440
+ end
441
+
442
+ it 'reports if the key is missing' do
443
+ File.delete(Puppet[:hostprivkey])
444
+
445
+ expects_command_to_fail(/The private key is missing from/)
446
+ end
447
+
448
+ it 'reports if the cert is missing' do
449
+ File.delete(Puppet[:hostcert])
450
+
451
+ expects_command_to_fail(/The client certificate is missing from/)
452
+ end
453
+
454
+ it 'prints certificate information' do
455
+ expects_command_to_pass(@host[:cert].to_text)
456
+ end
457
+ end
435
458
  end
@@ -7,8 +7,10 @@ require 'timeout'
7
7
 
8
8
  describe Puppet::Application do
9
9
  before(:each) do
10
- @app = Class.new(Puppet::Application).new
11
- @appclass = @app.class
10
+ @appclass = Class.new(Puppet::Application) do
11
+ def handle_unknown(opt, arg); end
12
+ end
13
+ @app = @appclass.new
12
14
 
13
15
  allow(@app).to receive(:name).and_return("test_app")
14
16
  end
@@ -511,6 +513,40 @@ describe Puppet::Application do
511
513
 
512
514
  expect { @app.configure_indirector_routes }.to raise_error(Puppet::Error, /mapping values are not allowed/)
513
515
  end
516
+
517
+ it "should treat master routes on server application" do
518
+ allow(@app).to receive(:name).and_return("server")
519
+
520
+ Puppet[:route_file] = tmpfile('routes')
521
+ File.open(Puppet[:route_file], 'w') do |f|
522
+ f.print <<-ROUTES
523
+ master:
524
+ node:
525
+ terminus: exec
526
+ ROUTES
527
+ end
528
+
529
+ @app.configure_indirector_routes
530
+
531
+ expect(Puppet::Node.indirection.terminus_class).to eq('exec')
532
+ end
533
+
534
+ it "should treat server routes on master application" do
535
+ allow(@app).to receive(:name).and_return("master")
536
+
537
+ Puppet[:route_file] = tmpfile('routes')
538
+ File.open(Puppet[:route_file], 'w') do |f|
539
+ f.print <<-ROUTES
540
+ server:
541
+ node:
542
+ terminus: exec
543
+ ROUTES
544
+ end
545
+
546
+ @app.configure_indirector_routes
547
+
548
+ expect(Puppet::Node.indirection.terminus_class).to eq('exec')
549
+ end
514
550
  end
515
551
 
516
552
  describe "when running" do
@@ -560,13 +596,6 @@ describe Puppet::Application do
560
596
  end
561
597
 
562
598
  it "should raise an error if dispatch returns no command" do
563
- allow(@app).to receive(:get_command).and_return(nil)
564
- expect(Puppet).to receive(:send_log).with(:err, "Could not run: No valid command or main")
565
- expect { @app.run }.to exit_with 1
566
- end
567
-
568
- it "should raise an error if dispatch returns an invalid command" do
569
- allow(@app).to receive(:get_command).and_return(:this_function_doesnt_exist)
570
599
  expect(Puppet).to receive(:send_log).with(:err, "Could not run: No valid command or main")
571
600
  expect { @app.run }.to exit_with 1
572
601
  end
@@ -684,5 +713,18 @@ describe Puppet::Application do
684
713
 
685
714
  @app.handle_logdest_arg(nil)
686
715
  end
716
+
717
+ it "accepts multiple destinations as a comma sepparated list" do
718
+ dest1 = '/tmp/path1'
719
+ dest2 = 'console'
720
+ dest3 = '/tmp/path2'
721
+ dest_args = [dest1, dest2, dest3].join(' , ')
722
+
723
+ [dest1, dest2, dest3].each do |dest|
724
+ expect(Puppet::Util::Log).to receive(:newdestination).with(dest)
725
+ end
726
+
727
+ @app.handle_logdest_arg(dest_args)
728
+ end
687
729
  end
688
730
  end
@@ -22,7 +22,7 @@ describe Puppet::Confine::Feature do
22
22
  end
23
23
 
24
24
  it "should use the Puppet features instance to test validity" do
25
- expect(Puppet.features).to receive(:myfeature?)
25
+ Puppet.features.add(:myfeature) do true end
26
26
  @confine.valid?
27
27
  end
28
28
 
@@ -2,6 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  require 'puppet/confine'
4
4
 
5
+ class Puppet::TestConfine < Puppet::Confine
6
+ def pass?(value)
7
+ false
8
+ end
9
+ end
10
+
5
11
  describe Puppet::Confine do
6
12
  it "should require a value" do
7
13
  expect { Puppet::Confine.new }.to raise_error(ArgumentError)
@@ -33,7 +39,7 @@ describe Puppet::Confine do
33
39
 
34
40
  describe "when testing all values" do
35
41
  before do
36
- @confine = Puppet::Confine.new(%w{a b c})
42
+ @confine = Puppet::TestConfine.new(%w{a b c})
37
43
  @confine.label = "foo"
38
44
  end
39
45
 
@@ -64,7 +70,7 @@ describe Puppet::Confine do
64
70
  end
65
71
 
66
72
  describe "when testing the result of the values" do
67
- before { @confine = Puppet::Confine.new(%w{a b c d}) }
73
+ before { @confine = Puppet::TestConfine.new(%w{a b c d}) }
68
74
 
69
75
  it "should return an array with the result of the test for each value" do
70
76
  allow(@confine).to receive(:pass?).and_return(true)
@@ -190,39 +190,8 @@ describe "Defaults" do
190
190
  end
191
191
  end
192
192
 
193
- describe "the call hook for the cadir setting", unless: Puppet::Util::Platform.windows? do
194
- it 'does not warn when the cadir is outside the puppet ssldir' do
195
- FileUtils.mkdir_p(Puppet[:confdir])
196
- # This is fun; in order to get the confdir setting from the spec_helper to
197
- # not be deleted by the #unsafe_clear in Puppet::Settings#parse_config,
198
- # we can code it into the confdir itself, and thus we can avoid getting
199
- # that setting wiped out during Puppet.initialize_settings.
200
- File.write(File.join(Puppet[:confdir], 'puppet.conf'),
201
- "cadir = /my/cool/path/for/my/cadir\n
202
- confdir = #{Puppet[:confdir]}")
203
- expect(Puppet).to_not receive(:log_ca_migration_warning)
204
- Puppet.initialize_settings
205
- expect(Puppet[:cadir]).to eq("/my/cool/path/for/my/cadir")
206
- end
207
-
208
- it 'does warn when the cadir is inside the puppet ssldir' do
209
- FileUtils.mkdir_p(Puppet[:confdir])
210
- cadir_location = File.join(Puppet[:ssldir], 'still_inside_ssldir')
211
- # This is fun; in order to get the confdir setting from the spec_helper to
212
- # not be deleted by the #unsafe_clear in Puppet::Settings#parse_config,
213
- # we can code it into the confdir itself, and thus we can avoid getting
214
- # that setting wiped out during Puppet.initialize_settings.
215
- File.write(File.join(Puppet[:confdir], 'puppet.conf'),
216
- "cadir = #{cadir_location}\n
217
- confdir = #{Puppet[:confdir]}")
218
- expect(Puppet).to receive(:log_ca_migration_warning).twice
219
- Puppet.initialize_settings
220
- expect(Puppet[:cadir]).to eq(cadir_location)
221
- end
222
- end
223
-
224
193
  describe "the default cadir", :unless => Puppet::Util::Platform.windows? do
225
- it 'defaults to the puppetserver confdir' do
194
+ it 'defaults to the puppetserver confdir when no cadir is found' do
226
195
  Puppet.initialize_settings
227
196
  expect(Puppet[:cadir]).to eq('/etc/puppetlabs/puppetserver/ca')
228
197
  end
@@ -234,34 +203,10 @@ describe "Defaults" do
234
203
  end
235
204
 
236
205
  describe '#default_cadir', :unless => Puppet::Util::Platform.windows? do
237
- it 'returns the new puppetserver directory when no ca dir is present' do
238
- expect(Puppet).to_not receive(:log_ca_migration_warning)
239
- expect(Puppet.default_cadir).to eq('/etc/puppetlabs/puppetserver/ca')
240
- end
241
-
242
206
  it 'warns when a CA dir exists in the current ssldir' do
243
207
  cadir = File.join(Puppet[:ssldir], 'ca')
244
208
  FileUtils.mkdir_p(cadir)
245
- expect(Puppet).to receive(:log_ca_migration_warning)
246
209
  expect(Puppet.default_cadir).to eq(cadir)
247
210
  end
248
-
249
- it 'warns when the cadir is a symlink still inside the ssldir' do
250
- another_dir = File.join(Puppet[:ssldir], 'another_dir')
251
- cadir = File.join(Puppet[:ssldir], 'ca')
252
- FileUtils.mkdir_p(another_dir)
253
- File.symlink(another_dir, cadir)
254
- expect(Puppet).to receive(:log_ca_migration_warning)
255
- expect(Puppet.default_cadir).to eq(another_dir)
256
- end
257
-
258
- it 'does not warn when the cadir is a symlink targeted outside the ssldir' do
259
- another_dir = Dir.mktmpdir
260
- cadir = File.join(Puppet[:ssldir], 'ca')
261
- FileUtils.mkdir_p(Puppet[:ssldir])
262
- File.symlink(another_dir, cadir)
263
- expect(Puppet).to_not receive(:log_ca_migration_warning)
264
- expect(Puppet.default_cadir).to eq(another_dir)
265
- end
266
211
  end
267
212
  end