Sync shared snapshot from 74942e5
Security / Secrets (gitleaks) (push) Successful in 1m19s
Security / Dependencies (Trivy) (push) Successful in 1m16s
Security / Code (Semgrep) (push) Successful in 2m32s
Docker / Docker Build & Push (push) Successful in 9m4s

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
GabrielandClaude Haiku 5.5 committed 2026-11-10 14:52:27 +01:00
1 parent 0fd1805502
commit 833eab04af
4 files changed
+25 -14

No files matched your search

@@ -48,15 +48,14 @@ class SharedBackendTests(unittest.TestCase):
self.assertFalse(password_hash_needs_upgrade(password_hash))
def test_unprefixed_legacy_bcrypt_hashes_still_verify_and_are_upgraded(self):
legacy = bcrypt.hashpw(
b"correct horse battery staple", bcrypt.gensalt(rounds=12)
).decode()
legacy = bcrypt.hashpw(b"correct horse battery staple", bcrypt.gensalt(rounds=12)).decode()
self.assertTrue(verify_password("correct horse battery staple", legacy))
self.assertFalse(verify_password("wrong password", legacy))
self.assertTrue(password_hash_needs_upgrade(legacy))
valid, upgraded = verify_and_upgrade_password("correct horse battery staple", legacy)
self.assertTrue(valid)
assert upgraded is not None
self.assertTrue(upgraded.startswith("bcrypt$$2b$12$"))
self.assertTrue(verify_password("correct horse battery staple", upgraded))
self.assertFalse(password_hash_needs_upgrade(upgraded))
@@ -70,14 +69,16 @@ class SharedBackendTests(unittest.TestCase):
legacy = f"{salt}:{expected}"
valid, upgraded = verify_and_upgrade_password(password, legacy)
self.assertTrue(valid)
assert upgraded is not None
self.assertTrue(upgraded.startswith("bcrypt-sha256$$2b$12$"))
self.assertTrue(verify_password(password, upgraded))
self.assertFalse(verify_password(password + "x", upgraded))
def test_a_cost_below_the_current_policy_is_upgraded(self):
low_cost = "bcrypt$" + bcrypt.hashpw(
b"correct horse battery staple", bcrypt.gensalt(rounds=4)
).decode()
low_cost = (
"bcrypt$"
+ bcrypt.hashpw(b"correct horse battery staple", bcrypt.gensalt(rounds=4)).decode()
)
self.assertTrue(password_hash_needs_upgrade(low_cost))
valid, upgraded = verify_and_upgrade_password("correct horse battery staple", low_cost)
self.assertTrue(valid)
@@ -107,6 +108,7 @@ class SharedBackendTests(unittest.TestCase):
async def run():
valid, upgraded = await verify_and_upgrade_password_async(password, legacy)
self.assertTrue(valid)
assert upgraded is not None
self.assertTrue(await verify_password_async(password, upgraded))
asyncio.run(run())
@@ -127,8 +129,12 @@ class SharedBackendTests(unittest.TestCase):
return len(attempts)
self.assertTrue(is_transient_connection_error(ConnectionRefusedError()))
self.assertTrue(is_transient_connection_error(asyncpg.exceptions.ConnectionDoesNotExistError("closed")))
self.assertFalse(is_transient_connection_error(asyncpg.exceptions.InvalidPasswordError("bad")))
self.assertTrue(
is_transient_connection_error(asyncpg.exceptions.ConnectionDoesNotExistError("closed"))
)
self.assertFalse(
is_transient_connection_error(asyncpg.exceptions.InvalidPasswordError("bad"))
)
self.assertFalse(is_transient_connection_error(ValueError("bad")))
self.assertEqual(asyncio.run(retry_with(ValueError("bad"))), 1)
self.assertEqual(asyncio.run(retry_with(ConnectionRefusedError())), 3)