Merge branch '21639-keep-cache-dict' refs #21639
[arvados.git] / services / api / test / integration / container_dispatch_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 ContainerDispatchTest < ActionDispatch::IntegrationTest
8   test "lock container with SystemRootToken" do
9     Rails.configuration.SystemRootToken = "xyzzy-SystemRootToken"
10     authheaders = {'HTTP_AUTHORIZATION' => "Bearer "+Rails.configuration.SystemRootToken}
11     get("/arvados/v1/api_client_authorizations/current",
12         headers: authheaders)
13     assert_response 200
14
15     system_auth_uuid = json_response['uuid']
16     post("/arvados/v1/containers/#{containers(:queued).uuid}/lock",
17          headers: authheaders)
18     assert_response 200
19     assert_equal system_auth_uuid, Container.find_by_uuid(containers(:queued).uuid).locked_by_uuid
20
21     get("/arvados/v1/containers",
22         params: {filters: SafeJSON.dump([['locked_by_uuid', '=', system_auth_uuid]])},
23         headers: authheaders)
24     assert_response 200
25     assert_equal containers(:queued).uuid, json_response['items'][0]['uuid']
26     assert_equal system_auth_uuid, json_response['items'][0]['locked_by_uuid']
27
28     post("/arvados/v1/containers/#{containers(:queued).uuid}/unlock",
29          headers: authheaders)
30     assert_response 200
31   end
32 end