[ARVADOS] updated: d66803ae05f4e4ac60c7bc8fb2e22b3a825bd95c

git at public.curoverse.com git at public.curoverse.com
Mon Mar 30 18:24:04 EDT 2015


Summary of changes:
 .../app/assets/javascripts/add_repository.js       | 10 ++++++---
 .../app/views/users/_add_repository_modal.html.erb |  3 ++-
 .../app/controllers/arvados/v1/users_controller.rb | 24 +++++++++++-----------
 services/api/app/models/repository.rb              |  6 +++---
 services/api/test/test_helper.rb                   |  9 ++++++++
 services/api/test/unit/repository_test.rb          | 22 ++++++++++++++++++++
 6 files changed, 55 insertions(+), 19 deletions(-)

       via  d66803ae05f4e4ac60c7bc8fb2e22b3a825bd95c (commit)
       via  ea103bd3ffbb3a9b342b7f6eabf3df818f914572 (commit)
       via  585a8655a91f8410e34ca1c75acbf4bc7e6f94c3 (commit)
       via  ebd5b4a23e1d782946c6d93a77cd266c0df795d1 (commit)
       via  0ce4725953f601a54f0505ceced900133f5de81b (commit)
      from  7ca7892c32d6de77729c43ac09b935d738a9cbbe (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 d66803ae05f4e4ac60c7bc8fb2e22b3a825bd95c
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Mar 30 18:05:26 2015 -0400

    4253: Add tests for renaming repos.

diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb
index f155fc0..bf5afea 100644
--- a/services/api/test/test_helper.rb
+++ b/services/api/test/test_helper.rb
@@ -62,6 +62,15 @@ class ActiveSupport::TestCase
     end
   end
 
+  def add_permission_link from_who, to_what, perm_type
+    act_as_system_user do
+      Link.create!(tail_uuid: from_who.uuid,
+                   head_uuid: to_what.uuid,
+                   link_class: 'permission',
+                   name: perm_type)
+    end
+  end
+
   def restore_configuration
     # Restore configuration settings changed during tests
     $application_config.each do |k,v|
diff --git a/services/api/test/unit/repository_test.rb b/services/api/test/unit/repository_test.rb
index 918e700..1752cad 100644
--- a/services/api/test/unit/repository_test.rb
+++ b/services/api/test/unit/repository_test.rb
@@ -227,4 +227,26 @@ class RepositoryTest < ActiveSupport::TestCase
                         name: "foo3")
     assert(repo.save)
   end
+
+  ### Renaming
+
+  test "non-admin can rename own repo" do
+    act_as_user users(:active) do
+      assert repositories(:foo).update_attributes(name: 'active/foo12345')
+    end
+  end
+
+  test "top level repo can be touched by non-admin with can_manage" do
+    add_permission users(:active), repositories(:arvados), 'can_manage'
+    act_as_user users(:active) do
+      assert changed_repo(:arvados, modified_at: Time.now).save
+    end
+  end
+
+  test "top level repo cannot be renamed by non-admin with can_manage" do
+    add_permission users(:active), repositories(:arvados), 'can_manage'
+    act_as_user users(:active) do
+      assert_not_allowed { changed_repo(:arvados, name: 'xarvados').save }
+    end
+  end
 end

commit ea103bd3ffbb3a9b342b7f6eabf3df818f914572
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Mar 30 17:12:31 2015 -0400

    4253: Add .git suffix as input-group-addon.

diff --git a/apps/workbench/app/views/users/_add_repository_modal.html.erb b/apps/workbench/app/views/users/_add_repository_modal.html.erb
index 1c14ab6..db74ec5 100644
--- a/apps/workbench/app/views/users/_add_repository_modal.html.erb
+++ b/apps/workbench/app/views/users/_add_repository_modal.html.erb
@@ -24,6 +24,7 @@
                   <span class="input-group-addon"><%= repo_prefix %></span>
                 <% end %>
                 <input type="text" class="form-control" id="add_repo_basename" name="add_repo_basename">
+                <span class="input-group-addon">.git</span>
               </div>
             </div>
           </div>

commit 585a8655a91f8410e34ca1c75acbf4bc7e6f94c3
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Mar 30 17:11:31 2015 -0400

    4253: Clear modal state when [re]opening.

diff --git a/apps/workbench/app/assets/javascripts/add_repository.js b/apps/workbench/app/assets/javascripts/add_repository.js
index f7e3e5f..373cc96 100644
--- a/apps/workbench/app/assets/javascripts/add_repository.js
+++ b/apps/workbench/app/assets/javascripts/add_repository.js
@@ -1,3 +1,7 @@
+$(document).on('shown.bs.modal', '#add-repository-modal', function(event) {
+    $('input[type=text]', event.target).val('');
+    $('#add-repository-error', event.target).hide();
+});
 $(document).on('submit', '#add-repository-form', function(event) {
     var $form = $(event.target),
     $submit = $(':submit', $form),
@@ -7,7 +11,7 @@ $(document).on('submit', '#add-repository-form', function(event) {
     repo_basename = $('input[name="add_repo_basename"]', $form).val();
 
     $submit.prop('disabled', true);
-    $error.toggleClass('hidden', true);
+    $error.hide();
     $.ajax('/repositories',
            {method: 'POST',
             dataType: 'json',
@@ -28,8 +32,8 @@ $(document).on('submit', '#add-repository-form', function(event) {
                           ": " + errlist + ").");
             }
             $error.text(errmsg);
-            $error.toggleClass('hidden', false);
+            $error.show();
             $submit.prop('disabled', false);
         });
     return false;
-});
\ No newline at end of file
+});
diff --git a/apps/workbench/app/views/users/_add_repository_modal.html.erb b/apps/workbench/app/views/users/_add_repository_modal.html.erb
index d7cbf72..1c14ab6 100644
--- a/apps/workbench/app/views/users/_add_repository_modal.html.erb
+++ b/apps/workbench/app/views/users/_add_repository_modal.html.erb
@@ -28,7 +28,7 @@
             </div>
           </div>
           <p class="alert alert-info">It may take a minute or two before you can clone your new repository.</p>
-          <p id="add-repository-error" class="hidden alert alert-danger"></p>
+          <p id="add-repository-error" class="alert alert-danger"></p>
         </div>
         <div class="modal-footer">
           <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

commit ebd5b4a23e1d782946c6d93a77cd266c0df795d1
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Mar 30 14:37:59 2015 -0400

    4253: Bikeshed error messages.

diff --git a/services/api/app/models/repository.rb b/services/api/app/models/repository.rb
index 5c990cb..7700008 100644
--- a/services/api/app/models/repository.rb
+++ b/services/api/app/models/repository.rb
@@ -60,14 +60,14 @@ class Repository < ArvadosModel
   def name_format
     if owner.uuid == system_user_uuid
       prefix_match = ""
-      errmsg_start = "must begin with"
+      errmsg_start = "must be"
     else
       prefix_match = Regexp.escape(owner.username + "/")
-      errmsg_start = "must begin with owner username, '/', then contain"
+      errmsg_start = "must be the owner's username, then '/', then"
     end
     if not /^#{prefix_match}[A-Za-z][A-Za-z0-9]*$/.match(name)
       errors.add(:name,
-                 "#{errmsg_start} a letter and contain only alphanumerics")
+                 "#{errmsg_start} a letter followed by alphanumerics")
       false
     end
   end

commit 0ce4725953f601a54f0505ceced900133f5de81b
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Mar 30 14:37:30 2015 -0400

    4253: Use same repo name logic whether or not user already existed before setup.

diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index b5ac195..345cd46 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -96,24 +96,24 @@ class Arvados::V1::UsersController < ApplicationController
       end
     end
 
-    # It's not always possible to know the user's username when submitting
-    # this request.  If it included a plain repository name, expand that to a
-    # user-owned name now.
+    # It's not always possible for the client to know the user's
+    # username when submitting this request: the username might have
+    # been assigned automatically in create!() above. If client
+    # provided a plain repository name, prefix it with the username
+    # now that we know what it is.
     if params[:repo_name].nil?
       full_repo_name = nil
+    elsif @object.username.nil?
+      raise ArgumentError.
+        new("cannot setup a repository because user has no username")
+    elsif params[:repo_name].include?("/")
+      full_repo_name = params[:repo_name]
     else
       full_repo_name = "#{@object.username}/#{params[:repo_name]}"
     end
+
     if object_found
-      if params[:repo_name].andand.include?("/")
-        repo_name = params[:repo_name]
-      elsif @object.username.nil?
-        raise ArgumentError.
-          new("can't setup a user without a username with a repository")
-      else
-        repo_name = full_repo_name
-      end
-      @response = @object.setup_repo_vm_links repo_name,
+      @response = @object.setup_repo_vm_links full_repo_name,
                     params[:vm_uuid], params[:openid_prefix]
     else
       @response = User.setup @object, params[:openid_prefix],

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list