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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-01 19:52:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-01 19:52:41 +0300
commita986819a7bce2002018dfafed3900dc3f2e8fb81 (patch)
tree15c063738d999a0aff035c4842885276a9ab6ac4 /spec/lib/gitlab/git_access_spec.rb
parent92d5172ad42ebc62eb78cac21b1e236ad6ace580 (diff)
Add latest changes from gitlab-org/security/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/lib/gitlab/git_access_spec.rb')
-rw-r--r--spec/lib/gitlab/git_access_spec.rb132
1 files changed, 118 insertions, 14 deletions
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 8153886a2ab..85567ab2e55 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -472,31 +472,135 @@ RSpec.describe Gitlab::GitAccess do
let(:actor) { key }
context 'pull code' do
- context 'when project is authorized' do
- before do
- key.projects << project
+ context 'when project is public' do
+ let(:project) { create(:project, :public, :repository, *options) }
+
+ context 'when deploy key exists in the project' do
+ before do
+ key.projects << project
+ end
+
+ context 'when the repository is public' do
+ let(:options) { %i[repository_enabled] }
+
+ it { expect { pull_access_check }.not_to raise_error }
+ end
+
+ context 'when the repository is private' do
+ let(:options) { %i[repository_private] }
+
+ it { expect { pull_access_check }.not_to raise_error }
+ end
+
+ context 'when the repository is disabled' do
+ let(:options) { %i[repository_disabled] }
+
+ it { expect { pull_access_check }.to raise_error('You are not allowed to download code from this project.') }
+ end
end
- it { expect { pull_access_check }.not_to raise_error }
+ context 'when deploy key does not exist in the project' do
+ context 'when the repository is public' do
+ let(:options) { %i[repository_enabled] }
+
+ it { expect { pull_access_check }.not_to raise_error }
+ end
+
+ context 'when the repository is private' do
+ let(:options) { %i[repository_private] }
+
+ it { expect { pull_access_check }.to raise_error('You are not allowed to download code from this project.') }
+ end
+
+ context 'when the repository is disabled' do
+ let(:options) { %i[repository_disabled] }
+
+ it { expect { pull_access_check }.to raise_error('You are not allowed to download code from this project.') }
+ end
+ end
end
- context 'when unauthorized' do
- context 'from public project' do
- let(:project) { create(:project, :public, :repository) }
+ context 'when project is internal' do
+ let(:project) { create(:project, :internal, :repository, *options) }
- it { expect { pull_access_check }.not_to raise_error }
+ context 'when deploy key exists in the project' do
+ before do
+ key.projects << project
+ end
+
+ context 'when the repository is public' do
+ let(:options) { %i[repository_enabled] }
+
+ it { expect { pull_access_check }.not_to raise_error }
+ end
+
+ context 'when the repository is private' do
+ let(:options) { %i[repository_private] }
+
+ it { expect { pull_access_check }.not_to raise_error }
+ end
+
+ context 'when the repository is disabled' do
+ let(:options) { %i[repository_disabled] }
+
+ it { expect { pull_access_check }.to raise_error('You are not allowed to download code from this project.') }
+ end
end
- context 'from internal project' do
- let(:project) { create(:project, :internal, :repository) }
+ context 'when deploy key does not exist in the project' do
+ context 'when the repository is public' do
+ let(:options) { %i[repository_enabled] }
- it { expect { pull_access_check }.to raise_not_found }
+ it { expect { pull_access_check }.to raise_error('The project you were looking for could not be found.') }
+ end
+
+ context 'when the repository is private' do
+ let(:options) { %i[repository_private] }
+
+ it { expect { pull_access_check }.to raise_error('The project you were looking for could not be found.') }
+ end
+
+ context 'when the repository is disabled' do
+ let(:options) { %i[repository_disabled] }
+
+ it { expect { pull_access_check }.to raise_error('The project you were looking for could not be found.') }
+ end
end
+ end
- context 'from private project' do
- let(:project) { create(:project, :private, :repository) }
+ context 'when project is private' do
+ let(:project) { create(:project, :private, :repository, *options) }
- it { expect { pull_access_check }.to raise_not_found }
+ context 'when deploy key exists in the project' do
+ before do
+ key.projects << project
+ end
+
+ context 'when the repository is private' do
+ let(:options) { %i[repository_private] }
+
+ it { expect { pull_access_check }.not_to raise_error }
+ end
+
+ context 'when the repository is disabled' do
+ let(:options) { %i[repository_disabled] }
+
+ it { expect { pull_access_check }.to raise_error('You are not allowed to download code from this project.') }
+ end
+ end
+
+ context 'when deploy key does not exist in the project' do
+ context 'when the repository is private' do
+ let(:options) { %i[repository_private] }
+
+ it { expect { pull_access_check }.to raise_error('The project you were looking for could not be found.') }
+ end
+
+ context 'when the repository is disabled' do
+ let(:options) { %i[repository_disabled] }
+
+ it { expect { pull_access_check }.to raise_error('The project you were looking for could not be found.') }
+ end
end
end
end