feat: account deletion request and active-user check

This commit is contained in:
2026-10-26 02:11:44 +01:00
parent 83bb5d9847
commit 0b5d18c4ee
27 changed files with 577 additions and 151 deletions

View File

@@ -71,3 +71,34 @@ async fn registering_with_a_short_password_fails() {
"expected password length error, got: {err}"
);
}
#[tokio::test]
async fn registration_refuses_a_retired_username() {
let users = InMemoryStore::new();
let b = TestContextBuilder::new().with_users(Arc::clone(&users) as _);
let deps = RegisterDeps {
user: b.user_repo.clone(),
password_hasher: b.password_hasher.clone(),
config: b.config.clone(),
};
register::execute(&deps, register_command("old@example.com", "ghost"))
.await
.unwrap();
let old = users
.find_by_email(&Email::new("old@example.com".into()).unwrap())
.await
.unwrap()
.unwrap();
users.mark_deleted(old.id(), &[]).await.unwrap();
// The purge removes the row; only the retired name keeps the username taken.
users.delete_user(old.id());
let err = register::execute(&deps, register_command("new@example.com", "Ghost"))
.await
.unwrap_err();
assert!(
matches!(&err, domain::errors::DomainError::ValidationError(m) if m == "Username already taken"),
"got {err:?}"
);
}