diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 15:09:45 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 15:09:45 +0000 |
commit | aaf59610548d9b0fd01acfd50e831cbe519ecba2 (patch) | |
tree | b6505abedcd965ebae5118b504b185b63129dc4c /spec/lib/api | |
parent | 1363ca12f1f07c634647cf55c4c16b7401098673 (diff) | |
download | gitlab-ce-aaf59610548d9b0fd01acfd50e831cbe519ecba2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/api')
-rw-r--r-- | spec/lib/api/helpers/custom_validators_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/lib/api/helpers/custom_validators_spec.rb b/spec/lib/api/helpers/custom_validators_spec.rb index 66b86d0a055..a4f2cd3452c 100644 --- a/spec/lib/api/helpers/custom_validators_spec.rb +++ b/spec/lib/api/helpers/custom_validators_spec.rb @@ -61,6 +61,47 @@ describe API::Helpers::CustomValidators do end end + describe API::Helpers::CustomValidators::GitRef do + subject do + described_class.new(['test'], {}, false, scope.new) + end + + context 'valid revision param' do + it 'does not raise a validation error' do + expect_no_validation_error('test' => '4e963fe') + expect_no_validation_error('test' => 'foo/bar/baz') + expect_no_validation_error('test' => "heads/fu\303\237") + expect_no_validation_error('test' => 'a' * 1024) + end + end + + context "revision param contains invalid chars" do + it 'raises a validation error' do + expect_validation_error('test' => '-4e963fe') + expect_validation_error('test' => '4e963fe..ed4ef') + expect_validation_error('test' => '4e96\3fe') + expect_validation_error('test' => '4e96@3fe') + expect_validation_error('test' => '4e9@{63fe') + expect_validation_error('test' => '4e963 fe') + expect_validation_error('test' => '4e96~3fe') + expect_validation_error('test' => '^4e963fe') + expect_validation_error('test' => '4:e963fe') + expect_validation_error('test' => '4e963fe.') + expect_validation_error('test' => 'heads/foo..bar') + expect_validation_error('test' => 'foo/bar/.') + expect_validation_error('test' => 'heads/v@{ation') + expect_validation_error('test' => 'refs/heads/foo.') + expect_validation_error('test' => 'heads/foo\bar') + expect_validation_error('test' => 'heads/f[/bar') + expect_validation_error('test' => "heads/foo\t") + expect_validation_error('test' => "heads/foo\177") + expect_validation_error('test' => "#{'a' * 1025}") + expect_validation_error('test' => nil) + expect_validation_error('test' => '') + end + end + end + describe API::Helpers::CustomValidators::FilePath do subject do described_class.new(['test'], {}, false, scope.new) |