Sha256: ed1d0d730bf0718ee8a9430227718cecd8de592188ad12fe7c14348cd4621670

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

require 'lite_spec_helper'

describe Mongo::Auth::Aws::Credentials do
  describe '#expired?' do
    context 'when expiration is nil' do
      let(:credentials) do
        described_class.new('access_key_id', 'secret_access_key', nil, nil)
      end

      it 'returns false' do
        expect(credentials.expired?).to be false
      end
    end

    context 'when expiration is not nil' do
      before do
        Timecop.freeze
      end
      after do
        Timecop.return
      end
      context 'when the expiration is more than five minutes away' do
        let(:credentials) do
          described_class.new('access_key_id', 'secret_access_key', nil, Time.now.utc + 400)
        end

        it 'returns false' do
          expect(credentials.expired?).to be false
        end
      end

      context 'when the expiration is less than five minutes away' do
        let(:credentials) do
          described_class.new('access_key_id', 'secret_access_key', nil, Time.now.utc + 200)
        end

        it 'returns true' do
          expect(credentials.expired?).to be true
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/mongo/auth/aws/credentials_spec.rb
mongo-2.20.1 spec/mongo/auth/aws/credentials_spec.rb
mogno-2.20.0 spec/mongo/auth/aws/credentials_spec.rb
mogno-1.0.0 spec/mongo/auth/aws/credentials_spec.rb
mongo-2.20.0 spec/mongo/auth/aws/credentials_spec.rb
mongo-2.19.3 spec/mongo/auth/aws/credentials_spec.rb
mongo-2.19.2 spec/mongo/auth/aws/credentials_spec.rb
mongo-2.19.1 spec/mongo/auth/aws/credentials_spec.rb
mongo-2.19.0 spec/mongo/auth/aws/credentials_spec.rb