diff options
author | Robert Speicher <robert@gitlab.com> | 2016-07-06 18:06:01 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-07-06 18:06:01 +0300 |
commit | be018ba8c4f61babfea494a3946df9931d476a8a (patch) | |
tree | cf5acc63374a7a570ae03deaf1800b183806be07 /spec/models | |
parent | 400f9f72233c6c5390367a95bf11ebee09c86d2c (diff) | |
parent | 54a50bf81d7bb304adaedffd8eb3e0bc0fc348a9 (diff) |
Merge branch 'fix/import-url-validator' into 'master'
Fixing URL validation for import_url on projects
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/17536
This MR fixes problems related to bypassing `import_url` validation on projects. This makes sure the URL is properly validated so we don't enter crap and fail while running workers that handle this URL.
It also adds a migration to fix current invalid `import_url`s
See merge request !4753
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/project_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a8c777d1e3e..2e89d6de3a2 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -129,6 +129,18 @@ describe Project, models: true do expect(project2.errors[:repository_storage].first).to match(/is not included in the list/) end end + + it 'should not allow an invalid URI as import_url' do + project2 = build(:project, import_url: 'invalid://') + + expect(project2).not_to be_valid + end + + it 'should allow a valid URI as import_url' do + project2 = build(:project, import_url: 'ssh://test@gitlab.com/project.git') + + expect(project2).to be_valid + end end describe 'default_scope' do |