feat: audit vocabulary/term/authority creation, attributing the acting user (#21)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use db::{Db, authority};
|
||||
use domain::{AuthorityKind, LocalizedLabel, NewAuthority};
|
||||
use domain::{AuditActor, AuthorityKind, LocalizedLabel, NewAuthority};
|
||||
use sqlx::PgPool;
|
||||
|
||||
fn new_person(name_sv: &str, name_en: &str) -> NewAuthority {
|
||||
@@ -24,9 +24,13 @@ async fn authority_round_trips_with_labels(pool: PgPool) {
|
||||
let db = Db::from_pool(pool);
|
||||
|
||||
let mut tx = db.pool().begin().await.unwrap();
|
||||
let id = authority::create_authority(&mut tx, &new_person("Carl Larsson", "Carl Larsson"))
|
||||
.await
|
||||
.unwrap();
|
||||
let id = authority::create_authority(
|
||||
&mut tx,
|
||||
AuditActor::System,
|
||||
&new_person("Carl Larsson", "Carl Larsson"),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
tx.commit().await.unwrap();
|
||||
|
||||
let got = authority::authority_by_id(db.pool(), id)
|
||||
@@ -47,11 +51,12 @@ async fn list_by_kind_filters(pool: PgPool) {
|
||||
let db = Db::from_pool(pool);
|
||||
|
||||
let mut tx = db.pool().begin().await.unwrap();
|
||||
authority::create_authority(&mut tx, &new_person("A", "A"))
|
||||
authority::create_authority(&mut tx, AuditActor::System, &new_person("A", "A"))
|
||||
.await
|
||||
.unwrap();
|
||||
authority::create_authority(
|
||||
&mut tx,
|
||||
AuditActor::System,
|
||||
&NewAuthority {
|
||||
kind: AuthorityKind::Place,
|
||||
external_uri: None,
|
||||
@@ -83,7 +88,7 @@ async fn resolve_authority_returns_kind(pool: PgPool) {
|
||||
let db = Db::from_pool(pool);
|
||||
|
||||
let mut tx = db.pool().begin().await.unwrap();
|
||||
let id = authority::create_authority(&mut tx, &new_person("X", "X"))
|
||||
let id = authority::create_authority(&mut tx, AuditActor::System, &new_person("X", "X"))
|
||||
.await
|
||||
.unwrap();
|
||||
tx.commit().await.unwrap();
|
||||
@@ -108,6 +113,7 @@ async fn authority_with_no_labels_round_trips_empty(pool: PgPool) {
|
||||
let mut tx = db.pool().begin().await.unwrap();
|
||||
let id = authority::create_authority(
|
||||
&mut tx,
|
||||
AuditActor::System,
|
||||
&NewAuthority {
|
||||
kind: AuthorityKind::Organisation,
|
||||
external_uri: None,
|
||||
|
||||
Reference in New Issue
Block a user