Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/git_access_wiki_spec.rb')
-rw-r--r--spec/lib/gitlab/git_access_wiki_spec.rb36
1 files changed, 33 insertions, 3 deletions
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