[ARVADOS] updated: 1.3.0-3298-g7ce1e5122

Git user git at public.arvados.org
Sat Oct 10 00:16:31 UTC 2020


Summary of changes:
 services/api/app/models/user.rb     | 29 ++++++++++++++++-------------
 services/api/test/unit/user_test.rb |  5 +++--
 2 files changed, 19 insertions(+), 15 deletions(-)

       via  7ce1e5122b6e913d90010254009c3c9efc5e1f60 (commit)
      from  6440951d141dbb7ec953a90f0bd5d7f47035707d (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 7ce1e5122b6e913d90010254009c3c9efc5e1f60
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Oct 9 20:12:53 2020 -0400

    Setup default VM/repo in setup method refs #16989
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index f8cc78c1d..f3cf4b38f 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -219,15 +219,29 @@ SELECT target_uuid, perm_level
                               link_class: 'permission',
                               name: 'can_read').empty?
 
+    # Add can_read link from this user to "all users" which makes this
+    # user "invited"
     group_perm = create_user_group_link
-    repo_perm = create_user_repo_link repo_name
 
+    # Add git repo
+    if repo_name.nil? && username && Rails.configuration.Users.AutoSetupNewUsersWithRepository
+      repo_name = "#{username}/#{username}"
+    end
+
+    repo_perm = if repo_name
+                  create_user_repo_link repo_name
+                end
+
+    # Add virtual machine
     if vm_uuid.nil? and !Rails.configuration.Users.AutoSetupNewUsersWithVmUUID.empty?
       vm_uuid = Rails.configuration.Users.AutoSetupNewUsersWithVmUUID
     end
 
-    vm_login_perm = create_vm_login_permission_link(vm_uuid, username) if vm_uuid
+    vm_login_perm = if vm_uuid && username
+                      create_vm_login_permission_link(vm_uuid, username)
+                    end
 
+    # Send welcome email
     if send_notification_email.nil?
       send_notification_email = Rails.configuration.Mail.SendUserSetupNotificationEmail
     end
@@ -769,17 +783,6 @@ update #{PERMISSION_VIEW} set target_uuid=$1 where target_uuid = $2
   # Automatically setup new user during creation
   def auto_setup_new_user
     setup
-    if username
-      create_vm_login_permission_link(Rails.configuration.Users.AutoSetupNewUsersWithVmUUID,
-                                      username)
-      repo_name = "#{username}/#{username}"
-      if Rails.configuration.Users.AutoSetupNewUsersWithRepository and
-          Repository.where(name: repo_name).first.nil?
-        repo = Repository.create!(name: repo_name, owner_uuid: uuid)
-        Link.create!(tail_uuid: uuid, head_uuid: repo.uuid,
-                     link_class: "permission", name: "can_manage")
-      end
-    end
   end
 
   # Send notification if the user saved profile for the first time
diff --git a/services/api/test/unit/user_test.rb b/services/api/test/unit/user_test.rb
index b6d66230d..f973c6ba1 100644
--- a/services/api/test/unit/user_test.rb
+++ b/services/api/test/unit/user_test.rb
@@ -387,7 +387,7 @@ class UserTest < ActiveSupport::TestCase
     [false, active_notify_list, inactive_notify_list, "&4a_d9. at example.com", true, true, "ad9"],
     [false, active_notify_list, inactive_notify_list, "&4a_d9. at example.com", false, false, "ad9"],
   ].each do |active, new_user_recipients, inactive_recipients, email, auto_setup_vm, auto_setup_repo, expect_username|
-    test "create new user with auto setup #{active} #{email} #{auto_setup_vm} #{auto_setup_repo}" do
+    test "create new user with auto setup active=#{active} email=#{email} vm=#{auto_setup_vm} repo=#{auto_setup_repo}" do
       set_user_from_auth :admin
 
       Rails.configuration.Users.AutoSetupNewUsers = true
@@ -621,6 +621,7 @@ class UserTest < ActiveSupport::TestCase
                           Rails.configuration.Users.AutoSetupNewUsersWithRepository),
                          named_repo.uuid, user.uuid, "permission", "can_manage")
     end
+
     # Check for VM login.
     if (auto_vm_uuid = Rails.configuration.Users.AutoSetupNewUsersWithVmUUID) != ""
       verify_link_exists(can_setup, auto_vm_uuid, user.uuid,
@@ -677,7 +678,7 @@ class UserTest < ActiveSupport::TestCase
                            tail_uuid: tail_uuid,
                            link_class: link_class,
                            name: link_name)
-    assert_equal link_exists, all_links.any?, "Link #{'not' if link_exists} found for #{link_name} #{link_class} #{property_value}"
+    assert_equal link_exists, all_links.any?, "Link#{' not' if link_exists} found for #{link_name} #{link_class} #{property_value}"
     if link_exists && property_name && property_value
       all_links.each do |link|
         assert_equal true, all_links.first.properties[property_name].start_with?(property_value), 'Property not found in link'

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list