puppet 2.6.1 → 2.6.2

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 (79) hide show
  1. data/CHANGELOG +51 -195
  2. data/LICENSE +2 -2
  3. data/conf/suse/puppet.spec +13 -10
  4. data/install.rb +7 -13
  5. data/lib/puppet.rb +1 -1
  6. data/lib/puppet/application.rb +17 -21
  7. data/lib/puppet/defaults.rb +1 -1
  8. data/lib/puppet/dsl.rb +0 -4
  9. data/lib/puppet/dsl/resource_type_api.rb +16 -10
  10. data/lib/puppet/external/event-loop/event-loop.rb +15 -11
  11. data/lib/puppet/feature/base.rb +2 -1
  12. data/lib/puppet/feature/rails.rb +1 -3
  13. data/lib/puppet/network/http/webrick/rest.rb +1 -0
  14. data/lib/puppet/network/http_pool.rb +0 -12
  15. data/lib/puppet/parser/ast/function.rb +1 -1
  16. data/lib/puppet/parser/ast/resource.rb +1 -5
  17. data/lib/puppet/parser/functions/extlookup.rb +1 -1
  18. data/lib/puppet/parser/functions/versioncmp.rb +3 -3
  19. data/lib/puppet/parser/lexer.rb +1 -1
  20. data/lib/puppet/parser/parser_support.rb +4 -2
  21. data/lib/puppet/parser/resource.rb +8 -0
  22. data/lib/puppet/parser/type_loader.rb +50 -48
  23. data/lib/puppet/provider/nameservice.rb +1 -0
  24. data/lib/puppet/provider/nameservice/objectadd.rb +2 -1
  25. data/lib/puppet/provider/service/freebsd.rb +1 -1
  26. data/lib/puppet/provider/service/launchd.rb +16 -9
  27. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -0
  28. data/lib/puppet/provider/user/hpux.rb +0 -1
  29. data/lib/puppet/provider/user/user_role_add.rb +21 -9
  30. data/lib/puppet/provider/user/useradd.rb +44 -3
  31. data/lib/puppet/rails.rb +3 -3
  32. data/lib/puppet/reference/configuration.rb +7 -12
  33. data/lib/puppet/reference/indirection.rb +2 -2
  34. data/lib/puppet/reference/metaparameter.rb +10 -9
  35. data/lib/puppet/reference/type.rb +6 -6
  36. data/lib/puppet/reports/rrdgraph.rb +1 -1
  37. data/lib/puppet/reports/tagmail.rb +1 -1
  38. data/lib/puppet/ssl/certificate_request.rb +1 -1
  39. data/lib/puppet/sslcertificates/ca.rb +4 -10
  40. data/lib/puppet/type.rb +3 -3
  41. data/lib/puppet/type/cron.rb +1 -1
  42. data/lib/puppet/type/tidy.rb +1 -0
  43. data/lib/puppet/type/user.rb +55 -0
  44. data/lib/puppet/type/whit.rb +4 -0
  45. data/lib/puppet/util.rb +8 -0
  46. data/lib/puppet/util/metric.rb +38 -9
  47. data/lib/puppet/util/rdoc/parser.rb +10 -7
  48. data/lib/puppet/util/reference.rb +4 -4
  49. data/lib/puppet/util/zaml.rb +0 -1
  50. data/spec/fixtures/yaml/report0.25.x.yaml +64 -0
  51. data/spec/fixtures/yaml/report2.6.x.yaml +190 -0
  52. data/spec/integration/application/doc_spec.rb +55 -0
  53. data/spec/integration/defaults_spec.rb +1 -1
  54. data/spec/integration/parser/compiler_spec.rb +21 -0
  55. data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
  56. data/spec/lib/puppet_spec/files.rb +1 -0
  57. data/spec/spec_helper.rb +1 -0
  58. data/spec/unit/application_spec.rb +16 -25
  59. data/spec/unit/dsl/resource_type_api_spec.rb +32 -12
  60. data/spec/unit/indirector/node/active_record_spec.rb +0 -1
  61. data/spec/unit/parser/ast/function_spec.rb +14 -4
  62. data/spec/unit/parser/lexer_spec.rb +8 -0
  63. data/spec/unit/parser/parser_spec.rb +0 -9
  64. data/spec/unit/parser/type_loader_spec.rb +3 -16
  65. data/spec/unit/provider/service/launchd_spec.rb +8 -5
  66. data/spec/unit/provider/user/user_role_add_spec.rb +18 -1
  67. data/spec/unit/provider/user/useradd_spec.rb +19 -0
  68. data/spec/unit/rails_spec.rb +10 -4
  69. data/spec/unit/reports/rrdgraph_spec.rb +31 -0
  70. data/spec/unit/reports/tagmail_spec.rb +1 -0
  71. data/spec/unit/sslcertificates/ca_spec.rb +110 -0
  72. data/spec/unit/type/user_spec.rb +19 -1
  73. data/spec/unit/type/whit_spec.rb +11 -0
  74. data/spec/unit/type_spec.rb +7 -0
  75. data/spec/unit/util/rdoc/parser_spec.rb +18 -14
  76. data/spec/unit/util/zaml_spec.rb +2 -1
  77. metadata +11 -6
  78. data/conf/suse/ruby-env.patch +0 -17
  79. data/test/certmgr/ca.rb +0 -87
@@ -47,14 +47,20 @@ describe Puppet::Rails, "when initializing any connection" do
47
47
  Puppet::Rails.connect
48
48
  end
49
49
 
50
- describe "on ActiveRecord 2.1.x" do
51
- confine("ActiveRecord 2.1.x") { ::ActiveRecord::VERSION::MAJOR == 2 and ::ActiveRecord::VERSION::MINOR <= 1 }
52
-
53
- it "should set ActiveRecord::Base.allow_concurrency" do
50
+ describe "ActiveRecord Version" do
51
+ it "should set ActiveRecord::Base.allow_concurrency if ActiveRecord is 2.1" do
52
+ Puppet::Util.stubs(:activerecord_version).returns(2.1)
54
53
  ActiveRecord::Base.expects(:allow_concurrency=).with(true)
55
54
 
56
55
  Puppet::Rails.connect
57
56
  end
57
+
58
+ it "should not set ActiveRecord::Base.allow_concurrency if ActiveRecord is >= 2.2" do
59
+ Puppet::Util.stubs(:activerecord_version).returns(2.2)
60
+ ActiveRecord::Base.expects(:allow_concurrency=).never
61
+
62
+ Puppet::Rails.connect
63
+ end
58
64
  end
59
65
 
60
66
  it "should call ActiveRecord::Base.verify_active_connections!" do
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
4
+
5
+ require 'puppet/reports'
6
+
7
+ processor = Puppet::Reports.report(:rrdgraph)
8
+
9
+ describe processor do
10
+ include PuppetSpec::Files
11
+ before do
12
+ Puppet[:rrddir] = tmpdir('rrdgraph')
13
+ Puppet.settings.use :master
14
+ end
15
+
16
+ after do
17
+ FileUtils.rm_rf(Puppet[:rrddir])
18
+ end
19
+
20
+ it "should not error on 0.25.x report format" do
21
+ report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report0.25.x.yaml')).extend processor
22
+ report.expects(:mkhtml)
23
+ lambda{ report.process }.should_not raise_error
24
+ end
25
+
26
+ it "should not error on 2.6.x report format" do
27
+ report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml')).extend processor
28
+ report.expects(:mkhtml)
29
+ lambda{ report.process }.should_not raise_error
30
+ end
31
+ end
@@ -31,6 +31,7 @@ describe tagmail do
31
31
 
32
32
  {
33
33
  "tag: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, []],
34
+ "tag.localhost: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag.localhost}, []],
34
35
  "tag, other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag other}, []],
35
36
  "tag-other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag-other}, []],
36
37
  "tag, !other: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, %w{other}],
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+
4
+ require 'puppet'
5
+ require 'puppet/sslcertificates'
6
+ require 'puppet/sslcertificates/ca'
7
+
8
+ describe Puppet::SSLCertificates::CA do
9
+ before :all do
10
+ @hosts = %w{host.domain.com Other.Testing.Com}
11
+ end
12
+
13
+ before :each do
14
+ Puppet::Util::SUIDManager.stubs(:asuser).yields
15
+ file = Tempfile.new("ca_testing")
16
+ @dir = file.path
17
+ file.delete
18
+
19
+ Puppet.settings[:confdir] = @dir
20
+ Puppet.settings[:vardir] = @dir
21
+
22
+ @ca = Puppet::SSLCertificates::CA.new
23
+ end
24
+
25
+ after :each do
26
+ system("rm -rf #{@dir}")
27
+ end
28
+
29
+ describe 'when cleaning' do
30
+ it 'should remove associated files' do
31
+ dirs = [:csrdir, :signeddir, :publickeydir, :privatekeydir, :certdir]
32
+
33
+ @hosts.each do |host|
34
+ files = []
35
+ dirs.each do |dir|
36
+ dir = Puppet[dir]
37
+
38
+ # Case insensitivity is handled through downcasing
39
+ file = File.join(dir, host.downcase + '.pem')
40
+
41
+ File.open(file, "w") do |f|
42
+ f.puts "testing"
43
+ end
44
+
45
+ files << file
46
+ end
47
+
48
+ lambda { @ca.clean(host) }.should_not raise_error
49
+
50
+ files.reject {|f| ! File.exists?(f)}.should be_empty
51
+ end
52
+ end
53
+ end
54
+
55
+ describe 'when mapping hosts to files' do
56
+ it 'should correctly return the certfile' do
57
+ @hosts.each do |host|
58
+ value = nil
59
+ lambda { value = @ca.host2certfile host }.should_not raise_error
60
+
61
+ File.join(Puppet[:signeddir], host.downcase + '.pem').should == value
62
+ end
63
+ end
64
+
65
+ it 'should correctly return the csrfile' do
66
+ @hosts.each do |host|
67
+ value = nil
68
+ lambda { value = @ca.host2csrfile host }.should_not raise_error
69
+
70
+ File.join(Puppet[:csrdir], host.downcase + '.pem').should == value
71
+ end
72
+ end
73
+ end
74
+
75
+ describe 'when listing' do
76
+ it 'should find all csr' do
77
+ list = []
78
+
79
+ # Make some fake CSRs
80
+ @hosts.each do |host|
81
+ file = File.join(Puppet[:csrdir], host.downcase + '.pem')
82
+ File.open(file, 'w') { |f| f.puts "yay" }
83
+ list << host.downcase
84
+ end
85
+
86
+ @ca.list.sort.should == list.sort
87
+ end
88
+ end
89
+
90
+ describe 'when creating a root certificate' do
91
+ before :each do
92
+ lambda { @ca.mkrootcert }.should_not raise_exception
93
+ end
94
+
95
+ it 'should store the public key' do
96
+ File.exists?(Puppet[:capub]).should be_true
97
+ end
98
+
99
+ it 'should prepend "Puppet CA: " to the fqdn as the ca_name by default' do
100
+ host_mock_fact = mock()
101
+ host_mock_fact.expects(:value).returns('myhost')
102
+ domain_mock_fact = mock()
103
+ domain_mock_fact.expects(:value).returns('puppetlabs.lan')
104
+ Facter.stubs(:[]).with('hostname').returns(host_mock_fact)
105
+ Facter.stubs(:[]).with('domain').returns(domain_mock_fact)
106
+
107
+ @ca.mkrootcert.name.should == 'Puppet CA: myhost.puppetlabs.lan'
108
+ end
109
+ end
110
+ end
@@ -35,6 +35,14 @@ describe user do
35
35
  user.provider_feature(:manages_solaris_rbac).should_not be_nil
36
36
  end
37
37
 
38
+ it "should have a manages_expiry feature" do
39
+ user.provider_feature(:manages_expiry).should_not be_nil
40
+ end
41
+
42
+ it "should have a manages_password_age feature" do
43
+ user.provider_feature(:manages_password_age).should_not be_nil
44
+ end
45
+
38
46
  describe "instances" do
39
47
  it "should have a valid provider" do
40
48
  user.new(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider)
@@ -47,7 +55,7 @@ describe user do
47
55
  end
48
56
  end
49
57
 
50
- properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :groups, :roles, :auths, :profiles, :project, :keys]
58
+ properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :password_min_age, :password_max_age, :groups, :roles, :auths, :profiles, :project, :keys, :expiry]
51
59
 
52
60
  properties.each do |property|
53
61
  it "should have a #{property} property" do
@@ -227,6 +235,16 @@ describe user do
227
235
  end
228
236
  end
229
237
 
238
+ describe "when managing expiry" do
239
+ before do
240
+ @expiry = user.attrclass(:expiry).new(:resource => @resource)
241
+ end
242
+
243
+ it "should fail if given an invalid date" do
244
+ lambda { @expiry.should = "200-20-20" }.should raise_error(Puppet::Error)
245
+ end
246
+ end
247
+
230
248
  describe "when managing passwords" do
231
249
  before do
232
250
  @password = user.attrclass(:password).new(:resource => @resource, :should => "mypass")
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../../spec_helper'
4
+
5
+ whit = Puppet::Type.type(:whit).new(:name => "Foo::Bar")
6
+
7
+ describe whit do
8
+ it "should stringify as though it were the class it represents" do
9
+ whit.to_s.should == "Class[Foo::Bar]"
10
+ end
11
+ end
@@ -545,6 +545,13 @@ describe Puppet::Type.metaparamclass(:audit) do
545
545
  @resource[:audit].should == list
546
546
  end
547
547
 
548
+ it "should accept the string 'all' to specify auditing all possible properties" do
549
+ @resource[:audit] = 'all'
550
+
551
+ list = @resource.class.properties.collect { |p| p.name }
552
+ @resource[:audit].should == list
553
+ end
554
+
548
555
  it "should fail if asked to audit an invalid property" do
549
556
  lambda { @resource[:audit] = :foobar }.should raise_error(Puppet::Error)
550
557
  end
@@ -19,7 +19,7 @@ describe RDoc::Parser do
19
19
  it "should parse puppet files with the puppet parser" do
20
20
  @parser.stubs(:scan_top_level)
21
21
  parser = stub 'parser'
22
- Puppet::Parser::Parser.expects(:new).returns(parser)
22
+ Puppet::Parser::Parser.stubs(:new).returns(parser)
23
23
  parser.expects(:parse)
24
24
  parser.expects(:file=).with("module/manifests/init.pp")
25
25
 
@@ -340,10 +340,12 @@ describe RDoc::Parser do
340
340
 
341
341
  def create_stmt(name)
342
342
  stmt_value = stub "#{name}_value", :value => "myclass"
343
- stmt = stub_everything 'stmt', :name => name, :arguments => [stmt_value], :doc => "mydoc"
344
- stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
345
- stmt.stubs(:is_a?).with(Puppet::Parser::AST::Function).returns(true)
346
- stmt
343
+
344
+ Puppet::Parser::AST::Function.new(
345
+ :name => name,
346
+ :arguments => [stmt_value],
347
+ :doc => 'mydoc'
348
+ )
347
349
  end
348
350
 
349
351
  before(:each) do
@@ -377,10 +379,11 @@ describe RDoc::Parser do
377
379
 
378
380
  def create_stmt
379
381
  stmt_value = stub "resource_ref", :to_s => "File[\"/tmp/a\"]"
380
- stmt = stub_everything 'stmt', :name => "realize", :arguments => [stmt_value], :doc => "mydoc"
381
- stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
382
- stmt.stubs(:is_a?).with(Puppet::Parser::AST::Function).returns(true)
383
- stmt
382
+ Puppet::Parser::AST::Function.new(
383
+ :name => 'realize',
384
+ :arguments => [stmt_value],
385
+ :doc => 'mydoc'
386
+ )
384
387
  end
385
388
 
386
389
  before(:each) do
@@ -432,11 +435,12 @@ describe RDoc::Parser do
432
435
  describe "when scanning for resources" do
433
436
  before :each do
434
437
  @class = stub_everything 'class'
435
-
436
- param = stub 'params', :children => []
437
- @stmt = stub_everything 'stmt', :type => "File", :title => "myfile", :doc => "mydoc", :params => param
438
- @stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
439
- @stmt.stubs(:is_a?).with(Puppet::Parser::AST::Resource).returns(true)
438
+ @stmt = Puppet::Parser::AST::Resource.new(
439
+ :type => "File",
440
+ :title => "myfile",
441
+ :doc => 'mydoc',
442
+ :parameters => Puppet::Parser::AST::ASTArray.new(:children => [])
443
+ )
440
444
 
441
445
  @code = stub_everything 'code'
442
446
  @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true)
@@ -11,7 +11,8 @@ describe "Pure ruby yaml implementation" do
11
11
  'test' => "--- test",
12
12
  [] => "--- []",
13
13
  :symbol => "--- !ruby/sym symbol",
14
- {:a => "A"} => "--- \n !ruby/sym a: A"
14
+ {:a => "A"} => "--- \n !ruby/sym a: A",
15
+ {:a => "x\ny"} => "--- \n !ruby/sym a: |-\n x\n y"
15
16
  }.each { |o,y|
16
17
  it "should convert the #{o.class} #{o.inspect} to yaml" do
17
18
  o.to_yaml.should == y
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 6
9
- - 1
10
- version: 2.6.1
9
+ - 2
10
+ version: 2.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Puppet Labs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-14 00:00:00 +10:00
18
+ date: 2010-10-08 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -633,7 +633,6 @@ files:
633
633
  - conf/epm.list
634
634
  - conf/suse/client.init
635
635
  - conf/suse/fileserver.conf
636
- - conf/suse/ruby-env.patch
637
636
  - conf/suse/puppet.spec
638
637
  - conf/suse/server.init
639
638
  - conf/suse/puppet.conf
@@ -850,7 +849,6 @@ files:
850
849
  - test/network/client/dipper.rb
851
850
  - test/certmgr/support.rb
852
851
  - test/certmgr/inventory.rb
853
- - test/certmgr/ca.rb
854
852
  - test/certmgr/certmgr.rb
855
853
  - test/Rakefile
856
854
  - test/ral/manager/manager.rb
@@ -935,6 +933,8 @@ files:
935
933
  - test/util/log.rb
936
934
  - test/util/fileparsing.rb
937
935
  - spec/fixtures/yaml/test.local.yaml
936
+ - spec/fixtures/yaml/report2.6.x.yaml
937
+ - spec/fixtures/yaml/report0.25.x.yaml
938
938
  - spec/monkey_patches/publicize_methods.rb
939
939
  - spec/monkey_patches/alias_should_to_must.rb
940
940
  - spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb
@@ -1072,6 +1072,7 @@ files:
1072
1072
  - spec/unit/parser/collector_spec.rb
1073
1073
  - spec/unit/parser/parser_spec.rb
1074
1074
  - spec/unit/reports/tagmail_spec.rb
1075
+ - spec/unit/reports/rrdgraph_spec.rb
1075
1076
  - spec/unit/reports/http_spec.rb
1076
1077
  - spec/unit/node/facts_spec.rb
1077
1078
  - spec/unit/node/environment_spec.rb
@@ -1127,6 +1128,7 @@ files:
1127
1128
  - spec/unit/module_spec.rb
1128
1129
  - spec/unit/puppet_spec.rb
1129
1130
  - spec/unit/rails_spec.rb
1131
+ - spec/unit/sslcertificates/ca_spec.rb
1130
1132
  - spec/unit/transaction/change_spec.rb
1131
1133
  - spec/unit/transaction/event_manager_spec.rb
1132
1134
  - spec/unit/transaction/resource_harness_spec.rb
@@ -1278,6 +1280,7 @@ files:
1278
1280
  - spec/unit/type/macauthorization_spec.rb
1279
1281
  - spec/unit/type/user_spec.rb
1280
1282
  - spec/unit/type/zone_spec.rb
1283
+ - spec/unit/type/whit_spec.rb
1281
1284
  - spec/unit/type/mcx_spec.rb
1282
1285
  - spec/unit/type/tidy_spec.rb
1283
1286
  - spec/unit/type/filebucket_spec.rb
@@ -1316,6 +1319,7 @@ files:
1316
1319
  - spec/integration/node_spec.rb
1317
1320
  - spec/integration/parser/compiler_spec.rb
1318
1321
  - spec/integration/parser/functions/require_spec.rb
1322
+ - spec/integration/parser/ruby_manifest_spec.rb
1319
1323
  - spec/integration/parser/collector_spec.rb
1320
1324
  - spec/integration/parser/parser_spec.rb
1321
1325
  - spec/integration/node/facts_spec.rb
@@ -1325,6 +1329,7 @@ files:
1325
1329
  - spec/integration/provider/package_spec.rb
1326
1330
  - spec/integration/type_spec.rb
1327
1331
  - spec/integration/transaction/report_spec.rb
1332
+ - spec/integration/application/doc_spec.rb
1328
1333
  - spec/integration/application/apply_spec.rb
1329
1334
  - spec/integration/indirector/report/rest_spec.rb
1330
1335
  - spec/integration/indirector/certificate_request/rest_spec.rb
@@ -1,17 +0,0 @@
1
- --- sbin/puppetd 2010-07-18 14:17:38.000000000 -0700
2
- +++ sbin/puppetd 2010-07-21 17:31:57.057138615 -0700
3
- @@ -1,4 +1,4 @@
4
- -#!/usr/bin/env ruby
5
- +#!/usr/bin/ruby
6
-
7
- require 'puppet/application/agent'
8
- Puppet::Application[:agent].run
9
-
10
- --- sbin/puppetmasterd 2010-07-18 14:17:38.000000000 -0700
11
- +++ sbin/puppetmasterd 2010-07-21 17:32:10.178513969 -0700
12
- @@ -1,4 +1,4 @@
13
- -#!/usr/bin/env ruby
14
- +#!/usr/bin/ruby
15
-
16
- require 'puppet/application/master'
17
- Puppet::Application[:master].run
@@ -1,87 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.dirname(__FILE__) + '/../lib/puppettest'
4
-
5
- require 'puppet'
6
- require 'puppet/sslcertificates/ca.rb'
7
- require 'puppettest'
8
- require 'puppettest/certificates'
9
- require 'mocha'
10
-
11
- class TestCA < Test::Unit::TestCase
12
- include PuppetTest
13
-
14
- def setup
15
- super
16
- Puppet::Util::SUIDManager.stubs(:asuser).yields
17
- end
18
-
19
- def hosts
20
- %w{host.domain.com Other.Testing.Com}
21
- end
22
- def mkca
23
- Puppet::SSLCertificates::CA.new
24
- end
25
-
26
- def test_clean
27
- dirs = [:csrdir, :signeddir, :publickeydir, :privatekeydir, :certdir]
28
- ca = mkca
29
-
30
- hosts.each do |host|
31
- files = []
32
- dirs.each do |dir|
33
- dir = Puppet[dir]
34
- # We handle case insensitivity through downcasing
35
- file = File.join(dir, host.downcase + ".pem")
36
- File.open(file, "w") do |f|
37
- f.puts "testing"
38
- end
39
- files << file
40
- end
41
- assert_nothing_raised do
42
- ca.clean(host)
43
- end
44
- files.each do |f|
45
- assert(! FileTest.exists?(f), "File #{f} was not deleted")
46
- end
47
- end
48
- end
49
-
50
- def test_host2Xfile
51
- ca = mkca
52
- hosts.each do |host|
53
- {:signeddir => :host2certfile, :csrdir => :host2csrfile}.each do |dir, method|
54
- val = nil
55
- assert_nothing_raised do
56
- val = ca.send(method, host)
57
- end
58
- assert_equal(File.join(Puppet[dir], host.downcase + ".pem"), val,
59
- "incorrect response from #{method}")
60
- end
61
- end
62
- end
63
-
64
- def test_list
65
- ca = mkca
66
- # Make a fake csr
67
- dir = Puppet[:csrdir]
68
- list = []
69
- hosts.each do |host|
70
- file = File.join(dir, host.downcase + ".pem")
71
- File.open(file, "w") { |f| f.puts "yay" }
72
- list << host.downcase
73
- end
74
-
75
- assert_equal(list.sort, ca.list.sort, "list was not correct")
76
- end
77
-
78
- # #142 - test storing the public key
79
- def test_store_public_key
80
- ca = mkca
81
- assert_nothing_raised do
82
- ca.mkrootcert
83
- end
84
- assert(FileTest.exists?(Puppet[:capub]), "did not store public key")
85
- end
86
- end
87
-