[ARVADOS] updated: 9624ed0931aac929f0d773dfee8b9e620b9352ad
git at public.curoverse.com
git at public.curoverse.com
Fri Aug 22 11:12:03 EDT 2014
Summary of changes:
services/api/app/models/user.rb | 5 +----
services/api/test/fixtures/links.yml | 4 ++--
services/api/test/unit/user_test.rb | 16 ++++++++++++----
3 files changed, 15 insertions(+), 10 deletions(-)
via 9624ed0931aac929f0d773dfee8b9e620b9352ad (commit)
from c005c5ab76492b844e84d1c66f75797bd98d0996 (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 9624ed0931aac929f0d773dfee8b9e620b9352ad
Author: radhika <radhika at curoverse.com>
Date: Fri Aug 22 11:09:31 2014 -0400
3153: when deriving unique name, look for all can_login links, not just the vm_uuid configured. update tests to assert the generated username ends with a number when using a preconfigured username for this link.
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 7b894ca..04bf681 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -456,13 +456,10 @@ class User < ArvadosModel
# Find a username that starts with the given string and does not collide
# with any existing repository name or VM login name
def derive_unique_username orig_username
- vm_uuid = Rails.configuration.auto_setup_new_users_with_vm_uuid
-
username = String.new orig_username
10000.times do |count|
if Repository.where(name: username).empty?
- login_collisions = Link.where(head_uuid: vm_uuid,
- link_class: 'permission',
+ login_collisions = Link.where(link_class: 'permission',
name: 'can_login').select do |perm|
perm.properties['username'] == username
end
diff --git a/services/api/test/fixtures/links.yml b/services/api/test/fixtures/links.yml
index 4b71e48..dc044b2 100644
--- a/services/api/test/fixtures/links.yml
+++ b/services/api/test/fixtures/links.yml
@@ -708,7 +708,7 @@ empty_collection_name_in_active_user_home_project:
properties: {}
updated_at: 2014-08-06 22:11:51.242010312 Z
-xyz_can_login_to_vm_username_can_login_to_test_vm:
+auto_setup_vm_login_username_can_login_to_test_vm:
uuid: zzzzz-o0j2j-i3n6m98766tmoi4
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
created_at: 2014-08-06 22:11:51.242392533 Z
@@ -719,5 +719,5 @@ xyz_can_login_to_vm_username_can_login_to_test_vm:
link_class: permission
name: can_login
head_uuid: zzzzz-2x53u-382brsig8rp3064
- properties: {username: 'xyz_can_login_to_vm'}
+ properties: {username: 'auto_setup_vm_login'}
updated_at: 2014-08-06 22:11:51.242010312 Z
diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb
index 98ce55b..c410787 100644
--- a/services/api/test/unit/user_test.rb
+++ b/services/api/test/unit/user_test.rb
@@ -159,10 +159,10 @@ class UserTest < ActiveSupport::TestCase
[false, 'active-notify at example.com', 'inactive-notify at example.com', 'auto_setup_repo at example.com', false, true, true], # existing repository name 'auto_setup_repo'
[false, 'active-notify at example.com', 'inactive-notify at example.com', 'auto_setup_repo at example.com', false, false, true], # existing repository name 'auto_setup_repo', but we are not creating repo or login link
- [false, 'active-notify at example.com', 'inactive-notify at example.com', 'xyz_can_login_to_vm at example.com', true, true, true], # existing vm login name
- [true, 'active-notify at example.com', 'inactive-notify at example.com', 'xyz_can_login_to_vm at example.com', true, false, true], # existing vm login name
- [false, 'active-notify at example.com', 'inactive-notify at example.com', 'xyz_can_login_to_vm at example.com', false, true, true], # existing vm login name
- [false, 'active-notify at example.com', 'inactive-notify at example.com', 'xyz_can_login_to_vm at example.com', false, false, true], # existing vm login name, but we are not creating repo or login link
+ [false, 'active-notify at example.com', 'inactive-notify at example.com', 'auto_setup_vm_login at example.com', true, true, true], # existing vm login name
+ [true, 'active-notify at example.com', 'inactive-notify at example.com', 'auto_setup_vm_login at example.com', true, false, true], # existing vm login name
+ [false, 'active-notify at example.com', 'inactive-notify at example.com', 'auto_setup_vm_login at example.com', false, true, true], # existing vm login name
+ [false, 'active-notify at example.com', 'inactive-notify at example.com', 'auto_setup_vm_login at example.com', false, false, true], # existing vm login name, but we are not creating repo or login link
[true, 'active-notify at example.com', 'inactive-notify at example.com', '*!*@example.com', true, false, false], # username is invalid format
[false, 'active-notify at example.com', 'inactive-notify at example.com', '*!*@example.com', false, false, true], # since no repo and vm login, username is ok (not validated)
@@ -500,6 +500,14 @@ class UserTest < ActiveSupport::TestCase
verify_link_exists true, repo_uuids, user.uuid, 'permission', 'can_manage', nil, nil
end
+ # if username is existing vm login name, make sure the username used to generate any repo is unique
+ if username == 'auto_setup_vm_login'
+ if repo_names.any?
+ assert repo_names.first.start_with? 'auto_setup_vm_login'
+ assert_not_nil /\d$/.match(repo_names.first)
+ end
+ end
+
# check vm uuid
vm_uuid = Rails.configuration.auto_setup_new_users_with_vm_uuid
if vm_uuid
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list