Draft: Add audit event when project avatar is updated
What does this MR do and why?
Closes #8056
Adds audit event whenever project avatar is updated.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Merge request reports
Activity
Hey @harshitprasad!
👋 Thank you for your contribution to GitLab. Please refer to the contribution documentation for an overview of the process.
When you're ready for a first review, post
@gitlab-bot ready
. If you know a relevant reviewer(s) (for example, someone that was involved in a related issue), you can also assign them directly with@gitlab-bot ready @user1 @user2
.At any time, if you need help, feel free to post
@gitlab-bot help
or initiate a mentor session on Discord. Read more on how to get help.You can comment
@gitlab-bot label <label1> <label2>
to add labels to your MR. Please see the list of allowed labels in thelabel
command documentation.This message was generated automatically. You're welcome to improve it.
added Community contribution workflowin dev labels
assigned to @harshitprasad
This merge request will be counted as part of the running Hackathon!
Check out the Hackathon page for more information!
🎉 This message was generated automatically. You're welcome to improve it.
added Hackathon label
mentioned in issue #8056
added linked-issue label
mentioned in issue gitlab-org/quality/triage-reports#14361 (closed)
requested review from @huzaifaiftikhar1
added backend featureenhancement groupcompliance labels
added typefeature label
added devopsgovern sectionsec labels
changed milestone to %16.5
- Resolved by Harshit Prasad
Issue: This job in the pipeline failed with the following error "Audit event types documentation is outdated! Please update it by running
bundle exec rake gitlab:audit_event_types:compile_docs
."Can you please run
bundle exec rake gitlab:audit_event_types:compile_docs
and commit the changes that are auto-generated?I tried running the command but, it gives me config error.
> bundle exec rake gitlab:audit_event_types:compile_docs rake aborted! Cannot load database configuration: Could not load database configuration. No such file - ["config/database.yml"]
Tried few things to resolve it and got another error related to secrets.yml:
Missing Rails.application.secrets.secret_key_base for development environment. The secret will be generated and stored in config/secrets.yml. Missing Rails.application.secrets.otp_key_base for development environment. The secret will be generated and stored in config/secrets.yml. Missing Rails.application.secrets.db_key_base for development environment. The secret will be generated and stored in config/secrets.yml. Missing Rails.application.secrets.openid_connect_signing_key for development environment. The secret will be generated and stored in config/secrets.yml. rake aborted!
The
config/secrets.yml
already exists with all the mentioned keys. Not sure, why it's not working.@harshitprasad This look weird as this command works fine for me locally, can you try setting up a clean GDK again and retry the command? You can also use Gitpod for development. In case this doesn't work then I will try run the command and push the changes. What do you think?
- Resolved by Harshit Prasad
3 3 module Audit 4 4 class ProjectChangesAuditor < BaseChangesAuditor 5 5 def execute 6 audit_changes(:avatar, as: 'avatar', model: model, event_type: 'project_avatar_updated') The RSpecs that have been added failed in this job. Can you please take a look and fix them?
RSpec failure logs
Audit::ProjectChangesAuditor # order random .audit_changes audit changes when project avatar is updated behaves like project_audit_events_from_to calls auditor (FAILED - 1) 1st Try error in ./ee/spec/lib/audit/project_changes_auditor_spec.rb:39: #<Gitlab::Audit::Auditor (class)> received :audit with unexpected arguments expected: ({:additional_details=>{:change=>"avatar", :from=>"interesting avatar", :target_details=>"group1/inter...>>, :target=>#<Project id:169 group1/interesting-path>>, :target_details=>"group1/interesting-path"}) got: ({:additional_details=>{:change=>"avatar", :from=>nil, :target_details=>"group1/interesting-path", :to...>>, :target=>#<Project id:169 group1/interesting-path>>, :target_details=>"group1/interesting-path"}) Diff: @@ -1,10 +1,10 @@ [{:additional_details=> {:change=>"avatar", - :from=>"interesting avatar", + :from=>nil, :target_details=>"group1/interesting-path", - :to=>"super cool avatar"}, + :to=>nil}, :author=>#<User id:131 @user1>, - :message=>"Changed avatar from interesting avatar to super cool avatar", + :message=>"Changed avatar", :name=>"project_avatar_updated", :scope=>#<Project id:169 group1/interesting-path>>, :target=>#<Project id:169 group1/interesting-path>>,
Thanks for working on this @harshitprasad, I've added a few comments, can you please take a look at those and ping me when ready for another review?
removed review request for @huzaifaiftikhar1
added 1 commit
- 453ceb8b - Added rspec for project avatar update audit event