diff --git a/doc/administration/audit_event_streaming/audit_event_types.md b/doc/administration/audit_event_streaming/audit_event_types.md index cb3b38d499dc2f505dd20a478b743b30a7269a11..b69f181539495c48807db9fc9b0a50710a990141 100644 --- a/doc/administration/audit_event_streaming/audit_event_types.md +++ b/doc/administration/audit_event_streaming/audit_event_types.md @@ -176,6 +176,7 @@ Every audit event is associated with an event type. The association with the eve | [`project_created`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117543) | Event triggered when a project is created. | **{check-circle}** Yes | **{check-circle}** Yes | `groups_and_projects` | GitLab [16.0](https://gitlab.com/gitlab-org/gitlab/-/issues/374105) | | [`project_default_branch_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117543) | Event triggered when default branch of a project's repository is updated. | **{check-circle}** Yes | **{check-circle}** Yes | `groups_and_projects` | GitLab [16.0](https://gitlab.com/gitlab-org/gitlab/-/issues/374105) | | [`project_deletion_marked`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117546) | Event triggered when a project is marked for deletion. | **{check-circle}** Yes | **{check-circle}** Yes | `compliance_management` | GitLab [15.11](https://gitlab.com/gitlab-org/gitlab/-/issues/374105) | +| [`project_description_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128978) | Triggered when a project's description is updated | **{dotted-circle}** No | **{check-circle}** Yes | `groups_and_projects` | GitLab [16.3](https://gitlab.com/gitlab-org/gitlab/-/issues/377769) | | [`project_destroyed`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117546) | Event triggered when a project is destroyed. | **{check-circle}** Yes | **{check-circle}** Yes | `compliance_management` | GitLab [15.11](https://gitlab.com/gitlab-org/gitlab/-/issues/374105) | | [`project_disable_overriding_approvers_per_merge_request_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/106652) | audit when project disable overriding approvers per mr setting is updated | **{check-circle}** Yes | **{check-circle}** Yes | `groups_and_projects` | GitLab [15.7](https://gitlab.com/gitlab-org/gitlab/-/issues/369288) | | [`project_export_file_download_started`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/117528) | Event triggered when download of project export file gets started. | **{check-circle}** Yes | **{check-circle}** Yes | `compliance_management` | GitLab [15.11](https://gitlab.com/gitlab-org/gitlab/-/issues/374105) | diff --git a/ee/config/audit_events/types/project_description_updated.yml b/ee/config/audit_events/types/project_description_updated.yml new file mode 100644 index 0000000000000000000000000000000000000000..e89a73fd7e7b3ce560673cbb49628ed08c18658e --- /dev/null +++ b/ee/config/audit_events/types/project_description_updated.yml @@ -0,0 +1,9 @@ +--- +name: project_description_updated +description: Triggered when a project's description is updated +introduced_by_issue: https://gitlab.com/gitlab-org/gitlab/-/issues/377769 +introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128978 +feature_category: groups_and_projects +milestone: '16.3' +saved_to_database: false +streamed: true diff --git a/ee/lib/audit/project_changes_auditor.rb b/ee/lib/audit/project_changes_auditor.rb index 5403dbce8101b0b0401422a9a1bca1123410729c..7ab8f101079a8d85847621111e9657227e151542 100644 --- a/ee/lib/audit/project_changes_auditor.rb +++ b/ee/lib/audit/project_changes_auditor.rb @@ -3,6 +3,7 @@ module Audit class ProjectChangesAuditor < BaseChangesAuditor def execute + audit_changes(:description, as: 'description', model: model, event_type: 'project_description_updated') audit_changes( :visibility_level, as: 'visibility_level', diff --git a/ee/spec/lib/audit/project_changes_auditor_spec.rb b/ee/spec/lib/audit/project_changes_auditor_spec.rb index ccc759785a71d6129e8dd3481fe27c2ead3bccca..f65d39b7aa3eaef14e192291319e81a9ba12f71c 100644 --- a/ee/spec/lib/audit/project_changes_auditor_spec.rb +++ b/ee/spec/lib/audit/project_changes_auditor_spec.rb @@ -8,12 +8,13 @@ let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } - let(:project) do + let_it_be(:project) do create( :project, group: group, visibility_level: 0, name: 'interesting name', + description: "Prince", path: 'interesting-path', repository_size_limit: 10, packages_enabled: true, @@ -79,14 +80,6 @@ end end - describe 'non audit changes' do - it 'does not call the audit event service' do - project.update!(description: 'new description') - - expect { auditor_instance.execute }.not_to change(AuditEvent, :count) - end - end - describe 'audit changes' do context 'when project visibility_level is updated' do let(:change) { "visibility_level" } @@ -101,6 +94,19 @@ it_behaves_like 'project_audit_events_from_to' end + context 'when project description is updated' do + let(:change) { "description" } + let(:event) { "project_description_updated" } + let(:change_from) { "Prince" } + let(:change_to) { "The Artist formerly known as Prince" } + + before do + project.update!(description: 'The Artist formerly known as Prince') + end + + it_behaves_like 'project_audit_events_from_to' + end + context 'when project name is updated' do let(:change) { "name" } let(:event) { "project_name_updated" }