Merge branch '14988-wb-rails5-upgrade'
[arvados.git] / services / api / test / functional / arvados / v1 / keep_disks_controller_test.rb
index ea7b5b765a9ba25a26e0ec5899b6f8d0640492dc..9da9d01631b820517caabf5bda2229b7666e3d6e 100644 (file)
@@ -1,13 +1,19 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'test_helper'
 
 class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
 
+  def default_ping_opts
+    {ping_secret: '', service_ssl_flag: false, service_port: 1234}
+  end
+
   test "add keep disk with admin token" do
     authorize_with :admin
-    post :ping, {
-      ping_secret: '',          # required by discovery doc, but ignored
-      filesystem_uuid: 'eb1e77a1-db84-4193-b6e6-ca2894f67d5f'
-    }
+    post :ping, params: default_ping_opts.
+      merge(filesystem_uuid: 'eb1e77a1-db84-4193-b6e6-ca2894f67d5f')
     assert_response :success
     assert_not_nil assigns(:object)
     new_keep_disk = JSON.parse(@response.body)
@@ -17,30 +23,27 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
   end
 
   [
-    {ping_secret: ''},
-    {ping_secret: '', filesystem_uuid: ''},
+    {},
+    {filesystem_uuid: ''},
   ].each do |opts|
-    test "add keep disk with no filesystem_uuid #{opts}" do
+    test "add keep disk with[out] filesystem_uuid #{opts}" do
       authorize_with :admin
-      post :ping, opts
+      post :ping, params: default_ping_opts.merge(opts)
       assert_response :success
       assert_not_nil JSON.parse(@response.body)['uuid']
     end
   end
 
   test "refuse to add keep disk without admin token" do
-    post :ping, {
-      ping_secret: '',
-    }
+    post :ping, params: default_ping_opts
     assert_response 404
   end
 
   test "ping keep disk" do
-    post :ping, {
-      id: keep_disks(:nonfull).uuid,
-      ping_secret: keep_disks(:nonfull).ping_secret,
-      filesystem_uuid: keep_disks(:nonfull).filesystem_uuid
-    }
+    post :ping, params: default_ping_opts.
+      merge(id: keep_disks(:nonfull).uuid,
+            ping_secret: keep_disks(:nonfull).ping_secret,
+            filesystem_uuid: keep_disks(:nonfull).filesystem_uuid)
     assert_response :success
     assert_not_nil assigns(:object)
     keep_disk = JSON.parse(@response.body)
@@ -89,13 +92,11 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
 
   test "search keep_services with 'any' operator" do
     authorize_with :active
-    get :index, {
+    get :index, params: {
       where: { any: ['contains', 'o2t1q5w'] }
     }
     assert_response :success
     found = assigns(:objects).collect(&:uuid)
     assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn')
   end
-
-
 end