Commit 788c82fd authored by Douwe Maan's avatar Douwe Maan

Merge branch '3588-fix-removing-username-from-import-url' into 'master'

Fix removing the username from the git repository URL for pull mirroring

Closes #3588

See merge request gitlab-org/gitlab-ee!3060
parents 19999388 fa40b662
---
title: Fix removing the username from the git repository URL for pull mirroring
merge_request: 3060
author:
type: fixed
...@@ -366,7 +366,7 @@ module EE ...@@ -366,7 +366,7 @@ module EE
end end
url = ::Gitlab::UrlSanitizer.new(value) url = ::Gitlab::UrlSanitizer.new(value)
creds = url.credentials.slice(:user) if url.credentials[:user].present? creds = url.credentials.slice(:user)
write_attribute(:import_url, url.sanitized_url) write_attribute(:import_url, url.sanitized_url)
create_or_update_import_data(credentials: creds) create_or_update_import_data(credentials: creds)
......
...@@ -70,11 +70,12 @@ feature 'Project mirror', js: true do ...@@ -70,11 +70,12 @@ feature 'Project mirror', js: true do
before do before do
project.add_master(user) project.add_master(user)
sign_in(user) sign_in(user)
visit project_settings_repository_path(project)
end end
describe 'password authentication' do describe 'password authentication' do
it 'can be set up' do it 'can be set up' do
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
check 'Mirror repository' check 'Mirror repository'
fill_in 'Git repository URL', with: 'http://user@example.com' fill_in 'Git repository URL', with: 'http://user@example.com'
...@@ -89,10 +90,30 @@ feature 'Project mirror', js: true do ...@@ -89,10 +90,30 @@ feature 'Project mirror', js: true do
expect(import_data.auth_method).to eq('password') expect(import_data.auth_method).to eq('password')
expect(project.import_url).to eq('http://user:foo@example.com') expect(project.import_url).to eq('http://user:foo@example.com')
end end
it 'can be changed to unauthenticated' do
project.update!(import_url: 'http://user:password@example.com')
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do
fill_in 'Git repository URL', with: 'http://2.example.com'
fill_in 'Password', with: ''
click_without_sidekiq 'Save changes'
end
expect(page).to have_content('Mirroring settings were successfully updated')
project.reload
expect(import_data.auth_method).to eq('password')
expect(project.import_url).to eq('http://2.example.com')
end
end end
describe 'SSH public key authentication' do describe 'SSH public key authentication' do
it 'can be set up' do it 'can be set up' do
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
check 'Mirror repository' check 'Mirror repository'
fill_in 'Git repository URL', with: 'ssh://user@example.com' fill_in 'Git repository URL', with: 'ssh://user@example.com'
...@@ -137,6 +158,8 @@ feature 'Project mirror', js: true do ...@@ -137,6 +158,8 @@ feature 'Project mirror', js: true do
it 'fills fingerprints and host keys when detecting' do it 'fills fingerprints and host keys when detecting' do
stub_reactive_cache(cache, known_hosts: key.key_text) stub_reactive_cache(cache, known_hosts: key.key_text)
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
fill_in 'Git repository URL', with: 'ssh://example.com' fill_in 'Git repository URL', with: 'ssh://example.com'
click_on 'Detect host keys' click_on 'Detect host keys'
...@@ -153,6 +176,8 @@ feature 'Project mirror', js: true do ...@@ -153,6 +176,8 @@ feature 'Project mirror', js: true do
it 'displays error if detection fails' do it 'displays error if detection fails' do
stub_reactive_cache(cache, error: 'Some error text here') stub_reactive_cache(cache, error: 'Some error text here')
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
fill_in 'Git repository URL', with: 'ssh://example.com' fill_in 'Git repository URL', with: 'ssh://example.com'
click_on 'Detect host keys' click_on 'Detect host keys'
...@@ -164,6 +189,8 @@ feature 'Project mirror', js: true do ...@@ -164,6 +189,8 @@ feature 'Project mirror', js: true do
end end
it 'allows manual host keys entry' do it 'allows manual host keys entry' do
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
fill_in 'Git repository URL', with: 'ssh://example.com' fill_in 'Git repository URL', with: 'ssh://example.com'
click_on 'Show advanced' click_on 'Show advanced'
...@@ -178,6 +205,8 @@ feature 'Project mirror', js: true do ...@@ -178,6 +205,8 @@ feature 'Project mirror', js: true do
describe 'authentication methods' do describe 'authentication methods' do
it 'shows SSH related fields for an SSH URL' do it 'shows SSH related fields for an SSH URL' do
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
fill_in 'Git repository URL', with: 'ssh://example.com' fill_in 'Git repository URL', with: 'ssh://example.com'
...@@ -198,6 +227,8 @@ feature 'Project mirror', js: true do ...@@ -198,6 +227,8 @@ feature 'Project mirror', js: true do
end end
it 'hides SSH-related fields for a HTTP URL' do it 'hides SSH-related fields for a HTTP URL' do
visit project_settings_repository_path(project)
page.within('.project-mirror-settings') do page.within('.project-mirror-settings') do
fill_in 'Git repository URL', with: 'https://example.com' fill_in 'Git repository URL', with: 'https://example.com'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment