summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-04-17 17:47:03 -0500
committerLuke Kanies <luke@madstop.com>2008-04-17 17:47:03 -0500
commitcbe522169ed6eb2426ecf5a77e24e27b6f7a4edf (patch)
treea2b793773b4be415fca31ec91178e5c39f93a898 /spec
parentc5f0eff51626baa76ebc5bd4bee9d319a0b220c5 (diff)
Adding SSL::Host-level support for managing the terminus and
cache classes. Also, defaulting to the :file terminus for all of the SSL classes.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/ssl/certificate.rb9
-rwxr-xr-xspec/unit/ssl/certificate_request.rb4
-rwxr-xr-xspec/unit/ssl/certificate_revocation_list.rb4
-rwxr-xr-xspec/unit/ssl/host.rb97
-rwxr-xr-xspec/unit/ssl/key.rb4
5 files changed, 111 insertions, 7 deletions
diff --git a/spec/unit/ssl/certificate.rb b/spec/unit/ssl/certificate.rb
index 7aaf8534d..a30591946 100755
--- a/spec/unit/ssl/certificate.rb
+++ b/spec/unit/ssl/certificate.rb
@@ -21,13 +21,8 @@ describe Puppet::SSL::Certificate do
@class.indirection.name.should == :certificate
end
- it "should default to a local certificate authority" do
- @class.ca_location.should == :local
- end
-
- it "should allow overriding the ca location" do
- @class.ca_is :remote
- @class.ca_location.should == :remote
+ it "should default to the :file terminus" do
+ @class.indirection.terminus_class.should == :file
end
describe "when managing instances" do
diff --git a/spec/unit/ssl/certificate_request.rb b/spec/unit/ssl/certificate_request.rb
index 19e72d65e..169cb64b9 100755
--- a/spec/unit/ssl/certificate_request.rb
+++ b/spec/unit/ssl/certificate_request.rb
@@ -22,6 +22,10 @@ describe Puppet::SSL::CertificateRequest do
@class.new("myname").name.should == "myname"
end
+ it "should default to the :file terminus" do
+ @class.indirection.terminus_class.should == :file
+ end
+
describe "when managing instances" do
before do
@request = @class.new("myname")
diff --git a/spec/unit/ssl/certificate_revocation_list.rb b/spec/unit/ssl/certificate_revocation_list.rb
index 01c197b25..3513607d9 100755
--- a/spec/unit/ssl/certificate_revocation_list.rb
+++ b/spec/unit/ssl/certificate_revocation_list.rb
@@ -11,6 +11,10 @@ describe Puppet::SSL::CertificateRevocationList do
@class = Puppet::SSL::CertificateRevocationList
end
+ it "should default to the :file terminus" do
+ @class.indirection.terminus_class.should == :file
+ end
+
describe "when an instance" do
before do
@class.any_instance.stubs(:read_or_generate)
diff --git a/spec/unit/ssl/host.rb b/spec/unit/ssl/host.rb
index 97d6c27d8..e1d6b5c9e 100755
--- a/spec/unit/ssl/host.rb
+++ b/spec/unit/ssl/host.rb
@@ -37,6 +37,103 @@ describe Puppet::SSL::Host do
lambda { @host.password_file = "/my/file" }.should_not raise_error
end
+ it "should have a method for determining the CA location" do
+ Puppet::SSL::Host.should respond_to(:ca_location)
+ end
+
+ it "should have a method for specifying the CA location" do
+ Puppet::SSL::Host.should respond_to(:ca_location=)
+ end
+
+ describe "when specifying the CA location" do
+ before do
+ [Puppet::SSL::Key, Puppet::SSL::Certificate, Puppet::SSL::CertificateRequest].each do |klass|
+ klass.stubs(:terminus_class=)
+ klass.stubs(:cache_class=)
+ end
+ end
+
+ it "should support the location ':local'" do
+ lambda { Puppet::SSL::Host.ca_location = :local }.should_not raise_error
+ end
+
+ it "should support the location ':remote'" do
+ lambda { Puppet::SSL::Host.ca_location = :remote }.should_not raise_error
+ end
+
+ it "should support the location ':none'" do
+ lambda { Puppet::SSL::Host.ca_location = :none }.should_not raise_error
+ end
+
+ it "should not support other modes" do
+ lambda { Puppet::SSL::Host.ca_location = :whatever }.should raise_error(ArgumentError)
+ end
+
+ describe "as 'local'" do
+ it "should set the cache class for Certificate and CertificateRequest as :file" do
+ Puppet::SSL::Certificate.expects(:cache_class=).with :file
+ Puppet::SSL::CertificateRequest.expects(:cache_class=).with :file
+
+ Puppet::SSL::Host.ca_location = :local
+ end
+
+ it "should set the terminus class for Key as :file" do
+ Puppet::SSL::Key.expects(:terminus_class=).with :file
+
+ Puppet::SSL::Host.ca_location = :local
+ end
+
+ it "should set the terminus class for Certificate and CertificateRequest as :ca_file" do
+ Puppet::SSL::Certificate.expects(:terminus_class=).with :ca_file
+ Puppet::SSL::CertificateRequest.expects(:terminus_class=).with :ca_file
+
+ Puppet::SSL::Host.ca_location = :local
+ end
+ end
+
+ describe "as 'remote'" do
+ it "should set the cache class for Certificate and CertificateRequest as :file" do
+ Puppet::SSL::Certificate.expects(:cache_class=).with :file
+ Puppet::SSL::CertificateRequest.expects(:cache_class=).with :file
+
+ Puppet::SSL::Host.ca_location = :remote
+ end
+
+ it "should set the terminus class for Key as :file" do
+ Puppet::SSL::Key.expects(:terminus_class=).with :file
+
+ Puppet::SSL::Host.ca_location = :remote
+ end
+
+ it "should set the terminus class for Certificate and CertificateRequest as :rest" do
+ Puppet::SSL::Certificate.expects(:terminus_class=).with :rest
+ Puppet::SSL::CertificateRequest.expects(:terminus_class=).with :rest
+
+ Puppet::SSL::Host.ca_location = :remote
+ end
+ end
+
+ describe "as 'only'" do
+ it "should set the terminus class for Key, Certificate, and CertificateRequest as :ca_file" do
+ Puppet::SSL::Key.expects(:terminus_class=).with :ca_file
+ Puppet::SSL::Certificate.expects(:terminus_class=).with :ca_file
+ Puppet::SSL::CertificateRequest.expects(:terminus_class=).with :ca_file
+
+ Puppet::SSL::Host.ca_location = :only
+ end
+ end
+
+ describe "as 'none'" do
+ it "should set the terminus class for Key, Certificate, and CertificateRequest as :file" do
+ Puppet::SSL::Key.expects(:terminus_class=).with :file
+ Puppet::SSL::Certificate.expects(:terminus_class=).with :file
+ Puppet::SSL::CertificateRequest.expects(:terminus_class=).with :file
+
+ Puppet::SSL::Host.ca_location = :none
+ end
+ end
+ end
+
describe "when managing its private key" do
before do
@realkey = "mykey"
diff --git a/spec/unit/ssl/key.rb b/spec/unit/ssl/key.rb
index 98b7e8a2b..8d89c0039 100755
--- a/spec/unit/ssl/key.rb
+++ b/spec/unit/ssl/key.rb
@@ -17,6 +17,10 @@ describe Puppet::SSL::Key do
@class.indirection.name.should == :key
end
+ it "should default to the :file terminus" do
+ @class.indirection.terminus_class.should == :file
+ end
+
describe "when managing instances" do
before do
@key = @class.new("myname")