puppet 5.2.0 → 5.3.1
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.
- data/Gemfile +9 -28
- data/lib/puppet.rb +1 -0
- data/lib/puppet/defaults.rb +21 -5
- data/lib/puppet/indirector/certificate_revocation_list/rest.rb +12 -0
- data/lib/puppet/network/http/connection.rb +108 -15
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +1 -1
- data/lib/puppet/pops/lookup/hiera_config.rb +1 -1
- data/lib/puppet/pops/parser/egrammar.ra +1 -1
- data/lib/puppet/pops/parser/eparser.rb +378 -378
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/patterns.rb +2 -1
- data/lib/puppet/pops/types/p_object_type.rb +2 -0
- data/lib/puppet/pops/types/puppet_object.rb +1 -1
- data/lib/puppet/pops/types/ruby_generator.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +1 -0
- data/lib/puppet/settings.rb +3 -1
- data/lib/puppet/settings/certificate_revocation_setting.rb +21 -0
- data/lib/puppet/ssl/certificate_authority.rb +1 -1
- data/lib/puppet/ssl/certificate_revocation_list.rb +1 -1
- data/lib/puppet/ssl/host.rb +29 -16
- data/lib/puppet/transaction/report.rb +9 -3
- data/lib/puppet/type/scheduled_task.rb +4 -5
- data/lib/puppet/vendor/pathspec/lib/pathspec.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/locales/ja/puppet.po +63 -57
- data/locales/puppet.pot +46 -32
- data/spec/unit/functions/epp_spec.rb +7 -2
- data/spec/unit/functions4_spec.rb +3 -2
- data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +8 -0
- data/spec/unit/network/http/connection_spec.rb +88 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +30 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +30 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +10 -2
- data/spec/unit/pops/types/type_calculator_spec.rb +13 -0
- data/spec/unit/pops/validator/validator_spec.rb +10 -0
- data/spec/unit/settings/certificate_revocation_setting_spec.rb +37 -0
- data/spec/unit/ssl/host_spec.rb +22 -4
- data/spec/unit/transaction/report_spec.rb +5 -0
- metadata +5 -2
data/locales/puppet.pot
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
#, fuzzy
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
|
-
"Project-Id-Version: Puppet automation framework 5.0
|
9
|
+
"Project-Id-Version: Puppet automation framework 5.3.0-6-gf66f9d9\n"
|
10
10
|
"\n"
|
11
11
|
"Report-Msgid-Bugs-To: https://tickets.puppetlabs.com\n"
|
12
|
-
"POT-Creation-Date: 2017-
|
13
|
-
"PO-Revision-Date: 2017-
|
12
|
+
"POT-Creation-Date: 2017-09-26 17:02+0000\n"
|
13
|
+
"PO-Revision-Date: 2017-09-26 17:02+0000\n"
|
14
14
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15
15
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
16
16
|
"Language: \n"
|
@@ -205,15 +205,15 @@ msgstr ""
|
|
205
205
|
msgid "Manage remote network devices"
|
206
206
|
msgstr ""
|
207
207
|
|
208
|
-
#: ../lib/puppet/application/device.rb:
|
208
|
+
#: ../lib/puppet/application/device.rb:204
|
209
209
|
msgid "Target device / certificate '%{target}' not found in %{config}"
|
210
210
|
msgstr ""
|
211
211
|
|
212
|
-
#: ../lib/puppet/application/device.rb:
|
212
|
+
#: ../lib/puppet/application/device.rb:206
|
213
213
|
msgid "No device found in %{config}"
|
214
214
|
msgstr ""
|
215
215
|
|
216
|
-
#: ../lib/puppet/application/device.rb:
|
216
|
+
#: ../lib/puppet/application/device.rb:216
|
217
217
|
msgid "starting applying configuration to %{target} at %{scheme}%{url_host}%{port}%{url_path}"
|
218
218
|
msgstr ""
|
219
219
|
|
@@ -3216,20 +3216,38 @@ msgstr ""
|
|
3216
3216
|
msgid "Unknown content encoding - %{encoding}"
|
3217
3217
|
msgstr ""
|
3218
3218
|
|
3219
|
-
#: ../lib/puppet/network/http/connection.rb:
|
3219
|
+
#: ../lib/puppet/network/http/connection.rb:55
|
3220
3220
|
msgid "Unrecognized option(s): %{opts}"
|
3221
3221
|
msgstr ""
|
3222
3222
|
|
3223
|
-
#: ../lib/puppet/network/http/connection.rb:
|
3223
|
+
#: ../lib/puppet/network/http/connection.rb:203
|
3224
3224
|
msgid "Too many HTTP redirections for %{host}:%{port}"
|
3225
3225
|
msgstr ""
|
3226
3226
|
|
3227
|
-
|
3228
|
-
|
3227
|
+
#. TRANSLATORS: Used in the phrase:
|
3228
|
+
#. "Received a response from the remote server."
|
3229
|
+
#: ../lib/puppet/network/http/connection.rb:234
|
3230
|
+
msgid "the remote server"
|
3229
3231
|
msgstr ""
|
3230
3232
|
|
3231
|
-
#: ../lib/puppet/network/http/connection.rb:
|
3232
|
-
msgid "
|
3233
|
+
#: ../lib/puppet/network/http/connection.rb:238
|
3234
|
+
msgid "Received a %{status_code} response from %{server_hostname}, but the Retry-After header value of \"%{retry_after}\" could not be converted to an integer or RFC 2822 date."
|
3235
|
+
msgstr ""
|
3236
|
+
|
3237
|
+
#: ../lib/puppet/network/http/connection.rb:249
|
3238
|
+
msgid "Received a %{status_code} response from %{server_hostname}. Sleeping for %{retry_sleep} seconds before retrying the request."
|
3239
|
+
msgstr ""
|
3240
|
+
|
3241
|
+
#: ../lib/puppet/network/http/connection.rb:320
|
3242
|
+
msgid "expected one of %{certnames}"
|
3243
|
+
msgstr ""
|
3244
|
+
|
3245
|
+
#: ../lib/puppet/network/http/connection.rb:322
|
3246
|
+
msgid "expected %{certname}"
|
3247
|
+
msgstr ""
|
3248
|
+
|
3249
|
+
#: ../lib/puppet/network/http/connection.rb:325
|
3250
|
+
msgid "Server hostname '%{host}' did not match server certificate; %{expected_certnames}"
|
3233
3251
|
msgstr ""
|
3234
3252
|
|
3235
3253
|
#: ../lib/puppet/network/http/error.rb:23
|
@@ -3511,10 +3529,6 @@ msgstr ""
|
|
3511
3529
|
msgid "Invalid node mapping in %{app}: Key %{k} is not a Node"
|
3512
3530
|
msgstr ""
|
3513
3531
|
|
3514
|
-
#: ../lib/puppet/parser/compiler.rb:322
|
3515
|
-
msgid "Node"
|
3516
|
-
msgstr ""
|
3517
|
-
|
3518
3532
|
#: ../lib/puppet/parser/compiler.rb:325
|
3519
3533
|
msgid "Invalid node mapping in %{app}: Value %{res} is not a resource"
|
3520
3534
|
msgstr ""
|
@@ -4669,10 +4683,6 @@ msgstr ""
|
|
4669
4683
|
msgid "The code loaded from %{source_ref} does not create the resource type '%{type_name}' - it is empty"
|
4670
4684
|
msgstr ""
|
4671
4685
|
|
4672
|
-
#: ../lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb:44
|
4673
|
-
msgid "new"
|
4674
|
-
msgstr ""
|
4675
|
-
|
4676
4686
|
#: ../lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb:49
|
4677
4687
|
msgid "The code loaded from %{source_ref} does not create the resource type '%{type_name}' - no call to %{rname}.new found."
|
4678
4688
|
msgstr ""
|
@@ -4759,10 +4769,6 @@ msgstr ""
|
|
4759
4769
|
msgid "%{config_path}: Use of 'hiera.yaml' version 4 is deprecated. It should be converted to version 5"
|
4760
4770
|
msgstr ""
|
4761
4771
|
|
4762
|
-
#: ../lib/puppet/pops/lookup/hiera_config.rb:588
|
4763
|
-
msgid "data"
|
4764
|
-
msgstr ""
|
4765
|
-
|
4766
4772
|
#: ../lib/puppet/pops/lookup/invocation.rb:84
|
4767
4773
|
msgid "Recursive lookup detected in [%{name_stack}]"
|
4768
4774
|
msgstr ""
|
@@ -4987,6 +4993,10 @@ msgstr ""
|
|
4987
4993
|
msgid "The type '%{type}' does not represent a valid set of parameters for %{subject}.new()"
|
4988
4994
|
msgstr ""
|
4989
4995
|
|
4996
|
+
#: ../lib/puppet/pops/types/p_object_type.rb:604
|
4997
|
+
msgid "reference to unresolved type '%{name}'"
|
4998
|
+
msgstr ""
|
4999
|
+
|
4990
5000
|
#: ../lib/puppet/pops/types/tree_iterators.rb:38
|
4991
5001
|
msgid "Only Array, Hash, and Object types can be used as container types. Got %{type}"
|
4992
5002
|
msgstr ""
|
@@ -5923,6 +5933,10 @@ msgstr ""
|
|
5923
5933
|
msgid "Invalid value '%{value}' for boolean parameter: %{name}"
|
5924
5934
|
msgstr ""
|
5925
5935
|
|
5936
|
+
#: ../lib/puppet/settings/certificate_revocation_setting.rb:18
|
5937
|
+
msgid "Invalid certificate revocation value %{value}: must be one of 'true', 'chain', 'leaf', or 'false'"
|
5938
|
+
msgstr ""
|
5939
|
+
|
5926
5940
|
#: ../lib/puppet/settings/config_file.rb:38
|
5927
5941
|
msgid "Could not match line %{text}"
|
5928
5942
|
msgstr ""
|
@@ -6197,10 +6211,6 @@ msgstr ""
|
|
6197
6211
|
msgid "Creating a new certificate revocation list"
|
6198
6212
|
msgstr ""
|
6199
6213
|
|
6200
|
-
#: ../lib/puppet/ssl/certificate_revocation_list.rb:42
|
6201
|
-
msgid "crl"
|
6202
|
-
msgstr ""
|
6203
|
-
|
6204
6214
|
#: ../lib/puppet/ssl/certificate_revocation_list.rb:49
|
6205
6215
|
msgid "Revoked certificate with serial %{serial}"
|
6206
6216
|
msgstr ""
|
@@ -6245,22 +6255,26 @@ msgid ""
|
|
6245
6255
|
" 2. puppet agent -t\n"
|
6246
6256
|
msgstr ""
|
6247
6257
|
|
6248
|
-
#: ../lib/puppet/ssl/host.rb:
|
6258
|
+
#: ../lib/puppet/ssl/host.rb:333 ../lib/puppet/ssl/host.rb:354
|
6249
6259
|
msgid "Could not request certificate: %{message}"
|
6250
6260
|
msgstr ""
|
6251
6261
|
|
6252
|
-
#: ../lib/puppet/ssl/host.rb:
|
6262
|
+
#: ../lib/puppet/ssl/host.rb:335
|
6253
6263
|
msgid "Exiting; failed to retrieve certificate and waitforcert is disabled"
|
6254
6264
|
msgstr ""
|
6255
6265
|
|
6256
|
-
#: ../lib/puppet/ssl/host.rb:
|
6266
|
+
#: ../lib/puppet/ssl/host.rb:344
|
6257
6267
|
msgid "Exiting; no certificate found and waitforcert is disabled"
|
6258
6268
|
msgstr ""
|
6259
6269
|
|
6260
|
-
#: ../lib/puppet/ssl/host.rb:
|
6270
|
+
#: ../lib/puppet/ssl/host.rb:352
|
6261
6271
|
msgid "Did not receive certificate"
|
6262
6272
|
msgstr ""
|
6263
6273
|
|
6274
|
+
#: ../lib/puppet/ssl/host.rb:393
|
6275
|
+
msgid "Certificate revocation checking is enabled but a CRL cannot be found; CRL checking will not be performed."
|
6276
|
+
msgstr ""
|
6277
|
+
|
6264
6278
|
#: ../lib/puppet/ssl/inventory.rb:32
|
6265
6279
|
msgid "Rebuilding inventory file"
|
6266
6280
|
msgstr ""
|
@@ -18,8 +18,13 @@ describe "the epp function" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "gets error accessing a variable that is malformed" do
|
21
|
-
expect { eval_template("<%= $kryptonite::USER %>")}.to raise_error(
|
22
|
-
/Illegal variable name, The given name 'kryptonite::USER' does not conform to the naming rule/)
|
21
|
+
expect { eval_template("<%= $kryptonite::bbbbbbbbbbbb::cccccccc::ddd::USER %>")}.to raise_error(
|
22
|
+
/Illegal variable name, The given name 'kryptonite::bbbbbbbbbbbb::cccccccc::ddd::USER' does not conform to the naming rule/)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "gets error accessing a variable that is malformed as reported in PUP-7848" do
|
26
|
+
expect { eval_template("USER='<%= $hg_oais::archivematica::requirements::automation_tools::USER %>'")}.to raise_error(
|
27
|
+
/Illegal variable name, The given name 'hg_oais::archivematica::requirements::automation_tools::USER' does not conform to the naming rule/)
|
23
28
|
end
|
24
29
|
|
25
30
|
it "get nil accessing a variable that is undef" do
|
@@ -440,6 +440,7 @@ describe 'the 4x function api' do
|
|
440
440
|
let(:parser) { Puppet::Pops::Parser::EvaluatingParser.new }
|
441
441
|
let(:node) { 'node.example.com' }
|
442
442
|
let(:scope) { s = create_test_scope_for_node(node); s }
|
443
|
+
let(:loader) { Puppet::Pops::Loaders.find_loader(nil) }
|
443
444
|
|
444
445
|
it 'function with required block can be called' do
|
445
446
|
# construct ruby function to call
|
@@ -455,9 +456,9 @@ describe 'the 4x function api' do
|
|
455
456
|
end
|
456
457
|
end
|
457
458
|
# add the function to the loader (as if it had been loaded from somewhere)
|
458
|
-
the_loader = loader
|
459
|
+
the_loader = loader
|
459
460
|
f = fc.new({}, the_loader)
|
460
|
-
loader.
|
461
|
+
loader.set_entry(Puppet::Pops::Loader::TypedName.new(:function, 'testing::test'), f)
|
461
462
|
# evaluate a puppet call
|
462
463
|
source = "testing::test(10) |$x| { $x+1 }"
|
463
464
|
program = parser.parse_string(source, __FILE__)
|
@@ -23,4 +23,12 @@ describe Puppet::SSL::CertificateRevocationList::Rest do
|
|
23
23
|
it "should use the :ca SRV service" do
|
24
24
|
expect(Puppet::SSL::CertificateRevocationList::Rest.srv_service).to eq(:ca)
|
25
25
|
end
|
26
|
+
|
27
|
+
it "temporarily disables revocation checking when finding a CRL and no CRL is available" do
|
28
|
+
Puppet::FileSystem.expects(:exist?).with(Puppet[:hostcrl]).returns false
|
29
|
+
Puppet.override({:certificate_revocation => :chain}) do
|
30
|
+
Puppet.expects(:override).with({:certificate_revocation => false}, anything)
|
31
|
+
subject.find(nil)
|
32
|
+
end
|
33
|
+
end
|
26
34
|
end
|
@@ -137,7 +137,7 @@ describe Puppet::Network::HTTP::Connection do
|
|
137
137
|
expect do
|
138
138
|
connection.get('request')
|
139
139
|
end.to raise_error(Puppet::Error) do |error|
|
140
|
-
error.message =~
|
140
|
+
error.message =~ /\AServer hostname 'my_server' did not match server certificate; expected one of (.+)/
|
141
141
|
expect($1.split(', ')).to match_array(%w[DNS:foo DNS:bar DNS:baz DNS:not_my_server not_my_server])
|
142
142
|
end
|
143
143
|
end
|
@@ -261,6 +261,93 @@ describe Puppet::Network::HTTP::Connection do
|
|
261
261
|
end
|
262
262
|
end
|
263
263
|
|
264
|
+
context "when response indicates an overloaded server" do
|
265
|
+
let(:http) { stub('http') }
|
266
|
+
let(:site) { Puppet::Network::HTTP::Site.new('http', 'my_server', 8140) }
|
267
|
+
let(:verify) { Puppet::SSL::Validator.no_validator }
|
268
|
+
let(:httpunavailable) { Net::HTTPServiceUnavailable.new('1.1', 503, 'Service Unavailable') }
|
269
|
+
|
270
|
+
subject { Puppet::Network::HTTP::Connection.new(site.host, site.port, :use_ssl => false, :verify => verify) }
|
271
|
+
|
272
|
+
context "when parsing Retry-After headers" do
|
273
|
+
# Private method. Create a reference that can be called by tests.
|
274
|
+
let(:header_parser) { subject.method(:parse_retry_after_header) }
|
275
|
+
|
276
|
+
it "returns 0 when parsing a RFC 2822 date that has passed" do
|
277
|
+
test_date = 'Wed, 13 Apr 2005 15:18:05 GMT'
|
278
|
+
|
279
|
+
expect(header_parser.call(test_date)).to eq(0)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
it "should return a 503 response if Retry-After is not set" do
|
284
|
+
http.stubs(:request).returns(httpunavailable)
|
285
|
+
|
286
|
+
pool = Puppet.lookup(:http_pool)
|
287
|
+
pool.expects(:with_connection).with(site, anything).yields(http)
|
288
|
+
|
289
|
+
result = subject.get('/foo')
|
290
|
+
|
291
|
+
expect(result.code).to eq(503)
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should return a 503 response if Retry-After is not convertable to an Integer or RFC 2822 Date" do
|
295
|
+
httpunavailable['Retry-After'] = 'foo'
|
296
|
+
http.stubs(:request).returns(httpunavailable)
|
297
|
+
|
298
|
+
pool = Puppet.lookup(:http_pool)
|
299
|
+
pool.expects(:with_connection).with(site, anything).yields(http)
|
300
|
+
|
301
|
+
result = subject.get('/foo')
|
302
|
+
|
303
|
+
expect(result.code).to eq(503)
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should sleep and retry if Retry-After is an Integer" do
|
307
|
+
httpunavailable['Retry-After'] = '42'
|
308
|
+
http.stubs(:request).returns(httpunavailable).then.returns(httpok)
|
309
|
+
|
310
|
+
pool = Puppet.lookup(:http_pool)
|
311
|
+
pool.expects(:with_connection).with(site, anything).twice.yields(http)
|
312
|
+
|
313
|
+
::Kernel.expects(:sleep).with(42)
|
314
|
+
|
315
|
+
result = subject.get('/foo')
|
316
|
+
|
317
|
+
expect(result.code).to eq(200)
|
318
|
+
end
|
319
|
+
|
320
|
+
it "should sleep and retry if Retry-After is an RFC 2822 Date" do
|
321
|
+
httpunavailable['Retry-After'] = 'Wed, 13 Apr 2005 15:18:05 GMT'
|
322
|
+
http.stubs(:request).returns(httpunavailable).then.returns(httpok)
|
323
|
+
|
324
|
+
now = DateTime.new(2005, 4, 13, 8, 17, 5, '-07:00')
|
325
|
+
DateTime.stubs(:now).returns(now)
|
326
|
+
|
327
|
+
pool = Puppet.lookup(:http_pool)
|
328
|
+
pool.expects(:with_connection).with(site, anything).twice.yields(http)
|
329
|
+
|
330
|
+
::Kernel.expects(:sleep).with(60)
|
331
|
+
|
332
|
+
result = subject.get('/foo')
|
333
|
+
|
334
|
+
expect(result.code).to eq(200)
|
335
|
+
end
|
336
|
+
|
337
|
+
it "should sleep for no more than the Puppet runinterval" do
|
338
|
+
httpunavailable['Retry-After'] = '60'
|
339
|
+
http.stubs(:request).returns(httpunavailable).then.returns(httpok)
|
340
|
+
Puppet[:runinterval] = 30
|
341
|
+
|
342
|
+
pool = Puppet.lookup(:http_pool)
|
343
|
+
pool.expects(:with_connection).with(site, anything).twice.yields(http)
|
344
|
+
|
345
|
+
::Kernel.expects(:sleep).with(30)
|
346
|
+
|
347
|
+
result = subject.get('/foo')
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
264
351
|
it "allows setting basic auth on get requests" do
|
265
352
|
expect_request_with_basic_auth
|
266
353
|
|
@@ -448,6 +448,36 @@ describe 'Lexer2' do
|
|
448
448
|
)
|
449
449
|
end
|
450
450
|
|
451
|
+
it 'strips only last newline when using trim option' do
|
452
|
+
code = <<-CODE.unindent
|
453
|
+
@(END)
|
454
|
+
Line 1
|
455
|
+
|
456
|
+
Line 2
|
457
|
+
-END
|
458
|
+
CODE
|
459
|
+
expect(tokens_scanned_from(code)).to match_tokens2(
|
460
|
+
[:HEREDOC, ''],
|
461
|
+
[:SUBLOCATE, ["Line 1\n", "\n", "Line 2\n"]],
|
462
|
+
[:STRING, "Line 1\n\nLine 2"],
|
463
|
+
)
|
464
|
+
end
|
465
|
+
|
466
|
+
it 'strips only one newline at the end when using trim option' do
|
467
|
+
code = <<-CODE.unindent
|
468
|
+
@(END)
|
469
|
+
Line 1
|
470
|
+
Line 2
|
471
|
+
|
472
|
+
-END
|
473
|
+
CODE
|
474
|
+
expect(tokens_scanned_from(code)).to match_tokens2(
|
475
|
+
[:HEREDOC, ''],
|
476
|
+
[:SUBLOCATE, ["Line 1\n", "Line 2\n", "\n"]],
|
477
|
+
[:STRING, "Line 1\nLine 2\n"],
|
478
|
+
)
|
479
|
+
end
|
480
|
+
|
451
481
|
context 'with bad syntax' do
|
452
482
|
def expect_issue(code, issue)
|
453
483
|
expect { tokens_scanned_from(code) }.to raise_error(Puppet::ParseErrorWithIssue) { |e|
|
@@ -207,6 +207,36 @@ describe "egrammar parsing basic expressions" do
|
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
|
+
context 'When parsing type aliases' do
|
211
|
+
it 'type A = B' do
|
212
|
+
expect(dump(parse('type A = B'))).to eq('(type-alias A b)')
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'type A = B[]' do
|
216
|
+
expect{parse('type A = B[]')}.to raise_error(/Syntax error at '\]'/)
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'type A = B[,]' do
|
220
|
+
expect{parse('type A = B[,]')}.to raise_error(/Syntax error at ','/)
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'type A = B[C]' do
|
224
|
+
expect(dump(parse('type A = B[C]'))).to eq('(type-alias A (slice b c))')
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'type A = B[C,]' do
|
228
|
+
expect(dump(parse('type A = B[C,]'))).to eq('(type-alias A (slice b c))')
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'type A = B[C,D]' do
|
232
|
+
expect(dump(parse('type A = B[C,D]'))).to eq('(type-alias A (slice b (c d)))')
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'type A = B[C,D,]' do
|
236
|
+
expect(dump(parse('type A = B[C,D,]'))).to eq('(type-alias A (slice b (c d)))')
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
210
240
|
context "When parsing assignments" do
|
211
241
|
it "Should allow simple assignment" do
|
212
242
|
expect(dump(parse("$a = 10"))).to eq("(= $a 10)")
|
@@ -920,6 +920,14 @@ describe 'The Object Type' do
|
|
920
920
|
/attribute MySecondObject\[a\] attempts to override final attribute MyObject\[a\]/)
|
921
921
|
end
|
922
922
|
|
923
|
+
it 'a type cannot be created using an unresolved parent' do
|
924
|
+
code = <<-CODE
|
925
|
+
notice(Object[{ name => 'MyObject', parent => Type('NoneSuch'), attributes => { a => String}}].new('hello'))
|
926
|
+
CODE
|
927
|
+
expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error,
|
928
|
+
/reference to unresolved type 'NoneSuch'/)
|
929
|
+
end
|
930
|
+
|
923
931
|
context 'type alias using bracket-less (implicit Object) form' do
|
924
932
|
let(:logs) { [] }
|
925
933
|
let(:notices) { logs.select { |log| log.level == :notice }.map { |log| log.message } }
|
@@ -970,7 +978,7 @@ describe 'The Object Type' do
|
|
970
978
|
Puppet[:strict] = 'warning'
|
971
979
|
compile(<<-CODE)
|
972
980
|
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
973
|
-
type MySecondObject = { parent =>
|
981
|
+
type MySecondObject = { parent => MyObject, attributes => { b => String }}
|
974
982
|
notice(MySecondObject =~ Type)
|
975
983
|
CODE
|
976
984
|
expect(warnings).to be_empty
|
@@ -981,7 +989,7 @@ describe 'The Object Type' do
|
|
981
989
|
Puppet[:strict] = 'warning'
|
982
990
|
compile(<<-CODE)
|
983
991
|
type MyObject = { name => 'MyFirstObject', attributes => { a => String }}
|
984
|
-
type MySecondObject = Object { parent =>
|
992
|
+
type MySecondObject = Object { parent => MyObject, attributes => { b => String }}
|
985
993
|
notice(MySecondObject =~ Type)
|
986
994
|
CODE
|
987
995
|
expect(warnings).to be_empty
|
@@ -523,6 +523,19 @@ describe 'The type calculator' do
|
|
523
523
|
end
|
524
524
|
end
|
525
525
|
end
|
526
|
+
|
527
|
+
it 'infers an instance of an anonymous class to Runtime[ruby]' do
|
528
|
+
cls = Class.new do
|
529
|
+
attr_reader :name
|
530
|
+
def initialize(name)
|
531
|
+
@name = name
|
532
|
+
end
|
533
|
+
end
|
534
|
+
t = calculator.infer(cls.new('test'))
|
535
|
+
expect(t.class).to eql(PRuntimeType)
|
536
|
+
expect(t.runtime).to eql(:ruby)
|
537
|
+
expect(t.name_or_pattern).to eql(nil)
|
538
|
+
end
|
526
539
|
end
|
527
540
|
|
528
541
|
context 'patterns' do
|