[ARVADOS] created: 0e239ef805b8c6eda936073197cf96d0329db048
git at public.curoverse.com
git at public.curoverse.com
Sun Jul 5 07:39:17 EDT 2015
at 0e239ef805b8c6eda936073197cf96d0329db048 (commit)
commit 0e239ef805b8c6eda936073197cf96d0329db048
Author: Brett Smith <brett at curoverse.com>
Date: Sun Jul 5 07:39:09 2015 -0400
5989: API repo perms method always returns all repos.
Previously the method would not return repositories that were not
accessible to any authorized key. This change helps deployment tools
like update-gitolite do repository setup correctly with a single API
call.
diff --git a/services/api/app/controllers/arvados/v1/repositories_controller.rb b/services/api/app/controllers/arvados/v1/repositories_controller.rb
index b5123d9..fd6ab58 100644
--- a/services/api/app/controllers/arvados/v1/repositories_controller.rb
+++ b/services/api/app/controllers/arvados/v1/repositories_controller.rb
@@ -4,14 +4,20 @@ class Arvados::V1::RepositoriesController < ApplicationController
before_filter :admin_required, :only => :get_all_permissions
def get_all_permissions
@users = {}
- User.includes(:authorized_keys).all.each do |u|
+ User.includes(:authorized_keys).find_each do |u|
@users[u.uuid] = u
end
admins = @users.select { |k,v| v.is_admin }
@user_aks = {}
@repo_info = {}
- @repos = Repository.includes(:permissions).all
- @repos.each do |repo|
+ Repository.includes(:permissions).find_each do |repo|
+ @repo_info[repo.uuid] = {
+ uuid: repo.uuid,
+ name: repo.name,
+ push_url: repo.push_url,
+ fetch_url: repo.fetch_url,
+ user_permissions: {},
+ }
gitolite_permissions = ''
perms = []
repo.permissions.each do |perm|
@@ -45,13 +51,6 @@ class Arvados::V1::RepositoriesController < ApplicationController
}
end || []
if @user_aks[user_uuid].any?
- @repo_info[repo.uuid] ||= {
- uuid: repo.uuid,
- name: repo.name,
- push_url: repo.push_url,
- fetch_url: repo.fetch_url,
- user_permissions: {}
- }
ri = (@repo_info[repo.uuid][:user_permissions][user_uuid] ||= {})
ri[perm[:name]] = true
end
diff --git a/services/api/test/functional/arvados/v1/repositories_controller_test.rb b/services/api/test/functional/arvados/v1/repositories_controller_test.rb
index 7f4ed8e..7ba2183 100644
--- a/services/api/test/functional/arvados/v1/repositories_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/repositories_controller_test.rb
@@ -88,6 +88,17 @@ class Arvados::V1::RepositoriesControllerTest < ActionController::TestCase
end
end
+ test "get_all_permissions lists repos with no authorized keys" do
+ authorize_with :admin
+ AuthorizedKey.destroy_all
+ get :get_all_permissions
+ assert_response :success
+ assert_equal(Repository.count, json_response["repositories"].size)
+ assert(json_response["repositories"].any? do |repo|
+ repo["user_permissions"].empty?
+ end, "test is invalid - all repositories have authorized keys")
+ end
+
test "default index includes fetch_url" do
authorize_with :active
get(:index)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list