Skip to content
This repository
tree: 7dc97d3a93
Fetching contributors…

Cannot retrieve contributors at this time

file 57 lines (47 sloc) 1.537 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
require 'test/test_helper'

class ProcKeyTest < Test::Unit::TestCase
  context 'With a Proc returning a string for a key pair' do
    setup do
      @password = 'boost facile'
      rebuild_model :key_pair => Proc.new {
        File.read(File.join(FIXTURES_DIR,'keypair.pem'))
      }
      @dummy = Dummy.new
      @dummy.secret = 'Shhhh'
    end

    should_encypted_and_decrypt
  end

  context 'With a Proc returning a key object' do
    setup do
      @password = 'boost facile'
      @private_key = OpenSSL::PKey::RSA.new(2048)
      rebuild_model :key_pair => Proc.new { @private_key }
      @dummy = Dummy.new
      @dummy.secret = 'Shhhh'
    end

    should_encypted_and_decrypt
  end

  context 'With Procs returning public and private key strings' do
    setup do
      @password = 'boost facile'
      @key_pair = File.read(File.join(FIXTURES_DIR,'keypair.pem'))

      rebuild_model :public_key => Proc.new { @key_pair },
                    :private_key => Proc.new { @key_pair }
      @dummy = Dummy.new
      @dummy.secret = 'Shhhh'
    end

    should_encypted_and_decrypt
  end

  context 'With Procs returning public and private key objects' do
    setup do
      @password = 'boost facile'
      @private_key = OpenSSL::PKey::RSA.new(2048)
      @public_key = @private_key.public_key

      rebuild_model :public_key => Proc.new { @public_key },
                    :private_key => Proc.new { @private_key }
      @dummy = Dummy.new
      @dummy.secret = 'Shhhh'
    end

    should_encypted_and_decrypt
  end
end
Something went wrong with that request. Please try again.