13994: Fix token handling in collection performance test.
[arvados.git] / services / api / test / test_helper.rb
index 639b53bfa717f1a89a5a30cadeaf7ea7eee7fe3f..73b45f95ec71a7b28564c8a5767eb48503ec5465 100644 (file)
@@ -65,6 +65,7 @@ class ActiveSupport::TestCase
     Thread.current[:api_client_authorization] = nil
     Thread.current[:api_client_uuid] = nil
     Thread.current[:api_client] = nil
+    Thread.current[:token] = nil
     Thread.current[:user] = nil
     restore_configuration
   end
@@ -110,6 +111,7 @@ class ActiveSupport::TestCase
     Thread.current[:api_client_authorization] = client_auth
     Thread.current[:api_client] = client_auth.api_client
     Thread.current[:user] = client_auth.user
+    Thread.current[:token] = client_auth.token
   end
 
   def expect_json
@@ -127,12 +129,12 @@ class ActiveSupport::TestCase
                              "HTTP_AUTHORIZATION" => "OAuth2 #{t}")
   end
 
-  def salt_token(fixture:, remote_id:)
+  def salt_token(fixture:, remote:)
     auth = api_client_authorizations(fixture)
     uuid = auth.uuid
     token = auth.api_token
-    hmac = OpenSSL::HMAC.hexdigest('sha1', token, remote_id)
-    return "v2,#{uuid},#{hmac}"
+    hmac = OpenSSL::HMAC.hexdigest('sha1', token, remote)
+    return "v2/#{uuid}/#{hmac}"
   end
 
   def self.skip_slow_tests?
@@ -143,7 +145,7 @@ class ActiveSupport::TestCase
   end
 
   def self.slow_test(name, &block)
-    define_method(name, block) unless skip_slow_tests?
+    test(name, &block) unless skip_slow_tests?
   end
 end
 
@@ -188,6 +190,7 @@ class ActionDispatch::IntegrationTest
     Thread.current[:api_client_authorization] = nil
     Thread.current[:api_client_uuid] = nil
     Thread.current[:api_client] = nil
+    Thread.current[:token] = nil
     Thread.current[:user] = nil
   end
 end