Sha256: efc0959b6505ed411c26c6549c5da795100a6aa28b7a978d2a7f2fb4681580c7

Contents?: true

Size: 1.25 KB

Versions: 19

Compression:

Stored size: 1.25 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../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

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/ssl/base_spec.rb
puppet-2.6.17 spec/unit/ssl/base_spec.rb
puppet-2.6.16 spec/unit/ssl/base_spec.rb
puppet-2.6.15 spec/unit/ssl/base_spec.rb
puppet-2.6.14 spec/unit/ssl/base_spec.rb
puppet-2.6.13 spec/unit/ssl/base_spec.rb
puppet-2.6.12 spec/unit/ssl/base_spec.rb
puppet-2.6.11 spec/unit/ssl/base_spec.rb
puppet-2.6.10 spec/unit/ssl/base_spec.rb
puppet-2.6.9 spec/unit/ssl/base_spec.rb
puppet-2.6.8 spec/unit/ssl/base_spec.rb
puppet-2.6.7 spec/unit/ssl/base_spec.rb
puppet-2.6.6 spec/unit/ssl/base_spec.rb
puppet-2.6.5 spec/unit/ssl/base_spec.rb
puppet-2.6.4 spec/unit/ssl/base_spec.rb
puppet-2.6.3 spec/unit/ssl/base_spec.rb
puppet-2.6.2 spec/unit/ssl/base_spec.rb
puppet-2.6.1 spec/unit/ssl/base_spec.rb
puppet-2.6.0 spec/unit/ssl/base_spec.rb