1 ENV["RAILS_ENV"] = "test"
2 require File.expand_path('../../config/environment', __FILE__)
3 require 'rails/test_help'
5 module ArvadosTestSupport
7 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
22 include ArvadosTestSupport
25 Thread.current[:api_client_ip_address] = nil
26 Thread.current[:api_client_authorization] = nil
27 Thread.current[:api_client_uuid] = nil
28 Thread.current[:api_client] = nil
29 Thread.current[:user] = nil
32 def set_user_from_auth(auth_name)
33 client_auth = api_client_authorizations(auth_name)
34 Thread.current[:api_client_authorization] = client_auth
35 Thread.current[:api_client] = client_auth.api_client
36 Thread.current[:user] = client_auth.user
40 self.request.headers["Accept"] = "text/json"
43 def authorize_with(api_client_auth_name)
44 ArvadosApiToken.new.call ({"rack.input" => "", "HTTP_AUTHORIZATION" => "OAuth2 #{api_client_authorizations(api_client_auth_name).api_token}"})
48 class ActionDispatch::IntegrationTest
50 Thread.current[:api_client_ip_address] = nil
51 Thread.current[:api_client_authorization] = nil
52 Thread.current[:api_client_uuid] = nil
53 Thread.current[:api_client] = nil
54 Thread.current[:user] = nil
58 # Ensure permissions are computed from the test fixtures.
59 User.invalidate_permissions_cache