Sha256: e8050a491f375ec8c1e9b4deb6003c440a5f5d65859cd29673c5005573248359

Contents?: true

Size: 1.25 KB

Versions: 51

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe RightSupport::Net::SSL do
  PATCH = RightSupport::Net::SSL::OpenSSLPatch

  context :with_expected_hostname do
    before(:all) do
      PATCH.enable!
    end

    it 'works' do
      OpenSSL::SSL.should respond_to(:verify_certificate_identity_without_hack)
      PATCH.enabled?.should be_true

      cert = flexmock('SSL certificate')

      flexmock(OpenSSL::SSL).
          should_receive(:verify_certificate_identity_without_hack).
          with(cert, 'reposeX.rightscale.com').and_return(true)
      RightSupport::Net::SSL.with_expected_hostname('reposeX.rightscale.com') do
        OpenSSL::SSL.verify_certificate_identity(cert, '1.2.3.4').should be_true
      end
    end

    context 'with disabled monkey-patch' do
      before(:all) do
        PATCH.disable!
      end
      it 'does not work' do
        PATCH.enabled?.should be_false
        cert = flexmock('SSL certificate')
        flexmock(OpenSSL::SSL).
            should_receive(:verify_certificate_identity_without_hack).
            with(cert, '1.2.3.4').and_return(false)

        RightSupport::Net::SSL.with_expected_hostname('reposeX.rightscale.com') do
          OpenSSL::SSL.verify_certificate_identity(cert, '1.2.3.4').should be_false
        end
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
right_support-2.11.3 spec/net/ssl_spec.rb
right_support-2.11.2 spec/net/ssl_spec.rb
right_support-2.10.1 spec/net/ssl_spec.rb
right_support-2.9.6 spec/net/ssl_spec.rb
right_support-2.9.5 spec/net/ssl_spec.rb
right_support-2.9.4 spec/net/ssl_spec.rb
right_support-2.9.3 spec/net/ssl_spec.rb
right_support-2.9.2 spec/net/ssl_spec.rb
right_support-2.9.1 spec/net/ssl_spec.rb
right_support-2.8.46 spec/net/ssl_spec.rb
right_support-2.8.45 spec/net/ssl_spec.rb
right_support-2.8.44 spec/net/ssl_spec.rb
right_support-2.8.43 spec/net/ssl_spec.rb
right_support-2.8.42 spec/net/ssl_spec.rb
right_support-2.8.41 spec/net/ssl_spec.rb
right_support-2.8.40 spec/net/ssl_spec.rb
right_support-2.8.39 spec/net/ssl_spec.rb
right_support-2.8.38 spec/net/ssl_spec.rb
right_support-2.8.37 spec/net/ssl_spec.rb
right_support-2.8.36 spec/net/ssl_spec.rb