puppet 2.7.18 → 2.7.19
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/CHANGELOG +82 -0
- data/CONTRIBUTING.md +114 -171
- data/README.md +8 -0
- data/README_DEVELOPER.md +38 -3
- data/Rakefile +19 -3
- data/conf/osx/createpackage.sh +3 -1
- data/conf/redhat/logrotate +1 -1
- data/conf/redhat/puppet.spec +35 -8
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +2 -0
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/configurer.rb +2 -3
- data/lib/puppet/defaults.rb +6 -5
- data/lib/puppet/face/module/install.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/indirector/file_content.rb +2 -2
- data/lib/puppet/indirector/file_metadata.rb +2 -2
- data/lib/puppet/indirector/indirection.rb +3 -4
- data/lib/puppet/indirector/rest.rb +12 -6
- data/lib/puppet/interface/action_manager.rb +1 -2
- data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
- data/lib/puppet/network/handler/fileserver.rb +2 -2
- data/lib/puppet/parser/ast/resource.rb +9 -2
- data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
- data/lib/puppet/parser/functions/md5.rb +2 -2
- data/lib/puppet/parser/functions/sha1.rb +2 -2
- data/lib/puppet/parser/functions/template.rb +0 -2
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +19 -1
- data/lib/puppet/provider/confine.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +97 -51
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
- data/lib/puppet/provider/service/gentoo.rb +0 -2
- data/lib/puppet/provider/service/openrc.rb +69 -0
- data/lib/puppet/provider/service/windows.rb +6 -4
- data/lib/puppet/provider/user/aix.rb +8 -4
- data/lib/puppet/provider/user/useradd.rb +6 -0
- data/lib/puppet/rails/benchmark.rb +2 -2
- data/lib/puppet/reports/store.rb +9 -9
- data/lib/puppet/resource/catalog.rb +2 -1
- data/lib/puppet/resource/type_collection.rb +2 -1
- data/lib/puppet/ssl/base.rb +1 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
- data/lib/puppet/test/test_helper.rb +2 -1
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/scheduled_task.rb +8 -10
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/util.rb +63 -25
- data/lib/puppet/util/autoload.rb +6 -4
- data/lib/puppet/util/checksums.rb +3 -8
- data/lib/puppet/util/diff.rb +2 -1
- data/lib/puppet/util/filetype.rb +1 -3
- data/lib/puppet/util/run_mode.rb +2 -1
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/file.rb +27 -0
- data/lib/puppet/util/windows/user.rb +1 -2
- data/man/man8/puppet-agent.8 +4 -0
- data/man/man8/puppet-master.8 +4 -0
- data/man/man8/puppetmasterd.8 +4 -0
- data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
- data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
- data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
- data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
- data/spec/integration/defaults_spec.rb +3 -3
- data/spec/integration/network/server/mongrel_spec.rb +8 -6
- data/spec/integration/parser/parser_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +49 -12
- data/spec/lib/puppet_spec/database.rb +5 -3
- data/spec/lib/puppet_spec/files.rb +2 -1
- data/spec/monkey_patches/alias_should_to_must.rb +15 -2
- data/spec/shared_behaviours/file_serving_model.rb +9 -6
- data/spec/shared_behaviours/path_parameters.rb +5 -5
- data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
- data/spec/unit/application/facts_spec.rb +1 -1
- data/spec/unit/application_spec.rb +10 -8
- data/spec/unit/configurer_spec.rb +11 -2
- data/spec/unit/face/ca_spec.rb +15 -15
- data/spec/unit/face/help_spec.rb +5 -5
- data/spec/unit/face/module/install_spec.rb +13 -2
- data/spec/unit/face/node_spec.rb +7 -6
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
- data/spec/unit/indirector/envelope_spec.rb +0 -13
- data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
- data/spec/unit/indirector/queue_spec.rb +3 -3
- data/spec/unit/indirector/rest_spec.rb +31 -20
- data/spec/unit/indirector_spec.rb +5 -5
- data/spec/unit/interface/action_builder_spec.rb +3 -2
- data/spec/unit/interface/action_manager_spec.rb +1 -1
- data/spec/unit/interface/action_spec.rb +4 -3
- data/spec/unit/interface/face_collection_spec.rb +1 -1
- data/spec/unit/interface/option_spec.rb +13 -9
- data/spec/unit/interface_spec.rb +5 -5
- data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
- data/spec/unit/network/handler/fileserver_spec.rb +3 -3
- data/spec/unit/other/transbucket_spec.rb +6 -9
- data/spec/unit/parser/ast/resource_spec.rb +27 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
- data/spec/unit/parser/lexer_spec.rb +5 -5
- data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
- data/spec/unit/provider/package/freebsd_spec.rb +2 -2
- data/spec/unit/provider/package/msi_spec.rb +181 -114
- data/spec/unit/provider/package/openbsd_spec.rb +1 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
- data/spec/unit/provider/service/openrc_spec.rb +209 -0
- data/spec/unit/provider/service/windows_spec.rb +57 -59
- data/spec/unit/provider/user/useradd_spec.rb +7 -0
- data/spec/unit/reports/store_spec.rb +13 -13
- data/spec/unit/resource/catalog_spec.rb +29 -24
- data/spec/unit/resource_spec.rb +13 -13
- data/spec/unit/simple_graph_spec.rb +12 -12
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
- data/spec/unit/transaction_spec.rb +3 -3
- data/spec/unit/type/cron_spec.rb +171 -171
- data/spec/unit/type/exec_spec.rb +29 -27
- data/spec/unit/type/file_spec.rb +22 -13
- data/spec/unit/type/interface_spec.rb +1 -1
- data/spec/unit/type/scheduled_task_spec.rb +15 -14
- data/spec/unit/type/tidy_spec.rb +2 -2
- data/spec/unit/type/user_spec.rb +15 -15
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +22 -25
- data/spec/unit/util/autoload_spec.rb +13 -7
- data/spec/unit/util/backups_spec.rb +36 -67
- data/spec/unit/util/storage_spec.rb +2 -9
- data/spec/unit/util/suidmanager_spec.rb +1 -1
- data/spec/unit/util_spec.rb +20 -28
- data/test/ral/manager/attributes.rb +1 -1
- metadata +1553 -1542
@@ -88,6 +88,13 @@ describe provider_class do
|
|
88
88
|
@resource.stubs(:managehome?).returns true
|
89
89
|
@provider.check_manage_home.must == ["-m"]
|
90
90
|
end
|
91
|
+
|
92
|
+
it "should return an array with -r flag if home is managed" do
|
93
|
+
@resource.stubs(:managehome?).returns true
|
94
|
+
@resource.stubs(:ensure) == :absent
|
95
|
+
@provider.stubs(:command).returns("userdel")
|
96
|
+
@provider.deletecmd.must == ["userdel", "-r", "fakeval"]
|
97
|
+
end
|
91
98
|
|
92
99
|
it "should return an array with -M if home is not managed and on Redhat" do
|
93
100
|
Facter.stubs(:value).with("operatingsystem").returns("RedHat")
|
@@ -45,31 +45,31 @@ describe processor do
|
|
45
45
|
@report.process
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
it "rejects invalid hostnames" do
|
49
|
+
@report.host = ".."
|
50
|
+
FileTest.expects(:exists?).never
|
51
|
+
Tempfile.expects(:new).never
|
52
|
+
expect { @report.process }.to raise_error(ArgumentError, /Invalid node/)
|
53
53
|
end
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
56
|
+
describe "::destroy" do
|
57
|
+
it "rejects invalid hostnames" do
|
58
|
+
File.expects(:unlink).never
|
59
|
+
expect { processor.destroy("..") }.to raise_error(ArgumentError, /Invalid node/)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
describe "::
|
63
|
+
describe "::validate_host" do
|
64
64
|
['..', 'hello/', '/hello', 'he/llo', 'hello/..', '.'].each do |node|
|
65
65
|
it "rejects #{node.inspect}" do
|
66
|
-
expect { processor.
|
66
|
+
expect { processor.validate_host(node) }.to raise_error(ArgumentError, /Invalid node/)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
['.hello', 'hello.', '..hi', 'hi..'].each do |node|
|
71
71
|
it "accepts #{node.inspect}" do
|
72
|
-
processor.
|
72
|
+
processor.validate_host(node)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -309,7 +309,12 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
309
309
|
end
|
310
310
|
|
311
311
|
it "should add all resources as RAL instances" do
|
312
|
-
@resources.each
|
312
|
+
@resources.each do |resource|
|
313
|
+
# Warning: a failure here will result in "global resource iteration is
|
314
|
+
# deprecated" being raised, because the rspec rendering to get the
|
315
|
+
# result tries to call `each` on the resource, and that raises.
|
316
|
+
@catalog.resource(resource.ref).must be_a_kind_of(Puppet::Type)
|
317
|
+
end
|
313
318
|
end
|
314
319
|
|
315
320
|
it "should copy the tag list to the new catalog" do
|
@@ -416,8 +421,8 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
416
421
|
|
417
422
|
it "should provide a method to add one or more resources" do
|
418
423
|
@catalog.add_resource @one, @two
|
419
|
-
@catalog.resource(@one.ref).
|
420
|
-
@catalog.resource(@two.ref).
|
424
|
+
@catalog.resource(@one.ref).must equal(@one)
|
425
|
+
@catalog.resource(@two.ref).must equal(@two)
|
421
426
|
end
|
422
427
|
|
423
428
|
it "should add resources to the relationship graph if it exists" do
|
@@ -433,20 +438,18 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
433
438
|
|
434
439
|
it "should make all vertices available by resource reference" do
|
435
440
|
@catalog.add_resource(@one)
|
436
|
-
@catalog.resource(@one.ref).
|
437
|
-
@catalog.vertices.find { |r| r.ref == @one.ref }.
|
441
|
+
@catalog.resource(@one.ref).must equal(@one)
|
442
|
+
@catalog.vertices.find { |r| r.ref == @one.ref }.must equal(@one)
|
438
443
|
end
|
439
444
|
|
440
445
|
it "should canonize how resources are referred to during retrieval when both type and title are provided" do
|
441
446
|
@catalog.add_resource(@one)
|
442
|
-
|
443
|
-
@catalog.resource("notify", "one").should equal(@one)
|
447
|
+
@catalog.resource("notify", "one").must equal(@one)
|
444
448
|
end
|
445
449
|
|
446
450
|
it "should canonize how resources are referred to during retrieval when just the title is provided" do
|
447
451
|
@catalog.add_resource(@one)
|
448
|
-
|
449
|
-
@catalog.resource("notify[one]", nil).should equal(@one)
|
452
|
+
@catalog.resource("notify[one]", nil).must equal(@one)
|
450
453
|
end
|
451
454
|
|
452
455
|
it "should not allow two resources with the same resource reference" do
|
@@ -502,26 +505,28 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
502
505
|
|
503
506
|
it "should be able to find resources by reference" do
|
504
507
|
@catalog.add_resource @one
|
505
|
-
@catalog.resource(@one.ref).
|
508
|
+
@catalog.resource(@one.ref).must equal(@one)
|
506
509
|
end
|
507
510
|
|
508
511
|
it "should be able to find resources by reference or by type/title tuple" do
|
509
512
|
@catalog.add_resource @one
|
510
|
-
@catalog.resource("notify", "one").
|
513
|
+
@catalog.resource("notify", "one").must equal(@one)
|
511
514
|
end
|
512
515
|
|
513
516
|
it "should have a mechanism for removing resources" do
|
514
|
-
@catalog.add_resource
|
515
|
-
@one.
|
517
|
+
@catalog.add_resource(@one)
|
518
|
+
@catalog.resource(@one.ref).must be
|
519
|
+
@catalog.vertex?(@one).must be_true
|
520
|
+
|
516
521
|
@catalog.remove_resource(@one)
|
517
|
-
@catalog.resource(@one.ref).
|
518
|
-
@catalog.vertex?(@one).
|
522
|
+
@catalog.resource(@one.ref).must be_nil
|
523
|
+
@catalog.vertex?(@one).must be_false
|
519
524
|
end
|
520
525
|
|
521
526
|
it "should have a method for creating aliases for resources" do
|
522
527
|
@catalog.add_resource @one
|
523
528
|
@catalog.alias(@one, "other")
|
524
|
-
@catalog.resource("notify", "other").
|
529
|
+
@catalog.resource("notify", "other").must equal(@one)
|
525
530
|
end
|
526
531
|
|
527
532
|
it "should ignore conflicting aliases that point to the aliased resource" do
|
@@ -534,7 +539,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
534
539
|
|
535
540
|
@catalog.add_resource(resource)
|
536
541
|
|
537
|
-
@catalog.resource(:file, @basepath+"/something").
|
542
|
+
@catalog.resource(:file, @basepath+"/something").must equal(resource)
|
538
543
|
end
|
539
544
|
|
540
545
|
it "should not create aliases for non-isomorphic resources whose names do not match their titles" do
|
@@ -550,7 +555,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
550
555
|
it "should alias using the class name from the resource reference, not the resource class name" do
|
551
556
|
@catalog.add_resource @one
|
552
557
|
@catalog.alias(@one, "other")
|
553
|
-
@catalog.resource("notify", "other").
|
558
|
+
@catalog.resource("notify", "other").must equal(@one)
|
554
559
|
end
|
555
560
|
|
556
561
|
it "should fail to add an alias if the aliased name already exists" do
|
@@ -565,13 +570,13 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
565
570
|
|
566
571
|
it "should not create aliases that point back to the resource" do
|
567
572
|
@catalog.alias(@one, "one")
|
568
|
-
@catalog.resource(:notify, "one").
|
573
|
+
@catalog.resource(:notify, "one").must be_nil
|
569
574
|
end
|
570
575
|
|
571
576
|
it "should be able to look resources up by their aliases" do
|
572
577
|
@catalog.add_resource @one
|
573
578
|
@catalog.alias @one, "two"
|
574
|
-
@catalog.resource(:notify, "two").
|
579
|
+
@catalog.resource(:notify, "two").must equal(@one)
|
575
580
|
end
|
576
581
|
|
577
582
|
it "should remove resource aliases when the target resource is removed" do
|
@@ -579,14 +584,14 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
579
584
|
@catalog.alias(@one, "other")
|
580
585
|
@one.expects :remove
|
581
586
|
@catalog.remove_resource(@one)
|
582
|
-
@catalog.resource("notify", "other").
|
587
|
+
@catalog.resource("notify", "other").must be_nil
|
583
588
|
end
|
584
589
|
|
585
590
|
it "should add an alias for the namevar when the title and name differ on isomorphic resource types" do
|
586
591
|
resource = Puppet::Type.type(:file).new :path => @basepath+"/something", :title => "other", :content => "blah"
|
587
592
|
resource.expects(:isomorphic?).returns(true)
|
588
593
|
@catalog.add_resource(resource)
|
589
|
-
@catalog.resource(:file, "other").
|
594
|
+
@catalog.resource(:file, "other").must equal(resource)
|
590
595
|
@catalog.resource(:file, @basepath+"/something").ref.should == resource.ref
|
591
596
|
end
|
592
597
|
|
@@ -594,7 +599,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
594
599
|
resource = Puppet::Type.type(:file).new :path => @basepath+"/something", :title => "other", :content => "blah"
|
595
600
|
resource.expects(:isomorphic?).returns(false)
|
596
601
|
@catalog.add_resource(resource)
|
597
|
-
@catalog.resource(:file, resource.title).
|
602
|
+
@catalog.resource(:file, resource.title).must equal(resource)
|
598
603
|
# We can't use .should here, because the resources respond to that method.
|
599
604
|
raise "Aliased non-isomorphic resource" if @catalog.resource(:file, resource.name)
|
600
605
|
end
|
@@ -604,7 +609,7 @@ describe Puppet::Resource::Catalog, "when compiling" do
|
|
604
609
|
resource = stub 'file', :ref => "File[/yay]", :catalog= => @catalog, :title => "/yay", :[] => "/yay"
|
605
610
|
Puppet::Type.type(:file).expects(:new).with(args).returns(resource)
|
606
611
|
@catalog.create_resource :file, args
|
607
|
-
@catalog.resource("File[/yay]").
|
612
|
+
@catalog.resource("File[/yay]").must equal(resource)
|
608
613
|
end
|
609
614
|
|
610
615
|
describe "when adding resources with multiple namevars" do
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Puppet::Resource do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should require the type and title" do
|
23
|
-
|
23
|
+
expect { Puppet::Resource.new }.to raise_error(ArgumentError)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should canonize types to capitalized strings" do
|
@@ -93,15 +93,15 @@ describe Puppet::Resource do
|
|
93
93
|
|
94
94
|
|
95
95
|
it "should fail if the title is nil and the type is not a valid resource reference string" do
|
96
|
-
expect { Puppet::Resource.new("resource-spec-foo") }.
|
96
|
+
expect { Puppet::Resource.new("resource-spec-foo") }.to raise_error(ArgumentError)
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'should fail if strict is set and type does not exist' do
|
100
|
-
expect { Puppet::Resource.new('resource-spec-foo', 'title', {:strict=>true}) }.
|
100
|
+
expect { Puppet::Resource.new('resource-spec-foo', 'title', {:strict=>true}) }.to raise_error(ArgumentError, 'Invalid resource type resource-spec-foo')
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should fail if strict is set and class does not exist' do
|
104
|
-
expect { Puppet::Resource.new('Class', 'resource-spec-foo', {:strict=>true}) }.
|
104
|
+
expect { Puppet::Resource.new('Class', 'resource-spec-foo', {:strict=>true}) }.to raise_error(ArgumentError, 'Could not find declared class resource-spec-foo')
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should fail if the title is a hash and the type is not a valid resource reference string" do
|
@@ -284,11 +284,11 @@ describe Puppet::Resource do
|
|
284
284
|
end
|
285
285
|
|
286
286
|
it "should fail if invalid parameters are used" do
|
287
|
-
expect { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.
|
287
|
+
expect { Puppet::Resource.new("file", "/path", :strict => true, :parameters => {:nosuchparam => "bar"}) }.to raise_error
|
288
288
|
end
|
289
289
|
|
290
290
|
it "should fail if the resource type cannot be resolved" do
|
291
|
-
expect { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.
|
291
|
+
expect { Puppet::Resource.new("nosuchtype", "/path", :strict => true) }.to raise_error
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
@@ -353,7 +353,7 @@ describe Puppet::Resource do
|
|
353
353
|
it "should be able to set the name for non-builtin types" do
|
354
354
|
resource = Puppet::Resource.new(:foo, "bar")
|
355
355
|
resource[:name] = "eh"
|
356
|
-
expect { resource[:name] = "eh" }.
|
356
|
+
expect { resource[:name] = "eh" }.to_not raise_error
|
357
357
|
end
|
358
358
|
|
359
359
|
it "should be able to return the name for non-builtin types" do
|
@@ -445,7 +445,7 @@ describe Puppet::Resource do
|
|
445
445
|
end
|
446
446
|
|
447
447
|
it "should be able to be dumped to yaml" do
|
448
|
-
|
448
|
+
expect { YAML.dump(@resource) }.to_not raise_error
|
449
449
|
end
|
450
450
|
|
451
451
|
it "should produce an equivalent yaml object" do
|
@@ -470,7 +470,7 @@ type: File
|
|
470
470
|
end
|
471
471
|
|
472
472
|
it "should deserialize a Puppet::Resource::Reference without exceptions" do
|
473
|
-
expect { YAML.load(@old_storedconfig_yaml) }.
|
473
|
+
expect { YAML.load(@old_storedconfig_yaml) }.to_not raise_error
|
474
474
|
end
|
475
475
|
|
476
476
|
it "should deserialize as a Puppet::Resource::Reference as a Puppet::Resource" do
|
@@ -486,7 +486,7 @@ type: File
|
|
486
486
|
it "should use the resource type's :new method to create the resource if the resource is of a builtin type" do
|
487
487
|
resource = Puppet::Resource.new("file", basepath+"/my/file")
|
488
488
|
result = resource.to_ral
|
489
|
-
result.
|
489
|
+
result.must be_instance_of(Puppet::Type.type(:file))
|
490
490
|
result[:path].should == basepath+"/my/file"
|
491
491
|
end
|
492
492
|
|
@@ -494,7 +494,7 @@ type: File
|
|
494
494
|
resource = Puppet::Resource.new("foobar", "somename")
|
495
495
|
result = resource.to_ral
|
496
496
|
|
497
|
-
result.
|
497
|
+
result.must be_instance_of(Puppet::Type.type(:component))
|
498
498
|
result.title.should == "Foobar[somename]"
|
499
499
|
end
|
500
500
|
end
|
@@ -735,12 +735,12 @@ type: File
|
|
735
735
|
|
736
736
|
it "should fail if no title is provided" do
|
737
737
|
@data.delete('title')
|
738
|
-
expect { Puppet::Resource.from_pson(@data) }.
|
738
|
+
expect { Puppet::Resource.from_pson(@data) }.to raise_error(ArgumentError)
|
739
739
|
end
|
740
740
|
|
741
741
|
it "should fail if no type is provided" do
|
742
742
|
@data.delete('type')
|
743
|
-
expect { Puppet::Resource.from_pson(@data) }.
|
743
|
+
expect { Puppet::Resource.from_pson(@data) }.to raise_error(ArgumentError)
|
744
744
|
end
|
745
745
|
|
746
746
|
it "should set each of the provided parameters" do
|
@@ -24,7 +24,7 @@ describe Puppet::SimpleGraph do
|
|
24
24
|
@graph = Puppet::SimpleGraph.new
|
25
25
|
@graph.add_edge(:one, :two)
|
26
26
|
|
27
|
-
|
27
|
+
expect { @graph.to_dot_graph }.to_not raise_error
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "when managing vertices" do
|
@@ -45,7 +45,7 @@ describe Puppet::SimpleGraph do
|
|
45
45
|
|
46
46
|
it "should ignore already-present vertices when asked to add a vertex" do
|
47
47
|
@graph.add_vertex(:test)
|
48
|
-
|
48
|
+
expect { @graph.add_vertex(:test) }.to_not raise_error
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should return true when asked if a vertex is present" do
|
@@ -72,7 +72,7 @@ describe Puppet::SimpleGraph do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should do nothing when a non-vertex is asked to be removed" do
|
75
|
-
|
75
|
+
expect { @graph.remove_vertex!(:one) }.to_not raise_error
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -291,22 +291,22 @@ describe Puppet::SimpleGraph do
|
|
291
291
|
|
292
292
|
it "should fail on two-vertex loops" do
|
293
293
|
add_edges :a => :b, :b => :a
|
294
|
-
|
294
|
+
expect { @graph.report_cycles_in_graph }.to raise_error(Puppet::Error)
|
295
295
|
end
|
296
296
|
|
297
297
|
it "should fail on multi-vertex loops" do
|
298
298
|
add_edges :a => :b, :b => :c, :c => :a
|
299
|
-
|
299
|
+
expect { @graph.report_cycles_in_graph }.to raise_error(Puppet::Error)
|
300
300
|
end
|
301
301
|
|
302
302
|
it "should fail when a larger tree contains a small cycle" do
|
303
303
|
add_edges :a => :b, :b => :a, :c => :a, :d => :c
|
304
|
-
|
304
|
+
expect { @graph.report_cycles_in_graph }.to raise_error(Puppet::Error)
|
305
305
|
end
|
306
306
|
|
307
307
|
it "should succeed on trees with no cycles" do
|
308
308
|
add_edges :a => :b, :b => :e, :c => :a, :d => :c
|
309
|
-
|
309
|
+
expect { @graph.report_cycles_in_graph }.to_not raise_error
|
310
310
|
end
|
311
311
|
|
312
312
|
it "should produce the correct relationship text" do
|
@@ -323,7 +323,7 @@ describe Puppet::SimpleGraph do
|
|
323
323
|
add_edges "b" => "c"
|
324
324
|
|
325
325
|
cycles = nil
|
326
|
-
expect { cycles = @graph.find_cycles_in_graph }.
|
326
|
+
expect { cycles = @graph.find_cycles_in_graph }.to_not raise_error
|
327
327
|
simplify(cycles).should be == [["a", "b"]]
|
328
328
|
end
|
329
329
|
|
@@ -332,7 +332,7 @@ describe Puppet::SimpleGraph do
|
|
332
332
|
add_edges "b" => "b1", "b1" => "b"
|
333
333
|
|
334
334
|
cycles = nil
|
335
|
-
expect { cycles = @graph.find_cycles_in_graph }.
|
335
|
+
expect { cycles = @graph.find_cycles_in_graph }.to_not raise_error
|
336
336
|
simplify(cycles).should be == [["a1", "a"], ["b1", "b"]]
|
337
337
|
end
|
338
338
|
|
@@ -342,7 +342,7 @@ describe Puppet::SimpleGraph do
|
|
342
342
|
add_edges "c" => "c1", "c1" => "c2", "c2" => "c3", "c3" => "c"
|
343
343
|
|
344
344
|
cycles = nil
|
345
|
-
expect { cycles = @graph.find_cycles_in_graph }.
|
345
|
+
expect { cycles = @graph.find_cycles_in_graph }.to_not raise_error
|
346
346
|
simplify(cycles).should be == [%w{a1 a}, %w{c1 c2 c3 c}]
|
347
347
|
end
|
348
348
|
|
@@ -353,7 +353,7 @@ describe Puppet::SimpleGraph do
|
|
353
353
|
add_edges "c" => "c2", "c2" => "b"
|
354
354
|
|
355
355
|
cycles = nil
|
356
|
-
expect { cycles = @graph.find_cycles_in_graph }.
|
356
|
+
expect { cycles = @graph.find_cycles_in_graph }.to_not raise_error
|
357
357
|
simplify(cycles).should be == [%w{a b c1 c2 c}]
|
358
358
|
end
|
359
359
|
|
@@ -362,7 +362,7 @@ describe Puppet::SimpleGraph do
|
|
362
362
|
(1..(limit - 1)).each do |n| add_edges n.to_s => (n+1).to_s end
|
363
363
|
|
364
364
|
cycles = nil
|
365
|
-
expect { cycles = @graph.find_cycles_in_graph }.
|
365
|
+
expect { cycles = @graph.find_cycles_in_graph }.to_not raise_error
|
366
366
|
simplify(cycles).should be == []
|
367
367
|
end
|
368
368
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env rspec
|
1
|
+
#!/usr/bin/env ruby -S rspec
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
require 'puppet/ssl/certificate_authority'
|
@@ -95,14 +95,14 @@ describe Puppet::SSL::CertificateAuthority::Interface do
|
|
95
95
|
lambda { @applier.apply(@ca) }.should raise_error(Puppet::SSL::CertificateAuthority::Interface::InterfaceError)
|
96
96
|
end
|
97
97
|
|
98
|
-
it "should log non-Interface failures
|
98
|
+
it "should log non-Interface failures" do
|
99
99
|
@applier = @class.new(:revoke, :to => :all)
|
100
100
|
|
101
101
|
@ca.expects(:list).raises ArgumentError
|
102
102
|
|
103
103
|
Puppet.expects(:err)
|
104
104
|
|
105
|
-
lambda { @applier.apply(@ca) }.
|
105
|
+
lambda { @applier.apply(@ca) }.should raise_error
|
106
106
|
end
|
107
107
|
|
108
108
|
describe "with an empty array specified and the method is not list" do
|
@@ -370,14 +370,15 @@ describe Puppet::SSL::CertificateAuthority do
|
|
370
370
|
it "should fail if no CSR can be found for the host" do
|
371
371
|
Puppet::SSL::CertificateRequest.indirection.expects(:find).with(@name).returns nil
|
372
372
|
|
373
|
-
|
373
|
+
expect { @ca.sign(@name) }.to raise_error(ArgumentError)
|
374
374
|
end
|
375
375
|
|
376
376
|
it "should fail if an unknown request extension is present" do
|
377
377
|
@request.stubs :request_extensions => [{ "oid" => "bananas",
|
378
378
|
"value" => "delicious" }]
|
379
|
-
expect {
|
380
|
-
|
379
|
+
expect {
|
380
|
+
@ca.sign(@name)
|
381
|
+
}.to raise_error(/CSR has request extensions that are not permitted/)
|
381
382
|
end
|
382
383
|
|
383
384
|
it "should fail if the CSR contains alt names and they are not expected" do
|
@@ -390,7 +391,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
390
391
|
|
391
392
|
it "should not fail if the CSR does not contain alt names and they are expected" do
|
392
393
|
@request.stubs(:subject_alt_names).returns []
|
393
|
-
expect { @ca.sign(@name, true) }.
|
394
|
+
expect { @ca.sign(@name, true) }.to_not raise_error
|
394
395
|
end
|
395
396
|
|
396
397
|
it "should reject alt names by default" do
|
@@ -705,7 +706,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
705
706
|
|
706
707
|
describe "when applying a method to a set of hosts" do
|
707
708
|
it "should fail if no subjects have been specified" do
|
708
|
-
|
709
|
+
expect { @ca.apply(:generate) }.to raise_error(ArgumentError)
|
709
710
|
end
|
710
711
|
|
711
712
|
it "should create an Interface instance with the specified method and the options" do
|
@@ -769,7 +770,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
769
770
|
it "should raise an error if the certificate or CSR cannot be found" do
|
770
771
|
Puppet::SSL::Certificate.indirection.expects(:find).with("myhost").returns nil
|
771
772
|
Puppet::SSL::CertificateRequest.indirection.expects(:find).with("myhost").returns nil
|
772
|
-
|
773
|
+
expect { @ca.fingerprint("myhost") }.to raise_error
|
773
774
|
end
|
774
775
|
|
775
776
|
it "should try to find a CSR if no certificate can be found" do
|
@@ -809,7 +810,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
809
810
|
it "should fail if the host's certificate cannot be found" do
|
810
811
|
Puppet::SSL::Certificate.indirection.expects(:find).with("me").returns(nil)
|
811
812
|
|
812
|
-
|
813
|
+
expect { @ca.verify("me") }.to raise_error(ArgumentError)
|
813
814
|
end
|
814
815
|
|
815
816
|
it "should create an SSL Store to verify" do
|
@@ -857,7 +858,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
857
858
|
|
858
859
|
@store.expects(:verify).with("mycert").returns false
|
859
860
|
|
860
|
-
|
861
|
+
expect { @ca.verify("me") }.to raise_error
|
861
862
|
end
|
862
863
|
end
|
863
864
|
|
@@ -877,7 +878,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
877
878
|
it "should fail if the certificate revocation list is disabled" do
|
878
879
|
@ca.stubs(:crl).returns false
|
879
880
|
|
880
|
-
|
881
|
+
expect { @ca.revoke('ca_testing') }.to raise_error(ArgumentError)
|
881
882
|
|
882
883
|
end
|
883
884
|
|
@@ -923,7 +924,7 @@ describe Puppet::SSL::CertificateAuthority do
|
|
923
924
|
it "should fail if a certificate already exists for the host" do
|
924
925
|
Puppet::SSL::Certificate.indirection.expects(:find).with("him").returns "something"
|
925
926
|
|
926
|
-
|
927
|
+
expect { @ca.generate("him") }.to raise_error(ArgumentError)
|
927
928
|
end
|
928
929
|
|
929
930
|
it "should create a new Host instance with the correct name" do
|