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']}
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
34 container_request: minimal_cr.merge(
35 secret_mounts: {'/foo' => {'type' => '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)
53 secret_mounts: {'/foo' => {'type' => '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' => {'type' => 'json', 'content' => 'bar'}})
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']