Sha256: 815497ddd786657a2b84152b15bd61a134df6587ebe008c1c02b30b061eeffad

Contents?: true

Size: 1.91 KB

Versions: 5

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
      orginal_env_core_key = ENV['CORE_KEY']
      ENV['CORE_KEY'] = 'some_env_core_key'
      session = Roqua::CoreApi.basic_auth_session
      ENV['CORE_KEY'] = orginal_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
      orginal_env_core_secret = ENV['CORE_SECRET']
      ENV['CORE_SECRET'] = 'some_env_core_secret'
      session = Roqua::CoreApi.basic_auth_session
      ENV['CORE_SECRET'] = orginal_env_core_secret
      expect(session.password).to eq('some_env_core_secret')
    end

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

    it 'defaults the AuthSession core_host CORE_HOST env variable default value' do
      orginal_env_core_host = ENV['CORE_HOST']
      ENV['CORE_HOST'] = 'some_env_core_host'
      session = Roqua::CoreApi.basic_auth_session
      ENV['CORE_HOST'] = orginal_env_core_host
      expect(session.core_host).to eq('some_env_core_host')
    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

5 entries across 5 versions & 1 rubygems

Version Path
roqua-core-api-0.0.16 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
roqua-core-api-0.0.15 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
roqua-core-api-0.0.14 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
roqua-core-api-0.0.13 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb
roqua-core-api-0.0.12 spec/lib/roqua/core_api/sessions/basic_auth_session_spec.rb