2020-05-04 02:10:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::GitAccessDesign do
|
2020-05-04 02:10:10 -04:00
|
|
|
include DesignManagementTestHelpers
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project) }
|
2022-01-24 07:10:54 -05:00
|
|
|
let_it_be(:user) { project.first_owner }
|
2021-04-21 02:09:28 -04:00
|
|
|
|
2020-05-04 02:10:10 -04:00
|
|
|
let(:protocol) { 'web' }
|
|
|
|
let(:actor) { user }
|
|
|
|
|
|
|
|
subject(:access) do
|
|
|
|
described_class.new(actor, project, protocol, authentication_abilities: [:read_project, :download_code, :push_code])
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#check' do
|
|
|
|
subject { access.check('git-receive-pack', ::Gitlab::GitAccess::ANY) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
enable_design_management
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user is allowed to manage designs' do
|
|
|
|
it do
|
|
|
|
is_expected.to be_a(::Gitlab::GitAccessResult::Success)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the user is not allowed to manage designs' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
|
|
|
it 'raises an error' do
|
|
|
|
expect { subject }.to raise_error(::Gitlab::GitAccess::ForbiddenError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the protocol is not web' do
|
|
|
|
let(:protocol) { 'https' }
|
|
|
|
|
|
|
|
it 'raises an error' do
|
|
|
|
expect { subject }.to raise_error(::Gitlab::GitAccess::ForbiddenError)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|