Sha256: f93851610852eebe47ef4fe024ea28e1bb64d49130a76c269007faa75c4cf179

Contents?: true

Size: 1.4 KB

Versions: 20

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe Mongo::Auth::X509 do

  let(:address) do
    default_address
  end

  let(:monitoring) do
    Mongo::Monitoring.new(monitoring: false)
  end

  let(:listeners) do
    Mongo::Event::Listeners.new
  end

  let(:cluster) do
    double('cluster').tap do |cl|
      allow(cl).to receive(:topology).and_return(topology)
      allow(cl).to receive(:app_metadata).and_return(app_metadata)
      allow(cl).to receive(:options).and_return({})
      allow(cl).to receive(:cluster_time).and_return(nil)
      allow(cl).to receive(:update_cluster_time)
    end
  end

  declare_topology_double

  let(:server) do
    Mongo::Server.new(address, cluster, monitoring, listeners,
      SpecConfig.instance.test_options
    ).tap do |server|
      server.scan!
    end
  end

  let(:connection) do
    Mongo::Server::Connection.new(server, SpecConfig.instance.test_options)
  end

  let(:user) do
    Mongo::Auth::User.new(database: SpecConfig.instance.test_db, user: 'driver', password: 'password')
  end

  describe '#login' do

    context 'when the user is not authorized for the database' do

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

      let(:login) do
        x509.login(connection).documents[0]
      end

      it 'logs the user into the connection' do
        expect {
          x509.login(connection)
        }.to raise_error(Mongo::Auth::Unauthorized)
      end
    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/mongo/auth/x509_spec.rb
mongo-2.10.5 spec/mongo/auth/x509_spec.rb
mongo-2.10.4 spec/mongo/auth/x509_spec.rb
mongo-2.10.3 spec/mongo/auth/x509_spec.rb
mongo-2.9.2 spec/mongo/auth/x509_spec.rb
mongo-2.10.2 spec/mongo/auth/x509_spec.rb
mongo-2.10.1 spec/mongo/auth/x509_spec.rb
mongo-2.10.0 spec/mongo/auth/x509_spec.rb
mongo-2.9.1 spec/mongo/auth/x509_spec.rb
mongo-2.10.0.rc0 spec/mongo/auth/x509_spec.rb
mongo-2.9.1.rc0 spec/mongo/auth/x509_spec.rb
mongo-2.9.0 spec/mongo/auth/x509_spec.rb
mongo-2.9.0.rc1 spec/mongo/auth/x509_spec.rb
mongo-2.9.0.rc0 spec/mongo/auth/x509_spec.rb
mongo-2.8.0 spec/mongo/auth/x509_spec.rb
mongo-2.7.2 spec/mongo/auth/x509_spec.rb
mongo-2.8.0.rc0 spec/mongo/auth/x509_spec.rb
mongo-2.7.1 spec/mongo/auth/x509_spec.rb
mongo-2.7.0 spec/mongo/auth/x509_spec.rb
mongo-2.7.0.rc0 spec/mongo/auth/x509_spec.rb