Sha256: ffbcf99f31410459e51d8b72daa926f61b2abe6718867214786f82a3f8deef5f

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

require 'spec_helper'

RSpec.describe Vault::Rails do
  describe "#memory_key_for" do
    input_examples = [
      ["path", "key"],
      ["path", "key", "context"],
      ["a_really_long_path", "a_really_long_key"],
      ["a_really_long_path", "a_really_long_key", "a_really_long_context"],
    ]

    input_examples.each do |path, key, encryption_context|
      context "with path=#{path}, key=#{key}, context=#{encryption_context}" do
        it "returns exactly 16 bytes as required by OpenSSL AES 128" do
          memory_key = Vault::Rails.send(
            :memory_key_for, path, key, context: encryption_context
          )
          expect(memory_key.bytesize).to eq(16)
        end
      end
    end

    it "returns unique keys for different paths, keys, and contexts" do
      memory_keys = input_examples.map { |path, key, encryption_context|
        Vault::Rails.send(
          :memory_key_for, path, key, context: encryption_context
        )
      }

      expect(memory_keys).to match_array(memory_keys.uniq)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vault-rails-0.9.0 spec/unit/vault/rails_spec.rb