1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
10 command: ['echo', 'hello'],
11 container_image: 'test',
16 test 'create with scheduling parameters' do
17 authorize_with :active
19 sp = {'partitions' => ['test1', 'test2']}
20 post :create, params: {
21 container_request: minimal_cr.merge(scheduling_parameters: sp.dup)
23 assert_response :success
25 cr = JSON.parse(@response.body)
26 assert_not_nil cr, 'Expected container request'
27 assert_equal sp, cr['scheduling_parameters']
30 test "secret_mounts not in #create responses" do
31 authorize_with :active
33 post :create, params: {
34 container_request: minimal_cr.merge(
35 secret_mounts: {'/foo' => {'kind' => 'json', 'content' => 'bar'}}),
37 assert_response :success
39 resp = JSON.parse(@response.body)
40 refute resp.has_key?('secret_mounts')
42 req = ContainerRequest.where(uuid: resp['uuid']).first
43 assert_equal 'bar', req.secret_mounts['/foo']['content']
46 test "update with secret_mounts" do
47 authorize_with :active
48 req = container_requests(:uncommitted)
50 patch :update, params: {
53 secret_mounts: {'/foo' => {'kind' => 'json', 'content' => 'bar'}},
56 assert_response :success
58 resp = JSON.parse(@response.body)
59 refute resp.has_key?('secret_mounts')
62 assert_equal 'bar', req.secret_mounts['/foo']['content']
65 test "update without deleting secret_mounts" do
66 authorize_with :active
67 req = container_requests(:uncommitted)
68 req.update_attributes!(secret_mounts: {'/foo' => {'kind' => 'json', 'content' => 'bar'}})
70 patch :update, params: {
73 command: ['echo', 'test'],
76 assert_response :success
78 resp = JSON.parse(@response.body)
79 refute resp.has_key?('secret_mounts')
82 assert_equal 'bar', req.secret_mounts['/foo']['content']
85 test "runtime_token not in #create responses" do
86 authorize_with :active
88 post :create, params: {
89 container_request: minimal_cr.merge(
90 runtime_token: api_client_authorizations(:spectator).token)
92 assert_response :success
94 resp = JSON.parse(@response.body)
95 refute resp.has_key?('runtime_token')
97 req = ContainerRequest.where(uuid: resp['uuid']).first
98 assert_equal api_client_authorizations(:spectator).token, req.runtime_token