Skip to content

fix(audit): skip LogAuditEvent when Auditor is disabled - #16

Open
ginaxu1 wants to merge 2 commits into
mainfrom
fix/middleware-respect-isenabled
Open

ginaxu1 wants to merge 2 commits into
mainfrom
fix/middleware-respect-isenabled

Conversation

@ginaxu1

@ginaxu1 ginaxu1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • AuditMiddleware.LogAuditEvent now returns early when client == nil or !client.IsEnabled(), matching the documented NewAuditMiddleware / InitializeGlobalAudit contract.
  • Adds thorough middleware unit tests (nil client, disabled/enabled custom Auditor, context/request forwarding, global init once-semantics, uninitialized warn).

Related: discovered while wiring audit in openndx-core; openndx/openndx-core#585 deferred asserting no events when disabled until Argus honors IsEnabled() in middleware.

Test plan

  • cd pkg/audit && go test -count=1 .
  • cd pkg/audit && go vet .
  • After merge: cut pkg/audit release tag so openndx-core can bump and assert len(mockClient.receivedEvents) == 0 in TestLogAuditEventWhenNotConfigured

Honor IsEnabled() in middleware so custom Auditor mocks are not invoked
when disabled, matching the documented NewAuditMiddleware contract.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover nil/disabled/enabled LogAuditEvent paths, global init once-semantics,
and uninitialized warn behavior so custom Auditor mocks are protected.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant