Skip to content

spp_audit: TestSelfProtection.test_rule_creation_logged asserts nothing #608

Backlog

Description

@gonzalesedwin1123

Problem

TestSelfProtection.test_rule_creation_logged in spp_audit/tests/test_audit_backend.py wraps its assertions in if audit_files:. In a normal run that list is empty, so the test passes without checking anything.

The cause is that SppAuditBackendFile caches its file handle and current date on the class (_file_handle, _current_date). An earlier test (TestFileBackend) opens the day's file in its own temporary directory and then deletes that directory. Later tests that patch OPENSPP_AUDIT_FILE_PATH to a new directory still write through the stale handle, so nothing appears in the directory they inspect.

test_rule_deletion_logged in the same class should be checked for the same pattern.

Expected

  • The tests reset the cached handle before pointing the file backend at their own directory, and assert unconditionally that the entry was written.
  • Consider whether the backend itself should reopen when the configured path changes, not only when the date changes.

Notes

spp_audit/tests/test_rpc_exposure.py (PR #605) has a _reset_file_handle helper that shows the reset.

Activity

  1. added
    bug
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions