Sha256: 9050f8c4fb7afd1b19dca9f4e73d2b3cec48a604ae1561ce2c3d30121540a128

Contents?: true

Size: 967 Bytes

Versions: 17

Compression:

Stored size: 967 Bytes

Contents

require "spec_helper"

module HashedValueSpec
  class Codec
    include Shamu::Security::HashedValue

    def initialize( private_key )
      @private_key = private_key
    end

    public :hash_value, :verify_hash
  end
end

describe Shamu::Security::HashedValue do
  let( :codec ) { HashedValueSpec::Codec.new( SecureRandom.random_bytes( 64 ) ) }

  describe "#pack" do
    subject { codec.hash_value( "example" ) }

    it { is_expected.to match /$/ }
    it { is_expected.to match /example/ }
  end

  describe "#unpack" do
    it "gets original value" do
      hashed = codec.hash_value( "example" )
      expect( codec.verify_hash( hashed ) ).to eq "example"
    end

    it "handles an empty feature value" do
      hashed = codec.hash_value( "" )
      expect( codec.verify_hash( hashed ) ).to eq ""
    end

    it "handles an nil feature hash" do
      hashed = codec.hash_value( nil )
      expect( codec.verify_hash( hashed ) ).to eq nil
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.21 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.20 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.19 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.18 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.17 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.15 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.14 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.13 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.11 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.9 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.8 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.7 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.5 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.4 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.3 spec/lib/shamu/security/hashed_value_spec.rb
shamu-0.0.2 spec/lib/shamu/security/hashed_value_spec.rb