Commit 75a86ef8 authored by Nick Thomas's avatar Nick Thomas

Fix a 500 error in the SSH host keys lookup action

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