1 ENV["RAILS_ENV"] = "test"
2 require File.expand_path('../../config/environment', __FILE__)
3 require 'rails/test_help'
5 module ArvadosTestSupport
7 @json_response ||= ActiveSupport::JSON.decode @response.body
10 def api_token(api_client_auth_name)
11 api_client_authorizations(api_client_auth_name).api_token
14 def auth(api_client_auth_name)
15 {'HTTP_AUTHORIZATION' => "OAuth2 #{api_token(api_client_auth_name)}"}
19 class ActiveSupport::TestCase
20 # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
22 # Note: You'll currently still have to declare fixtures explicitly in integration tests
23 # -- they do not yet inherit this setting
26 include ArvadosTestSupport
29 Thread.current[:api_client_ip_address] = nil
30 Thread.current[:api_client_authorization] = nil
31 Thread.current[:api_client_uuid] = nil
32 Thread.current[:api_client] = nil
33 Thread.current[:user] = nil
37 self.request.headers["Accept"] = "text/json"
40 def authorize_with(api_client_auth_name)
41 ArvadosApiToken.new.call ({"rack.input" => "", "HTTP_AUTHORIZATION" => "OAuth2 #{api_client_authorizations(api_client_auth_name).api_token}"})
45 class ActionDispatch::IntegrationTest
47 Thread.current[:api_client_ip_address] = nil
48 Thread.current[:api_client_authorization] = nil
49 Thread.current[:api_client_uuid] = nil
50 Thread.current[:api_client] = nil
51 Thread.current[:user] = nil
55 # Ensure permissions are computed from the test fixtures.
56 User.invalidate_permissions_cache