Commit e13d699a authored by Douwe Maan's avatar Douwe Maan

Merge branch '3312-fix-500-in-ssh-host-keys-action' into 'master'

Fix a 500 error in the SSH host keys lookup action

Closes #3312

See merge request !2827
parents 272abb33 75a86ef8
---
title: Fix a 500 error in the SSH host keys lookup action
merge_request: 2827
author:
type: fixed
...@@ -125,5 +125,7 @@ class SshHostKey ...@@ -125,5 +125,7 @@ class SshHostKey
raise ArgumentError.new("Invalid URL") unless full_url&.scheme == 'ssh' raise ArgumentError.new("Invalid URL") unless full_url&.scheme == 'ssh'
Addressable::URI.parse("ssh://#{full_url.host}:#{full_url.inferred_port}") Addressable::URI.parse("ssh://#{full_url.host}:#{full_url.inferred_port}")
rescue Addressable::URI::InvalidURIError
raise ArgumentError.new("Invalid URL")
end end
end end
...@@ -223,12 +223,16 @@ describe Projects::MirrorsController do ...@@ -223,12 +223,16 @@ describe Projects::MirrorsController do
sign_in(project.owner) sign_in(project.owner)
end end
context 'invalid URL' do context 'invalid URLs' do
it 'returns an error with a 400 response' do where(url: %w[INVALID git@example.com:foo/bar.git ssh://git@example.com:foo/bar.git])
do_get(project, 'INVALID URL')
expect(response).to have_http_status(400) with_them do
expect(json_response).to eq('message' => 'Invalid URL') it 'returns an error with a 400 response' do
do_get(project, url)
expect(response).to have_http_status(400)
expect(json_response).to eq('message' => 'Invalid URL')
end
end end
end end
......
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