Sha256: 01c96224da466f615b6f6e028a43e6cf62a66e6acc43b127f4607e32bc087c25

Contents?: true

Size: 1015 Bytes

Versions: 11

Compression:

Stored size: 1015 Bytes

Contents

require File.join(File.dirname(__FILE__), '../test_helper')
require 'apipie_bindings/authenticators/credentials_legacy'

describe ApipieBindings::Authenticators::CredentialsLegacy do
  let(:authenticator) { ApipieBindings::Authenticators::CredentialsLegacy.new(@credentials) }
  let(:user) { 'john_doe' }
  let(:passwd) { 'secret_password' }
  let(:request) { mock() }
  let(:args) { {} }

  before do
    @credentials = mock()
  end

  describe '#authenticate' do
    it 'uses result of to_params for base auth of the request' do
      @credentials.expects(:to_params).returns({ :user => user, :password => passwd })
      request.expects(:basic_auth).with(user, passwd)
      authenticator.authenticate(request, args)
    end
  end

  describe '#error' do
    it 'clears credentials on RestClient::Unauthorized' do
      @credentials.expects(:clear)
      authenticator.error(RestClient::Unauthorized.new)
    end

    it 'lets other errors pass' do
      authenticator.error(RuntimeError.new)
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
apipie-bindings-0.7.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.6.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.5.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.4.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.3.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.2.3 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.2.2 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.2.1 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.2.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.1.0 test/unit/authenticators/credentials_legacy_test.rb
apipie-bindings-0.0.19 test/unit/authenticators/credentials_legacy_test.rb