Sha256: 5b71031fb1e077797c8a32088e3d53c06b604794f941fb6be2f071abcd5bda1b

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'spec_helper'

describe Mongo::Auth::X509::Conversation do

  let(:user) do
    Mongo::Auth::User.new(
      database: '$external',
      user: 'user',
    )
  end

  let(:conversation) do
    described_class.new(user, double('connection'))
  end

  describe '#start' do

    let(:query) do
      conversation.start(nil)
    end

    let(:selector) do
      query.selector
    end

    it 'sets username' do
      expect(selector[:user]).to eq('user')
    end

    it 'sets the mechanism' do
      expect(selector[:mechanism]).to eq('MONGODB-X509')
    end

    context 'when a username is not provided' do

      let(:user) do
        Mongo::Auth::User.new(
          database: '$external',
        )
      end

      it 'does not set the username' do
        expect(selector[:user]).to be_nil
      end

      it 'sets the mechanism' do
        expect(selector[:mechanism]).to eq('MONGODB-X509')
      end
    end

    context 'when the username is nil' do

      let(:user) do
        Mongo::Auth::User.new(
          database: '$external',
          user: nil
        )
      end

      it 'does not set the username' do
        expect(selector.has_key?(:user)).to be(false)
      end

      it 'sets the mechanism' do
        expect(selector[:mechanism]).to eq('MONGODB-X509')
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mongo-2.16.4 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.17.4 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.18.3 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.18.2 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.17.3 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.18.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.18.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.17.2 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.16.3 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.18.0.beta1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.16.2 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.17.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.16.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.17.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.16.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.15.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.16.0.alpha1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.15.0 spec/mongo/auth/x509/conversation_spec.rb