aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/shared_context.rb
blob: 5e472eb852abf4a909ce4cacdc52a42b4d08c0e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
shared_context 'iboo authenticated api user' do
  let(:api_key) { create(:api_key, organisation: organisation) }

  before do
    request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(api_key.organisation.code, api_key.token)
  end
end

shared_context 'iboo wrong authorisation api user' do
  let(:api_key) { create(:api_key, organisation: organisation) }

  before do
    request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('fake code', api_key.token)
  end
end

shared_context 'iboo authenticated internal api' do
  let(:api_key) { Rails.application.secrets.api_token }

  before do
    request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(api_key)
  end
end

shared_context 'iboo wrong authorisation internal api' do
  let(:api_key) { "false_api_token" }

  before do
    request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(api_key)
  end
end