This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
Fix TOTP retry logic, improve cassette handling; document #135
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As part of working on #134 I noticed that
setUp
intest_api.py
was not working as expected: when regenerating the cassette, authentication would either succeed, or it would fail and keep failing. The TOTP code was not successfully re-retrieved.The logic does not work as currently written because 1) it would keep using the same TOTP code if it actually looped, which it doesn't because, 2) it will quietly exit the loop after sleeping.
Because we're already using a cassette to record the API response(s), there's really no reason for an additional utility method to stash and load it -- we just need to make sure we don't run sleeps when we're in playback mode.
Also fixes a path error for the RPC policy changes documented in the README.
Status
Ready for review. CI will fail until #133 and #136 land.
Test plan
Reproduce the error
On the
main
branch, run the following command in your virtualenv:rm data/test-setup.yml && python -m pytest -v -k test_api_auth
What this command does: remove the setup cassette and attempt to obtain a fresh, valid API token
Run it again once or twice, in quick succession.
Reproduce the fix
Perform the same steps on this branch.
No sleep during playback
Check that the file
data/test-setup.yml
still contains a 403 response from the previous run. If not, re-run until you observe a sleep, then preservedata/test-setup.yml
with a 403 in it.Run all tests from the cassettes (reminded that dev env needs to be restarted between full test runs, due to the deletion related tests):