16314: Search both user and tmp paths for gems.
[arvados.git] / services / api / test / unit / api_client_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class ApiClientTest < ActiveSupport::TestCase
8   include CurrentApiClient
9
10   test "configured workbench is trusted" do
11     Rails.configuration.Services.Workbench1.ExternalURL = URI("http://wb1.example.com")
12     Rails.configuration.Services.Workbench2.ExternalURL = URI("https://wb2.example.com:443")
13
14     act_as_system_user do
15       [["http://wb0.example.com", false],
16        ["http://wb1.example.com", true],
17        ["http://wb2.example.com", false],
18        ["https://wb2.example.com", true],
19        ["https://wb2.example.com/", true],
20       ].each do |pfx, result|
21         a = ApiClient.create(url_prefix: pfx, is_trusted: false)
22         assert_equal result, a.is_trusted
23       end
24
25       a = ApiClient.create(url_prefix: "http://example.com", is_trusted: true)
26       a.save!
27       a.reload
28       assert a.is_trusted
29     end
30   end
31 end