forge
Explore
Log in

Don't you dare go Hollow

1efe92446302b4c68ccefe1262b04d53e06766e6Ahmet Kaan GümüşParent: b660c8b
  • style
    • cargo fmt --all
Show full message
🎨 style: cargo fmt --all

The tree had never been through rustfmt, so the first run reformatted code from
earlier slices. Nothing here changes behaviour; keeping it separate leaves the
next commit readable.
crates/dizey-core/src/accounts.rsmodified+17 -7
@@ -15,11 +15,9 @@ use std::sync::Arc;
1515
1616 use time::{Duration, OffsetDateTime};
1717
18-use crate::auth::{
19- self, AuthError, PasswordProblem, Token, hash_password, verify_password,
20-};
21-use crate::store::{NewUser, Session, Store, StoreError, User, Workspace};
2218 use crate::Role;
19+use crate::auth::{self, AuthError, PasswordProblem, Token, hash_password, verify_password};
20+use crate::store::{NewUser, Session, Store, StoreError, User, Workspace};
2321
2422 /// How long a first-sign-in link is good for. The mockups say seven days, and
2523 /// an expired link is not a dead account: resending opens the same one.
@@ -243,7 +241,11 @@ impl Accounts {
243241
244242 self.store.set_password_hash(&user.id, &hash).await?;
245243 self.store.clear_auth_attempts(&client_bucket).await?;
246- let user = self.store.user(&user.id).await?.ok_or(StoreError::NotFound)?;
244+ let user = self
245+ .store
246+ .user(&user.id)
247+ .await?
248+ .ok_or(StoreError::NotFound)?;
247249 self.start_session(user).await
248250 }
249251
@@ -318,7 +320,11 @@ impl Accounts {
318320 self.store
319321 .record_auth_attempt(&client_bucket, OffsetDateTime::now_utc())
320322 .await?;
321- let user = self.store.user(user_id).await?.ok_or(StoreError::NotFound)?;
323+ let user = self
324+ .store
325+ .user(user_id)
326+ .await?
327+ .ok_or(StoreError::NotFound)?;
322328 let ok = match user.password_hash.as_deref() {
323329 Some(stored) => verify_password(current, stored),
324330 None => {
@@ -337,7 +343,11 @@ impl Accounts {
337343 self.store
338344 .revoke_sessions_for_user(&user.id, OffsetDateTime::now_utc())
339345 .await?;
340- let user = self.store.user(&user.id).await?.ok_or(StoreError::NotFound)?;
346+ let user = self
347+ .store
348+ .user(&user.id)
349+ .await?
350+ .ok_or(StoreError::NotFound)?;
341351 self.start_session(user).await
342352 }
343353
crates/dizey-core/src/auth.rsmodified+13 -3
@@ -66,7 +66,9 @@ pub fn hash_password(password: &str) -> Result<String, AuthError> {
6666 /// the cost later does not lock anyone out.
6767 pub fn verify_password(password: &str, phc: &str) -> bool {
6868 match PasswordHash::new(phc) {
69- Ok(parsed) => argon2().verify_password(password.as_bytes(), &parsed).is_ok(),
69+ Ok(parsed) => argon2()
70+ .verify_password(password.as_bytes(), &parsed)
71+ .is_ok(),
7072 Err(_) => false,
7173 }
7274 }
@@ -146,7 +148,11 @@ fn hex(bytes: &[u8]) -> String {
146148 }
147149
148150 /// The rules the first-sign-in screen states, checked server-side.
149-pub fn check_password(password: &str, email: &str, display_name: &str) -> Result<(), PasswordProblem> {
151+pub fn check_password(
152+ password: &str,
153+ email: &str,
154+ display_name: &str,
155+) -> Result<(), PasswordProblem> {
150156 // Counted in characters, not bytes: a ten-character password is ten
151157 // characters whatever alphabet it is in.
152158 if password.chars().count() < 10 {
@@ -279,7 +285,11 @@ mod dummy_hash_generator {
279285 #[test]
280286 #[ignore = "generator, not a check"]
281287 fn print_a_dummy_hash() {
282- let token = format!("{}{}", super::Token::mint().expose(), super::Token::mint().expose());
288+ let token = format!(
289+ "{}{}",
290+ super::Token::mint().expose(),
291+ super::Token::mint().expose()
292+ );
283293 println!("{}", super::hash_password(&token).unwrap());
284294 }
285295 }
crates/dizey-core/src/store/mod.rsmodified+1 -1
@@ -8,9 +8,9 @@ use async_trait::async_trait;
88 use serde::{Deserialize, Serialize};
99 use time::OffsetDateTime;
1010
11+use crate::Role;
1112 use crate::board::{BoardReads, TaskRow};
1213 use crate::detail::{ActivityKind, DetailReads};
13-use crate::Role;
1414
1515 pub mod turso_store;
1616
crates/dizey-core/src/store/turso_store.rsmodified+50 -24
@@ -57,10 +57,7 @@ impl TursoStore {
5757 // (a second process, or a careless second open) fails outright with
5858 // "database is locked" and silently drops the write unless a busy
5959 // timeout is set. Both pragmas are set on every connection we hand out.
60- for pragma in [
61- "PRAGMA foreign_keys = ON",
62- "PRAGMA busy_timeout = 5000",
63- ] {
60+ for pragma in ["PRAGMA foreign_keys = ON", "PRAGMA busy_timeout = 5000"] {
6461 conn.execute(pragma, ()).await.map_err(backend)?;
6562 }
6663 let store = Self { conn, db };
@@ -112,7 +109,12 @@ impl TursoStore {
112109
113110 /// The schema version the database is actually at.
114111 pub async fn schema_version(&self) -> Result<i64> {
115- Ok(self.applied_versions().await?.into_iter().max().unwrap_or(0))
112+ Ok(self
113+ .applied_versions()
114+ .await?
115+ .into_iter()
116+ .max()
117+ .unwrap_or(0))
116118 }
117119
118120 /// A connection of its own, for work that opens a transaction.
@@ -191,9 +193,7 @@ fn opt_text(row: &Row, idx: usize) -> Result<Option<String>> {
191193 }
192194
193195 fn count_of(row: &Row) -> Result<u64> {
194- row.get::<i64>(0)
195- .map_err(backend)
196- .map(|n| n.max(0) as u64)
196+ row.get::<i64>(0).map_err(backend).map(|n| n.max(0) as u64)
197197 }
198198
199199 fn workspace_from(row: &Row) -> Result<Workspace> {
@@ -230,8 +230,7 @@ fn user_from(row: &Row) -> Result<User> {
230230 workspace_id: text(row, 1)?,
231231 email: text(row, 2)?,
232232 display_name: text(row, 3)?,
233- role: Role::parse(&text(row, 4)?)
234- .ok_or_else(|| StoreError::Corrupt("role".into()))?,
233+ role: Role::parse(&text(row, 4)?).ok_or_else(|| StoreError::Corrupt("role".into()))?,
235234 password_hash: opt_text(row, 5)?,
236235 photo_path: opt_text(row, 6)?,
237236 created_at: parse_stamp(&text(row, 7)?)?,
@@ -463,7 +462,11 @@ impl Store for TursoStore {
463462
464463 async fn create_user(&self, new: NewUser) -> Result<User> {
465464 let email = fold_email(&new.email);
466- if self.user_by_email(&new.workspace_id, &email).await?.is_some() {
465+ if self
466+ .user_by_email(&new.workspace_id, &email)
467+ .await?
468+ .is_some()
469+ {
467470 return Err(StoreError::Conflict("account"));
468471 }
469472 let id = Uuid::new_v4().to_string();
@@ -494,8 +497,7 @@ impl Store for TursoStore {
494497 }
495498
496499 async fn user_by_email(&self, workspace_id: &str, email: &str) -> Result<Option<User>> {
497- let sql =
498- format!("SELECT {USER_COLUMNS} FROM user WHERE workspace_id = ?1 AND email = ?2");
500+ let sql = format!("SELECT {USER_COLUMNS} FROM user WHERE workspace_id = ?1 AND email = ?2");
499501 match self
500502 .one_row(&sql, params![workspace_id, fold_email(email)])
501503 .await?
@@ -509,7 +511,11 @@ impl Store for TursoStore {
509511 let sql = format!(
510512 "SELECT {USER_COLUMNS} FROM user WHERE workspace_id = ?1 ORDER BY created_at, id"
511513 );
512- let mut rows = self.conn.query(&sql, params![workspace_id]).await.map_err(backend)?;
514+ let mut rows = self
515+ .conn
516+ .query(&sql, params![workspace_id])
517+ .await
518+ .map_err(backend)?;
513519 let mut out = Vec::new();
514520 while let Some(row) = rows.next().await.map_err(backend)? {
515521 out.push(user_from(&row)?);
@@ -539,7 +545,11 @@ impl Store for TursoStore {
539545 )
540546 .await
541547 .map_err(backend)?;
542- if n == 0 { Err(StoreError::NotFound) } else { Ok(()) }
548+ if n == 0 {
549+ Err(StoreError::NotFound)
550+ } else {
551+ Ok(())
552+ }
543553 }
544554
545555 async fn set_profile(
@@ -560,7 +570,11 @@ impl Store for TursoStore {
560570 )
561571 .await
562572 .map_err(backend)?;
563- if n == 0 { Err(StoreError::NotFound) } else { Ok(()) }
573+ if n == 0 {
574+ Err(StoreError::NotFound)
575+ } else {
576+ Ok(())
577+ }
564578 }
565579
566580 async fn set_role(&self, user_id: &str, role: Role) -> Result<()> {
@@ -572,7 +586,11 @@ impl Store for TursoStore {
572586 )
573587 .await
574588 .map_err(backend)?;
575- if n == 0 { Err(StoreError::NotFound) } else { Ok(()) }
589+ if n == 0 {
590+ Err(StoreError::NotFound)
591+ } else {
592+ Ok(())
593+ }
576594 }
577595
578596 async fn mark_signed_in(&self, user_id: &str, at: OffsetDateTime) -> Result<()> {
@@ -584,7 +602,11 @@ impl Store for TursoStore {
584602 )
585603 .await
586604 .map_err(backend)?;
587- if n == 0 { Err(StoreError::NotFound) } else { Ok(()) }
605+ if n == 0 {
606+ Err(StoreError::NotFound)
607+ } else {
608+ Ok(())
609+ }
588610 }
589611
590612 async fn create_signin_link(
@@ -708,7 +730,11 @@ impl Store for TursoStore {
708730 )
709731 .await
710732 .map_err(backend)?;
711- if n == 0 { Err(StoreError::NotFound) } else { Ok(()) }
733+ if n == 0 {
734+ Err(StoreError::NotFound)
735+ } else {
736+ Ok(())
737+ }
712738 }
713739
714740 async fn revoke_sessions_for_user(&self, user_id: &str, at: OffsetDateTime) -> Result<u64> {
@@ -749,7 +775,10 @@ impl Store for TursoStore {
749775
750776 async fn clear_auth_attempts(&self, bucket: &str) -> Result<()> {
751777 self.conn
752- .execute("DELETE FROM auth_attempt WHERE bucket = ?1", params![bucket])
778+ .execute(
779+ "DELETE FROM auth_attempt WHERE bucket = ?1",
780+ params![bucket],
781+ )
753782 .await
754783 .map_err(backend)?;
755784 Ok(())
@@ -1362,10 +1391,7 @@ impl DetailReads for TursoStore {
13621391 Ok(out)
13631392 }
13641393
1365- async fn dependencies_for_task(
1366- &self,
1367- task_id: &str,
1368- ) -> Result<Vec<(bool, DependencyEdge)>> {
1394+ async fn dependencies_for_task(&self, task_id: &str) -> Result<Vec<(bool, DependencyEdge)>> {
13691395 // Both directions in one round trip: the leading column says which.
13701396 let mut rows = self
13711397 .conn
crates/dizey-core/tests/store.rsmodified+293 -69
@@ -6,9 +6,9 @@
66
77 use std::path::PathBuf;
88
9+use dizey_core::Role;
910 use dizey_core::auth::{Token, hash_password};
1011 use dizey_core::store::{DeletePolicy, NewUser, Store, StoreError, TursoStore, User};
11-use dizey_core::Role;
1212 use time::{Duration, OffsetDateTime};
1313 use uuid::Uuid;
1414
@@ -129,7 +129,10 @@ async fn a_second_claim_loses_and_changes_nothing() {
129129 assert!(matches!(second, Err(StoreError::AlreadyClaimed)));
130130
131131 // The loser must not have joined as anything at all.
132- assert_eq!(scratch.store.workspace().await.unwrap().unwrap().name, "Dizey");
132+ assert_eq!(
133+ scratch.store.workspace().await.unwrap().unwrap().name,
134+ "Dizey"
135+ );
133136 assert_eq!(scratch.store.count_users("").await.unwrap(), 0);
134137 let ws_id = scratch.store.workspace().await.unwrap().unwrap().id;
135138 assert_eq!(scratch.store.count_users(&ws_id).await.unwrap(), 1);
@@ -179,7 +182,11 @@ async fn concurrent_claims_produce_exactly_one_admin() {
179182 assert_eq!(winners.len(), 1, "exactly one claim wins: {winners:?}");
180183
181184 let ws_id = store.workspace().await.unwrap().unwrap().id;
182- assert_eq!(store.count_users(&ws_id).await.unwrap(), 1, "no half-written losers");
185+ assert_eq!(
186+ store.count_users(&ws_id).await.unwrap(),
187+ 1,
188+ "no half-written losers"
189+ );
183190 let owner = store.owner().await.unwrap().unwrap();
184191 assert_eq!(owner.email, winners[0]);
185192
@@ -202,7 +209,10 @@ async fn workspace_defaults_match_the_settings_screen() {
202209 .unwrap();
203210 assert_eq!(ws.attachment_limit_bytes, 25 * 1024 * 1024);
204211 assert_eq!(ws.photo_limit_bytes, 2 * 1024 * 1024);
205- assert!(ws.allowed_file_types.is_empty(), "every type until narrowed");
212+ assert!(
213+ ws.allowed_file_types.is_empty(),
214+ "every type until narrowed"
215+ );
206216 assert_eq!(ws.who_can_delete_tasks, DeletePolicy::Anyone);
207217 assert!(ws.smtp_host.is_none());
208218 }
@@ -212,7 +222,15 @@ async fn smtp_password_is_never_part_of_the_workspace_record() {
212222 let (scratch, ws_id, _) = workspace_with_admin().await;
213223 scratch
214224 .store
215- .set_smtp(&ws_id, "smtp.fastmail.com", 465, "dizey", "hunter2", "Dizey", "dizey@dizey.sh")
225+ .set_smtp(
226+ &ws_id,
227+ "smtp.fastmail.com",
228+ 465,
229+ "dizey",
230+ "hunter2",
231+ "Dizey",
232+ "dizey@dizey.sh",
233+ )
216234 .await
217235 .unwrap();
218236
@@ -224,7 +242,12 @@ async fn smtp_password_is_never_part_of_the_workspace_record() {
224242 let serialised = serde_json::to_string(&ws).unwrap();
225243 assert!(!serialised.contains("hunter2"), "{serialised}");
226244 assert_eq!(
227- scratch.store.smtp_password(&ws_id).await.unwrap().as_deref(),
245+ scratch
246+ .store
247+ .smtp_password(&ws_id)
248+ .await
249+ .unwrap()
250+ .as_deref(),
228251 Some("hunter2")
229252 );
230253 }
@@ -235,7 +258,13 @@ async fn limits_round_trip_including_the_file_type_list() {
235258 let types = vec!["png".to_string(), "pdf".to_string()];
236259 scratch
237260 .store
238- .set_limits(&ws_id, 10 * 1024 * 1024, 512 * 1024, &types, DeletePolicy::Admin)
261+ .set_limits(
262+ &ws_id,
263+ 10 * 1024 * 1024,
264+ 512 * 1024,
265+ &types,
266+ DeletePolicy::Admin,
267+ )
239268 .await
240269 .unwrap();
241270 let ws = scratch.store.workspace().await.unwrap().unwrap();
@@ -329,10 +358,7 @@ async fn members_list_and_count_for_the_admin_screen() {
329358 assert_eq!(scratch.store.count_users(&ws_id).await.unwrap(), 3);
330359 let users = scratch.store.users(&ws_id).await.unwrap();
331360 assert_eq!(users[0].id, admin_id);
332- assert_eq!(
333- users.iter().filter(|u| u.role == Role::Viewer).count(),
334- 1
335- );
361+ assert_eq!(users.iter().filter(|u| u.role == Role::Viewer).count(), 1);
336362 }
337363
338364 #[tokio::test]
@@ -354,7 +380,11 @@ async fn profile_and_role_updates_stick() {
354380 .set_profile(&user.id, "Grace H.", Some("photos/grace.png"))
355381 .await
356382 .unwrap();
357- scratch.store.set_role(&user.id, Role::Viewer).await.unwrap();
383+ scratch
384+ .store
385+ .set_role(&user.id, Role::Viewer)
386+ .await
387+ .unwrap();
358388 let at = OffsetDateTime::now_utc();
359389 scratch.store.mark_signed_in(&user.id, at).await.unwrap();
360390
@@ -369,8 +399,21 @@ async fn profile_and_role_updates_stick() {
369399 );
370400
371401 // Clearing the photo is a real update, not a no-op.
372- scratch.store.set_profile(&user.id, "Grace H.", None).await.unwrap();
373- assert!(scratch.store.user(&user.id).await.unwrap().unwrap().photo_path.is_none());
402+ scratch
403+ .store
404+ .set_profile(&user.id, "Grace H.", None)
405+ .await
406+ .unwrap();
407+ assert!(
408+ scratch
409+ .store
410+ .user(&user.id)
411+ .await
412+ .unwrap()
413+ .unwrap()
414+ .photo_path
415+ .is_none()
416+ );
374417 }
375418
376419 #[tokio::test]
@@ -427,7 +470,13 @@ async fn a_signin_link_stores_only_the_hash_and_is_used_once() {
427470 .is_none()
428471 );
429472
430- assert!(scratch.store.consume_signin_link(&link.id, now).await.unwrap());
473+ assert!(
474+ scratch
475+ .store
476+ .consume_signin_link(&link.id, now)
477+ .await
478+ .unwrap()
479+ );
431480 let used = scratch
432481 .store
433482 .signin_link_by_hash("hash-of-the-token")
@@ -436,7 +485,13 @@ async fn a_signin_link_stores_only_the_hash_and_is_used_once() {
436485 .unwrap();
437486 assert!(!used.is_usable(now));
438487 // A second use finds nothing left to consume.
439- assert!(!scratch.store.consume_signin_link(&link.id, now).await.unwrap());
488+ assert!(
489+ !scratch
490+ .store
491+ .consume_signin_link(&link.id, now)
492+ .await
493+ .unwrap()
494+ );
440495 }
441496
442497 #[tokio::test]
@@ -556,7 +611,11 @@ async fn a_session_lives_until_it_expires_or_is_revoked() {
556611 Some(token.hash())
557612 );
558613
559- scratch.store.revoke_session(&session.id, now).await.unwrap();
614+ scratch
615+ .store
616+ .revoke_session(&session.id, now)
617+ .await
618+ .unwrap();
560619 let revoked = scratch
561620 .store
562621 .session_by_hash(&token.hash())
@@ -782,7 +841,12 @@ async fn the_claim_screen_enforces_its_own_password_rules() {
782841 async fn a_second_claim_is_refused() {
783842 let (_scratch, accounts, _admin) = claimed().await;
784843 let second = accounts
785- .claim_workspace("Theirs", "mallory@elsewhere.example", "Mallory", "tide-tables-1892")
844+ .claim_workspace(
845+ "Theirs",
846+ "mallory@elsewhere.example",
847+ "Mallory",
848+ "tide-tables-1892",
849+ )
786850 .await;
787851 assert!(matches!(second, Err(AccountError::AlreadyClaimed)));
788852 }
@@ -795,7 +859,10 @@ async fn an_invited_member_chooses_their_own_password() {
795859 .await
796860 .unwrap();
797861 assert!(!invitation.user.has_signed_in(), "no password yet");
798- assert!(invitation.expires_at > OffsetDateTime::now_utc() + SIGNIN_LINK_LIFETIME - Duration::minutes(1));
862+ assert!(
863+ invitation.expires_at
864+ > OffsetDateTime::now_utc() + SIGNIN_LINK_LIFETIME - Duration::minutes(1)
865+ );
799866
800867 // The admin cannot sign in as them in the meantime.
801868 let as_them = accounts
@@ -804,7 +871,11 @@ async fn an_invited_member_chooses_their_own_password() {
804871 assert!(matches!(as_them, Err(AccountError::Rejected)));
805872
806873 let signed_in = accounts
807- .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7")
874+ .redeem_signin_link(
875+ invitation.token.expose(),
876+ "sextant-and-chart",
877+ "198.51.100.7",
878+ )
808879 .await
809880 .unwrap();
810881 assert_eq!(signed_in.user.id, invitation.user.id);
@@ -825,7 +896,11 @@ async fn only_an_admin_may_invite() {
825896 .await
826897 .unwrap();
827898 let member = accounts
828- .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7")
899+ .redeem_signin_link(
900+ invitation.token.expose(),
901+ "sextant-and-chart",
902+ "198.51.100.7",
903+ )
829904 .await
830905 .unwrap()
831906 .user;
@@ -839,7 +914,9 @@ async fn only_an_admin_may_invite() {
839914 let mut viewer = member.clone();
840915 viewer.role = Role::Viewer;
841916 assert!(matches!(
842- accounts.invite(&viewer, "linus@dizey.sh", "Linus", Role::Viewer).await,
917+ accounts
918+ .invite(&viewer, "linus@dizey.sh", "Linus", Role::Viewer)
919+ .await,
843920 Err(AccountError::Forbidden)
844921 ));
845922 }
@@ -853,11 +930,19 @@ async fn a_link_works_once_and_a_wrong_one_never_does() {
853930 .unwrap();
854931
855932 accounts
856- .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7")
933+ .redeem_signin_link(
934+ invitation.token.expose(),
935+ "sextant-and-chart",
936+ "198.51.100.7",
937+ )
857938 .await
858939 .unwrap();
859940 let again = accounts
860- .redeem_signin_link(invitation.token.expose(), "another-password", "198.51.100.7")
941+ .redeem_signin_link(
942+ invitation.token.expose(),
943+ "another-password",
944+ "198.51.100.7",
945+ )
861946 .await;
862947 assert!(matches!(again, Err(AccountError::Rejected)));
863948
@@ -882,16 +967,28 @@ async fn a_rejected_password_does_not_burn_the_invitation() {
882967 .unwrap();
883968
884969 assert!(matches!(
885- accounts.redeem_signin_link(invitation.token.expose(), "grace!!", "198.51.100.7").await,
970+ accounts
971+ .redeem_signin_link(invitation.token.expose(), "grace!!", "198.51.100.7")
972+ .await,
886973 Err(AccountError::Password(PasswordProblem::TooShort))
887974 ));
888975 assert!(matches!(
889- accounts.redeem_signin_link(invitation.token.expose(), "grace-hopper-1906", "198.51.100.7").await,
976+ accounts
977+ .redeem_signin_link(
978+ invitation.token.expose(),
979+ "grace-hopper-1906",
980+ "198.51.100.7"
981+ )
982+ .await,
890983 Err(AccountError::Password(PasswordProblem::LooksLikeYou))
891984 ));
892985 // Still redeemable with a password that passes.
893986 accounts
894- .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7")
987+ .redeem_signin_link(
988+ invitation.token.expose(),
989+ "sextant-and-chart",
990+ "198.51.100.7",
991+ )
895992 .await
896993 .unwrap();
897994 }
@@ -916,7 +1013,9 @@ async fn an_expired_link_is_refused_and_resending_opens_the_same_account() {
9161013 .await
9171014 .unwrap();
9181015 assert!(matches!(
919- accounts.redeem_signin_link(stale.expose(), "sextant-and-chart", "198.51.100.7").await,
1016+ accounts
1017+ .redeem_signin_link(stale.expose(), "sextant-and-chart", "198.51.100.7")
1018+ .await,
9201019 Err(AccountError::Rejected)
9211020 ));
9221021
@@ -998,12 +1097,16 @@ async fn sign_in_attempts_are_rate_limited_per_address() {
9981097 }
9991098 // The next attempt is refused before any Argon2 work happens.
10001099 assert!(matches!(
1001- accounts.sign_in("ada@dizey.sh", "wrong", "203.0.113.9").await,
1100+ accounts
1101+ .sign_in("ada@dizey.sh", "wrong", "203.0.113.9")
1102+ .await,
10021103 Err(AccountError::RateLimited)
10031104 ));
10041105 // A different address from a fresh client is unaffected.
10051106 assert!(matches!(
1006- accounts.sign_in("someone@dizey.sh", "wrong", "203.0.113.9").await,
1107+ accounts
1108+ .sign_in("someone@dizey.sh", "wrong", "203.0.113.9")
1109+ .await,
10071110 Err(AccountError::Rejected)
10081111 ));
10091112 }
@@ -1068,13 +1171,21 @@ async fn link_redemption_is_rate_limited_per_client() {
10681171 // Even the real link is refused now, from that client.
10691172 assert!(matches!(
10701173 accounts
1071- .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "203.0.113.9")
1174+ .redeem_signin_link(
1175+ invitation.token.expose(),
1176+ "sextant-and-chart",
1177+ "203.0.113.9"
1178+ )
10721179 .await,
10731180 Err(AccountError::RateLimited)
10741181 ));
10751182 // And the person on another machine is unaffected.
10761183 accounts
1077- .redeem_signin_link(invitation.token.expose(), "sextant-and-chart", "198.51.100.7")
1184+ .redeem_signin_link(
1185+ invitation.token.expose(),
1186+ "sextant-and-chart",
1187+ "198.51.100.7",
1188+ )
10781189 .await
10791190 .unwrap();
10801191 }
@@ -1091,7 +1202,12 @@ async fn changing_a_password_is_rate_limited_per_client() {
10911202 }
10921203 assert!(matches!(
10931204 accounts
1094- .change_password(&admin.id, "tide-tables-1892", "chronometer-1761", "203.0.113.9")
1205+ .change_password(
1206+ &admin.id,
1207+ "tide-tables-1892",
1208+ "chronometer-1761",
1209+ "203.0.113.9"
1210+ )
10951211 .await,
10961212 Err(AccountError::RateLimited)
10971213 ));
@@ -1111,7 +1227,9 @@ async fn a_successful_sign_in_clears_the_bucket() {
11111227 .unwrap();
11121228 // Someone who mistypes and then gets it right is not left at the edge.
11131229 assert!(matches!(
1114- accounts.sign_in("ada@dizey.sh", "wrong", "198.51.100.7").await,
1230+ accounts
1231+ .sign_in("ada@dizey.sh", "wrong", "198.51.100.7")
1232+ .await,
11151233 Err(AccountError::Rejected)
11161234 ));
11171235 }
@@ -1127,20 +1245,41 @@ async fn changing_a_password_signs_out_every_device() {
11271245 .sign_in("ada@dizey.sh", "tide-tables-1892", "198.51.100.8")
11281246 .await
11291247 .unwrap();
1130- assert!(accounts.authenticate(first.session_token.expose()).await.unwrap().is_some());
1248+ assert!(
1249+ accounts
1250+ .authenticate(first.session_token.expose())
1251+ .await
1252+ .unwrap()
1253+ .is_some()
1254+ );
11311255
11321256 let fresh = accounts
1133- .change_password(&admin.id, "tide-tables-1892", "chronometer-1761", "198.51.100.7")
1257+ .change_password(
1258+ &admin.id,
1259+ "tide-tables-1892",
1260+ "chronometer-1761",
1261+ "198.51.100.7",
1262+ )
11341263 .await
11351264 .unwrap();
11361265
11371266 for old in [&first, &second] {
11381267 assert!(
1139- accounts.authenticate(old.session_token.expose()).await.unwrap().is_none(),
1268+ accounts
1269+ .authenticate(old.session_token.expose())
1270+ .await
1271+ .unwrap()
1272+ .is_none(),
11401273 "the pane promises this"
11411274 );
11421275 }
1143- assert!(accounts.authenticate(fresh.session_token.expose()).await.unwrap().is_some());
1276+ assert!(
1277+ accounts
1278+ .authenticate(fresh.session_token.expose())
1279+ .await
1280+ .unwrap()
1281+ .is_some()
1282+ );
11441283 accounts
11451284 .sign_in("ada@dizey.sh", "chronometer-1761", "198.51.100.7")
11461285 .await
@@ -1151,11 +1290,15 @@ async fn changing_a_password_signs_out_every_device() {
11511290 async fn changing_a_password_needs_the_current_one_and_obeys_the_rules() {
11521291 let (_scratch, accounts, admin) = claimed().await;
11531292 assert!(matches!(
1154- accounts.change_password(&admin.id, "not-it", "chronometer-1761", "198.51.100.7").await,
1293+ accounts
1294+ .change_password(&admin.id, "not-it", "chronometer-1761", "198.51.100.7")
1295+ .await,
11551296 Err(AccountError::Rejected)
11561297 ));
11571298 assert!(matches!(
1158- accounts.change_password(&admin.id, "tide-tables-1892", "short", "198.51.100.7").await,
1299+ accounts
1300+ .change_password(&admin.id, "tide-tables-1892", "short", "198.51.100.7")
1301+ .await,
11591302 Err(AccountError::Password(PasswordProblem::TooShort))
11601303 ));
11611304 // The old password still works after both refusals.
@@ -1177,9 +1320,24 @@ async fn signing_out_ends_that_browser_only() {
11771320 .await
11781321 .unwrap();
11791322
1180- accounts.sign_out(laptop.session_token.expose()).await.unwrap();
1181- assert!(accounts.authenticate(laptop.session_token.expose()).await.unwrap().is_none());
1182- assert!(accounts.authenticate(phone.session_token.expose()).await.unwrap().is_some());
1323+ accounts
1324+ .sign_out(laptop.session_token.expose())
1325+ .await
1326+ .unwrap();
1327+ assert!(
1328+ accounts
1329+ .authenticate(laptop.session_token.expose())
1330+ .await
1331+ .unwrap()
1332+ .is_none()
1333+ );
1334+ assert!(
1335+ accounts
1336+ .authenticate(phone.session_token.expose())
1337+ .await
1338+ .unwrap()
1339+ .is_some()
1340+ );
11831341 // Signing out an unknown token is not an error.
11841342 accounts.sign_out(&"0".repeat(32)).await.unwrap();
11851343 }
@@ -1192,11 +1350,15 @@ async fn an_address_can_only_be_invited_once() {
11921350 .await
11931351 .unwrap();
11941352 assert!(matches!(
1195- accounts.invite(&admin, "GRACE@dizey.sh", "Grace again", Role::Member).await,
1353+ accounts
1354+ .invite(&admin, "GRACE@dizey.sh", "Grace again", Role::Member)
1355+ .await,
11961356 Err(AccountError::AddressTaken)
11971357 ));
11981358 assert!(matches!(
1199- accounts.invite(&admin, "ada@dizey.sh", "Ada again", Role::Member).await,
1359+ accounts
1360+ .invite(&admin, "ada@dizey.sh", "Ada again", Role::Member)
1361+ .await,
12001362 Err(AccountError::AddressTaken)
12011363 ));
12021364 }
@@ -1434,10 +1596,29 @@ async fn a_card_carries_its_assignees_comments_and_dependency_keys() {
14341596 async fn a_cleared_dependency_stops_showing_on_the_card() {
14351597 let (scratch, workspace, admin) = workspace_with_admin().await;
14361598 let store = &scratch.store;
1437- let blocking = add_task(store, &workspace, "In Progress", "Invite flow", None, &admin).await;
1438- let blocked = add_task(store, &workspace, "Backlog", "Terms of service", None, &admin).await;
1599+ let blocking = add_task(
1600+ store,
1601+ &workspace,
1602+ "In Progress",
1603+ "Invite flow",
1604+ None,
1605+ &admin,
1606+ )
1607+ .await;
1608+ let blocked = add_task(
1609+ store,
1610+ &workspace,
1611+ "Backlog",
1612+ "Terms of service",
1613+ None,
1614+ &admin,
1615+ )
1616+ .await;
14391617 let now = OffsetDateTime::now_utc();
1440- store.add_dependency(&blocked, &blocking, now).await.unwrap();
1618+ store
1619+ .add_dependency(&blocked, &blocking, now)
1620+ .await
1621+ .unwrap();
14411622
14421623 let board = board_of(store, &workspace).await;
14431624 assert!(
@@ -1646,7 +1827,10 @@ async fn a_task_detail_carries_both_directions_of_its_dependencies() {
16461827 assert_eq!(blocked_by, ["before"]);
16471828 assert_eq!(blocks, ["after"]);
16481829 assert!(detail.is_blocked());
1649- assert_eq!(detail.blocked_by[0].blocked_by_label(), "blocking this task");
1830+ assert_eq!(
1831+ detail.blocked_by[0].blocked_by_label(),
1832+ "blocking this task"
1833+ );
16501834 assert_eq!(detail.blocks[0].blocks_label(), "waiting on this task");
16511835 }
16521836
@@ -1665,7 +1849,10 @@ async fn a_viewer_is_never_offered_as_an_assignee() {
16651849 .unwrap();
16661850 let task = add_task(store, &workspace, "Backlog", "a task", None, &admin).await;
16671851
1668- let detail = load_detail(store, &workspace, &task).await.unwrap().unwrap();
1852+ let detail = load_detail(store, &workspace, &task)
1853+ .await
1854+ .unwrap()
1855+ .unwrap();
16691856 assert!(
16701857 !detail.assignable.iter().any(|p| p.id == quiet.id),
16711858 "a viewer cannot be given work, so the picker never lists one"
@@ -1749,19 +1936,31 @@ async fn deleting_a_task_frees_what_was_waiting_on_it() {
17491936 .add_dependency(&still_stuck, &blocking, now)
17501937 .await
17511938 .unwrap();
1752- store.add_dependency(&still_stuck, &other, now).await.unwrap();
1939+ store
1940+ .add_dependency(&still_stuck, &other, now)
1941+ .await
1942+ .unwrap();
17531943
17541944 let unblocked = store.delete_task(&blocking, &admin, now).await.unwrap();
1755- assert_eq!(unblocked, vec![freed.clone()], "only the one with nothing else in front of it");
1945+ assert_eq!(
1946+ unblocked,
1947+ vec![freed.clone()],
1948+ "only the one with nothing else in front of it"
1949+ );
17561950
17571951 // The deleted task is gone from the board and from the edges it stood in.
17581952 let board = board_of(store, &workspace).await;
1759- assert!(!board
1760- .columns
1761- .iter()
1762- .flat_map(|column| column.cards.iter())
1763- .any(|card| card.id == blocking));
1764- let freed_detail = load_detail(store, &workspace, &freed).await.unwrap().unwrap();
1953+ assert!(
1954+ !board
1955+ .columns
1956+ .iter()
1957+ .flat_map(|column| column.cards.iter())
1958+ .any(|card| card.id == blocking)
1959+ );
1960+ let freed_detail = load_detail(store, &workspace, &freed)
1961+ .await
1962+ .unwrap()
1963+ .unwrap();
17651964 assert!(freed_detail.blocked_by.is_empty());
17661965 assert!(!freed_detail.is_blocked());
17671966
@@ -1772,18 +1971,26 @@ async fn deleting_a_task_frees_what_was_waiting_on_it() {
17721971 .iter()
17731972 .find(|entry| entry.kind == ActivityKind::Unblocked)
17741973 .expect("the freeing is on the record");
1775- assert!(unblocked_line.actor.is_none(), "the system did this, not a person");
1974+ assert!(
1975+ unblocked_line.actor.is_none(),
1976+ "the system did this, not a person"
1977+ );
17761978 assert!(unblocked_line.sentence().starts_with("unblocked this task"));
17771979
17781980 let stuck_detail = load_detail(store, &workspace, &still_stuck)
17791981 .await
17801982 .unwrap()
17811983 .unwrap();
1782- assert!(stuck_detail.is_blocked(), "something else is still in front of it");
1783- assert!(!stuck_detail
1784- .activity
1785- .iter()
1786- .any(|entry| entry.kind == ActivityKind::Unblocked));
1984+ assert!(
1985+ stuck_detail.is_blocked(),
1986+ "something else is still in front of it"
1987+ );
1988+ assert!(
1989+ !stuck_detail
1990+ .activity
1991+ .iter()
1992+ .any(|entry| entry.kind == ActivityKind::Unblocked)
1993+ );
17871994
17881995 // A second delete finds nothing to delete.
17891996 assert!(matches!(
@@ -1809,9 +2016,16 @@ async fn saving_a_task_records_only_what_changed() {
18092016 )
18102017 .await
18112018 .unwrap();
1812- let detail = load_detail(store, &workspace, &task).await.unwrap().unwrap();
2019+ let detail = load_detail(store, &workspace, &task)
2020+ .await
2021+ .unwrap()
2022+ .unwrap();
18132023 let kinds: Vec<&ActivityKind> = detail.activity.iter().map(|e| &e.kind).collect();
1814- assert_eq!(kinds, [&ActivityKind::Created], "a save that changed nothing says nothing");
2024+ assert_eq!(
2025+ kinds,
2026+ [&ActivityKind::Created],
2027+ "a save that changed nothing says nothing"
2028+ );
18152029
18162030 store
18172031 .save_task(
@@ -1824,7 +2038,10 @@ async fn saving_a_task_records_only_what_changed() {
18242038 )
18252039 .await
18262040 .unwrap();
1827- let detail = load_detail(store, &workspace, &task).await.unwrap().unwrap();
2041+ let detail = load_detail(store, &workspace, &task)
2042+ .await
2043+ .unwrap()
2044+ .unwrap();
18282045 assert_eq!(detail.title, "second title");
18292046 assert_eq!(detail.description, "some prose");
18302047 assert_eq!(detail.deadline_input(), "2026-09-12");
@@ -1871,10 +2088,17 @@ async fn a_task_detail_costs_seven_queries_whatever_it_carries() {
18712088 .await
18722089 .unwrap();
18732090 store
1874- .record_activity(&heavy, Some(&person.id), &ActivityKind::Moved, "to Review", now)
2091+ .record_activity(
2092+ &heavy,
2093+ Some(&person.id),
2094+ &ActivityKind::Moved,
2095+ "to Review",
2096+ now,
2097+ )
18752098 .await
18762099 .unwrap();
1877- let neighbour = add_task(store, &workspace, "Backlog", &format!("n{n}"), None, &admin).await;
2100+ let neighbour =
2101+ add_task(store, &workspace, "Backlog", &format!("n{n}"), None, &admin).await;
18782102 store.add_dependency(&neighbour, &heavy, now).await.unwrap();
18792103 }
18802104
crates/dizey-web/src/main.rsmodified+2 -2
@@ -29,8 +29,8 @@ async fn main() {
2929 listener,
3030 app.into_make_service_with_connect_info::<std::net::SocketAddr>(),
3131 )
32- .await
33- .expect("server error");
32+ .await
33+ .expect("server error");
3434 }
3535
3636 #[cfg(not(feature = "ssr"))]