Sha256: f3b9d555dd2b6e012e7ff8e8b868c7e763865265ac63b48f9739951337927af2

Contents?: true

Size: 1022 Bytes

Versions: 92

Compression:

Stored size: 1022 Bytes

Contents

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

require 'puppet/ssl/digest'

describe Puppet::SSL::Digest do
  it "defaults to sha256" do
    digest = described_class.new(nil, 'blah')
    digest.name.should == 'SHA256'
    digest.digest.hexdigest.should == "8b7df143d91c716ecfa5fc1730022f6b421b05cedee8fd52b1fc65a96030ad52"
  end

  describe '#name' do
    it "prints the hashing algorithm used by the openssl digest" do
      described_class.new('SHA224', 'blah').name.should == 'SHA224'
    end

    it "upcases the hashing algorithm" do
      described_class.new('sha224', 'blah').name.should == 'SHA224'
    end
  end

  describe '#to_hex' do
    it "returns ':' separated upper case hex pairs" do
      described_class.new(nil, 'blah').to_hex =~ /\A([A-Z0-9]:)+[A-Z0-9]\Z/
    end
  end

  describe '#to_s' do
    it "formats the digest algorithm and the digest as a string" do
      digest = described_class.new('sha512', 'some content')
      digest.to_s.should == "(#{digest.name}) #{digest.to_hex}"
    end
  end
end

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
puppet-3.8.7 spec/unit/ssl/digest_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.6 spec/unit/ssl/digest_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.5 spec/unit/ssl/digest_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.4 spec/unit/ssl/digest_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.3 spec/unit/ssl/digest_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.2 spec/unit/ssl/digest_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/ssl/digest_spec.rb
puppet-3.8.1 spec/unit/ssl/digest_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/ssl/digest_spec.rb