Commit bba4adc0 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'dz-dependency-proxy-permissions' into 'master'

Allow developers to configure dependency proxy

See merge request gitlab-org/gitlab-ee!13899
parents 04a55c8f f0ac71bb
......@@ -18,4 +18,8 @@ module DependencyProxyAccess
def authorize_read_dependency_proxy!
access_denied! unless can?(current_user, :read_dependency_proxy, group)
end
def authorize_admin_dependency_proxy!
access_denied! unless can?(current_user, :admin_dependency_proxy, group)
end
end
......@@ -4,7 +4,7 @@ module Groups
class DependencyProxiesController < Groups::ApplicationController
include DependencyProxyAccess
before_action :authorize_admin_group!, only: :update
before_action :authorize_admin_dependency_proxy!, only: :update
before_action :dependency_proxy
def show
......
......@@ -45,6 +45,9 @@ module EE
rule { can?(:read_group) & dependency_proxy_available }
.enable :read_dependency_proxy
rule { developer & dependency_proxy_available }
.enable :admin_dependency_proxy
rule { can?(:read_group) & epics_available }.enable :read_epic
rule { reporter & epics_available }.policy do
......
......@@ -8,7 +8,7 @@
= s_('Create a local proxy for storing frequently used upstream images. %{link_start}Learn more%{link_end} about dependency proxies.').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- if @group.public?
- if can?(current_user, :admin_group, @group)
- if can?(current_user, :admin_dependency_proxy, @group)
= form_for(@dependency_proxy, method: :put, url: group_dependency_proxy_path(@group)) do |f|
.form-group
.js-dependency-proxy-toggle-area
......
---
title: Allow developers to configure dependency proxy
merge_request: 13899
author:
type: changed
......@@ -3,14 +3,14 @@
require 'spec_helper'
describe 'Group Dependency Proxy' do
let(:owner) { create(:user) }
let(:developer) { create(:user) }
let(:reporter) { create(:user) }
let(:group) { create(:group) }
let(:path) { group_dependency_proxy_path(group) }
before do
group.add_owner(owner)
group.add_developer(developer)
group.add_reporter(reporter)
enable_feature
stub_licensed_features(dependency_proxy: true)
......@@ -29,9 +29,9 @@ describe 'Group Dependency Proxy' do
end
context 'feature is available', :js do
context 'when logged in as group owner' do
context 'when logged in as group developer' do
before do
sign_in(owner)
sign_in(developer)
visit path
end
......@@ -57,9 +57,9 @@ describe 'Group Dependency Proxy' do
end
end
context 'when logged in as group developer' do
context 'when logged in as group reporter' do
before do
sign_in(developer)
sign_in(reporter)
visit path
end
......@@ -72,7 +72,7 @@ describe 'Group Dependency Proxy' do
context 'feature is not avaible' do
before do
sign_in(owner)
sign_in(developer)
end
context 'group is private' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment