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)
end
[
- {config: "example.com", host: "example.com"},
- {config: false, host: "git.zzzzz.arvadosapi.com"}
- ].each do |set_git_host|
- test "setting git_host to #{set_git_host[:host]} changes fetch/push_url to #{set_git_host[:config]}" do
- Rails.configuration.git_host = set_git_host[:config]
+ {cfg: :git_repo_ssh_base, cfgval: "git@example.com:", match: %r"^git@example.com:/"},
+ {cfg: :git_repo_ssh_base, cfgval: true, match: %r"^git@git.zzzzz.arvadosapi.com:/"},
+ {cfg: :git_repo_ssh_base, cfgval: false, refute: /^git@/ },
+ {cfg: :git_repo_https_base, cfgval: "https://example.com/", match: %r"https://example.com/"},
+ {cfg: :git_repo_https_base, cfgval: true, match: %r"^https://git.zzzzz.arvadosapi.com/"},
+ {cfg: :git_repo_https_base, cfgval: false, refute: /^http/ },
+ ].each do |expect|
+ test "set #{expect[:cfg]} to #{expect[:cfgval]}" do
+ Rails.configuration.send expect[:cfg].to_s+"=", expect[:cfgval]
authorize_with :active
- get(:index)
+ get :index
assert_response :success
- assert_includes(json_response["items"].map { |r| r["fetch_url"] },
- "git@#{set_git_host[:host]}:active/foo.git")
- assert_includes(json_response["items"].map { |r| r["push_url"] },
- "git@#{set_git_host[:host]}:active/foo.git")
+ json_response['items'].each do |r|
+ if expect[:refute]
+ r['clone_urls'].each do |u|
+ refute_match expect[:refute], u
+ end
+ else
+ assert r['clone_urls'].any? do |u|
+ expect[:prefix].match u
+ end
+ end
+ end
end
end
- test "can select push_url in index" do
+ test "select push_url in index" do
authorize_with :active
get(:index, {select: ["uuid", "push_url"]})
assert_response :success
assert_includes(json_response["items"].map { |r| r["push_url"] },
"git@git.zzzzz.arvadosapi.com:active/foo.git")
end
+
+ test "select clone_urls in index" do
+ authorize_with :active
+ get(:index, {select: ["uuid", "clone_urls"]})
+ assert_response :success
+ assert_includes(json_response["items"].map { |r| r["clone_urls"] }.flatten,
+ "git@git.zzzzz.arvadosapi.com:active/foo.git")
+ end
end