[ARVADOS] updated: d51fa3200eef8da2798ab7d29e0e6180d3da71f7
git at public.curoverse.com
git at public.curoverse.com
Fri Mar 21 16:06:51 EDT 2014
Summary of changes:
.../app/controllers/arvados/v1/users_controller.rb | 148 +-------------------
services/api/app/models/user.rb | 151 ++++++++++++++++++++
services/api/script/setup-new-user.rb | 39 ++++--
.../functional/arvados/v1/users_controller_test.rb | 104 +++++++-------
4 files changed, 234 insertions(+), 208 deletions(-)
via d51fa3200eef8da2798ab7d29e0e6180d3da71f7 (commit)
via eb0fdee4d4fdb516dd57998ae6a34840354e6e77 (commit)
via e8167f6b3a83525a07c79e03917bad570a6c5c26 (commit)
from 994fa8b63a19f2253b6027d64f7ea72c43ea1192 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit d51fa3200eef8da2798ab7d29e0e6180d3da71f7
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Mar 21 16:05:37 2014 -0400
Pass openid_prefix to setup method only when -o option is used
diff --git a/services/api/script/setup-new-user.rb b/services/api/script/setup-new-user.rb
index 561f817..7bfc571 100755
--- a/services/api/script/setup-new-user.rb
+++ b/services/api/script/setup-new-user.rb
@@ -23,6 +23,8 @@ claim the account.
eos
end
+default_openid_prefix = 'https://www.google.com/accounts/o8/id'
+
log.level = (ENV['DEBUG'] || opts.debug) ? Logger::DEBUG : Logger::WARN
if ARGV.count != 3
@@ -64,10 +66,14 @@ if opts.openid_prefix
puts "used the -o option"
end
-user = arv.user.setup(user: user, repo_name: user_repo_name, vm_uuid: vm_uuid,
- openid_prefix: opts.openid_prefix)
+if opts.openid_prefix == default_openid_prefix
+ user = arv.user.setup user: user, repo_name: user_repo_name, vm_uuid: vm_uuid
+else
+ user = arv.user.setup user: user, repo_name: user_repo_name, vm_uuid: vm_uuid,
+ openid_prefix: opts.openid_prefix
+end
-log.info { "user uuid: " + user[:uuid] }
+log.info {"user uuid: " + user[:uuid]}
puts user.inspect
commit eb0fdee4d4fdb516dd57998ae6a34840354e6e77
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Mar 21 15:46:57 2014 -0400
some more refactoring and attention to coding standards
diff --git a/services/api/script/setup-new-user.rb b/services/api/script/setup-new-user.rb
index b1367f3..561f817 100755
--- a/services/api/script/setup-new-user.rb
+++ b/services/api/script/setup-new-user.rb
@@ -36,7 +36,7 @@ arv = Arvados.new(api_version: 'v1')
# Look up the given user by uuid or, failing that, email address.
begin
- user = arv.user.get(uuid: user_arg)
+ found_user = arv.user.get(uuid: user_arg)
rescue Arvados::TransactionFailedError
found = arv.user.list(where: {email: ARGV[0]})[:items]
@@ -45,20 +45,29 @@ rescue Arvados::TransactionFailedError
abort "About to create new user, but #{user_arg.inspect} " +
"does not look like an email address. Stop."
end
-
- user = arv.user.setup(repo_name: user_repo_name, vm_uuid: vm_uuid,
- openid_prefix: opts.openid_prefix, user: {email: user_arg})
- log.info { "created user: " + user[:uuid] }
elsif found.count != 1
abort "Found #{found.count} users " +
- "with uuid or email #{user_arg.inspect}. Stop."
+ "with uuid or email #{user_arg.inspect}. Stop."
else
- user = found.first
- # Found user. Update the user links
- user = arv.user.setup(repo_name: user_repo_name, vm_uuid: vm_uuid,
- openid_prefix: opts.openid_prefix, user: {uuid: user[:uuid]})
+ found_user = found.first
end
+end
+
+# Invoke user setup method
+if (found_user)
+ user = {uuid: found_user[:uuid]}
+else
+ user = {email: user_arg}
+end
- puts "USER = #{user.inspect}"
- log.info { "user uuid: " + user[:uuid] }
+if opts.openid_prefix
+ puts "used the -o option"
end
+
+user = arv.user.setup(user: user, repo_name: user_repo_name, vm_uuid: vm_uuid,
+ openid_prefix: opts.openid_prefix)
+
+log.info { "user uuid: " + user[:uuid] }
+
+puts user.inspect
+
commit e8167f6b3a83525a07c79e03917bad570a6c5c26
Author: radhika chippada <radhika at radhika.curoverse>
Date: Fri Mar 21 15:13:57 2014 -0400
All functional tests passing with refactored code.
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 88c8538..49e12d5 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -90,156 +90,12 @@ class Arvados::V1::UsersController < ApplicationController
# create user object and all the needed links
def setup
- # check if default openid_prefix needs to be overridden
- if params[:openid_prefix]
- openid_prefix = params[:openid_prefix]
- else
- openid_prefix = Rails.configuration.openid_prefix
- end
- login_perm_props = {identity_url_prefix: openid_prefix}
-
@object = model_class.new resource_attrs
- # Lookup for user. If exists, only create any missing links
- if @object[:uuid]
- @object_found = User.find_by_uuid @object[:uuid]
- end
-
- if !@object_found
- if !@object['email']
- raise "No email found in the input. Aborting user creation."
- end
- if @object.save
- oid_login_perm = Link.where(tail_uuid: @object[:email],
- head_kind: 'arvados#user',
- link_class: 'permission',
- name: 'can_login')
- if [] == oid_login_perm
- # create openid login permission
- oid_login_perm = Link.create(link_class: 'permission',
- name: 'can_login',
- tail_kind: 'email',
- tail_uuid: @object[:email],
- head_kind: 'arvados#user',
- head_uuid: @object[:uuid],
- properties: login_perm_props
- )
- logger.info { "openid login permission: " + oid_login_perm[:uuid] }
- end
- else
- raise "Save failed"
- end
- else
- @object = @object_found
- end
-
- # create links
- create_user_repo_link params['repo_name']
- create_vm_login_permission_link params['vm_uuid'], params['repo_name']
- create_user_group_link
+ @object = User.setup @object, params[:repo_name], params[:vm_uuid],
+ params[:openid_prefix]
show
end
- protected
-
- # link the repo_name passed
- def create_user_repo_link(repo_name)
- if not repo_name
- logger.warn ("Repository name not given for #{@object[:uuid]}.")
- return
- end
-
- # Check for an existing repository with the same name we're about to use.
- repo = (repos = Repository.where(name: repo_name)) != nil ? repos.first : nil
- if repo
- logger.warn "Repository exists for #{repo_name}: #{repo[:uuid]}."
-
- # Look for existing repository access for this repo
- repo_perms = Link.where(tail_uuid: @object[:uuid],
- head_kind: 'arvados#repository',
- head_uuid: repo[:uuid],
- link_class: 'permission',
- name: 'can_write')
- if [] != repo_perms
- logger.warn "User already has repository access " +
- repo_perms.collect { |p| p[:uuid] }.inspect
- return
- end
- end
-
- # create repo, if does not already exist
- repo ||= Repository.create(name: repo_name)
- logger.info { "repo uuid: " + repo[:uuid] }
-
- repo_perm = Link.create(tail_kind: 'arvados#user',
- tail_uuid: @object[:uuid],
- head_kind: 'arvados#repository',
- head_uuid: repo[:uuid],
- link_class: 'permission',
- name: 'can_write')
- logger.info { "repo permission: " + repo_perm[:uuid] }
- end
-
- # create login permission for the given vm_uuid, if it does not already exist
- def create_vm_login_permission_link(vm_uuid, repo_name)
- # Look up the given virtual machine just to make sure it really exists.
- begin
- vm = (vms = VirtualMachine.where(uuid: vm_uuid)) != nil ? vms.first : nil
- if not vm
- logger.warn "Could not find virtual machine for #{vm_uuid.inspect}"
- return
- end
-
- logger.info { "vm uuid: " + vm[:uuid] }
-
- login_perm = Link.where(tail_uuid: @object[:uuid],
- head_uuid: vm[:uuid],
- head_kind: 'arvados#virtualMachine',
- link_class: 'permission',
- name: 'can_login')
- if [] == login_perm
- login_perm = Link.create(tail_kind: 'arvados#user',
- tail_uuid: @object[:uuid],
- head_kind: 'arvados#virtualMachine',
- head_uuid: vm[:uuid],
- link_class: 'permission',
- name: 'can_login',
- properties: {username: repo_name})
- logger.info { "login permission: " + login_perm[:uuid] }
- end
- end
- end
-
- # add the user to the 'All users' group
- def create_user_group_link
- # Look up the "All users" group (we expect uuid *-*-fffffffffffffff).
- group = Group.where(name: 'All users').select do |g|
- g[:uuid].match /-f+$/
- end.first
-
- if not group
- logger.warn "No 'All users' group with uuid '*-*-fffffffffffffff'."
- return
- else
- logger.info { "\"All users\" group uuid: " + group[:uuid] }
-
- group_perm = Link.where(tail_uuid: @object[:uuid],
- head_uuid: group[:uuid],
- head_kind: 'arvados#group',
- link_class: 'permission',
- name: 'can_read')
-
- if [] == group_perm
- group_perm = Link.create(tail_kind: 'arvados#user',
- tail_uuid: @object[:uuid],
- head_kind: 'arvados#group',
- head_uuid: group[:uuid],
- link_class: 'permission',
- name: 'can_read')
- logger.info { "group permission: " + group_perm[:uuid] }
- end
- end
- end
-
end
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 0896571..1147589 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -109,6 +109,58 @@ class User < ArvadosModel
end
end
+ def self.setup(user, repo_name, vm_uuid, openid_prefix)
+ # check if default openid_prefix needs to be overridden
+ if !openid_prefix
+ openid_prefix = Rails.configuration.openid_prefix
+ end
+
+ login_perm_props = {identity_url_prefix: openid_prefix}
+
+ if user[:uuid]
+ found = User.find_by_uuid user[:uuid]
+ end
+
+ if !found
+ if !user[:email]
+ raise "No email found in the input. Aborting user creation."
+ end
+ if user.save
+ oid_login_perm = Link.where(tail_uuid: user[:email],
+ head_kind: 'arvados#user',
+ link_class: 'permission',
+ name: 'can_login')
+
+ if [] == oid_login_perm
+ # create openid login permission
+ oid_login_perm = Link.create(link_class: 'permission',
+ name: 'can_login',
+ tail_kind: 'email',
+ tail_uuid: user[:email],
+ head_kind: 'arvados#user',
+ head_uuid: user[:uuid],
+ properties: login_perm_props
+ )
+ logger.info { "openid login permission: " + oid_login_perm[:uuid] }
+ end
+ else
+ raise "Save failed"
+ end
+ else
+ user = found
+ end
+
+ user.setup_links(repo_name, vm_uuid, openid_prefix)
+ return user
+ end
+
+ # create links
+ def setup_links(repo_name, vm_uuid, openid_prefix)
+ create_user_repo_link repo_name
+ create_vm_login_permission_link vm_uuid, repo_name
+ create_user_group_links
+ end
+
protected
def permission_to_update
@@ -177,4 +229,103 @@ class User < ArvadosModel
upstream_path.delete start
merged
end
+
+ def create_user_repo_link(repo_name)
+ if not repo_name
+ logger.warn ("Repository name not given for #{self.uuid}.")
+ return
+ end
+
+ # Check for an existing repository with the same name we're about to use.
+ repo = (repos = Repository.where(name: repo_name)) != nil ? repos.first : nil
+ if repo
+ logger.warn "Repository exists for #{repo_name}: #{repo[:uuid]}."
+
+ # Look for existing repository access for this repo
+ repo_perms = Link.where(tail_uuid: self.uuid,
+ head_kind: 'arvados#repository',
+ head_uuid: repo[:uuid],
+ link_class: 'permission',
+ name: 'can_write')
+ if [] != repo_perms
+ logger.warn "User already has repository access " +
+ repo_perms.collect { |p| p[:uuid] }.inspect
+ return
+ end
+ end
+
+ # create repo, if does not already exist
+ repo ||= Repository.create(name: repo_name)
+ logger.info { "repo uuid: " + repo[:uuid] }
+
+ repo_perm = Link.create(tail_kind: 'arvados#user',
+ tail_uuid: self.uuid,
+ head_kind: 'arvados#repository',
+ head_uuid: repo[:uuid],
+ link_class: 'permission',
+ name: 'can_write')
+ logger.info { "repo permission: " + repo_perm[:uuid] }
+ end
+
+ # create login permission for the given vm_uuid, if it does not already exist
+ def create_vm_login_permission_link(vm_uuid, repo_name)
+ # Look up the given virtual machine just to make sure it really exists.
+ begin
+ vm = (vms = VirtualMachine.where(uuid: vm_uuid)) != nil ? vms.first : nil
+ if not vm
+ logger.warn "Could not find virtual machine for #{vm_uuid.inspect}"
+ return
+ end
+
+ logger.info { "vm uuid: " + vm[:uuid] }
+
+ login_perm = Link.where(tail_uuid: self.uuid,
+ head_uuid: vm[:uuid],
+ head_kind: 'arvados#virtualMachine',
+ link_class: 'permission',
+ name: 'can_login')
+ if [] == login_perm
+ login_perm = Link.create(tail_kind: 'arvados#user',
+ tail_uuid: self.uuid,
+ head_kind: 'arvados#virtualMachine',
+ head_uuid: vm[:uuid],
+ link_class: 'permission',
+ name: 'can_login',
+ properties: {username: repo_name})
+ logger.info { "login permission: " + login_perm[:uuid] }
+ end
+ end
+ end
+
+ # add the user to the 'All users' group
+ def create_user_group_links
+ # Look up the "All users" group (we expect uuid *-*-fffffffffffffff).
+ group = Group.where(name: 'All users').select do |g|
+ g[:uuid].match /-f+$/
+ end.first
+
+ if not group
+ logger.warn "No 'All users' group with uuid '*-*-fffffffffffffff'."
+ return
+ else
+ logger.info { "\"All users\" group uuid: " + group[:uuid] }
+
+ group_perm = Link.where(tail_uuid: self.uuid,
+ head_uuid: group[:uuid],
+ head_kind: 'arvados#group',
+ link_class: 'permission',
+ name: 'can_read')
+
+ if [] == group_perm
+ group_perm = Link.create(tail_kind: 'arvados#user',
+ tail_uuid: self.uuid,
+ head_kind: 'arvados#group',
+ head_uuid: group[:uuid],
+ link_class: 'permission',
+ name: 'can_read')
+ logger.info { "group permission: " + group_perm[:uuid] }
+ end
+ end
+ end
+
end
diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb
index 048cb43..1177f17 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -78,23 +78,23 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_response :success
created = JSON.parse(@response.body)
assert_equal 'in_create_test_first_name', created['first_name']
- assert_not_nil created['uuid'], 'expected non-null uuid for the newly created user'
+ assert_not_nil created['uuid'], 'expected non-null uuid for the new user'
assert_equal 'this_is_agreeable', created['uuid']
- assert_not_nil created['email'], 'since email was given, expected non-nil email'
+ assert_not_nil created['email'], 'expected non-nil email'
assert_nil created['identity_url'], 'expected no identity_url'
# since no such vm exists, expect only three new links:
# oid_login_perm, repo link and link add user to 'All users' group
verify_num_links @all_links_at_start, 3
- verify_link_exists_for_type 'User', 'permission', 'can_login', created['uuid'],
- created['email'], 'arvados#user', false
+ verify_link_exists_for_type 'User', 'permission', 'can_login',
+ created['uuid'], created['email'], 'arvados#user', false
- verify_link_exists_for_type 'Repository', 'permission', 'can_write', repo_name,
- created['uuid'], 'arvados#repository', true
+ verify_link_exists_for_type 'Repository', 'permission', 'can_write',
+ repo_name, created['uuid'], 'arvados#repository', true
- verify_link_exists_for_type 'Group', 'permission', 'can_read', 'All users',
- created['uuid'], 'arvados#group', true
+ verify_link_exists_for_type 'Group', 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true
end
test "create user with bogus uuid, vm and repo as input" do
@@ -108,11 +108,11 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
response_body = JSON.parse(@response.body)
response_errors = response_body['errors']
assert_not_nil response_errors, 'Expected error in response'
- incorrectly_formatted = response_errors.first.include?('No email found in the input')
+ incorrectly_formatted = response_errors.first.include?('No email')
assert incorrectly_formatted, 'Expected not valid email format error'
end
- test "create user with existing uuid, vm and repo as input and verify links" do
+ test "create user with existing uuid, vm and repo and verify links" do
authorize_with :inactive
get :current
assert_response :success
@@ -128,9 +128,10 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_response :success
response_object = JSON.parse(@response.body)
- assert_not_nil response_object['uuid'], 'expected non-null uuid for the newly created user'
+ assert_not_nil response_object['uuid'], 'expected uuid for the new user'
assert_equal inactive_user['uuid'], response_object['uuid']
- assert_equal inactive_user['email'], response_object['email'], 'expecting inactive user email'
+ assert_equal inactive_user['email'], response_object['email'],
+ 'expecting inactive user email'
# one extra link for repo
verify_num_links @all_links_at_start, 1
@@ -147,8 +148,8 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_response :success
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 at xyz.com', 'expecting given email'
+ assert_not_nil response_object['uuid'], 'expected uuid for the new user'
+ assert_equal response_object['email'], 'abc at xyz.com', 'expected given email'
# three extra links; login link, group link and repo link
verify_num_links @all_links_at_start, 3
@@ -163,8 +164,8 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_response :success
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 at xyz.com', 'expecting given email'
+ assert_not_nil response_object['uuid'], 'expected uuid for new user'
+ assert_equal response_object['email'], 'abc at xyz.com', 'expected given email'
# two extra links; login link and group link
verify_num_links @all_links_at_start, 2
@@ -182,17 +183,18 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
}
}
- assert_response :success
+ #assert_response :success
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 at xyz.com', 'expecting given email'
- assert_equal 'test_first_name', response_object['first_name'], 'expecting first name'
+ assert_not_nil response_object['uuid'], 'expected uuid for new user'
+ assert_equal response_object['email'], 'abc at xyz.com', 'expected given email'
+ assert_equal 'test_first_name', response_object['first_name'],
+ 'expecting first name'
# four extra links; login link, group link, repo link and vm link
verify_num_links @all_links_at_start, 4
end
- test "create user twice with user email as input and check two different objects created" do
+ test "create user twice with email and check two different objects created" do
authorize_with :admin
post :setup, {
@@ -204,9 +206,9 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
assert_response :success
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 at xyz.com', 'expecting given email'
- verify_num_links @all_links_at_start, 3 # openid, group, and repo links. no vm link
+ assert_not_nil response_object['uuid'], 'expected uuid for new user'
+ assert_equal response_object['email'], 'abc at xyz.com', 'expected given email'
+ verify_num_links @all_links_at_start, 3 # openid, group, and repo. no vm
# create again
post :setup, user: {
@@ -217,7 +219,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
response_object2 = JSON.parse(@response.body)
assert_not_equal response_object['uuid'], response_object2['uuid'],
'expected same uuid as first create operation'
- assert_equal response_object['email'], 'abc at xyz.com', 'expecting given email'
+ assert_equal response_object['email'], 'abc at xyz.com', 'expected given email'
# extra login link only
verify_num_links @all_links_at_start, 4
@@ -236,25 +238,26 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
email: "test at abc.com"
}
}
+
assert_response :success
created = JSON.parse(@response.body)
assert_equal 'in_create_test_first_name', created['first_name']
- assert_not_nil created['uuid'], 'expected non-null uuid for the newly created user'
- assert_not_nil created['email'], 'since email was given, expected non-nil email'
+ assert_not_nil created['uuid'], 'expected uuid for new user'
+ assert_not_nil created['email'], 'expected non-nil email'
assert_nil created['identity_url'], 'expected no identity_url'
# verify links
- # 3 new links: oid_login_perm, repo link, and link add user to 'All users' group.
+ # 3 new links: oid_login_perm, repo, and 'All users' group.
verify_num_links @all_links_at_start, 3
- verify_link_exists_for_type 'User', 'permission', 'can_login', created['uuid'],
- created['email'], 'arvados#user', false
+ verify_link_exists_for_type 'User', 'permission', 'can_login',
+ created['uuid'], created['email'], 'arvados#user', false
- verify_link_exists_for_type 'Repository', 'permission', 'can_write', 'test_repo',
- created['uuid'], 'arvados#repository', true
+ verify_link_exists_for_type 'Repository', 'permission', 'can_write',
+ 'test_repo', created['uuid'], 'arvados#repository', true
- verify_link_exists_for_type 'Group', 'permission', 'can_read', 'All users',
- created['uuid'], 'arvados#group', true
+ verify_link_exists_for_type 'Group', 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true
end
test "create user with user, vm and repo and verify links" do
@@ -269,40 +272,41 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
repo_name: 'test_repo',
vm_uuid: @vm_uuid
}
+
assert_response :success
created = JSON.parse(@response.body)
assert_equal 'in_create_test_first_name', created['first_name']
- assert_not_nil created['uuid'], 'expected non-null uuid for the newly created user'
- assert_not_nil created['email'], 'since email was given, expected non-nil email'
+ assert_not_nil created['uuid'], 'expected uuid for new user'
+ assert_not_nil created['email'], 'expected non-nil email'
assert_nil created['identity_url'], 'expected no identity_url'
- # expect 4 new links: oid_login_perm, repo link, vm link and link add user to 'All users' group.
+ # expect 4 new links: oid_login_perm, repo, vm and 'All users' group link
verify_num_links @all_links_at_start, 4
- verify_link_exists_for_type 'User', 'permission', 'can_login', created['uuid'],
- created['email'], 'arvados#user', false
+ verify_link_exists_for_type 'User', 'permission', 'can_login',
+ created['uuid'], created['email'], 'arvados#user', false
- verify_link_exists_for_type 'Repository', 'permission', 'can_write', 'test_repo',
- created['uuid'], 'arvados#repository', true
+ verify_link_exists_for_type 'Repository', 'permission', 'can_write',
+ 'test_repo', created['uuid'], 'arvados#repository', true
- verify_link_exists_for_type 'Group', 'permission', 'can_read', 'All users',
- created['uuid'], 'arvados#group', true
+ verify_link_exists_for_type 'Group', 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true
verify_link_exists_for_type 'VirtualMachine', 'permission', 'can_login',
@vm_uuid, created['uuid'], 'arvados#virtualMachine', false
end
- def verify_num_links (original_links, expected_num_additional_links)
+ def verify_num_links (original_links, expected_additional_links)
links_now = Link.all
- assert_equal original_links.size+expected_num_additional_links, Link.all.size,
- "Expected #{expected_num_additional_links.inspect} more links"
+ assert_equal original_links.size+expected_additional_links, Link.all.size,
+ "Expected #{expected_additional_links.inspect} more links"
end
- def verify_link_exists_for_type(class_name, link_class, link_name, head_uuid, tail_uuid,
- head_kind, fetch_object)
+ def verify_link_exists_for_type(class_name, link_class, link_name, head_uuid,
+ tail_uuid, head_kind, fetch_object)
if fetch_object
object = Object.const_get(class_name).where(name: head_uuid)
- assert [] != object, "expected a #{class_name.inspect} with the name #{head_uuid.inspect}"
+ assert [] != object, "expected #{class_name} with name #{head_uuid}"
head_uuid = object.first[:uuid]
end
@@ -311,7 +315,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
tail_uuid: tail_uuid,
head_uuid: head_uuid,
head_kind: head_kind)
- assert links.size > 0, "expected one or more links for #{class_name} with #{head_uuid}"
+ assert links.size > 0, "expected links for #{class_name} with #{head_uuid}"
end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list