[ARVADOS] updated: a248323fdb1bfa315a3dc9af0a2362aa5b0a0f46
git at public.curoverse.com
git at public.curoverse.com
Mon Mar 24 18:05:28 EDT 2014
Summary of changes:
.../app/controllers/application_controller.rb | 3 +-
apps/workbench/app/controllers/users_controller.rb | 63 +++++++++-
apps/workbench/app/helpers/application_helper.rb | 14 ++-
apps/workbench/app/models/arvados_base.rb | 4 +
apps/workbench/app/models/arvados_resource_list.rb | 7 +
.../app/views/users/_show_activity.html.erb | 4 +
apps/workbench/app/views/users/activity.html.erb | 72 +++++++++++
apps/workbench/config/routes.rb | 1 +
.../arvados/v1/collections_controller_test.rb | 22 ++++
services/api/test/unit/user_test.rb | 131 +++++++++++++++++++-
10 files changed, 312 insertions(+), 9 deletions(-)
create mode 100644 apps/workbench/app/views/users/_show_activity.html.erb
create mode 100644 apps/workbench/app/views/users/activity.html.erb
via a248323fdb1bfa315a3dc9af0a2362aa5b0a0f46 (commit)
via 67a54670123669370bb4e664c7e40c71f7539b5f (commit)
via 8dd84d8f667aa40b9c8ce91d1a9248e1a7218039 (commit)
via 4baccff09d5f8c48cc3c431365f1e029a8c40bb1 (commit)
via 3dc88c9d537e6056e544746753f7e7befe55cbff (commit)
via ea812dad57e1e31cfce0167a8b8431aad15bf01a (commit)
via af19eb3a35900457a1dcfadee789a9052fb50335 (commit)
via 7db862a48062c6086ea8a6787149afa7d66b1919 (commit)
via cf7e30873ef4b92cc8ec099b2bb344391a070e93 (commit)
via 4127b85f2c1af611bb70d5ab469adac126d0a7a4 (commit)
via 2d9d106c40b83e9a72d431bdb198ed5b8b13550a (commit)
via acf1ba5bb4d987012030de8978cc6930e1bee654 (commit)
via fca114122bb204b34414a17e278748ec8e87e136 (commit)
via b37cf5e27548d8af4ec355c9a102c9a5734b3306 (commit)
from 0e560c4a9b3f1d46edcbd3fbc595beffc6efca47 (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 a248323fdb1bfa315a3dc9af0a2362aa5b0a0f46
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Mar 24 18:05:08 2014 -0400
Add unit test for user model
diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb
index 4695c91..d42c3d1 100644
--- a/services/api/test/unit/user_test.rb
+++ b/services/api/test/unit/user_test.rb
@@ -143,8 +143,10 @@ class UserTest < ActiveSupport::TestCase
begin
user = User.new
user.save
- rescue ArvadosModel::PermissionDeniedError
+ rescue ArvadosModel::PermissionDeniedError => e
end
+ assert (e.message.include? 'PermissionDeniedError'),
+ 'Expected PermissionDeniedError'
end
test "setup new user as non-admin user" do
@@ -155,7 +157,132 @@ class UserTest < ActiveSupport::TestCase
user.email = 'abc at xyz.com'
User.setup user, 'http://openid/prefix'
- rescue ArvadosModel::PermissionDeniedError
+ rescue ArvadosModel::PermissionDeniedError => e
+ end
+
+ assert (e.message.include? 'PermissionDeniedError'),
+ 'Expected PermissionDeniedError'
+ end
+
+ test "setup new user with no email" do
+ Thread.current[:user] = @admin_user
+
+ begin
+ user = User.new
+
+ User.setup user, 'http://openid/prefix'
+ rescue ArvadosModel::RuntimeError => e
+ end
+
+ assert (e.message.include? 'No email found'),
+ 'Expected RuntimeError'
+ end
+
+ test "setup new user with email but no openid_prefix" do
+ Thread.current[:user] = @admin_user
+
+ begin
+ user = User.new
+ user.email = 'abc at xyz.com'
+
+ User.setup user
+
+ rescue ArvadosModel::ArgumentError => e
+ end
+ assert (e.message.include? 'wrong number of arguments'),
+ 'Expected ArgumentError'
+ end
+
+ test "setup new user with email and openid_prefix" do
+ Thread.current[:user] = @admin_user
+
+ email = 'abc at xyz.com'
+ openid_prefix = 'http://openid/prefix'
+
+ user = User.new
+ user.email = email
+
+ response = User.setup user, openid_prefix
+
+ resp_user = response[:user]
+ verify_user resp_user, email
+
+ oid_login_perm = response[:oid_login_perm]
+ verify_link oid_login_perm, 'permission', 'can_login', resp_user[:email],
+ resp_user[:uuid]
+ assert_equal openid_prefix, oid_login_perm[:properties][:identity_url_prefix],
+ 'expected identity_url_prefix not found for oid_login_perm'
+
+ verify_link response[:group_perm], 'permission', 'can_read',
+ resp_user[:uuid], nil
+
+ # invoke setup again with repo_name
+ user = User.new
+ user.uuid = resp_user[:uuid]
+
+ response = User.setup user, openid_prefix, 'test_repo'
+
+ resp_user = response[:user]
+ verify_user resp_user, email
+ assert_equal user.uuid, resp_user[:uuid], 'expected uuid not found'
+
+ oid_login_perm = response[:oid_login_perm]
+ verify_link oid_login_perm, 'permission', 'can_login', resp_user[:email],
+ resp_user[:uuid]
+ assert_equal openid_prefix, oid_login_perm[:properties][:identity_url_prefix],
+ 'expected identity_url_prefix not found for oid_login_perm'
+
+ verify_link response[:group_perm], 'permission', 'can_read',
+ resp_user[:uuid], nil
+
+ verify_link response[:repo_perm], 'permission', 'can_write',
+ resp_user[:uuid], nil
+
+ # invoke setup again with a vm_uuid
+ vm = VirtualMachine.create
+
+ response = User.setup user, openid_prefix, 'test_repo', vm.uuid
+
+ resp_user = response[:user]
+ verify_user resp_user, email
+ assert_equal user.uuid, resp_user[:uuid], 'expected uuid not found'
+
+ oid_login_perm = response[:oid_login_perm]
+ verify_link oid_login_perm, 'permission', 'can_login', resp_user[:email],
+ resp_user[:uuid]
+ assert_equal openid_prefix, oid_login_perm[:properties][:identity_url_prefix],
+ 'expected identity_url_prefix not found for oid_login_perm'
+
+ verify_link response[:group_perm], 'permission', 'can_read',
+ resp_user[:uuid], nil
+
+ verify_link response[:repo_perm], 'permission', 'can_write',
+ resp_user[:uuid], nil
+
+ verify_link response[:vm_login_perm], 'permission', 'can_login',
+ resp_user[:uuid], vm.uuid
+ end
+
+ def verify_user resp_user, email
+ assert_not_nil resp_user, 'expected user object'
+ assert_not_nil resp_user[:uuid], 'expected user object'
+ assert_equal email, resp_user[:email], 'expected email not found'
+
+ end
+
+ def verify_link (link_object, link_class, link_name, tail_uuid, head_uuid)
+ assert_not_nil link_object, 'expected link for #{link_class} #{link_name}'
+ assert_not_nil link_object[:uuid],
+ 'expected non-nil uuid for link for #{link_class} #{link_name}'
+ assert_equal link_class, link_object[:link_class],
+ 'expected link_class not found for #{link_class} #{link_name}'
+ assert_equal link_name, link_object[:name],
+ 'expected link_name not found for #{link_class} #{link_name}'
+ assert_equal tail_uuid, link_object[:tail_uuid],
+ 'expected tail_uuid not found for group_perm'
+ if head_uuid
+ assert_equal tail_uuid, link_object[:tail_uuid],
+ 'expected tail_uuid not found for group_perm'
end
end
commit 67a54670123669370bb4e664c7e40c71f7539b5f
Merge: 0e560c4 8dd84d8
Author: radhika chippada <radhika at radhika.curoverse>
Date: Mon Mar 24 14:19:48 2014 -0400
Merge branch 'master' into 2187-enhance-user-setup
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list