Sha256: 302518debd5f26a8686741b77888a1bc48a1f547a0e7a455e6d2bdfa3fe205c8

Contents?: true

Size: 1.63 KB

Versions: 30

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe RightSupport::Validation::OpenSSL do
  GOOD_PEM_PUB_RSA            = read_fixture('good_pub_rsa.pem')
  GOOD_PEM_PRIV_RSA           = read_fixture('good_priv_rsa.pem')
  GOOD_ENCRYPTED_PEM_PRIV_RSA = read_fixture('encrypted_priv_rsa.pem')
  GOOD_SSH_PUB_RSA            = read_fixture('good_pub_rsa.ssh')
  GOOD_SSH_PUB_DSA            = read_fixture('good_pub_dsa.ssh')
  GOOD_PEM_PRIV_DSA           = read_fixture('good_priv_dsa.pem')

  context :pem_public_key? do
    it 'recognizes valid keys' do
      RightSupport::Validation.pem_public_key?(GOOD_PEM_PUB_RSA).should == true
    end
    it 'recognizes bad keys' do
      RightSupport::Validation.pem_public_key?(corrupt(GOOD_PEM_PUB_RSA)).should == false
      RightSupport::Validation.pem_public_key?(nil).should == false
      RightSupport::Validation.pem_public_key?('').should == false
    end
  end

  context :pem_private_key? do
    it 'recognizes valid keys' do
      RightSupport::Validation.pem_private_key?(GOOD_PEM_PRIV_RSA).should == true
      RightSupport::Validation.pem_private_key?(GOOD_PEM_PRIV_DSA).should == true
    end
    it 'considers encrypted keys to be "bad" (not usable)' do
      RightSupport::Validation.pem_private_key?(GOOD_ENCRYPTED_PEM_PRIV_RSA).should == false
    end
    it 'recognizes bad keys' do
      RightSupport::Validation.pem_private_key?(corrupt(GOOD_PEM_PRIV_RSA)).should == false
      RightSupport::Validation.pem_private_key?(corrupt(GOOD_PEM_PRIV_RSA, 16)).should == false
      RightSupport::Validation.pem_private_key?(nil).should == false
      RightSupport::Validation.pem_private_key?('').should == false
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
right_support-2.8.34 spec/validation/openssl_spec.rb
right_support-2.8.33 spec/validation/openssl_spec.rb
right_support-2.8.32 spec/validation/openssl_spec.rb
right_support-2.8.31 spec/validation/openssl_spec.rb
right_support-2.8.30 spec/validation/openssl_spec.rb
right_support-2.8.29 spec/validation/openssl_spec.rb
right_support-2.8.28 spec/validation/openssl_spec.rb
right_support-2.8.27 spec/validation/openssl_spec.rb
right_support-2.8.26 spec/validation/openssl_spec.rb
right_support-2.8.25 spec/validation/openssl_spec.rb
right_support-2.8.24 spec/validation/openssl_spec.rb
right_support-2.8.23 spec/validation/openssl_spec.rb
right_support-2.8.22 spec/validation/openssl_spec.rb
right_support-2.8.21 spec/validation/openssl_spec.rb
right_support-2.8.20 spec/validation/openssl_spec.rb
right_support-2.8.17 spec/validation/openssl_spec.rb
right_support-2.8.16 spec/validation/openssl_spec.rb
right_support-2.8.15 spec/validation/openssl_spec.rb
right_support-2.8.12 spec/validation/openssl_spec.rb
right_support-2.8.11 spec/validation/openssl_spec.rb