Sha256: c172b6acbadd95a37039595f551ed446e1759acdaeea04124e5a737f070c3098
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true RSpec.shared_examples_for 'a token authenticatable api' do let(:token_value) { 'abc123' } context 'with authorization header' do let(:headers) { { 'Authorization' => "Bearer #{token_value}" } } include_examples 'token validation' end context 'with access token parameter' do let(:params) { { 'access_token' => token_value } } include_examples 'token validation' end context 'without authentication information' do before { subject } it 'should be unauthorized' do expect(response.status).to eq(401) end it 'should return an authenticate header without details' do expect(response.headers['WWW-Authenticate']).to eq('Bearer') end end context 'with environment variables for password credentials' do before do ENV['G5_AUTH_USERNAME'] = 'my.user@test.host' ENV['G5_AUTH_PASSWORD'] = 'my_secret' end after do ENV['G5_AUTH_USERNAME'] = nil ENV['G5_AUTH_PASSWORD'] = nil end before { subject } it 'should be unauthorized' do expect(response.status).to eq(401) end it 'should return an authenticate header without details' do expect(response.headers['WWW-Authenticate']).to eq('Bearer') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
g5_authenticatable_api-1.0.0 | spec/support/shared_examples/token_authenticatable_api.rb |
g5_authenticatable_api-1.0.0.pre.1 | spec/support/shared_examples/token_authenticatable_api.rb |