4.8 KiB
4.8 KiB
1. Worktree
- 1.1
scripts/agent-worktree.sh create fix-cognito-signinand confirm.worktree/fix-cognito-signin/.agent-lockexists on branchagent/fix-cognito-signin
2. API client sign-in
- 2.1 Add
RECAPTCHA_DOMAIN = "https://www.perfectdraft.com"toconst.py; dropRECAPTCHA_ACTION_SIGN_INfromapi.pyin favour ofconst.RECAPTCHA_ACTION, and moveCOGNITO_IDP_URLalongside if it reads better; verifyrg RECAPTCHA_ACTION_SIGN_INfinds nothing - 2.2 Give
AuthenticationErroroptionalcodeandreason, akindproperty (credentials/token/other, per the design table) and a never-emptydisplay_reason(trailing period stripped, at most 200 chars); existing single-argument raises still work - 2.3 Rewrite
authenticate()as CognitoInitiateAuthUSER_PASSWORD_AUTHwithClientMetadata {recaptchaToken, recaptchaAction, domain}; parse withcontent_type=None; read tokens fromAuthenticationResult; raiseAuthenticationError(code =ChallengeName) when the result is missing or incomplete; parse__type/messagefrom rejection bodies, tolerating namespaced types and non-JSON bodies; log no secrets - 2.4 Add
tests/test_api_authenticate.py(stdlib-only, loadsapi.pywithout Home Assistant, fake session) covering every scenario in theapi-clientdelta; verifypython3 -m unittest tests.test_api_authenticatepasses
3. Config flow errors
- 3.1 In
async_step_token, maperr.kindtotoken_rejected/invalid_credentials/invalid_auth; oninvalid_credentialsre-show theuserform (setup) orreauth_confirmform (reauth) with the error instead of the token form - 3.2 Pass
description_placeholders={"reason": ...}on everyasync_show_formforuser,reauth_confirmandtoken(empty string when there is no error) - 3.3 In
strings.jsonandtranslations/en.json, rewordinvalid_authto include{reason}and addinvalid_credentialsandtoken_rejected; verify the two files stay identical (diff) - 3.4 Extend
tests/test_config_flow.py: one test per error key (setup and reauth), asserting the form step, the error key and thereasonplaceholder; updatetest_reauth_bad_token_keeps_old_tokensfor the new key; add a check that everyerrors["base"]value inconfig_flow.pyexists in both translation files; verify.venv-test/bin/pytest tests/passes (harness bumped to 0.13.375 / core 2026.10.4, see branch commit)
4. README
- 4.1 Keep step 2 to one command that logs the token and adds a "Click THIS BLACK BOX to copy" button using
navigator.clipboard.writeText(DevToolscopy()cannot copy an async result in Firefox or Chromium, and Chromium truncatesprompt()defaults at 2,000 chars); test in Firefox and Chrome/Edge that the clipboard receives the full token; reword steps 4–5 to "paste it"; add one sentence to run it once at the console prompt (not as a Live expression) and a fallback line usingconsole.log(t); verify the snippet runs in a browser console on the en-gb login page and the clipboard holds a ~2,600-char token
5. On-device verification and version
- 5.1 Bump
manifest.jsonto 0.4.4 (shared withadd-keg-48180, which must not bump it again) - 5.5 Run the full suite (
.venv-test/bin/pytest tests/andpython3 -m unittest discover -s tests) and confirm green
Deferred: shipping without on-device checks
Maintainer decision, 2026-11-07: ship v0.4.4 without these on-device checks (no time for a Home Assistant reinstall). Coverage at release is the automated suite plus the README token verified in Firefox and Chromium; sign-in against the live service is untested. Run them after release; the open TODO is in PROJECT_HYGIENE.md.
- 5.2 Install the branch build on Home Assistant and add the integration from scratch with a fresh README token; confirm the entry is created and sensors populate
- 5.3 With a deliberately wrong password, confirm the flow returns to the credentials form showing
invalid_credentialsand Cognito's reason; with a stale (>2 min) token, confirmtoken_rejectedon the token form - 5.4 Trigger a reauth on the existing entry and confirm it succeeds; if a keg is fitted, also confirm Keg Freshness keeps its countdown and clear that TODO in
PROJECT_HYGIENE.md
Workflow follow-up
- Release jointly with
add-keg-48180: integration v0.4.4 and card v0.4.4, published together. Release notes credit cesa030 (root cause and fix in #11) and brettjenkins (fork that confirmed it). - After the release is live, comment on #11 with the release link and close it.
- #12 and #13 are closed as duplicates of #11 (each with a thank-you comment) ahead of the release; post the release link there too.
- Archive per
AGENTS.md(merge, push, syncapi-clientandconfig-flowspecs, archive, remove worktree and branch).