Fix flaky deleted-principal test

- The test deleted and recreated "bob", a name every test in the file
  creates. Basic credentials are cached per process, so a parallel test
  could resolve the recreated account to its own user id (401)
- Use a name only this test creates

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
AuthorKonata <konata@posteo.jp>
Date
Commit8d1cd5ab93f01299b354a21bd19a7a3032d9d116
Parentaf8101e
1 file changed, 19 insertions(+), 14 deletions(-)
▾Mserver/tests/api_pim_derived.rs
@@ -302,6 +302,9 @@ fn addr(user: &str) -> String {
#[tokio::test]
async fn deleted_principals_are_forgotten() {
let pim = Pim::new(Env::new().await).await;
// A name no other test uses: Basic credentials are cached per process,
// and a recreated account must not collide with a parallel test's.
create_user(&pim.admin, "erin", PW, &[]).await;
let r = pim
.admin
.post_json(
@@ -320,17 +323,17 @@ async fn deleted_principals_are_forgotten() {
&meeting(
"own",
&addr("alice"),
&[&addr("bob"), atrium],
&[&addr("erin"), atrium],
"20260310T100000Z",
),
)
.await;
pim.put(
"bob",
"/pim/calendars/bob/default/theirs.ics",
"erin",
"/pim/calendars/erin/default/theirs.ics",
&meeting(
"theirs",
&addr("bob"),
&addr("erin"),
&[&addr("alice")],
"20260311T100000Z",
),
@@ -341,10 +344,10 @@ async fn deleted_principals_are_forgotten() {
assert_eq!(copies.len(), 2, "{copies:?}");
let token = pim.sync_token("alice", alice_cal).await;
let bob_id = user_id(&pim.admin, "bob").await;
let erin_id = user_id(&pim.admin, "erin").await;
let r = pim
.admin
.delete(&format!("/api/admin/users/{bob_id}"))
.delete(&format!("/api/admin/users/{erin_id}"))
.await;
assert_eq!(r.status, StatusCode::OK, "{}", r.text());
let r = pim.admin.delete(&format!("/api/admin/rooms/{room}")).await;
@@ -352,7 +355,7 @@ async fn deleted_principals_are_forgotten() {
assert_ne!(pim.sync_token("alice", alice_cal).await, token);
let org = unfold(&pim.req("alice", "GET", own, "0", "").await.text());
assert!(!org.contains(&addr("bob")), "{org}");
assert!(!org.contains(&addr("erin")), "{org}");
assert!(!org.contains(atrium), "{org}");
let tombs: Vec<&str> = org
.lines()
@@ -365,17 +368,19 @@ async fn deleted_principals_are_forgotten() {
);
// The display name stays.
assert!(
tombs.iter().any(|l| l.replace('"', "").contains("CN=bob;")),
tombs
.iter()
.any(|l| l.replace('"', "").contains("CN=erin;")),
"{org}"
);
let theirs = copies.iter().find(|h| !h.ends_with("own.ics")).unwrap();
let copy = unfold(&pim.req("alice", "GET", theirs, "0", "").await.text());
assert!(copy.contains("STATUS:CANCELLED"), "{copy}");
assert!(copy.contains("ORGANIZER:mailto:bob-"), "{copy}");
assert!(copy.contains("ORGANIZER:mailto:erin-"), "{copy}");
// A new bob is not the old one: alice's next update reaches no one.
create_user(&pim.admin, "bob", PW, &[]).await;
// A new erin is not the old one: alice's next update reaches no one.
create_user(&pim.admin, "erin", PW, &[]).await;
pim.put(
"alice",
own,
@@ -384,17 +389,17 @@ async fn deleted_principals_are_forgotten() {
)
.await;
assert!(
pim.members("bob", "/pim/calendars/bob/default/")
pim.members("erin", "/pim/calendars/erin/default/")
.await
.is_empty()
);
assert!(
pim.members("bob", "/pim/calendars/bob/inbox/")
pim.members("erin", "/pim/calendars/erin/inbox/")
.await
.is_empty()
);
let org = unfold(&pim.req("alice", "GET", own, "0", "").await.text());
assert!(!org.contains(&addr("bob")), "{org}");
assert!(!org.contains(&addr("erin")), "{org}");
}
#[tokio::test]