[ARVADOS] updated: 4d2b509734d1ac5351ab6da16e08a092ba77f148
git at public.curoverse.com
git at public.curoverse.com
Fri Sep 26 21:50:30 EDT 2014
Summary of changes:
.../app/helpers/pipeline_components_helper.rb | 3 +-
.../app/helpers/pipeline_instances_helper.rb | 15 +-
.../pipeline_instances/_running_component.html.erb | 14 +-
.../_show_components_json.html.erb | 14 ++
.../pipeline_instances_controller_test.rb | 11 ++
services/api/test/fixtures/pipeline_instances.yml | 20 ++
.../arvados/v1/groups_controller_test.rb | 41 ----
.../functional/arvados/v1/users_controller_test.rb | 101 +---------
services/api/test/helpers/users_test_helper.rb | 100 ++++++++++
services/api/test/integration/users_test.rb | 216 +++++++++++++++++++++
services/fuse/arvados_fuse/__init__.py | 9 +-
services/fuse/bin/arv-mount | 3 +-
12 files changed, 392 insertions(+), 155 deletions(-)
create mode 100644 services/api/test/helpers/users_test_helper.rb
create mode 100644 services/api/test/integration/users_test.rb
via 4d2b509734d1ac5351ab6da16e08a092ba77f148 (commit)
via 0c376a152770021334e0b2c3cb7c897dd4ad74bd (commit)
via 093bae4c914a872c501c3235f06096092725f015 (commit)
via 9756d91f6f1e2472184be0dc45e8849c2c9ab35b (commit)
via 16b0697d6ea10d21381936bc9b5ad10914deb9b1 (commit)
via 029656d8b2646bae51de03426a6496cbce0cc9d7 (commit)
via c02331eb9e7d302efdd788af0dd3ba9124352edb (commit)
via b27fe91e18bec8df031e4c8bf87f4da293d7b733 (commit)
via 44242bfe2c86302c65650cf7fe3a7187223c6304 (commit)
via bbaaeabfc2d28c8a24f106b81e6677832cd68b3d (commit)
via be3b98a52ae6773913696955e2d9c6585fc89441 (commit)
from bb3ec0fefd17c68d9c0123dcfcc5e4ef616fb25e (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 4d2b509734d1ac5351ab6da16e08a092ba77f148
Merge: 0c376a1 093bae4
Author: radhika <radhika at curoverse.com>
Date: Fri Sep 26 21:50:16 2014 -0400
Merge branch 'master' into 3889-functional-testing
commit 0c376a152770021334e0b2c3cb7c897dd4ad74bd
Author: radhika <radhika at curoverse.com>
Date: Fri Sep 26 21:48:51 2014 -0400
3889: add a new integration tester for users controller. Refactor code so that users functional and integration tests can reuse some of the helper methods.
diff --git a/services/api/test/functional/arvados/v1/groups_controller_test.rb b/services/api/test/functional/arvados/v1/groups_controller_test.rb
index 59dcd2b..5790b74 100644
--- a/services/api/test/functional/arvados/v1/groups_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/groups_controller_test.rb
@@ -239,47 +239,6 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
assert_equal 0, json_response['items_available']
end
- [0, 5, 10, 15, 20].each do |offset|
- test "get pages of group-owned objects with offset #{offset}" do
- authorize_with :active
- limit = 5
- items_available = nil
- uuid_received = {}
- owner_received = {}
-
- @json_response = nil
- get :contents, {
- id: groups(:aproject).uuid,
- limit: limit,
- offset: offset,
- format: :json,
- }
- assert_response :success
- items_available ||= json_response['items_available']
- if offset >= items_available
- assert_equal(0, json_response['items'].count,
- "items_available=#{items_available} but received #{json_response['items']} "\
- "items with offset=#{offset}")
- else
- assert_operator(0, :<, json_response['items'].count,
- "items_available=#{items_available} but received "\
- "items with offset=#{offset}")
- assert_equal(items_available, json_response['items_available'],
- "items_available changed between page #{offset/limit} "\
- "and page #{1+offset/limit}")
- json_response['items'].each do |item|
- uuid = item['uuid']
- assert_equal(nil, uuid_received[uuid],
- "Received '#{uuid}' again on page #{1+offset/limit}")
- uuid_received[uuid] = true
- owner_received[item['owner_uuid']] = true
- offset += 1
- assert_equal groups(:aproject).uuid, item['owner_uuid']
- end
- end
- end
- end
-
%w(offset limit).each do |arg|
['foo', '', '1234five', '0x10', '-8'].each do |val|
test "Raise error on bogus #{arg} parameter #{val.inspect}" do
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 1cfb63e..9c4d18b 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -1,7 +1,9 @@
require 'test_helper'
+require 'helpers/users_test_helper'
class Arvados::V1::UsersControllerTest < ActionController::TestCase
include CurrentApiClient
+ include UsersTestHelper
setup do
@all_links_at_start = Link.all
@@ -855,103 +857,4 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
}
return return_obj
end
-
- def verify_link(response_items, link_object_name, expect_link, link_class,
- link_name, head_uuid, tail_uuid, head_kind, fetch_object, class_name)
-
- link = find_obj_in_resp response_items, 'Link', link_object_name
-
- if !expect_link
- assert_nil link, "Expected no link for #{link_object_name}"
- return
- end
-
- assert_not_nil link, "Expected link for #{link_object_name}"
-
- if fetch_object
- object = Object.const_get(class_name).where(name: head_uuid)
- assert [] != object, "expected #{class_name} with name #{head_uuid}"
- head_uuid = object.first[:uuid]
- end
- assert_equal link_class, link['link_class'],
- "did not find expected link_class for #{link_object_name}"
-
- assert_equal link_name, link['name'],
- "did not find expected link_name for #{link_object_name}"
-
- assert_equal tail_uuid, link['tail_uuid'],
- "did not find expected tail_uuid for #{link_object_name}"
-
- assert_equal head_kind, link['head_kind'],
- "did not find expected head_kind for #{link_object_name}"
-
- assert_equal head_uuid, link['head_uuid'],
- "did not find expected head_uuid for #{link_object_name}"
- end
-
- def verify_link_existence uuid, email, expect_oid_login_perms,
- expect_repo_perms, expect_vm_perms, expect_group_perms, expect_signatures
- # verify that all links are deleted for the user
- oid_login_perms = Link.where(tail_uuid: email,
- link_class: 'permission',
- name: 'can_login').where("head_uuid like ?", User.uuid_like_pattern)
- if expect_oid_login_perms
- assert oid_login_perms.any?, "expected oid_login_perms"
- else
- assert !oid_login_perms.any?, "expected all oid_login_perms deleted"
- end
-
- repo_perms = Link.where(tail_uuid: uuid,
- link_class: 'permission',
- name: 'can_manage').where("head_uuid like ?", Repository.uuid_like_pattern)
- if expect_repo_perms
- assert repo_perms.any?, "expected repo_perms"
- else
- assert !repo_perms.any?, "expected all repo_perms deleted"
- end
-
- vm_login_perms = Link.
- where(tail_uuid: uuid,
- link_class: 'permission',
- name: 'can_login').
- where("head_uuid like ?",
- VirtualMachine.uuid_like_pattern).
- where('uuid <> ?',
- links(:auto_setup_vm_login_username_can_login_to_test_vm).uuid)
- if expect_vm_perms
- assert vm_login_perms.any?, "expected vm_login_perms"
- else
- assert !vm_login_perms.any?, "expected all vm_login_perms deleted"
- end
-
- group = Group.where(name: 'All users').select do |g|
- g[:uuid].match /-f+$/
- end.first
- group_read_perms = Link.where(tail_uuid: uuid,
- head_uuid: group[:uuid],
- link_class: 'permission',
- name: 'can_read')
- if expect_group_perms
- assert group_read_perms.any?, "expected all users group read perms"
- else
- assert !group_read_perms.any?, "expected all users group perm deleted"
- end
-
- signed_uuids = Link.where(link_class: 'signature',
- tail_uuid: uuid)
-
- if expect_signatures
- assert signed_uuids.any?, "expected signatures"
- else
- assert !signed_uuids.any?, "expected all signatures deleted"
- end
-
- end
-
- def verify_system_group_permission_link_for user_uuid
- assert_equal 1, Link.where(link_class: 'permission',
- name: 'can_manage',
- tail_uuid: system_group_uuid,
- head_uuid: user_uuid).count
- end
end
diff --git a/services/api/test/helpers/users_test_helper.rb b/services/api/test/helpers/users_test_helper.rb
new file mode 100644
index 0000000..2a61820
--- /dev/null
+++ b/services/api/test/helpers/users_test_helper.rb
@@ -0,0 +1,100 @@
+module UsersTestHelper
+ def verify_link(response_items, link_object_name, expect_link, link_class,
+ link_name, head_uuid, tail_uuid, head_kind, fetch_object, class_name)
+ link = find_obj_in_resp response_items, 'arvados#link', link_object_name
+
+ if !expect_link
+ assert_nil link, "Expected no link for #{link_object_name}"
+ return
+ end
+
+ assert_not_nil link, "Expected link for #{link_object_name}"
+
+ if fetch_object
+ object = Object.const_get(class_name).where(name: head_uuid)
+ assert [] != object, "expected #{class_name} with name #{head_uuid}"
+ head_uuid = object.first[:uuid]
+ end
+ assert_equal link_class, link['link_class'],
+ "did not find expected link_class for #{link_object_name}"
+
+ assert_equal link_name, link['name'],
+ "did not find expected link_name for #{link_object_name}"
+
+ assert_equal tail_uuid, link['tail_uuid'],
+ "did not find expected tail_uuid for #{link_object_name}"
+
+ assert_equal head_kind, link['head_kind'],
+ "did not find expected head_kind for #{link_object_name}"
+
+ assert_equal head_uuid, link['head_uuid'],
+ "did not find expected head_uuid for #{link_object_name}"
+ end
+
+ def verify_system_group_permission_link_for user_uuid
+ assert_equal 1, Link.where(link_class: 'permission',
+ name: 'can_manage',
+ tail_uuid: system_group_uuid,
+ head_uuid: user_uuid).count
+ end
+
+ def verify_link_existence uuid, email, expect_oid_login_perms,
+ expect_repo_perms, expect_vm_perms, expect_group_perms, expect_signatures
+ # verify that all links are deleted for the user
+ oid_login_perms = Link.where(tail_uuid: email,
+ link_class: 'permission',
+ name: 'can_login').where("head_uuid like ?", User.uuid_like_pattern)
+ if expect_oid_login_perms
+ assert oid_login_perms.any?, "expected oid_login_perms"
+ else
+ assert !oid_login_perms.any?, "expected all oid_login_perms deleted"
+ end
+
+ repo_perms = Link.where(tail_uuid: uuid,
+ link_class: 'permission',
+ name: 'can_manage').where("head_uuid like ?", Repository.uuid_like_pattern)
+ if expect_repo_perms
+ assert repo_perms.any?, "expected repo_perms"
+ else
+ assert !repo_perms.any?, "expected all repo_perms deleted"
+ end
+
+ vm_login_perms = Link.
+ where(tail_uuid: uuid,
+ link_class: 'permission',
+ name: 'can_login').
+ where("head_uuid like ?",
+ VirtualMachine.uuid_like_pattern).
+ where('uuid <> ?',
+ links(:auto_setup_vm_login_username_can_login_to_test_vm).uuid)
+ if expect_vm_perms
+ assert vm_login_perms.any?, "expected vm_login_perms"
+ else
+ assert !vm_login_perms.any?, "expected all vm_login_perms deleted"
+ end
+
+ group = Group.where(name: 'All users').select do |g|
+ g[:uuid].match /-f+$/
+ end.first
+ group_read_perms = Link.where(tail_uuid: uuid,
+ head_uuid: group[:uuid],
+ link_class: 'permission',
+ name: 'can_read')
+ if expect_group_perms
+ assert group_read_perms.any?, "expected all users group read perms"
+ else
+ assert !group_read_perms.any?, "expected all users group perm deleted"
+ end
+
+ signed_uuids = Link.where(link_class: 'signature',
+ tail_uuid: uuid)
+
+ if expect_signatures
+ assert signed_uuids.any?, "expected signatures"
+ else
+ assert !signed_uuids.any?, "expected all signatures deleted"
+ end
+
+ end
+
+end
diff --git a/services/api/test/integration/users_test.rb b/services/api/test/integration/users_test.rb
new file mode 100644
index 0000000..0d6c0f3
--- /dev/null
+++ b/services/api/test/integration/users_test.rb
@@ -0,0 +1,216 @@
+require 'test_helper'
+require 'helpers/users_test_helper'
+
+class UsersTest < ActionDispatch::IntegrationTest
+ include UsersTestHelper
+
+ test "setup user multiple times" do
+ repo_name = 'test_repo'
+
+ post "/arvados/v1/users/setup", {
+ repo_name: repo_name,
+ openid_prefix: 'https://www.google.com/accounts/o8/id',
+ user: {
+ uuid: 'zzzzz-tpzed-abcdefghijklmno',
+ first_name: "in_create_test_first_name",
+ last_name: "test_last_name",
+ email: "foo at example.com"
+ }
+ }, auth(:admin)
+
+ assert_response :success
+
+ response_items = json_response['items']
+
+ created = find_obj_in_resp response_items, 'arvados#user', nil
+
+ assert_equal 'in_create_test_first_name', created['first_name']
+ assert_not_nil created['uuid'], 'expected non-null uuid for the new user'
+ assert_equal 'zzzzz-tpzed-abcdefghijklmno', created['uuid']
+ assert_not_nil created['email'], 'expected non-nil email'
+ assert_nil created['identity_url'], 'expected no identity_url'
+
+ # arvados#user, repo link and link add user to 'All users' group
+ verify_link response_items, 'arvados#user', true, 'permission', 'can_login',
+ created['uuid'], created['email'], 'arvados#user', false, 'arvados#user'
+
+ verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage',
+ repo_name, created['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+ verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login',
+ nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+
+ verify_system_group_permission_link_for created['uuid']
+
+ # invoke setup again with the same data
+ post "/arvados/v1/users/setup", {
+ repo_name: repo_name,
+ vm_uuid: virtual_machines(:testvm).uuid,
+ openid_prefix: 'https://www.google.com/accounts/o8/id',
+ user: {
+ uuid: 'zzzzz-tpzed-abcdefghijklmno',
+ first_name: "in_create_test_first_name",
+ last_name: "test_last_name",
+ email: "foo at example.com"
+ }
+ }, auth(:admin)
+
+ assert_response :success
+
+ response_items = json_response['items']
+
+ created = find_obj_in_resp response_items, 'arvados#user', nil
+ assert_equal 'in_create_test_first_name', created['first_name']
+ assert_not_nil created['uuid'], 'expected non-null uuid for the new user'
+ assert_equal 'zzzzz-tpzed-abcdefghijklmno', created['uuid']
+ assert_not_nil created['email'], 'expected non-nil email'
+ assert_nil created['identity_url'], 'expected no identity_url'
+
+ # arvados#user, repo link and link add user to 'All users' group
+ verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage',
+ repo_name, created['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+ verify_link response_items, 'arvados#virtualMachine', true, 'permission', 'can_login',
+ virtual_machines(:testvm).uuid, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+
+ verify_system_group_permission_link_for created['uuid']
+ end
+
+ test "setup user in multiple steps and verify response" do
+ post "/arvados/v1/users/setup", {
+ openid_prefix: 'http://www.example.com/account',
+ user: {
+ email: "foo at example.com"
+ }
+ }, auth(:admin)
+
+ assert_response :success
+ response_items = json_response['items']
+ created = find_obj_in_resp response_items, 'arvados#user', nil
+
+ assert_not_nil created['uuid'], 'expected uuid for new user'
+ assert_not_nil created['email'], 'expected non-nil email'
+ assert_equal created['email'], 'foo at example.com', 'expected input email'
+
+ # three new links: system_group, arvados#user, and 'All users' group.
+ verify_link response_items, 'arvados#user', true, 'permission', 'can_login',
+ created['uuid'], created['email'], 'arvados#user', false, 'arvados#user'
+
+ verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+ verify_link response_items, 'arvados#repository', false, 'permission', 'can_manage',
+ 'test_repo', created['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login',
+ nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+
+ # invoke setup with a repository
+ post "/arvados/v1/users/setup", {
+ openid_prefix: 'http://www.example.com/account',
+ repo_name: 'new_repo',
+ uuid: created['uuid']
+ }, auth(:admin)
+
+ assert_response :success
+
+ response_items = json_response['items']
+ created = find_obj_in_resp response_items, 'arvados#user', nil
+
+ assert_equal 'foo at example.com', created['email'], 'expected input email'
+
+ # verify links
+ verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+ verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage',
+ 'new_repo', created['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'arvados#virtualMachine', false, 'permission', 'can_login',
+ nil, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+
+ # invoke setup with a vm_uuid
+ post "/arvados/v1/users/setup", {
+ vm_uuid: virtual_machines(:testvm).uuid,
+ openid_prefix: 'http://www.example.com/account',
+ user: {
+ email: 'junk_email'
+ },
+ uuid: created['uuid']
+ }, auth(:admin)
+
+ assert_response :success
+
+ response_items = json_response['items']
+ created = find_obj_in_resp response_items, 'arvados#user', nil
+
+ assert_equal created['email'], 'foo at example.com', 'expected original email'
+
+ # verify links
+ verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+ # since no repo name in input, we won't get any; even though user has one
+ verify_link response_items, 'arvados#repository', false, 'permission', 'can_manage',
+ 'new_repo', created['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'arvados#virtualMachine', true, 'permission', 'can_login',
+ virtual_machines(:testvm).uuid, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+ end
+
+ test "setup and unsetup user" do
+ post "/arvados/v1/users/setup", {
+ repo_name: 'test_repo',
+ vm_uuid: virtual_machines(:testvm).uuid,
+ user: {email: 'foo at example.com'},
+ openid_prefix: 'https://www.google.com/accounts/o8/id'
+ }, auth(:admin)
+
+ assert_response :success
+ response_items = json_response['items']
+ created = find_obj_in_resp response_items, 'arvados#user', nil
+ assert_not_nil created['uuid'], 'expected uuid for the new user'
+ assert_equal created['email'], 'foo at example.com', 'expected given email'
+
+ # five extra links: system_group, login, group, repo and vm
+ verify_link response_items, 'arvados#user', true, 'permission', 'can_login',
+ created['uuid'], created['email'], 'arvados#user', false, 'arvados#user'
+
+ verify_link response_items, 'arvados#group', true, 'permission', 'can_read',
+ 'All users', created['uuid'], 'arvados#group', true, 'Group'
+
+ verify_link response_items, 'arvados#repository', true, 'permission', 'can_manage',
+ 'test_repo', created['uuid'], 'arvados#repository', true, 'Repository'
+
+ verify_link response_items, 'arvados#virtualMachine', true, 'permission', 'can_login',
+ virtual_machines(:testvm).uuid, created['uuid'], 'arvados#virtualMachine', false, 'VirtualMachine'
+
+ verify_link_existence created['uuid'], created['email'], true, true, true, true, false
+
+ post "/arvados/v1/users/#{created['uuid']}/unsetup", {}, auth(:admin)
+
+ assert_response :success
+
+ created2 = json_response
+ assert_not_nil created2['uuid'], 'expected uuid for the newly created user'
+ assert_equal created['uuid'], created2['uuid'], 'expected uuid not found'
+
+ verify_link_existence created['uuid'], created['email'], false, false, false, false, false
+ end
+
+ def find_obj_in_resp (response_items, kind, head_kind=nil)
+ response_items.each do |x|
+ if x && x['kind']
+ return x if (x['kind'] == kind && x['head_kind'] == head_kind)
+ end
+ end
+ nil
+ end
+
+end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list