Link project_bot user deletion audit event to its resource if possible
Currently the problem is as a bot user is deleted an audit event is generated for instance level admin
and group owner cannot access that audit event.
We need an audit event at Group and Project level for the owners to know a bot user has been scheduled for deletion either by
- token revocation, https://gitlab.com/gitlab-org/gitlab/-/blob/b492ef2eb88126dad41130f6f91792b9fe1ad8bf/app/services/resource_access_tokens/revoke_service.rb#L24
- membership expiration, https://gitlab.com/gitlab-org/gitlab/-/blob/b492ef2eb88126dad41130f6f91792b9fe1ad8bf/app/workers/remove_expired_members_worker.rb#L56
-
ResourceAccessTokens::InactiveTokensDeletionCronWorker
cron job, https://gitlab.com/gitlab-org/gitlab/-/blob/13f4aca3b9f571fc250cbe112bd4b51fffea4ef2/app/workers/resource_access_tokens/inactive_tokens_deletion_cron_worker.rb
Add specs for all 3 cases to ensure that audit event is created for all deletion flows.
Edited by Bogdan Denkovych