Sha256: a5ead758c2202a460070aacd6319b09e6d3d7ede8b76b5ae05db5a3dff0f6e0b

Contents?: true

Size: 805 Bytes

Versions: 5

Compression:

Stored size: 805 Bytes

Contents

require 'spec_helper'

module CryptKeeper::LogSubscriber
  describe MysqlAes do
    use_postgres

    # Fire the ActiveSupport.on_load
    before do
      CryptKeeper::Provider::MysqlAes.new key: 'secret'
    end

    subject { ::ActiveRecord::LogSubscriber.new }

    let(:input_query) do
      "SELECT AES_ENCRYPT('encrypt_value', 'encrypt_key'), AES_ENCRYPT('decrypt_value', 'decrypt_key') FROM DUAL;"
    end

    let(:output_query) do
      "SELECT AES_ENCRYPT([FILTERED]), AES_DECRYPT([FILTERED]) FROM DUAL;"
    end

    it "filters mysql aes functions" do
      subject.should_receive(:sql_without_mysql_aes) do |event|
        event.payload[:sql].should == output_query
      end

      subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: output_query }))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
crypt_keeper-0.12.0 spec/log_subscriber/mysql_aes_spec.rb
crypt_keeper-0.11.0 spec/log_subscriber/mysql_aes_spec.rb
crypt_keeper-0.10.0.pre spec/log_subscriber/mysql_aes_spec.rb
crypt_keeper-0.9.0.pre spec/log_subscriber/mysql_aes_spec.rb
crypt_keeper-0.8.0 spec/log_subscriber/mysql_aes_spec.rb