Sha256: 8ae349923e6b9f52f84bb4267ac1e5da9021b1a858b2aa9631992575310e59fa

Contents?: true

Size: 804 Bytes

Versions: 18

Compression:

Stored size: 804 Bytes

Contents

require 'spec_helper'

describe AttrVault::Secret do
  it "can resolve a URL safe base64 encoded 32 byte string" do
    resolves_input(Base64.urlsafe_encode64("A"*16 + "B"*16))
  end

  it "can resolve a base64 encoded 32 byte string" do
    resolves_input(Base64.encode64("A"*16 + "B"*16))
  end

  it "can resolve a 32 byte string without encoding" do
    resolves_input("A"*16 + "B"*16)
  end

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

  def resolves_input(input)
    secret = AttrVault::Secret.new(input)

    expect(
      secret.signing_key
    ).to eq("A"*16)

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
attr_vault-2.1.2 spec/attr_vault/secret_spec.rb
attr_vault-2.1.1 spec/attr_vault/secret_spec.rb
attr_vault-2.1.0 spec/attr_vault/secret_spec.rb
attr_vault-2.0.0 spec/attr_vault/secret_spec.rb
attr_vault-1.0.1 spec/attr_vault/secret_spec.rb
attr_vault-1.0.0 spec/attr_vault/secret_spec.rb
attr_vault-0.2.1 spec/attr_vault/secret_spec.rb
attr_vault-0.2.0 spec/attr_vault/secret_spec.rb
attr_vault-0.1.2 spec/attr_vault/secret_spec.rb
attr_vault-0.1.1 spec/attr_vault/secret_spec.rb
attr_vault-0.0.9 spec/attr_vault/secret_spec.rb
attr_vault-0.0.8 spec/attr_vault/secret_spec.rb
attr_vault-0.0.7 spec/attr_vault/secret_spec.rb
attr_vault-0.0.6 spec/attr_vault/secret_spec.rb
attr_vault-0.0.4 spec/attr_vault/secret_spec.rb
attr_vault-0.0.3 spec/attr_vault/secret_spec.rb
attr_vault-0.0.2 spec/attr_vault/secret_spec.rb
attr_vault-0.0.1 spec/attr_vault/secret_spec.rb