2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-03-09 11:57:57 -05:00
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'Private Group access' do
|
2016-03-09 11:57:57 -05:00
|
|
|
include AccessMatchers
|
|
|
|
|
2016-11-29 02:08:11 -05:00
|
|
|
let(:group) { create(:group, :private) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :private, group: group) }
|
2016-11-29 02:08:11 -05:00
|
|
|
let(:project_guest) do
|
|
|
|
create(:user) do |user|
|
|
|
|
project.add_guest(user)
|
|
|
|
end
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|
|
|
|
|
2016-03-20 16:03:53 -04:00
|
|
|
describe "Group should be private" do
|
|
|
|
describe '#private?' do
|
|
|
|
subject { group.private? }
|
2019-10-18 07:11:44 -04:00
|
|
|
|
2016-03-20 16:03:53 -04:00
|
|
|
it { is_expected.to be_truthy }
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|
2016-03-20 16:03:53 -04:00
|
|
|
end
|
2016-03-09 11:57:57 -05:00
|
|
|
|
2016-03-20 16:03:53 -04:00
|
|
|
describe 'GET /groups/:path' do
|
|
|
|
subject { group_path(group) }
|
|
|
|
|
2021-03-09 13:09:41 -05:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
end
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { is_expected.to be_denied_for(:admin) }
|
|
|
|
end
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:owner).of(group) }
|
2018-07-11 10:36:08 -04:00
|
|
|
it { is_expected.to be_allowed_for(:maintainer).of(group) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:developer).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(group) }
|
2019-03-13 09:24:03 -04:00
|
|
|
it { is_expected.to be_allowed_for(project_guest) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|
|
|
|
|
2020-02-14 16:09:08 -05:00
|
|
|
describe 'GET /groups/:path/-/issues' do
|
2016-03-20 16:03:53 -04:00
|
|
|
subject { issues_group_path(group) }
|
|
|
|
|
2021-03-09 13:09:41 -05:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
end
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { is_expected.to be_denied_for(:admin) }
|
|
|
|
end
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:owner).of(group) }
|
2018-07-11 10:36:08 -04:00
|
|
|
it { is_expected.to be_allowed_for(:maintainer).of(group) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:developer).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(group) }
|
2019-03-13 09:24:03 -04:00
|
|
|
it { is_expected.to be_allowed_for(project_guest) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-03-20 16:03:53 -04:00
|
|
|
end
|
2016-03-09 11:57:57 -05:00
|
|
|
|
2020-02-14 16:09:08 -05:00
|
|
|
describe 'GET /groups/:path/-/merge_requests' do
|
2017-07-26 18:01:19 -04:00
|
|
|
let(:project) { create(:project, :private, :repository, group: group) }
|
2019-12-17 13:07:48 -05:00
|
|
|
|
2016-03-20 16:03:53 -04:00
|
|
|
subject { merge_requests_group_path(group) }
|
|
|
|
|
2021-03-09 13:09:41 -05:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
end
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { is_expected.to be_denied_for(:admin) }
|
|
|
|
end
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:owner).of(group) }
|
2018-07-11 10:36:08 -04:00
|
|
|
it { is_expected.to be_allowed_for(:maintainer).of(group) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:developer).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(group) }
|
2019-03-13 09:24:03 -04:00
|
|
|
it { is_expected.to be_allowed_for(project_guest) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|
|
|
|
|
2020-02-14 16:09:08 -05:00
|
|
|
describe 'GET /groups/:path/-/group_members' do
|
2016-03-20 16:03:53 -04:00
|
|
|
subject { group_group_members_path(group) }
|
|
|
|
|
2021-03-09 13:09:41 -05:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
end
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { is_expected.to be_denied_for(:admin) }
|
|
|
|
end
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:owner).of(group) }
|
2018-07-11 10:36:08 -04:00
|
|
|
it { is_expected.to be_allowed_for(:maintainer).of(group) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:developer).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(group) }
|
2022-06-01 17:08:14 -04:00
|
|
|
it { is_expected.to be_denied_for(project_guest) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|
|
|
|
|
2020-02-14 16:09:08 -05:00
|
|
|
describe 'GET /groups/:path/-/edit' do
|
2016-03-20 16:03:53 -04:00
|
|
|
subject { edit_group_path(group) }
|
|
|
|
|
2021-03-09 13:09:41 -05:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
end
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { is_expected.to be_denied_for(:admin) }
|
|
|
|
end
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_allowed_for(:owner).of(group) }
|
2018-07-11 10:36:08 -04:00
|
|
|
it { is_expected.to be_denied_for(:maintainer).of(group) }
|
2016-11-29 02:08:11 -05:00
|
|
|
it { is_expected.to be_denied_for(:developer).of(group) }
|
|
|
|
it { is_expected.to be_denied_for(:reporter).of(group) }
|
|
|
|
it { is_expected.to be_denied_for(:guest).of(group) }
|
|
|
|
it { is_expected.to be_denied_for(project_guest) }
|
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|
2019-02-11 06:53:58 -05:00
|
|
|
|
|
|
|
describe 'GET /groups/:path for shared projects' do
|
|
|
|
let(:project) { create(:project, :public) }
|
2019-03-13 09:24:03 -04:00
|
|
|
|
2019-02-11 06:53:58 -05:00
|
|
|
before do
|
2019-03-13 06:54:06 -04:00
|
|
|
create(:project_group_link, project: project, group: group)
|
2019-02-11 06:53:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { group_path(group) }
|
|
|
|
|
2021-03-09 13:09:41 -05:00
|
|
|
context 'when admin mode is enabled', :enable_admin_mode do
|
|
|
|
it { is_expected.to be_allowed_for(:admin) }
|
|
|
|
end
|
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it { is_expected.to be_denied_for(:admin) }
|
|
|
|
end
|
2019-02-11 06:53:58 -05:00
|
|
|
it { is_expected.to be_allowed_for(:owner).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:maintainer).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:developer).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:reporter).of(group) }
|
|
|
|
it { is_expected.to be_allowed_for(:guest).of(group) }
|
|
|
|
it { is_expected.to be_denied_for(project_guest) }
|
|
|
|
it { is_expected.to be_denied_for(:user) }
|
|
|
|
it { is_expected.to be_denied_for(:external) }
|
|
|
|
it { is_expected.to be_denied_for(:visitor) }
|
|
|
|
end
|
2016-03-09 11:57:57 -05:00
|
|
|
end
|