assert_equal(['foo'], hrefs.compact.sort,
"download page did provide strictly file links")
end
+
+ test "can view empty collection" do
+ uuid = 'd41d8cd98f00b204e9800998ecf8427e+0'
+ visit page_with_token('active', "/collections/#{uuid}")
+ assert page.has_text?('This collection is empty')
+ end
end
def can?(actions)
return true if is_admin
actions.each do |action, target|
- target_uuid = target
- if target.respond_to? :uuid
- target_uuid = target.uuid
+ unless target.nil?
+ if target.respond_to? :uuid
+ target_uuid = target.uuid
+ else
+ target_uuid = target
+ target = ArvadosModel.find_by_uuid(target_uuid)
+ end
end
next if target_uuid == self.uuid
next if (group_permissions[target_uuid] and
--- /dev/null
+class EmptyCollection < ActiveRecord::Migration
+ include CurrentApiClient
+
+ def up
+ empty_collection
+ end
+
+ def down
+ act_as_system_user do
+ empty_collection.destroy
+ end
+ end
+end
system_group
anonymous_group
anonymous_user
+empty_collection
INSERT INTO schema_migrations (version) VALUES ('20140627210837');
-INSERT INTO schema_migrations (version) VALUES ('20140709172343');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20140709172343');
+
+INSERT INTO schema_migrations (version) VALUES ('20140714184006');
\ No newline at end of file
$anonymous_user
end
+ def empty_collection_uuid
+ 'd41d8cd98f00b204e9800998ecf8427e+0'
+ end
+
+ def empty_collection
+ if not $empty_collection
+ act_as_system_user do
+ $empty_collection = Collection.
+ where(uuid: empty_collection_uuid).
+ first_or_create!(owner_uuid: anonymous_group_uuid,
+ manifest_text: '')
+ end
+ end
+ $empty_collection
+ end
end
modified_at: 2014-06-11T17:22:54Z
updated_at: 2014-06-11T17:22:54Z
manifest_text: ". d21353cfe035e3e384563ee55eadbb2f+67108864 5c77a43e329b9838cbec18ff42790e57+55605760 0:122714624:d8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678.tar\n"
+
+anonymous:
+ # Collection owned by the anonymous group
+ # (should be readable by all users)
+ uuid: 39e4ec5e67d7c6c8dcb549d7593180af+32
+ owner_uuid: zzzzz-j7d0g-anonymouspublic
+ created_at: 2014-06-11T17:22:54Z
+ modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+ modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+ modified_at: 2014-06-11T17:22:54Z
+ updated_at: 2014-06-11T17:22:54Z
+ manifest_text: ". anonymous-collection-file.txt\n"
+
+empty:
+ # Empty collection owned by anonymous_group is added with rake db:seed.
+ uuid: d41d8cd98f00b204e9800998ecf8427e+0
+ owner_uuid: zzzzz-j7d0g-anonymouspublic
+ created_at: 2014-06-11T17:22:54Z
+ modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+ modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+ modified_at: 2014-06-11T17:22:54Z
+ updated_at: 2014-06-11T17:22:54Z
+ manifest_text: ""
require 'test_helper'
class PermissionsTest < ActionDispatch::IntegrationTest
+ include CurrentApiClient # for empty_collection
fixtures :users, :groups, :api_client_authorizations, :collections
test "adding and removing direct can_read links" do
get "/arvados/v1/permissions/#{groups(:public).uuid}", nil, auth(:active)
assert_response 403
end
+
+ test "active user can read an object in the anonymous group" do
+ # make sure there is no link explicitly granting permission to
+ # the anonymous collection or its owner
+ get("/arvados/v1/permissions/#{collections(:anonymous).owner_uuid}",
+ { :format => :json },
+ auth(:admin))
+ assert_response :success
+ assert_empty json_response['items']
+
+ get("/arvados/v1/permissions/#{collections(:anonymous).uuid}",
+ { :format => :json },
+ auth(:admin))
+ assert_response :success
+ assert_empty json_response['items']
+
+ # the active user should still be able to read the anonymous collection.
+ get("/arvados/v1/collections/#{collections(:anonymous).uuid}",
+ { :format => :json },
+ auth(:active))
+ assert_response :success
+ assert_equal json_response['manifest_text'], collections(:anonymous).manifest_text
+
+ # the active user should be able to read the empty collection
+ get("/arvados/v1/collections/#{empty_collection_uuid}",
+ { :format => :json },
+ auth(:active))
+ assert_response :success
+ assert_empty json_response['manifest_text'], "empty collection manifest_text is not empty"
+ end
end