next
end
- pdh = mount['portable_data_hash']
- uuid = mount['uuid']
+ uuid = mount.delete 'uuid'
- # Prioritize PDH over UUID for mount selection
- if not pdh.nil?
- c = Collection.
- readable_by(current_user).
- where(portable_data_hash: pdh)
- if c.count > 0
- if uuid && c.where(uuid: uuid).count == 0
- raise ArgumentError.new "cannot mount collection #{uuid.inspect}: current portable_data_hash #{pdh.inspect} does not match #{c.first.portable_data_hash.inspect} in request"
- end
- # mount.delete 'uuid'
- next
- end
- raise ArgumentError.new "cannot mount collection #{pdh.inspect}: not found"
- end
-
- # PDH not supplied, try by UUID
- if uuid
+ if mount['portable_data_hash'].nil?
+ # PDH not supplied, try by UUID
c = Collection.
readable_by(current_user).
where(uuid: uuid).
lambda do |resolved|
resolved["/out"] == {
"portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
- "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
"kind" => "collection",
"path" => "/foo",
}
lambda do |resolved|
resolved["/out"] == {
"portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
- "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
"kind" => "collection",
"path" => "/foo",
}
end],
- [{"/out" => {
+ [{"/out" => {
"kind" => "collection",
"portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
"path" => "/foo"}},
- lambda do |resolved|
- resolved["/out"] == {
- "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
- "kind" => "collection",
- "path" => "/foo",
- }
- end],
+ lambda do |resolved|
+ resolved["/out"] == {
+ "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
+ "kind" => "collection",
+ "path" => "/foo",
+ }
+ end],
].each do |mounts, okfunc|
test "resolve mounts #{mounts.inspect} to values" do
set_user_from_auth :active
"path" => "/foo",
},
}
- assert_raises(ArgumentError) do
- Container.resolve_mounts(m)
- end
+ resolved_mounts = Container.resolve_mounts(m)
+ assert_equal m['portable_data_hash'], resolved_mounts['portable_data_hash']
end
['arvados/apitestfixture:latest',