Sha256: c3a177927f46ed9b28db1187ac94907433aa3c7f20679986f27cfcd77298a89a

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

require 'mongo'

describe 'kerberos authentication' do
  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

  before do
    skip 'ENTERPRISE_AUTH_TESTS env var not specified' unless ENV['ENTERPRISE_AUTH_TESTS']
  end

  let(:doc) do
    require 'mongo_kerberos'

    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

20 entries across 20 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.5 spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.4 spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.3 spec/enterprise_auth/kerberos_spec.rb
mongo-2.9.2 spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.2 spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.1 spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.9.1 spec/enterprise_auth/kerberos_spec.rb
mongo-2.10.0.rc0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.9.1.rc0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.9.0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.9.0.rc1 spec/enterprise_auth/kerberos_spec.rb
mongo-2.9.0.rc0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.8.0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.7.2 spec/enterprise_auth/kerberos_spec.rb
mongo-2.8.0.rc0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.7.1 spec/enterprise_auth/kerberos_spec.rb
mongo-2.7.0 spec/enterprise_auth/kerberos_spec.rb
mongo-2.7.0.rc0 spec/enterprise_auth/kerberos_spec.rb