Sha256: 78a0d9bee453c9085229e0fdca051a558b06f2483eba45c5cc55fc0d0252b8e7

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe BasicAuthSession do
  describe '#initialize' do
    it 'sets the username instance variable' do
      session = Roqua::CoreApi.basic_auth_session username: 'some_username'
      expect(session.username).to eq('some_username')
    end

    it 'defaults the username to the CORE_KEY env variable' do
      original_env_core_key = ENV['CORE_KEY']
      ENV['CORE_KEY'] = 'some_env_core_key'
      session = Roqua::CoreApi.basic_auth_session
      ENV['CORE_KEY'] = original_env_core_key
      expect(session.username).to eq('some_env_core_key')
    end

    it 'sets the password instance variable' do
      session = Roqua::CoreApi.basic_auth_session password: 'some_password'
      expect(session.password).to eq('some_password')
    end

    it 'defaults the password to the CORE_SECRET env variable' do
      original_env_core_secret = ENV['CORE_SECRET']
      ENV['CORE_SECRET'] = 'some_env_core_secret'
      session = Roqua::CoreApi.basic_auth_session
      ENV['CORE_SECRET'] = original_env_core_secret
      expect(session.password).to eq('some_env_core_secret')
    end

    it 'allows to override the core_site variable' do
      session = Roqua::CoreApi.basic_auth_session core_site: 'some_core_site'
      expect(session.core_site).to eq('some_core_site')
    end

    it 'defaults the AuthSession core_site CORE_SITE env variable default value' do
      orginal_env_core_site = ENV['CORE_SITE']
      ENV['CORE_SITE'] = 'some_env_core_site'
      session = Roqua::CoreApi.basic_auth_session
      ENV['CORE_SITE'] = orginal_env_core_site
      expect(session.core_site).to eq('some_env_core_site')
    end
  end

  describe '#basic_auth' do
    it 'returns the username and password variables' do
      session = Roqua::CoreApi.basic_auth_session username: 'some_username', password: 'some_password'
      expect(session.send :basic_auth).to eq(username: 'some_username', password: 'some_password')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roqua-core-api-0.0.18 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
roqua-core-api-0.0.17 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb