From 0ea3fcec397b69815975647f5e2aa5fe944a8486 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Jun 2022 11:10:13 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-1-stable-ee --- spec/lib/gitlab/git_access_wiki_spec.rb | 36 ++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'spec/lib/gitlab/git_access_wiki_spec.rb') diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb index de3e674c3a7..11c19c7d3f0 100644 --- a/spec/lib/gitlab/git_access_wiki_spec.rb +++ b/spec/lib/gitlab/git_access_wiki_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Gitlab::GitAccessWiki do redirected_path: redirected_path) end - RSpec.shared_examples 'wiki access by level' do + RSpec.shared_examples 'download wiki access by level' do where(:project_visibility, :project_member?, :wiki_access_level, :wiki_repo?, :expected_behavior) do [ # Private project - is a project member @@ -103,7 +103,7 @@ RSpec.describe Gitlab::GitAccessWiki do subject { access.check('git-upload-pack', Gitlab::GitAccess::ANY) } context 'when actor is a user' do - it_behaves_like 'wiki access by level' + it_behaves_like 'download wiki access by level' end context 'when the actor is a deploy token' do @@ -116,6 +116,36 @@ RSpec.describe Gitlab::GitAccessWiki do subject { access.check('git-upload-pack', changes) } + context 'when the wiki feature is enabled' do + let(:wiki_access_level) { ProjectFeature::ENABLED } + + it { expect { subject }.not_to raise_error } + end + + context 'when the wiki feature is disabled' do + let(:wiki_access_level) { ProjectFeature::DISABLED } + + it { expect { subject }.to raise_wiki_forbidden } + end + + context 'when the wiki feature is private' do + let(:wiki_access_level) { ProjectFeature::PRIVATE } + + it { expect { subject }.to raise_wiki_forbidden } + end + end + + context 'when the actor is a deploy key' do + let_it_be(:actor) { create(:deploy_key) } + let_it_be(:deploy_key_project) { create(:deploy_keys_project, project: project, deploy_key: actor) } + let_it_be(:user) { actor } + + before do + project.project_feature.update_attribute(:wiki_access_level, wiki_access_level) + end + + subject { access.check('git-upload-pack', changes) } + context 'when the wiki is enabled' do let(:wiki_access_level) { ProjectFeature::ENABLED } @@ -140,7 +170,7 @@ RSpec.describe Gitlab::GitAccessWiki do subject { access.check('git-upload-pack', changes) } - it_behaves_like 'wiki access by level' + it_behaves_like 'download wiki access by level' end end -- cgit v1.2.3