Sha256: bb8a7ff908529a26f065df5ac4e6bfab5399be90bdec2100914e015dc02bc63d

Contents?: true

Size: 1.22 KB

Versions: 35

Compression:

Stored size: 1.22 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

require 'puppet/ssl/certificate'

class TestCertificate < Puppet::SSL::Base; end

describe Puppet::SSL::Certificate do
  before :each do
    @base = TestCertificate.new("name")
  end

  describe "when fingerprinting content" do
    before :each do
      @cert = stub 'cert', :to_der => "DER"
      @base.stubs(:content).returns(@cert)
      OpenSSL::Digest.stubs(:constants).returns ["MD5", "DIGEST"]
      @digest = stub_everything
      OpenSSL::Digest.stubs(:const_get).returns @digest
    end

    it "should digest the certificate DER value and return a ':' seperated nibblet string" do
      @cert.expects(:to_der).returns("DER")
      @digest.expects(:hexdigest).with("DER").returns "digest"

      @base.fingerprint.should == "DI:GE:ST"
    end

    it "should raise an error if the digest algorithm is not defined" do
      OpenSSL::Digest.expects(:constants).returns []

      lambda { @base.fingerprint }.should raise_error
    end

    it "should use the given digest algorithm" do
      OpenSSL::Digest.stubs(:const_get).with("DIGEST").returns @digest
      @digest.expects(:hexdigest).with("DER").returns "digest"

      @base.fingerprint(:digest).should == "DI:GE:ST"
    end
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/unit/ssl/base_spec.rb
puppet-2.7.25 spec/unit/ssl/base_spec.rb
puppet-2.7.24 spec/unit/ssl/base_spec.rb
puppet-2.7.23 spec/unit/ssl/base_spec.rb
puppet-2.7.22 spec/unit/ssl/base_spec.rb
puppet-2.7.21 spec/unit/ssl/base_spec.rb
puppet-2.7.20 spec/unit/ssl/base_spec.rb
puppet-2.7.20.rc1 spec/unit/ssl/base_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/ssl/base_spec.rb
puppet-2.7.19 spec/unit/ssl/base_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/ssl/base_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/ssl/base_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/ssl/base_spec.rb
puppet-2.7.18 spec/unit/ssl/base_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/ssl/base_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/ssl/base_spec.rb
puppet-2.7.17 spec/unit/ssl/base_spec.rb
puppet-2.7.16 spec/unit/ssl/base_spec.rb
puppet-2.7.14 spec/unit/ssl/base_spec.rb
puppet-2.7.13 spec/unit/ssl/base_spec.rb