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
16 manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",
17 uuid: "d30fe8ae534397864cb96c544f4cf102"
20 assert_response :success
21 assert_nil assigns(:objects)
24 test "create with owner_uuid set to owned group" do
25 authorize_with :active
26 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
29 owner_uuid: 'zzzzz-j7d0g-rew6elm53kancon',
30 manifest_text: manifest_text,
31 uuid: "d30fe8ae534397864cb96c544f4cf102"
34 assert_response :success
35 resp = JSON.parse(@response.body)
36 assert_equal 'zzzzz-tpzed-000000000000000', resp['owner_uuid']
39 test "create with owner_uuid set to group i can_manage" do
40 authorize_with :active
41 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
44 owner_uuid: 'zzzzz-j7d0g-8ulrifv67tve5sx',
45 manifest_text: manifest_text,
46 uuid: "d30fe8ae534397864cb96c544f4cf102"
49 assert_response :success
50 resp = JSON.parse(@response.body)
51 assert_equal 'zzzzz-tpzed-000000000000000', resp['owner_uuid']
54 test "create with owner_uuid set to group with no can_manage permission" do
55 authorize_with :active
56 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
59 owner_uuid: 'zzzzz-j7d0g-it30l961gq3t0oi',
60 manifest_text: manifest_text,
61 uuid: "d30fe8ae534397864cb96c544f4cf102"
67 test "admin create with owner_uuid set to group with no permission" do
69 manifest_text = ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n"
72 owner_uuid: 'zzzzz-j7d0g-it30l961gq3t0oi',
73 manifest_text: manifest_text,
74 uuid: "d30fe8ae534397864cb96c544f4cf102"
77 assert_response :success
80 test "should create with collection passed as json" do
81 authorize_with :active
85 "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",\
86 "uuid":"d30fe8ae534397864cb96c544f4cf102"\
90 assert_response :success
93 test "should fail to create with checksum mismatch" do
94 authorize_with :active
98 "manifest_text":". d41d8cd98f00b204e9800998ecf8427e 0:0:bar.txt\n",\
99 "uuid":"d30fe8ae534397864cb96c544f4cf102"\
106 test "get full provenance for baz file" do
107 authorize_with :active
108 get :provenance, uuid: 'ea10d51bcf88862dbcc36eb292017dfd+45'
109 assert_response :success
110 resp = JSON.parse(@response.body)
111 assert_not_nil resp['ea10d51bcf88862dbcc36eb292017dfd+45'] # baz
112 assert_not_nil resp['fa7aeb5140e2848d39b416daeef4ffc5+45'] # bar
113 assert_not_nil resp['1f4b0bc7583c2a7f9102c395f4ffc5e3+45'] # foo
114 assert_not_nil resp['zzzzz-8i9sb-cjs4pklxxjykyuq'] # bar->baz
115 assert_not_nil resp['zzzzz-8i9sb-aceg2bnq7jt7kon'] # foo->bar
118 test "get no provenance for foo file" do
119 # spectator user cannot even see baz collection
120 authorize_with :spectator
121 get :provenance, uuid: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
125 test "get partial provenance for baz file" do
126 # spectator user can see bar->baz job, but not foo->bar job
127 authorize_with :spectator
128 get :provenance, uuid: 'ea10d51bcf88862dbcc36eb292017dfd+45'
129 assert_response :success
130 resp = JSON.parse(@response.body)
131 assert_not_nil resp['ea10d51bcf88862dbcc36eb292017dfd+45'] # baz
132 assert_not_nil resp['fa7aeb5140e2848d39b416daeef4ffc5+45'] # bar
133 assert_not_nil resp['zzzzz-8i9sb-cjs4pklxxjykyuq'] # bar->baz
134 assert_nil resp['zzzzz-8i9sb-aceg2bnq7jt7kon'] # foo->bar
135 assert_nil resp['1f4b0bc7583c2a7f9102c395f4ffc5e3+45'] # foo