Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

test: stop the password-change race loop once the change answers

Boris 'B' Kurktchiev9a8ca16b4e31
diff --git a/api/test/server-password.test.js b/api/test/server-password.test.js
index 23e7c6962..5b25f8534 100644
--- a/api/test/server-password.test.js
+++ b/api/test/server-password.test.js
@@ -377,10 +377,13 @@ for (const [label, stored] of [['current', () => pwHash], ['older parameters', (
const owner = `gymsid=${mintSession('u1')}`;
const next = 'a much better passphrase';
const attempts = [];
- let change;
- for (let i = 0; i < 30; i++) {
+ let change, changed = false;
+ // Stop once the change has answered. A sign-in with the old password sent after that is a real
+ // wrong password, and the sixth of those would pause the name for the new one below too.
+ for (let i = 0; i < 30 && !changed; i++) {
attempts.push(login(h, 'Ana', GOOD, `198.51.100.${10 + i}`));
- if (i === 3) change = h.req('POST', '/api/account/password', { body: { next, current: GOOD }, cookie: owner, ip: '203.0.113.200' });
+ if (i === 3) change = h.req('POST', '/api/account/password', { body: { next, current: GOOD }, cookie: owner, ip: '203.0.113.200' })
+ .finally(() => { changed = true; });
await new Promise(r => setTimeout(r, 20));
}
const done = await change;