Sha256: 8785ecc7efab5ebea6002cd59c26da075734adfa8b62f965b4a6cf6c99604241

Contents?: true

Size: 1.29 KB

Versions: 41

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

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

  let(:user) do
    Mongo::Auth::User.new(
      database: Mongo::Database::ADMIN,
      user: 'user',
    )
  end

  let(:conversation) do
    described_class.new(user)
  end

  describe '#start' do

    let(:query) do
      conversation.start
    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: Mongo::Database::ADMIN
        )
      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: Mongo::Database::ADMIN,
          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

41 entries across 39 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.5 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.4 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.11.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.3 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.11.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.9.2 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.2 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.11.0.rc0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.9.1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.10.0.rc0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.9.1.rc0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.9.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.9.0.rc1 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.9.0.rc0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.8.0 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.7.2 spec/mongo/auth/x509/conversation_spec.rb
mongo-2.8.0.rc0 spec/mongo/auth/x509/conversation_spec.rb