Ensure REST API handles SSH key expiry todos
What does this MR do and why?
Ensure REST API handles SSH key expiry todos
This ensures the SSH
todo type properly maps to the SSHKey
API
entity to prevent 500 errors when hitting the REST todos API.
Changelog: fixed
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Create an SSH expiry to-do
- Create an SSH key at http://gdk.test:3000/-/user_settings/ssh_keys
- Set its
expires_at
to today via therails console
:Key.last.update(expires_at: 1.hour.ago)
- Don't set an earlier date here, as the following background job only notifies about the keys that expired today.
- Still in the console, trigger the job that would otherwise run only twice a day:
SshKeys::ExpiredNotificationWorker.new.perform
Hit the REST API
- Navigate to http://gdk.test:3000/api/v4/todos?per_page=100
- On
master
, this should throw a 500 error. - On this branch, the endpoint should load without issues.
- On
Related to #510792
Edited by Paul Gascou-Vaillancourt