1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class ContainerAuthTest < ActionDispatch::IntegrationTest
10 test "container token validate, Running, regular auth" do
11 get "/arvados/v1/containers/current", {
13 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:running_container_auth).token}/#{containers(:running).uuid}"}
14 # Container is Running, token can be used
15 assert_response :success
16 assert_equal containers(:running).uuid, json_response['uuid']
19 test "container token validate, Locked, runtime_token" do
20 get "/arvados/v1/containers/current", {
22 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
23 # Container is Running, token can be used
24 assert_response :success
25 assert_equal containers(:runtime_token).uuid, json_response['uuid']
28 test "container token validate, Cancelled, runtime_token" do
29 put "/arvados/v1/containers/#{containers(:runtime_token).uuid}", {
31 :container => {:state => "Cancelled"}
32 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
33 assert_response :success
34 get "/arvados/v1/containers/current", {
36 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
37 # Container is Queued, token cannot be used
41 test "container token validate, Running, without optional portion" do
42 get "/arvados/v1/containers/current", {
44 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:running_container_auth).token}"}
45 # Container is Running, token can be used
46 assert_response :success
47 assert_equal containers(:running).uuid, json_response['uuid']
50 test "container token validate, Locked, runtime_token, without optional portion" do
51 get "/arvados/v1/containers/current", {
53 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}"}
54 # runtime_token without container uuid won't return 'current'
58 test "container token validate, wrong container uuid" do
59 get "/arvados/v1/containers/current", {
61 }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:running).uuid}"}
62 # Container uuid mismatch, token can't be used