1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class Arvados::V1::KeepServicesControllerTest < ActionController::TestCase
9 test "search by service_port with < query" do
10 authorize_with :active
12 filters: [['service_port', '<', 25107]]
14 assert_response :success
15 assert_equal false, assigns(:objects).any?
18 test "search by service_port with >= query" do
19 authorize_with :active
21 filters: [['service_port', '>=', 25107]]
23 assert_response :success
24 assert_equal true, assigns(:objects).any?
27 [:admin, :active, :inactive, :anonymous, nil].each do |u|
28 test "accessible to #{u.inspect} user" do
29 authorize_with(u) if u
31 assert_response :success
32 assert_not_empty json_response['items']
33 json_response['items'].each do |ks|
34 assert_not_equal ks['service_type'], 'proxy'
39 test "report configured servers if db is empty" do
40 KeepService.unscoped.all.delete_all
43 Rails.configuration.Services.Keepstore.InternalURLs.each do |k,v|
46 expect_rvz[k.to_s] = rvz
47 Rails.configuration.Services.Keepstore.InternalURLs[k].Rendezvous = rvz
49 expect_rvz[Rails.configuration.Services.Keepproxy.ExternalURL] = true
50 refute_empty expect_rvz
51 authorize_with :active
53 params: {:format => :json}
54 assert_response :success
55 json_response['items'].each do |svc|
56 url = "#{svc['service_ssl_flag'] ? 'https' : 'http'}://#{svc['service_host']}:#{svc['service_port']}/"
57 assert_equal true, expect_rvz.has_key?(url), "#{url} does not match any configured service: expecting #{expect_rvz}"
60 assert_equal "zzzzz-bi6l4-#{rvz}", svc['uuid'], "exported service UUID should match InternalURLs.*.Rendezvous value"
62 expect_rvz.delete(url)
64 assert_equal({}, expect_rvz, "all configured Keepstore and Keepproxy services should be returned")