MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / assert_audit_has

Function assert_audit_has

nodedb-test-support/src/pgwire_auth_helpers.rs:149–165  ·  view source on GitHub ↗

Assert that the audit log contains at least one entry with `event` and `db_id`.

(
    state: &SharedState,
    event: nodedb::control::security::audit::AuditEvent,
    db_id: Option<nodedb_types::id::DatabaseId>,
)

Source from the content-addressed store, hash-verified

147
148/// Assert that the audit log contains at least one entry with `event` and `db_id`.
149pub fn assert_audit_has(
150 state: &SharedState,
151 event: nodedb::control::security::audit::AuditEvent,
152 db_id: Option<nodedb_types::id::DatabaseId>,
153) {
154 let log = state.audit.lock().unwrap_or_else(|p| p.into_inner());
155 assert!(
156 log.all()
157 .iter()
158 .any(|e| e.event == event && e.database_id == db_id),
159 "expected audit event {event:?} for db {db_id:?}, got {:?}",
160 log.all()
161 .iter()
162 .map(|e| (e.event.clone(), e.database_id))
163 .collect::<Vec<_>>()
164 );
165}

Calls 1

lockMethod · 0.80