Sha256: 303cc52481e0135c18312c8ce086b601c8b6ee4ad5e2cf4fcabc0252bf005427

Contents?: true

Size: 1.51 KB

Versions: 24

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true
RSpec.describe FinApps::Middleware::TenantAuthentication do
  let(:valid_tenant_options) { VALID_CREDENTIALS }
  let(:key) { FinApps::Middleware::TenantAuthentication::KEY }

  describe '#call' do
    fake_app = proc {|env| env }

    context 'when company credentials were provided' do
      let(:middleware) do
        FinApps::Middleware::TenantAuthentication.new(fake_app,
                                                      VALID_CREDENTIALS[:identifier],
                                                      VALID_CREDENTIALS[:token])
      end
      let(:expected_header) { "#{valid_tenant_options[:identifier]}=#{valid_tenant_options[:token]}" }

      context 'when header was not previously set' do
        let(:request_env) { {request_headers: {}} }
        subject(:actual_header) { middleware.call(request_env)[:request_headers][key] }

        it('generates a Tenant Authentication header') { expect(actual_header).to eq(expected_header) }
      end

      context 'when header was previously set' do
        let(:existing_header) { {FinApps::Middleware::TenantAuthentication::KEY => 'foo'} }
        let(:request_env) { {request_headers: existing_header} }
        subject(:actual_header) { middleware.call(request_env)[:request_headers][key] }

        it('does not override existing Tenant Authentication header') { expect(actual_header).to eq('foo') }
        it('does not generate a Tenant Authentication header') { expect(actual_header).to_not eq(expected_header) }
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
finapps-2.1.4 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.1.3 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.1.2 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.1.1 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.30 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.29 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.28 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.27 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.26 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.25 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.24 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.23 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.22 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.21 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.20 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.19 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.17 spec/middleware/request/tenant_authentication_spec.rb
finapps-2.0.16 spec/middleware/tenant_authentication_spec.rb
finapps-2.0.15 spec/middleware/tenant_authentication_spec.rb
finapps-2.0.14 spec/middleware/tenant_authentication_spec.rb