3 class Arvados::V1::CollectionsControllerTest < ActionController::TestCase
5 test "should get index" do
8 assert_response :success
9 assert_not_nil assigns(:objects)
12 test "should create" do
13 authorize_with :active
15 manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",
16 uuid: "d30fe8ae534397864cb96c544f4cf102"
19 collection: test_collection
21 assert_response :success
22 assert_nil assigns(:objects)
25 id: "d30fe8ae534397864cb96c544f4cf102"
27 assert_response :success
28 assert_not_nil assigns(:object)
29 resp = JSON.parse(@response.body)
30 assert_equal 'd30fe8ae534397864cb96c544f4cf102+47', resp['uuid']
31 assert_equal test_collection[:manifest_text], resp['manifest_text']
34 test "create with owner_uuid set to owned group" do
35 authorize_with :active
36 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
39 owner_uuid: 'zzzzz-j7d0g-rew6elm53kancon',
40 manifest_text: manifest_text,
41 uuid: "d30fe8ae534397864cb96c544f4cf102"
44 assert_response :success
45 resp = JSON.parse(@response.body)
46 assert_equal 'zzzzz-tpzed-000000000000000', resp['owner_uuid']
49 test "create with owner_uuid set to group i can_manage" do
50 authorize_with :active
51 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
54 owner_uuid: 'zzzzz-j7d0g-8ulrifv67tve5sx',
55 manifest_text: manifest_text,
56 uuid: "d30fe8ae534397864cb96c544f4cf102"
59 assert_response :success
60 resp = JSON.parse(@response.body)
61 assert_equal 'zzzzz-tpzed-000000000000000', resp['owner_uuid']
64 test "create with owner_uuid set to group with no can_manage permission" do
65 authorize_with :active
66 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
69 owner_uuid: 'zzzzz-j7d0g-it30l961gq3t0oi',
70 manifest_text: manifest_text,
71 uuid: "d30fe8ae534397864cb96c544f4cf102"
77 test "admin create with owner_uuid set to group with no permission" do
79 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
82 owner_uuid: 'zzzzz-j7d0g-it30l961gq3t0oi',
83 manifest_text: manifest_text,
84 uuid: "d30fe8ae534397864cb96c544f4cf102"
87 assert_response :success
90 test "should create with collection passed as json" do
91 authorize_with :active
95 "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",\
96 "uuid":"d30fe8ae534397864cb96c544f4cf102"\
100 assert_response :success
103 test "should fail to create with checksum mismatch" do
104 authorize_with :active
108 "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:bar.txt\n",\
109 "uuid":"d30fe8ae534397864cb96c544f4cf102"\
116 test "get full provenance for baz file" do
117 authorize_with :active
118 get :provenance, uuid: 'ea10d51bcf88862dbcc36eb292017dfd+45'
119 assert_response :success
120 resp = JSON.parse(@response.body)
121 assert_not_nil resp['ea10d51bcf88862dbcc36eb292017dfd+45'] # baz
122 assert_not_nil resp['fa7aeb5140e2848d39b416daeef4ffc5+45'] # bar
123 assert_not_nil resp['1f4b0bc7583c2a7f9102c395f4ffc5e3+45'] # foo
124 assert_not_nil resp['zzzzz-8i9sb-cjs4pklxxjykyuq'] # bar->baz
125 assert_not_nil resp['zzzzz-8i9sb-aceg2bnq7jt7kon'] # foo->bar
128 test "get no provenance for foo file" do
129 # spectator user cannot even see baz collection
130 authorize_with :spectator
131 get :provenance, uuid: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
135 test "get partial provenance for baz file" do
136 # spectator user can see bar->baz job, but not foo->bar job
137 authorize_with :spectator
138 get :provenance, uuid: 'ea10d51bcf88862dbcc36eb292017dfd+45'
139 assert_response :success
140 resp = JSON.parse(@response.body)
141 assert_not_nil resp['ea10d51bcf88862dbcc36eb292017dfd+45'] # baz
142 assert_not_nil resp['fa7aeb5140e2848d39b416daeef4ffc5+45'] # bar
143 assert_not_nil resp['zzzzz-8i9sb-cjs4pklxxjykyuq'] # bar->baz
144 assert_nil resp['zzzzz-8i9sb-aceg2bnq7jt7kon'] # foo->bar
145 assert_nil resp['1f4b0bc7583c2a7f9102c395f4ffc5e3+45'] # foo