Sha256: bc5ab45d1111b48ea25dd4f7e573d9a204cb13589dd45e22857b5cbb8c6ae2a8

Contents?: true

Size: 990 Bytes

Versions: 2

Compression:

Stored size: 990 Bytes

Contents

require_relative "spec_helper"

describe Strongroom::Encryptor do

  before do
    @cipher = ::MiniTest::Mock.new.tap do |c|
      c.expect :name, "AES-128-TEST"
      c.expect :encrypt, nil
      c.expect :random_key, "rkey"
      c.expect :key=, "rkey", [ "rkey" ]
      c.expect :random_iv, "riv"
      c.expect :iv=, "riv", [ "riv" ]
      c.expect :update, "cipherte", [ "input" ]
      c.expect :final, "xt=="
    end
    @key = ::MiniTest::Mock.new.tap do |k|
      k.expect :public_encrypt, "encryptedkey", [ "rkey" ]
    end
  end

  it "calls OpenSSL methods" do
    Strongroom::Encryptor.new(@key, @cipher).encrypt("input")
    [ @cipher, @key ].each &:verify
  end

  it "creates correct Enigma" do
    Strongroom::Encryptor.new(@key, @cipher).encrypt("input").tap do |enigma|
      enigma.ciphertext.must_equal "ciphertext=="
      enigma.encrypted_key.must_equal "encryptedkey"
      enigma.iv.must_equal "riv"
      enigma.cipher.must_equal "AES-128-TEST"
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
strongroom-0.0.2 spec/strongroom_encryptor_spec.rb
strongroom-0.0.1 spec/strongroom_encryptor_spec.rb