2014-10-07 13:05:24 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-09 10:55:36 +00:00
|
|
|
describe Gitlab::GitAccessWiki, lib: true do
|
2017-06-16 00:03:54 +00:00
|
|
|
let(:access) { Gitlab::GitAccessWiki.new(user, project, 'web', authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
|
2017-01-24 23:42:12 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
2014-10-07 13:05:24 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-06-16 00:03:54 +00:00
|
|
|
let(:redirected_path) { nil }
|
2016-09-16 07:59:10 +00:00
|
|
|
let(:authentication_abilities) do
|
2016-09-15 13:40:53 +00:00
|
|
|
[
|
|
|
|
:read_project,
|
|
|
|
:download_code,
|
|
|
|
:push_code
|
|
|
|
]
|
|
|
|
end
|
2014-10-07 13:05:24 +00:00
|
|
|
|
|
|
|
describe 'push_allowed?' do
|
|
|
|
before do
|
|
|
|
create(:protected_branch, name: 'master', project: project)
|
|
|
|
project.team << [user, :developer]
|
|
|
|
end
|
|
|
|
|
2016-11-02 21:50:44 +00:00
|
|
|
subject { access.check('git-receive-pack', changes) }
|
2014-10-07 13:05:24 +00:00
|
|
|
|
2017-05-19 19:58:45 +00:00
|
|
|
it { expect { subject }.not_to raise_error }
|
2014-10-07 13:05:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def changes
|
|
|
|
['6f6d7e7ed 570e7b2ab refs/heads/master']
|
|
|
|
end
|
2016-11-29 19:31:42 +00:00
|
|
|
|
2016-12-20 13:19:07 +00:00
|
|
|
describe '#access_check_download!' do
|
2016-11-29 19:31:42 +00:00
|
|
|
subject { access.check('git-upload-pack', '_any') }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :developer]
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when wiki feature is enabled' do
|
|
|
|
it 'give access to download wiki code' do
|
2017-05-19 19:58:45 +00:00
|
|
|
expect { subject }.not_to raise_error
|
2016-11-29 19:31:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when wiki feature is disabled' do
|
|
|
|
it 'does not give access to download wiki code' do
|
|
|
|
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
|
|
|
|
|
2017-05-19 19:58:45 +00:00
|
|
|
expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to download code from this project.')
|
2016-11-29 19:31:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-07 13:05:24 +00:00
|
|
|
end
|