20846: More kwargs / Ruby 3 compatibility fixes.
authorTom Clegg <tom@curii.com>
Tue, 31 Oct 2023 19:11:04 +0000 (15:11 -0400)
committerTom Clegg <tom@curii.com>
Tue, 31 Oct 2023 19:11:04 +0000 (15:11 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

services/api/test/functional/arvados/v1/users_controller_test.rb
services/api/test/integration/api_client_authorizations_scopes_test.rb
services/api/test/integration/cross_origin_test.rb

index 6a9cb74195e025301f2af475787be63a39e32445..16271c9e8f2db71758137850b479633e54136808 100644 (file)
@@ -68,7 +68,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
 
   test "respond 401 if given token exists but user record is missing" do
     authorize_with :valid_token_deleted_user
-    get :current, {format: :json}
+    get :current, format: :json
     assert_response 401
   end
 
index d015e450a610df0cbcddefe138393a598eca4296..3b28a3163feef85b026345a39b061db3e9c8372c 100644 (file)
@@ -16,40 +16,43 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
   end
 
   test "user list token can only list users" do
-    get_args = [params: {}, headers: auth(:active_userlist)]
-    get(v1_url('users'), *get_args)
+    get_args = {params: {}, headers: auth(:active_userlist)}
+    get(v1_url('users'), **get_args)
     assert_response :success
-    get(v1_url('users', ''), *get_args)  # Add trailing slash.
+    get(v1_url('users', ''), **get_args)  # Add trailing slash.
     assert_response :success
-    get(v1_url('users', 'current'), *get_args)
+    get(v1_url('users', 'current'), **get_args)
     assert_response 403
-    get(v1_url('virtual_machines'), *get_args)
+    get(v1_url('virtual_machines'), **get_args)
     assert_response 403
   end
 
   test "narrow + wide scoped tokens for different users" do
-    get_args = [params: {
-                  reader_tokens: [api_client_authorizations(:anonymous).api_token]
-                }, headers: auth(:active_userlist)]
-    get(v1_url('users'), *get_args)
+    get_args = {
+      params: {
+        reader_tokens: [api_client_authorizations(:anonymous).api_token]
+      },
+      headers: auth(:active_userlist),
+    }
+    get(v1_url('users'), **get_args)
     assert_response :success
-    get(v1_url('users', ''), *get_args)  # Add trailing slash.
+    get(v1_url('users', ''), **get_args)  # Add trailing slash.
     assert_response :success
-    get(v1_url('users', 'current'), *get_args)
+    get(v1_url('users', 'current'), **get_args)
     assert_response 403
-    get(v1_url('virtual_machines'), *get_args)
+    get(v1_url('virtual_machines'), **get_args)
     assert_response 403
    end
 
   test "specimens token can see exactly owned specimens" do
-    get_args = [params: {}, headers: auth(:active_specimens)]
-    get(v1_url('specimens'), *get_args)
+    get_args = {params: {}, headers: auth(:active_specimens)}
+    get(v1_url('specimens'), **get_args)
     assert_response 403
-    get(v1_url('specimens', specimens(:owned_by_active_user).uuid), *get_args)
+    get(v1_url('specimens', specimens(:owned_by_active_user).uuid), **get_args)
     assert_response :success
-    head(v1_url('specimens', specimens(:owned_by_active_user).uuid), *get_args)
+    head(v1_url('specimens', specimens(:owned_by_active_user).uuid), **get_args)
     assert_response :success
-    get(v1_url('specimens', specimens(:owned_by_spectator).uuid), *get_args)
+    get(v1_url('specimens', specimens(:owned_by_spectator).uuid), **get_args)
     assert_includes(403..404, @response.status)
   end
 
@@ -82,12 +85,12 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
   test "token without scope has no access" do
     # Logs are good for this test, because logs have relatively
     # few access controls enforced at the model level.
-    req_args = [params: {}, headers: auth(:admin_noscope)]
-    get(v1_url('logs'), *req_args)
+    req_args = {params: {}, headers: auth(:admin_noscope)}
+    get(v1_url('logs'), **req_args)
     assert_response 403
-    get(v1_url('logs', logs(:noop).uuid), *req_args)
+    get(v1_url('logs', logs(:noop).uuid), **req_args)
     assert_response 403
-    post(v1_url('logs'), *req_args)
+    post(v1_url('logs'), **req_args)
     assert_response 403
   end
 
@@ -97,10 +100,10 @@ class ApiTokensScopeTest < ActionDispatch::IntegrationTest
     def vm_logins_url(name)
       v1_url('virtual_machines', virtual_machines(name).uuid, 'logins')
     end
-    get_args = [params: {}, headers: auth(:admin_vm)]
-    get(vm_logins_url(:testvm), *get_args)
+    get_args = {params: {}, headers: auth(:admin_vm)}
+    get(vm_logins_url(:testvm), **get_args)
     assert_response :success
-    get(vm_logins_url(:testvm2), *get_args)
+    get(vm_logins_url(:testvm2), **get_args)
     assert_includes(400..419, @response.status,
                     "getting testvm2 logins should have failed")
   end
index e3099f15735dec3d9ebf688b251553aad3964463..6a3db89fc43a43ca1eaa49c5ae1164422ca33c48 100644 (file)
@@ -5,10 +5,10 @@
 require 'test_helper'
 
 class CrossOriginTest < ActionDispatch::IntegrationTest
-  def options *args
+  def options path, **kwargs
     # Rails doesn't support OPTIONS the same way as GET, POST, etc.
     reset! unless integration_session
-    integration_session.__send__(:process, :options, *args).tap do
+    integration_session.__send__(:process, :options, path, **kwargs).tap do
       copy_session_variables!
     end
   end