2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
RSpec.describe Gitlab::ProjectAuthorizations, feature_category: :system_access do
|
2017-09-10 17:25:29 +05:30
|
|
|
def map_access_levels(rows)
|
|
|
|
rows.each_with_object({}) do |row, hash|
|
|
|
|
hash[row.project_id] = row.access_level
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
subject(:authorizations) do
|
2019-10-12 21:52:04 +05:30
|
|
|
described_class.new(user).calculate
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
# Inline this shared example while cleaning up feature flag linear_project_authorization
|
|
|
|
RSpec.shared_examples 'project authorizations' do
|
|
|
|
context 'user added to group and project' do
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let!(:other_project) { create(:project) }
|
|
|
|
let!(:group_project) { create(:project, namespace: group) }
|
|
|
|
let!(:owned_project) { create(:project) }
|
|
|
|
let(:user) { owned_project.namespace.owner }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
other_project.add_reporter(user)
|
|
|
|
group.add_developer(user)
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'returns the correct number of authorizations' do
|
|
|
|
expect(authorizations.length).to eq(3)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'includes the correct projects' do
|
|
|
|
expect(authorizations.pluck(:project_id))
|
|
|
|
.to include(owned_project.id, other_project.id, group_project.id)
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'includes the correct access levels' do
|
|
|
|
mapping = map_access_levels(authorizations)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[owned_project.id]).to eq(Gitlab::Access::OWNER)
|
|
|
|
expect(mapping[other_project.id]).to eq(Gitlab::Access::REPORTER)
|
|
|
|
expect(mapping[group_project.id]).to eq(Gitlab::Access::DEVELOPER)
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'unapproved access request' do
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
subject(:mapping) { map_access_levels(authorizations) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'group membership' do
|
|
|
|
let!(:group_project) { create(:project, namespace: group) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_member, :developer, :access_request, user: user, group: group)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[group_project.id]).to be_nil
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'inherited group membership' do
|
|
|
|
let!(:sub_group) { create(:group, parent: group) }
|
|
|
|
let!(:sub_group_project) { create(:project, namespace: sub_group) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_member, :developer, :access_request, user: user, group: group)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[sub_group_project.id]).to be_nil
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'project membership' do
|
|
|
|
let!(:group_project) { create(:project, namespace: group) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:project_member, :developer, :access_request, user: user, project: group_project)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[group_project.id]).to be_nil
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'shared group' do
|
|
|
|
let!(:shared_group) { create(:group) }
|
|
|
|
let!(:shared_group_project) { create(:project, namespace: shared_group) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_group_link, shared_group: shared_group, shared_with_group: group)
|
|
|
|
create(:group_member, :developer, :access_request, user: user, group: group)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[shared_group_project.id]).to be_nil
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'shared project' do
|
|
|
|
let!(:another_group) { create(:group) }
|
|
|
|
let!(:shared_project) { create(:project, namespace: another_group) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:project_group_link, group: group, project: shared_project)
|
|
|
|
create(:group_member, :developer, :access_request, user: user, group: group)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[shared_project.id]).to be_nil
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'user with minimal access to group' do
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
subject(:mapping) { map_access_levels(authorizations) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'group membership' do
|
|
|
|
let!(:group_project) { create(:project, namespace: group) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_member, :minimal_access, user: user, source: group)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[group_project.id]).to be_nil
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'inherited group membership' do
|
|
|
|
let!(:sub_group) { create(:group, parent: group) }
|
|
|
|
let!(:sub_group_project) { create(:project, namespace: sub_group) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_member, :minimal_access, user: user, source: group)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[sub_group_project.id]).to be_nil
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'shared group' do
|
|
|
|
let!(:shared_group) { create(:group) }
|
|
|
|
let!(:shared_group_project) { create(:project, namespace: shared_group) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_group_link, shared_group: shared_group, shared_with_group: group)
|
|
|
|
create(:group_member, :minimal_access, user: user, source: group)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[shared_group_project.id]).to be_nil
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'shared project' do
|
|
|
|
let!(:another_group) { create(:group) }
|
|
|
|
let!(:shared_project) { create(:project, namespace: another_group) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:project_group_link, group: group, project: shared_project)
|
|
|
|
create(:group_member, :minimal_access, user: user, source: group)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[shared_project.id]).to be_nil
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'with nested groups' do
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let!(:nested_group) { create(:group, parent: group) }
|
|
|
|
let!(:nested_project) { create(:project, namespace: nested_group) }
|
|
|
|
let(:user) { create(:user) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'includes nested groups' do
|
|
|
|
expect(authorizations.pluck(:project_id)).to include(nested_project.id)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'inherits access levels when the user is not a member of a nested group' do
|
|
|
|
mapping = map_access_levels(authorizations)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[nested_project.id]).to eq(Gitlab::Access::DEVELOPER)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'uses the greatest access level when a user is a member of a nested group' do
|
|
|
|
nested_group.add_maintainer(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
mapping = map_access_levels(authorizations)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[nested_project.id]).to eq(Gitlab::Access::MAINTAINER)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'with shared projects' do
|
|
|
|
let_it_be(:shared_with_group) { create(:group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, group: create(:group)) }
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
let(:mapping) { map_access_levels(authorizations) }
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
before do
|
2023-07-09 08:55:56 +05:30
|
|
|
create(:project_group_link, :developer, project: project, group: shared_with_group)
|
|
|
|
shared_with_group.add_maintainer(user)
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates proper authorizations' do
|
|
|
|
expect(mapping[project.id]).to eq(Gitlab::Access::DEVELOPER)
|
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'even when the `lock_memberships_to_ldap` setting has been turned ON' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(lock_memberships_to_ldap: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates proper authorizations' do
|
|
|
|
expect(mapping[project.id]).to eq(Gitlab::Access::DEVELOPER)
|
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'when the group containing the project has forbidden group shares for any of its projects' do
|
|
|
|
before do
|
|
|
|
project.namespace.update!(share_with_group_lock: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create authorizations' do
|
|
|
|
expect(mapping[project.id]).to be_nil
|
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'with shared groups' do
|
|
|
|
let(:parent_group_user) { create(:user) }
|
|
|
|
let(:group_user) { create(:user) }
|
|
|
|
let(:child_group_user) { create(:user) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
let_it_be(:group_parent) { create(:group, :private) }
|
|
|
|
let_it_be(:group) { create(:group, :private, parent: group_parent) }
|
|
|
|
let_it_be(:group_child) { create(:group, :private, parent: group) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
let_it_be(:shared_group_parent) { create(:group, :private) }
|
|
|
|
let_it_be(:shared_group) { create(:group, :private, parent: shared_group_parent) }
|
|
|
|
let_it_be(:shared_group_child) { create(:group, :private, parent: shared_group) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
let_it_be(:project_parent) { create(:project, group: shared_group_parent) }
|
|
|
|
let_it_be(:project) { create(:project, group: shared_group) }
|
|
|
|
let_it_be(:project_child) { create(:project, group: shared_group_child) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
group_parent.add_owner(parent_group_user)
|
|
|
|
group.add_owner(group_user)
|
|
|
|
group_child.add_owner(child_group_user)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
create(:group_group_link, shared_group: shared_group, shared_with_group: group)
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'group user' do
|
|
|
|
let(:user) { group_user }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'creates proper authorizations' do
|
|
|
|
mapping = map_access_levels(authorizations)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[project_parent.id]).to be_nil
|
|
|
|
expect(mapping[project.id]).to eq(Gitlab::Access::DEVELOPER)
|
|
|
|
expect(mapping[project_child.id]).to eq(Gitlab::Access::DEVELOPER)
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'with lower group access level than max access level for share' do
|
|
|
|
let(:user) { create(:user) }
|
2020-03-07 23:17:34 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'creates proper authorizations' do
|
|
|
|
group.add_reporter(user)
|
2020-03-07 23:17:34 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
mapping = map_access_levels(authorizations)
|
2020-03-07 23:17:34 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[project_parent.id]).to be_nil
|
|
|
|
expect(mapping[project.id]).to eq(Gitlab::Access::REPORTER)
|
|
|
|
expect(mapping[project_child.id]).to eq(Gitlab::Access::REPORTER)
|
|
|
|
end
|
2020-03-07 23:17:34 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'parent group user' do
|
|
|
|
let(:user) { parent_group_user }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'creates proper authorizations' do
|
|
|
|
mapping = map_access_levels(authorizations)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[project_parent.id]).to be_nil
|
|
|
|
expect(mapping[project.id]).to be_nil
|
|
|
|
expect(mapping[project_child.id]).to be_nil
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'child group user' do
|
|
|
|
let(:user) { child_group_user }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'creates proper authorizations' do
|
|
|
|
mapping = map_access_levels(authorizations)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[project_parent.id]).to be_nil
|
|
|
|
expect(mapping[project.id]).to be_nil
|
|
|
|
expect(mapping[project_child.id]).to be_nil
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'user without accepted access request' do
|
|
|
|
let!(:user) { create(:user) }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not have access to group and its projects' do
|
|
|
|
create(:group_member, :developer, :access_request, user: user, group: group)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
mapping = map_access_levels(authorizations)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[project_parent.id]).to be_nil
|
|
|
|
expect(mapping[project.id]).to be_nil
|
|
|
|
expect(mapping[project_child.id]).to be_nil
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'unrelated project owner' do
|
|
|
|
let(:common_id) { non_existing_record_id }
|
|
|
|
let!(:group) { create(:group, id: common_id) }
|
|
|
|
let!(:unrelated_project) { create(:project, id: common_id) }
|
|
|
|
let(:user) { unrelated_project.first_owner }
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not have access to group and its projects' do
|
|
|
|
mapping = map_access_levels(authorizations)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(mapping[project_parent.id]).to be_nil
|
|
|
|
expect(mapping[project.id]).to be_nil
|
|
|
|
expect(mapping[project_child.id]).to be_nil
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'with pending memberships' do
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
subject(:mapping) { map_access_levels(authorizations) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'group membership' do
|
|
|
|
let!(:group_project) { create(:project, namespace: group) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_member, :developer, :awaiting, user: user, group: group)
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[group_project.id]).to be_nil
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'inherited group membership' do
|
|
|
|
let!(:sub_group) { create(:group, parent: group) }
|
|
|
|
let!(:sub_group_project) { create(:project, namespace: sub_group) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_member, :developer, :awaiting, user: user, group: group)
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[sub_group_project.id]).to be_nil
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'project membership' do
|
|
|
|
let!(:group_project) { create(:project, namespace: group) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:project_member, :developer, :awaiting, user: user, project: group_project)
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[group_project.id]).to be_nil
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'shared group' do
|
|
|
|
let!(:shared_group) { create(:group) }
|
|
|
|
let!(:shared_group_project) { create(:project, namespace: shared_group) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:group_group_link, shared_group: shared_group, shared_with_group: group)
|
|
|
|
create(:group_member, :developer, :awaiting, user: user, group: group)
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[shared_group_project.id]).to be_nil
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
end
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
context 'shared project' do
|
|
|
|
let!(:another_group) { create(:group) }
|
|
|
|
let!(:shared_project) { create(:project, namespace: another_group) }
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
before do
|
|
|
|
create(:project_group_link, group: group, project: shared_project)
|
|
|
|
create(:group_member, :developer, :awaiting, user: user, group: group)
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
it 'does not create authorization' do
|
|
|
|
expect(mapping[shared_project.id]).to be_nil
|
|
|
|
end
|
2022-04-04 11:22:00 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-07-09 08:55:56 +05:30
|
|
|
|
|
|
|
context 'when feature_flag linear_project_authorization_is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(linear_project_authorization: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'project authorizations'
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'project authorizations'
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|