feat(sync): paginate Android sync with change tokens
Lint / Lint (push) Successful in 1m8s
Tests / Go backend (push) Failing after 1m23s
Tests / Dashboard checks (push) Failing after 38s
Docker / Docker Build & Push (push) Failing after 6m29s

This commit is contained in:
Gabriel20xx committed 2026-10-20 15:27:53 +00:00
1 parent 0ff94f9b10
commit 97c237be80
76 files changed
+3401 -851

No files matched your search

@@ -9,7 +9,12 @@ from shared_backend.auth import (
verify_password,
)
from shared_backend.clientip import client_address, parse_trusted_proxies
from shared_backend.totp import verify_totp
from shared_backend.coreconfig import (
EXAMPLE_INTERNAL_SECRETS,
MIN_INTERNAL_SECRET_LENGTH,
internal_secret_matches,
)
from shared_backend.totp import verify_totp, verify_totp_step
# The Go, Node and Python auth helpers load the same fixtures; see "description" in the file.
CONTRACT_PATH = Path(__file__).resolve().parents[3] / "contract" / "auth-contract.json"
@@ -27,22 +32,24 @@ class AuthContractTests(unittest.TestCase):
password = self.contract["password"]
for entry in password["hashes"]:
with self.subTest(entry["name"]):
plaintext = entry.get("password", password["plaintext"])
wrong_password = entry.get("wrongPassword", password["wrongPassword"])
self.assertEqual(
verify_password(password["plaintext"], entry["hash"]),
verify_password(plaintext, entry["hash"]),
entry["verifies"]["python"],
)
self.assertFalse(verify_password(password["wrongPassword"], entry["hash"]))
self.assertFalse(verify_password(wrong_password, entry["hash"]))
if "python" in entry.get("needsUpgrade", {}):
want = entry["needsUpgrade"]["python"]
self.assertEqual(password_hash_needs_upgrade(entry["hash"]), want)
valid, upgraded = verify_and_upgrade_password(
password["plaintext"], entry["hash"]
plaintext, entry["hash"]
)
self.assertTrue(valid)
self.assertEqual(upgraded is not None, want)
if upgraded is not None:
self.assertTrue(upgraded.startswith("bcrypt$"))
self.assertTrue(verify_password(password["plaintext"], upgraded))
self.assertTrue(upgraded.startswith(("bcrypt$", "bcrypt-sha256$")))
self.assertTrue(verify_password(plaintext, upgraded))
def test_the_password_length_contract_holds_for_python(self) -> None:
too_long = self.contract["password"]["tooLongToHash"]
@@ -59,6 +66,11 @@ class AuthContractTests(unittest.TestCase):
with self.subTest(entry["name"]):
secret = entry.get("secret", totp["secret"])
self.assertEqual(verify_totp(secret, entry["code"], entry["unix"]), entry["valid"])
if entry["valid"]:
self.assertEqual(
verify_totp_step(secret, entry["code"], entry["unix"]),
entry.get("matchedStep", entry["unix"] // 30),
)
def test_client_address_follows_the_contract(self) -> None:
section = self.contract["clientAddress"]
@@ -72,6 +84,17 @@ class AuthContractTests(unittest.TestCase):
with self.subTest(value), self.assertRaises(ValueError):
parse_trusted_proxies(value)
def test_internal_secret_gate_follows_the_contract(self) -> None:
rule = self.contract["internalSecret"]
self.assertEqual(MIN_INTERNAL_SECRET_LENGTH, rule["minLength"])
self.assertEqual(EXAMPLE_INTERNAL_SECRETS, frozenset(rule["placeholders"]))
for entry in rule["cases"]:
with self.subTest(entry["name"]):
self.assertEqual(
internal_secret_matches(entry["provided"], entry["secret"]),
entry["matches"],
)
if __name__ == "__main__":
unittest.main()