diff options
| author | Luke Kanies <luke@madstop.com> | 2008-04-02 10:53:40 -0500 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-04-15 21:34:07 -0500 |
| commit | 6900f9776a7875ea13cbb5fe1f2eaa48fe05e667 (patch) | |
| tree | a656741fb515e634e3c3beb4f8a70c52fc2cd5dc | |
| parent | 174b9c99f7eb904ec7d415d3884f3620b6b65d40 (diff) | |
| download | puppet-6900f9776a7875ea13cbb5fe1f2eaa48fe05e667.tar.gz puppet-6900f9776a7875ea13cbb5fe1f2eaa48fe05e667.tar.xz puppet-6900f9776a7875ea13cbb5fe1f2eaa48fe05e667.zip | |
Adding a :to_text method that will convert the contained
thing to readable human text.
| -rw-r--r-- | lib/puppet/ssl/base.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/ssl/certificate.rb | 7 | ||||
| -rwxr-xr-x | spec/unit/ssl/certificate_request.rb | 7 | ||||
| -rwxr-xr-x | spec/unit/ssl/key.rb | 7 |
4 files changed, 27 insertions, 0 deletions
diff --git a/lib/puppet/ssl/base.rb b/lib/puppet/ssl/base.rb index 781ccb805..674330373 100644 --- a/lib/puppet/ssl/base.rb +++ b/lib/puppet/ssl/base.rb @@ -33,6 +33,12 @@ class Puppet::SSL::Base content.to_pem end + # Provide the full text of the thing we're dealing with. + def to_text + return "" unless content + content.to_text + end + private def wrapped_class diff --git a/spec/unit/ssl/certificate.rb b/spec/unit/ssl/certificate.rb index 1f847e16e..18b432e9e 100755 --- a/spec/unit/ssl/certificate.rb +++ b/spec/unit/ssl/certificate.rb @@ -71,6 +71,13 @@ describe Puppet::SSL::Certificate do @certificate.content = certificate @certificate.to_s.should == "pem" end + + it "should have a :to_text method that it delegates to the actual key" do + real_certificate = mock 'certificate' + real_certificate.expects(:to_text).returns "certificatetext" + @certificate.content = real_certificate + @certificate.to_text.should == "certificatetext" + end end describe "when generating the certificate" do diff --git a/spec/unit/ssl/certificate_request.rb b/spec/unit/ssl/certificate_request.rb index 6d684f9ae..2b4545bee 100755 --- a/spec/unit/ssl/certificate_request.rb +++ b/spec/unit/ssl/certificate_request.rb @@ -63,6 +63,13 @@ describe Puppet::SSL::CertificateRequest do @request.content = request @request.to_s.should == "pem" end + + it "should have a :to_text method that it delegates to the actual key" do + real_request = mock 'request' + real_request.expects(:to_text).returns "requesttext" + @request.content = real_request + @request.to_text.should == "requesttext" + end end describe "when generating" do diff --git a/spec/unit/ssl/key.rb b/spec/unit/ssl/key.rb index 57ad943c2..9955f468a 100755 --- a/spec/unit/ssl/key.rb +++ b/spec/unit/ssl/key.rb @@ -67,6 +67,13 @@ describe Puppet::SSL::Key do @key.content = key @key.to_s.should == "pem" end + + it "should have a :to_text method that it delegates to the actual key" do + real_key = mock 'key' + real_key.expects(:to_text).returns "keytext" + @key.content = real_key + @key.to_text.should == "keytext" + end end describe "when generating the private key" do |
