summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-03-19 17:50:09 -0500
committerLuke Kanies <luke@madstop.com>2008-04-15 21:34:05 -0500
commit1efed0304ebdc13a55eb2d865cdc4965c5253d3a (patch)
treeb571ac1f93e07f01a0d52bae47cd641916cc8571 /lib
parentee07d0b7f198857f700b9ad09713fe6b992ffee8 (diff)
downloadpuppet-1efed0304ebdc13a55eb2d865cdc4965c5253d3a.tar.gz
puppet-1efed0304ebdc13a55eb2d865cdc4965c5253d3a.tar.xz
puppet-1efed0304ebdc13a55eb2d865cdc4965c5253d3a.zip
Adding tests for the easy bits of the CertificateFactory.
I probably am going to skip the tests for the rest, since the code is unlikely to ever change, and it's going to be a royal pain to test.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/ssl/certificate_factory.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/puppet/ssl/certificate_factory.rb b/lib/puppet/ssl/certificate_factory.rb
index abdeb8a2c..47b9f74d7 100644
--- a/lib/puppet/ssl/certificate_factory.rb
+++ b/lib/puppet/ssl/certificate_factory.rb
@@ -1,3 +1,5 @@
+require 'puppet/ssl'
+
# The tedious class that does all the manipulations to the
# certificate to correctly sign it. Yay.
class Puppet::SSL::CertificateFactory
@@ -8,23 +10,30 @@ class Puppet::SSL::CertificateFactory
"h" => 60 * 60,
"s" => 1
}
+
+ attr_reader :name, :cert_type, :csr, :issuer, :serial
def initialize(cert_type, csr, issuer, serial)
- @cert_type, @csr, @issuer = cert_type, csr, issuer
+ @cert_type, @csr, @issuer, @serial = cert_type, csr, issuer, serial
@name = @csr.subject
+ end
+ # Actually generate our certificate.
+ def result
@cert = OpenSSL::X509::Certificate.new
@cert.version = 2 # X509v3
- @cert.subject = csr.subject
- @cert.issuer = issuer.subject
- @cert.public_key = csr.public_key
- @cert.serial = serial
+ @cert.subject = @csr.subject
+ @cert.issuer = @issuer.subject
+ @cert.public_key = @csr.public_key
+ @cert.serial = @serial
build_extensions()
set_ttl
+
+ @cert
end
private