aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/api_key.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/api_key.rb')
-rw-r--r--spec/support/api_key.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/spec/support/api_key.rb b/spec/support/api_key.rb
index 5aaa31217..cc08cd7f1 100644
--- a/spec/support/api_key.rb
+++ b/spec/support/api_key.rb
@@ -7,18 +7,22 @@ module ApiKeyHelper
def get_api_key
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