@object = model_class.new resource_attrs
- # If user_param is passed, lookup for user. If exists, skip create and create any missing links.
+ # If user_param is passed, lookup for user. If exists, skip create and only create any missing links.
if params[:user_param]
- begin
+ begin
@object_found = find_user_from_input params[:user_param], params[:user_param]
end
if !@object_found
else # need to create user for the given user data
@object_found = find_user_from_input @object[:uuid], @object[:email]
if !@object_found
- need_to_create = true
+ need_to_create = true # use the user object sent in to create with the user
else
@object = @object_found
end
# create if need be, and then create or update the links as needed
if need_to_create
- if @object.save # save succeeded
+ if @object.save
oid_login_perm = Link.where(tail_uuid: @object[:email],
head_kind: 'arvados#user',
link_class: 'permission',
protected
- # find the user from the given user parameter
+ # find the user from the given user parameters
def find_user_from_input(user_uuid, user_email)
if user_uuid
found_object = User.find_by_uuid user_uuid
end
end
end
-
+
end
assert_equal response_object['email'], 'abc@xyz.com', 'expecting given email'
end
- test "create user with user_param and user which will be ignored" do
+ test "create user with user_param and non-empty user which will be ignored" do
authorize_with :admin
post :create, {
repo_name: 'test_repo',
vm_uuid: 'no_such_vm',
user: {
- email: 'will_be_ignored@xyz.om'
+ first_name: 'test_first_name',
+ email: 'will_be_ignored@xyz.com'
}
}
response_object = JSON.parse(@response.body)
assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
assert_equal response_object['email'], 'abc@xyz.com', 'expecting user_param as email'
+ assert_nil response_object['first_name'], 'expecting no first name since it will be reset when user_param is used'
end
test "create user with valid email user_param, vm and repo as input with opt.n" do