Sha256: e89c83f7cbb6ba6272a8ab26b9b6325cf9aae4a05c082c9ad384a6c207e7b4ee

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'mongo'
require 'support/lite_constraints'

RSpec.configure do |config|
  config.extend(LiteConstraints)
end

describe 'kerberos authentication' do
  require_mongo_kerberos

  let(:user) do
   "#{ENV['SASL_USER']}%40#{ENV['SASL_HOST'].upcase}"
  end

  let(:host) do
    "#{ENV['SASL_HOST']}"
  end

  let(:kerberos_db) do
    "#{ENV['KERBEROS_DB']}"
  end

  let(:auth_source) do
    "#{ENV['SASL_DB']}"
  end

  let(:uri) do
    uri = "mongodb://#{user}@#{host}/#{kerberos_db}?authMechanism=GSSAPI&authSource=#{auth_source}"
  end

  let(:client) do
    Mongo::Client.new(uri)
  end

  let(:doc) do
    client.database[:test].find.first
  end

  it 'correctly authenticates' do
    expect(doc['kerberos']).to eq(true)
    expect(doc['authenticated']).to eq('yeah')
  end

  context 'when canonicalize_host_name is true' do
    let(:host) do
      "#{ENV['IP_ADDR']}"
    end

    let(:uri) do
      uri = "mongodb://#{user}@#{host}/#{kerberos_db}?authMechanism=GSSAPI&authSource=#{auth_source}&authMechanismProperties=CANONICALIZE_HOST_NAME:true"
    end

    it 'correctly authenticates when using the IP' do
      expect(doc['kerberos']).to eq(true)
      expect(doc['authenticated']).to eq('yeah')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongo-2.11.6 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.5 spec/enterprise_auth/kerberos_spec.rb
mongo-2.12.0.rc0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.4 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.3 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.2 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.1 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.11.0.rc0 spec/enterprise_auth/kerberos_spec.rb