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
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,12 +223,16 @@ describe Projects::MirrorsController do
sign_in(project.owner)
end
context 'invalid URL' do
it 'returns an error with a 400 response' do
do_get(project, 'INVALID URL')
context 'invalid URLs' do
where(url: %w[INVALID git@example.com:foo/bar.git ssh://git@example.com:foo/bar.git])
expect(response).to have_http_status(400)
expect(json_response).to eq('message' => 'Invalid URL')
with_them do
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
......
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