end
def api_token(api_client_auth_name)
- api_client_authorizations(api_client_auth_name).api_token
+ api_client_authorizations(api_client_auth_name).token
end
def auth(api_client_auth_name)
- {'HTTP_AUTHORIZATION' => "OAuth2 #{api_token(api_client_auth_name)}"}
+ {'HTTP_AUTHORIZATION' => "Bearer #{api_token(api_client_auth_name)}"}
end
def show_errors model
def restore_configuration
# Restore configuration settings changed during tests
- $application_config.each do |k,v|
- if k.match(/^[^.]*$/)
- Rails.configuration.send (k + '='), v
- end
- end
+ ConfigLoader.copy_into_config $arvados_config, Rails.configuration
+ ConfigLoader.copy_into_config $remaining_config, Rails.configuration
end
def set_user_from_auth(auth_name)
end
def authorize_with api_client_auth_name
- authorize_with_token api_client_authorizations(api_client_auth_name).api_token
+ authorize_with_token api_client_authorizations(api_client_auth_name).token
end
def authorize_with_token token
t = token
- t = t.api_token if t.respond_to? :api_token
+ t = t.token if t.respond_to? :token
ArvadosApiToken.new.call("rack.input" => "",
- "HTTP_AUTHORIZATION" => "OAuth2 #{t}")
+ "HTTP_AUTHORIZATION" => "Bearer #{t}")
end
def salt_token(fixture:, remote:)
class ActionController::TestCase
setup do
@test_counter = 0
+ self.request.headers['Accept'] = 'application/json'
+ self.request.headers['Content-Type'] = 'application/json'
end
def check_counter action
[:get, :post, :put, :patch, :delete].each do |method|
define_method method do |action, *args|
check_counter action
+ # After Rails 5.0 upgrade, some params don't get properly serialized.
+ # One case are filters: [['attr', 'op', 'val']] become [['attr'], ['op'], ['val']]
+ # if not passed upstream as a JSON string.
+ if args[0].is_a?(Hash) && args[0][:params].is_a?(Hash)
+ args[0][:params].each do |key, _|
+ next if key == :exclude_script_versions # Job Reuse tests
+ # Keys could be: :filters, :where, etc
+ if [Array, Hash].include?(args[0][:params][key].class)
+ args[0][:params][key] = SafeJSON.dump(args[0][:params][key])
+ end
+ end
+ end
super action, *args
end
end