Skip to content

Commit d746ddd

Browse files
committed
fix(auth): the confirmation recheck test proves the caller was confirmed while waiting
The recheck test's one-second confirmation started before the logout was set up, and nothing checked it was still valid once the mutation waited, so a slow setup could expire it first and the test passed for the wrong reason. The confirmation now starts after the setup, lasts two seconds, and the test asserts it is still valid once the mutation waits for the logout.
1 parent e11a7df commit d746ddd

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎apps/auth-service/src/admin/tests/mutations.rs‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@ async fn mutations_recheck_the_confirmation_after_waiting() {
1616
let harness = Harness::isolated().await;
1717
let admin = harness.admin().await;
1818
let user = harness.account().await;
19-
// The confirmation ends a second from now, and the logout ends just after it,
20-
// so the mutation waits about a second, well within the lock wait limit.
21-
let window = Duration::seconds(CONFIRMATION_MAX_AGE.into());
22-
let auth_time = Utc::now() - window + Duration::seconds(1);
2319
let mut logout = harness.database.begin().await.expect("transaction");
2420
user.sign_out(&mut logout).await;
2521
let service = harness.service();
2622
let reason = reason("Spam");
23+
// The confirmation ends two seconds from now, and the logout ends just after
24+
// it, so the mutation waits about two seconds, well within the lock wait limit.
25+
let window = Duration::seconds(CONFIRMATION_MAX_AGE.into());
26+
let auth_time = Utc::now() - window + Duration::seconds(2);
2727
let operator = operator(admin, auth_time);
2828
let (result, ()) = tokio::join!(
2929
service.disable_user(&operator, user.user_id, reason),
3030
async {
3131
until_blocked(&mut logout, 1).await;
32+
assert!(
33+
operator.confirmation_left() > Duration::zero(),
34+
"the mutation waits while its caller is still confirmed"
35+
);
3236
let expired = auth_time + window + Duration::milliseconds(10) - Utc::now();
3337
tokio::time::sleep(expired.to_std().unwrap_or_default()).await;
3438
logout.commit().await.expect("logout");

0 commit comments

Comments
 (0)