diff --git a/tests/common/app.rs b/tests/common/app.rs index 955fbbe..c372272 100644 --- a/tests/common/app.rs +++ b/tests/common/app.rs @@ -44,12 +44,12 @@ impl TestApp { event_log_retention_days: 30, }; - // Seed the admin DID directly so tests don't rely on auto-bootstrap. - sqlx::query("INSERT INTO admins (did) VALUES ($1) ON CONFLICT DO NOTHING") + // Seed the admin user directly so tests don't rely on auto-bootstrap. + sqlx::query("INSERT INTO users (did, is_super) VALUES ($1, TRUE) ON CONFLICT DO NOTHING") .bind(&admin_did) .execute(&pool) .await - .expect("failed to seed admin DID"); + .expect("failed to seed admin user"); let lexicons = LexiconRegistry::new(); lexicons diff --git a/tests/common/db.rs b/tests/common/db.rs index b5db95f..fec9f09 100644 --- a/tests/common/db.rs +++ b/tests/common/db.rs @@ -19,8 +19,10 @@ pub async fn test_pool() -> PgPool { /// Truncate all application tables, preserving schema. pub async fn truncate_all(pool: &PgPool) { - sqlx::query("TRUNCATE records, lexicons, backfill_jobs, admins RESTART IDENTITY CASCADE") - .execute(pool) - .await - .expect("failed to truncate tables"); + sqlx::query( + "TRUNCATE records, lexicons, backfill_jobs, users, user_permissions, api_keys, event_logs, script_variables, dead_letter_hooks, record_refs RESTART IDENTITY CASCADE", + ) + .execute(pool) + .await + .expect("failed to truncate tables"); } diff --git a/tests/e2e_admin.rs b/tests/e2e_admin.rs index 97c1ba9..3e5867f 100644 --- a/tests/e2e_admin.rs +++ b/tests/e2e_admin.rs @@ -125,8 +125,8 @@ async fn admin_non_admin_did_returns_403() { async fn admin_auto_bootstrap_first_user() { let app = TestApp::new().await; - // Clear the seeded admin so the table is empty. - sqlx::query("DELETE FROM admins") + // Clear the seeded user so the table is empty. + sqlx::query("DELETE FROM users") .execute(&app.state.db) .await .unwrap(); @@ -145,7 +145,7 @@ async fn admin_auto_bootstrap_first_user() { assert_eq!(resp.status(), StatusCode::OK); // Verify the DID was inserted. - let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM admins WHERE did = $1") + let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM users WHERE did = $1") .bind(bootstrap_did) .fetch_one(&app.state.db) .await @@ -514,7 +514,7 @@ async fn admin_create_returns_did() { let resp = app .router - .oneshot(admin_post("/admin/admins", &app.admin_token, &body)) + .oneshot(admin_post("/admin/users", &app.admin_token, &body)) .await .unwrap(); @@ -536,7 +536,7 @@ async fn admin_created_did_authenticates() { // Create admin via the existing admin app.router .clone() - .oneshot(admin_post("/admin/admins", &app.admin_token, &body)) + .oneshot(admin_post("/admin/users", &app.admin_token, &body)) .await .unwrap(); @@ -560,7 +560,7 @@ async fn admin_list_returns_dids() { let resp = app .router - .oneshot(admin_get("/admin/admins", &app.admin_token)) + .oneshot(admin_get("/admin/users", &app.admin_token)) .await .unwrap(); @@ -586,7 +586,7 @@ async fn admin_delete_returns_204() { .router .clone() .oneshot(admin_post( - "/admin/admins", + "/admin/users", &app.admin_token, &json!({ "did": "did:plc:disposable" }), )) @@ -598,7 +598,7 @@ async fn admin_delete_returns_204() { let resp = app .router .oneshot(admin_delete( - &format!("/admin/admins/{id}"), + &format!("/admin/users/{id}"), &app.admin_token, )) .await @@ -616,7 +616,7 @@ async fn admin_delete_not_found() { let resp = app .router .oneshot(admin_delete( - "/admin/admins/00000000-0000-0000-0000-000000000000", + "/admin/users/00000000-0000-0000-0000-000000000000", &app.admin_token, )) .await