From 7c33646494e128c02d858bccead669ba5307a14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 17:55:31 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20the=202FA=20enrollment=20?= =?UTF-8?q?test=20picks=20a=20code=20that=20is=20wrong=20at=20every=20step?= =?UTF-8?q?=20near=20now;=20000000=20was=20valid=20about=20once=20in=20300?= =?UTF-8?q?=20000=20runs=20and=20failed=20CI=20#189?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/settings_security.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/forge-web-account/src/pages/settings_security.rs b/crates/forge-web-account/src/pages/settings_security.rs index cee7f8d..31c529e 100644 --- a/crates/forge-web-account/src/pages/settings_security.rs +++ b/crates/forge-web-account/src/pages/settings_security.rs @@ -1162,6 +1162,17 @@ mod tests { totp::code_at(shared, totp::step_for(forge_core::time::now_unix())) } + fn wrong_code(shared: &[u8]) -> String { + let now = totp::step_for(forge_core::time::now_unix()); + let near: Vec = (now - 2..=now + 2) + .map(|step| totp::code_at(shared, step)) + .collect(); + (0..) + .map(|n| format!("{n:06}")) + .find(|code| !near.contains(code)) + .unwrap() + } + async fn enable_totp_directly(fx: &Fixture) -> Vec { let shared = totp::new_secret(); let sealed = secret::seal(&fx.state.key, &shared).unwrap(); @@ -1491,7 +1502,7 @@ mod tests { "uri shown" ); - let wrong = format!("csrf={CSRF}&code=000000"); + let wrong = format!("csrf={CSRF}&code={}", wrong_code(&shared)); let reply = send( &fx.router, "POST",