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-02-27 00:09:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 00:09:11 +0300
commitf82d5dcab7c3d9a672abc827c92f86887b683a7d (patch)
tree4a4379a82ab825185aaeafdfb9eb0f9029dc286c /spec/lib/api
parent619d0b6922a6cf95d291fbbf5fa3d09e772a1ea8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/api')
-rw-r--r--spec/lib/api/helpers/custom_validators_spec.rb59
1 files changed, 45 insertions, 14 deletions
diff --git a/spec/lib/api/helpers/custom_validators_spec.rb b/spec/lib/api/helpers/custom_validators_spec.rb
index 1ebce2ab5c4..10505210e65 100644
--- a/spec/lib/api/helpers/custom_validators_spec.rb
+++ b/spec/lib/api/helpers/custom_validators_spec.rb
@@ -24,7 +24,38 @@ describe API::Helpers::CustomValidators do
context 'invalid parameters' do
it 'raises a validation error' do
- expect_validation_error({ 'test' => 'some_value' })
+ expect_validation_error('test' => 'some_value')
+ end
+ end
+ end
+
+ describe API::Helpers::CustomValidators::FilePath do
+ subject do
+ described_class.new(['test'], {}, false, scope.new)
+ end
+
+ context 'valid file path' do
+ it 'does not raise a validation error' do
+ expect_no_validation_error('test' => './foo')
+ expect_no_validation_error('test' => './bar.rb')
+ expect_no_validation_error('test' => 'foo%2Fbar%2Fnew%2Ffile.rb')
+ expect_no_validation_error('test' => 'foo%2Fbar%2Fnew')
+ expect_no_validation_error('test' => 'foo%252Fbar%252Fnew%252Ffile.rb')
+ end
+ end
+
+ context 'invalid file path' do
+ it 'raise a validation error' do
+ expect_validation_error('test' => '../foo')
+ expect_validation_error('test' => '../')
+ expect_validation_error('test' => 'foo/../../bar')
+ expect_validation_error('test' => 'foo/../')
+ expect_validation_error('test' => 'foo/..')
+ expect_validation_error('test' => '../')
+ expect_validation_error('test' => '..\\')
+ expect_validation_error('test' => '..\/')
+ expect_validation_error('test' => '%2e%2e%2f')
+ expect_validation_error('test' => '/etc/passwd')
end
end
end
@@ -36,12 +67,12 @@ describe API::Helpers::CustomValidators do
context 'valid parameters' do
it 'does not raise a validation error' do
- expect_no_validation_error({ 'test' => 2 })
- expect_no_validation_error({ 'test' => 100 })
- expect_no_validation_error({ 'test' => 'None' })
- expect_no_validation_error({ 'test' => 'Any' })
- expect_no_validation_error({ 'test' => 'none' })
- expect_no_validation_error({ 'test' => 'any' })
+ expect_no_validation_error('test' => 2)
+ expect_no_validation_error('test' => 100)
+ expect_no_validation_error('test' => 'None')
+ expect_no_validation_error('test' => 'Any')
+ expect_no_validation_error('test' => 'none')
+ expect_no_validation_error('test' => 'any')
end
end
@@ -59,18 +90,18 @@ describe API::Helpers::CustomValidators do
context 'valid parameters' do
it 'does not raise a validation error' do
- expect_no_validation_error({ 'test' => [] })
- expect_no_validation_error({ 'test' => [1, 2, 3] })
- expect_no_validation_error({ 'test' => 'None' })
- expect_no_validation_error({ 'test' => 'Any' })
- expect_no_validation_error({ 'test' => 'none' })
- expect_no_validation_error({ 'test' => 'any' })
+ expect_no_validation_error('test' => [])
+ expect_no_validation_error('test' => [1, 2, 3])
+ expect_no_validation_error('test' => 'None')
+ expect_no_validation_error('test' => 'Any')
+ expect_no_validation_error('test' => 'none')
+ expect_no_validation_error('test' => 'any')
end
end
context 'invalid parameters' do
it 'raises a validation error' do
- expect_validation_error({ 'test' => 'some_other_string' })
+ expect_validation_error('test' => 'some_other_string')
end
end
end