Created
March 22, 2011 23:49
-
-
Save lak/882356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Puppet::SSL::CertificateStatus | |
| extend Puppet::Indirector | |
| indirects :certificate_status, :terminus_class => :file | |
| attr_accessor :name, :fingerprint, :message | |
| attr_reader :state | |
| CERT_STATES = %w{requested signed invoked invalid} | |
| def initialize(name) | |
| @name = name | |
| end | |
| def state=(value) | |
| unless CERT_STATES.include?(value) | |
| string = CERT_STATES.join(", ") | |
| raise ArgumentError, "Invalid certificate state '#{value}'; must be one of #{string}" | |
| end | |
| @state = value | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/usr/bin/env ruby
require File.expand_path(File.dirname(FILE) + '/../../spec_helper.rb')
require 'puppet/ssl/certificate_status'
describe Puppet::SSL::CertificateStatus do
before do
@status = Puppet::SSL::CertificateStatus.new("mysigner")
Puppet::SSL::CertificateAuthority.stubs(:ca?).returns true
end
it "should have a name" do
@status.name.should == "mysigner"
end
it "should accept a 'fingerprint' attribute" do
@status.fingerprint = "something"
@status.fingerprint.should == "something"
end
it "should accept a 'message' attribute" do
@status.message = "something"
@status.message.should == "something"
end
it "should accept a 'state' attribute" do
@status.state = "invalid"
@status.state.should == "invalid"
end
it "should fail unless the state is a valid listed state" do
lambda { @status.state = "bad" }.should raise_error(ArgumentError, /certificate state/)
end
%w{requested signed invoked invalid}.each do |state|
it "should accept '#{state}' as a valid state" do
@status.state = state
@status.state.should == state
end
end
end