assert_response 404
end
- test "RO group-admin finds user's specimens, RW group-admin can update" do
+ test "RO group-admin finds user's collections, RW group-admin can update" do
+ other_user_collection = act_as_user(users(:user_foo_in_sharing_group)) do
+ Collection.create()
+ end
[[:rominiadmin, false],
[:miniadmin, true]].each do |which_user, update_should_succeed|
- get "/arvados/v1/specimens",
+ get "/arvados/v1/collections",
params: {:format => :json},
headers: auth(which_user)
assert_response :success
resp_uuids = json_response['items'].collect { |i| i['uuid'] }
- [[true, specimens(:owned_by_active_user).uuid],
- [true, specimens(:owned_by_private_group).uuid],
- [false, specimens(:owned_by_spectator).uuid],
+ [[true, collections(:collection_owned_by_active).uuid],
+ [true, collections(:foo_collection_in_aproject).uuid],
+ [false, other_user_collection.uuid],
].each do |should_find, uuid|
assert_equal(should_find, !resp_uuids.index(uuid).nil?,
- "%s should%s see %s in specimen list" %
+ "%s should%s see %s in collection list" %
[which_user.to_s,
- should_find ? '' : 'not ',
+ should_find ? '' : ' not',
uuid])
- put "/arvados/v1/specimens/#{uuid}",
+ put "/arvados/v1/collections/#{uuid}",
params: {
- :specimen => {
+ :collection => {
properties: {
miniadmin_was_here: true
}
assert_response :success
assert_empty json_response['manifest_text'], "empty collection manifest_text is not empty"
end
+
+ [['can_write', 'can_read', 'can_write'],
+ ['can_manage', 'can_write', 'can_manage'],
+ ['can_manage', 'can_read', 'can_manage'],
+ ['can_read', 'can_write', 'can_write'],
+ ['can_read', 'can_manage', 'can_manage'],
+ ['can_write', 'can_manage', 'can_manage'],
+ ].each do |perm1, perm2, expect|
+ test "creating #{perm2} permission returns existing #{perm1} link as #{expect}" do
+ link1 = act_as_system_user do
+ Link.create!({
+ link_class: "permission",
+ tail_uuid: users(:active).uuid,
+ head_uuid: collections(:baz_file).uuid,
+ name: perm1,
+ })
+ end
+ post "/arvados/v1/links",
+ params: {
+ link: {
+ link_class: "permission",
+ tail_uuid: users(:active).uuid,
+ head_uuid: collections(:baz_file).uuid,
+ name: perm2,
+ },
+ },
+ headers: auth(:admin)
+ assert_response :success
+ assert_equal link1.uuid, json_response["uuid"]
+ assert_equal expect, json_response["name"]
+ link1.reload
+ assert_equal expect, link1.name
+ end
+ end
+
+ test "creating duplicate login permission returns existing link" do
+ link1 = act_as_system_user do
+ Link.create!({
+ link_class: "permission",
+ tail_uuid: users(:active).uuid,
+ head_uuid: virtual_machines(:testvm2).uuid,
+ name: "can_login",
+ properties: {"username": "foo1"}
+ })
+ end
+ link2 = act_as_system_user do
+ Link.create!({
+ link_class: "permission",
+ tail_uuid: users(:active).uuid,
+ head_uuid: virtual_machines(:testvm2).uuid,
+ name: "can_login",
+ properties: {"username": "foo2"}
+ })
+ end
+ link3 = act_as_system_user do
+ Link.create!({
+ link_class: "permission",
+ tail_uuid: users(:active).uuid,
+ head_uuid: virtual_machines(:testvm2).uuid,
+ name: "can_read",
+ })
+ end
+ post "/arvados/v1/links",
+ params: {
+ link: {
+ link_class: "permission",
+ tail_uuid: users(:active).uuid,
+ head_uuid: virtual_machines(:testvm2).uuid,
+ name: "can_login",
+ properties: {"username": "foo2"},
+ },
+ },
+ headers: auth(:admin)
+ assert_response :success
+ assert_equal link2.uuid, json_response["uuid"]
+ assert_equal link2.created_at.to_date, json_response["created_at"].to_date
+ assert_equal "can_login", json_response["name"]
+ assert_equal "foo2", json_response["properties"]["username"]
+ link1.reload
+ assert_equal "foo1", link1.properties["username"]
+ link2.reload
+ assert_equal "foo2", link2.properties["username"]
+ end
end