Sha256: c8121fa31220283016fced6f98941c854e625bb9f11adea13d12453682196daf

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

Contents

require 'spec_helper'

describe Mongo::Socket::SSL do

  describe '#connect!', if: running_ssl? do

    let(:socket) do
      described_class.new(*DEFAULT_ADDRESS.split(":"), 5, Socket::PF_INET, options)
    end

    context 'when a certificate is provided' do

      let(:options) do
        {
          :ssl => true,
          :ssl_cert => CLIENT_PEM,
          :ssl_key => CLIENT_PEM
        }
      end

      before do
        socket.connect!
      end

      it 'connects to the server' do
        expect(socket).to be_alive
      end
    end

    context 'when a bad certificate is provided' do

      let(:options) do
        {
          :ssl => true,
          :ssl_cert => CLIENT_PEM,
          :ssl_key => CRL_PEM
        }
      end

      it 'raises an exception' do
        expect {
          socket.connect!
        }.to raise_error
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo-2.0.4 spec/mongo/socket/ssl_spec.rb
mongo-2.0.3 spec/mongo/socket/ssl_spec.rb