Skip to content

Conversation

chlins
Copy link
Member

@chlins chlins commented Apr 21, 2025

This pull request enhances the audit functionality by introducing support for query parameters in the GetAudits endpoint, improving the filtering and sorting of audit records, and updating the corresponding test cases. Below are the key changes:

Enhancements to Audit Query Functionality:

  • Updated the GetAuditsQuery struct in manager/types/audit.go to include new fields (ActorType, ActorName, EventType, Operation, State, Path, and StatusCode) for filtering audit records. Each field has validation rules for allowed values and formats.
  • Modified the GetAudits method in manager/service/audit.go to apply filtering based on the new query parameters and to sort results by created_at in descending order.

Test Case Updates:

  • Added a new test case in manager/handlers/audit_test.go to verify the GetAudits endpoint's behavior when query parameters are provided. This test ensures correct filtering, pagination, and response structure.

Description

Related Issue

#3811

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Signed-off-by: chlins <chlins.zhang@gmail.com>
@chlins chlins added the enhancement New feature or request label Apr 21, 2025
@chlins chlins added this to the v2.3.0 milestone Apr 21, 2025
@chlins chlins requested a review from a team as a code owner April 21, 2025 04:12
@chlins chlins enabled auto-merge (squash) April 21, 2025 04:14
Copy link

codecov bot commented Apr 21, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.43%. Comparing base (df69b4f) to head (5607dd4).
⚠️ Report is 224 commits behind head on main.

Files with missing lines Patch % Lines
manager/service/audit.go 0.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3970   +/-   ##
=======================================
  Coverage   34.42%   34.43%           
=======================================
  Files         342      342           
  Lines       40079    40087    +8     
=======================================
+ Hits        13799    13802    +3     
- Misses      25372    25379    +7     
+ Partials      908      906    -2     
Flag Coverage Δ
unittests 34.43% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
manager/service/audit.go 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@Liam-Zhao Liam-Zhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chlins chlins merged commit b03e14a into main Apr 22, 2025
27 checks passed
@chlins chlins deleted the feat/audit-query branch April 22, 2025 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants