Sha256: 62bf8310379d7e298fa9478ed771d0d683350f7b1a62e20795d34b4700cae61e

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

require 'spec_helper'
require 'fernet/secret'

describe Fernet::Secret do
  it "expects base64 encoded 32 byte strings" do
    secret = Base64.urlsafe_encode64("A"*32)
    expect do
      Fernet::Secret.new(secret)
    end.to_not raise_error
  end

  it "extracts encryption and signing keys" do
    secret = Base64.urlsafe_encode64("A"*16 + "B"*16)
    fernet_secret = Fernet::Secret.new(secret)
    expect(
      fernet_secret.signing_key
    ).to eq("A"*16)

    expect(
      fernet_secret.encryption_key
    ).to eq("B"*16)
  end

  it "fails loudly when an invalid secret is provided" do
    secret = Base64.urlsafe_encode64("bad")
    expect do
      Fernet::Secret.new(secret)
    end.to raise_error(Fernet::Secret::InvalidSecret)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fernet-2.0.rc1 spec/secret_spec.rb