Commit 7b798038 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '273379-incorrect-status-code-ssh-deletion' into 'master'

Return 404 when deleting non-existant SSH key

See merge request gitlab-org/gitlab!46450
parents 122c9c2e e0e5ee4e
......@@ -17,16 +17,14 @@ module CredentialsInventoryActions
def destroy
key = KeysFinder.new({ users: users, key_type: 'ssh' }).find_by_id(params[:id])
alert = if key.present?
if Keys::DestroyService.new(current_user).execute(key)
return render_404 if key.nil?
alert = if Keys::DestroyService.new(current_user).execute(key)
notify_deleted_or_revoked_credential(key)
_('User key was successfully removed.')
else
_('Failed to remove user key.')
end
else
_('Cannot find user key.')
end
redirect_to credentials_inventory_path(filter: 'ssh_keys'), status: :found, notice: alert
end
......
---
title: Return 404 when attempting to delete non-existent SSH key
merge_request: 46450
author:
type: fixed
......@@ -63,8 +63,7 @@ RSpec.shared_examples_for 'credentials inventory controller delete SSH key' do |
it 'renders a not found message' do
subject
expect(response).to redirect_to(credentials_path)
expect(flash[:notice]).to eql 'Cannot find user key.'
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -4853,9 +4853,6 @@ msgstr ""
msgid "Cannot enable shared runners because parent group does not allow it"
msgstr ""
msgid "Cannot find user key."
msgstr ""
msgid "Cannot have multiple Jira imports running at the same time"
msgstr ""
......
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