1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
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
|