diff options
| author | Xinhui | 2017-08-25 17:13:24 +0200 |
|---|---|---|
| committer | Xinhui | 2017-08-25 17:13:24 +0200 |
| commit | 0777d35ff4460cf07c34e69ee7c10c0270a446bf (patch) | |
| tree | b2d850bbce3c8669ee6c636fa93e91c5a6a662bc /spec/support/api_key.rb | |
| parent | 5dda0f5286043823acab68a73d84437a3cbd803f (diff) | |
| parent | 1d7db2b6c254ac55105c08ee177580036b0377f3 (diff) | |
| download | chouette-core-0777d35ff4460cf07c34e69ee7c10c0270a446bf.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'spec/support/api_key.rb')
| -rw-r--r-- | spec/support/api_key.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/support/api_key.rb b/spec/support/api_key.rb index 9353fac15..cc08cd7f1 100644 --- a/spec/support/api_key.rb +++ b/spec/support/api_key.rb @@ -1,20 +1,28 @@ module ApiKeyHelper + def authorization_token_header(key) + {'Authorization' => "Token token=#{key}"} + end + def get_api_key - Api::V1::ApiKey.first_or_create( :referential_id => referential.id, :name => "test") + Api::V1::ApiKey.first_or_create(referential: referential, organisation: organisation) end + def config_formatted_request_with_authorization( format) request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials( get_api_key.token) request.accept = format end + def config_formatted_request_with_dummy_authorization( format) request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials( "dummy") request.accept = format end + def config_formatted_request_without_authorization( format) request.env['HTTP_AUTHORIZATION'] = nil request.accept = format end + def json_xml_format? request.accept == "application/json" || request.accept == "application/xml" end |
