Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict credential authentication in tests #2368

Merged
merged 17 commits into from
Oct 22, 2024
Merged

Strict credential authentication in tests #2368

merged 17 commits into from
Oct 22, 2024

Conversation

erikbern
Copy link
Contributor

@erikbern erikbern commented Oct 21, 2024

This makes the credential authentication in tests a lot more strict – it checks the token and secret on every request. Basically what the real production API already does.

This change will make it easier to remove ClientHello while retain tests for most/all of the logic (since we're going to rely on grpc errors from other routes instead).

Broken out of #2361 which conflated a bunch of different changes. Better to make tests stricter first.

Ended up being a much bigger change than I anticipated (lots of test that relied on no authentication).

Open question: should we create a random token for each test? That wouldn't be significantly harder and maybe it's an even stronger test.

@erikbern erikbern changed the title Fix authentication in tests (WIP) Strict credential authentication in tests Oct 21, 2024
@erikbern erikbern requested a review from mwaskom October 21, 2024 22:21
@erikbern erikbern requested a review from freider October 21, 2024 22:48
Copy link
Contributor

@mwaskom mwaskom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that isn't obvious to me here is when we need the token_env fixture.

Open question: should we create a random token for each test? That wouldn't be significantly harder and maybe it's an even stronger test.

Yeah — this feels like it might be worth doing? We've had weird state-spillover issues with the mocking in the past that have caused and/or masked issues.

@erikbern
Copy link
Contributor Author

One thing that isn't obvious to me here is when we need the token_env fixture.

Mostly when we have subprocesses (since they inherit env from the parent) but arguably it would be cleaner to make that explicit

Open question: should we create a random token for each test? That wouldn't be significantly harder and maybe it's an even stronger test.

Yeah — this feels like it might be worth doing? We've had weird state-spillover issues with the mocking in the past that have caused and/or masked issues.

Let me see if it's easy to do. There's a risk it's hard but I'll try in a separate PR.

@erikbern erikbern merged commit c6e51c1 into main Oct 22, 2024
21 checks passed
@erikbern erikbern deleted the erikbern/test-auth branch October 22, 2024 00:35
@erikbern
Copy link
Contributor Author

Thanks @mwaskom

freider pushed a commit that referenced this pull request Oct 22, 2024
* Check credentials in unit tests

* Fix e2e_test

* Fix container_app_test

* Fix container_test

* Better event handler

* Fix token flow tests

* Fix client_test

* Fix grpc_utils_test

* Fix live_reload_test

* Fix cli_test

* Fix mounted_files_test

* Fix config_test

* Fix shutdown_test

* Fix image_test

* Fix? fork_test

* Use enums instead of hardcoded integers

* typo
modal-pr-review-automation bot pushed a commit that referenced this pull request Oct 24, 2024
….-prefixed ancestor dirs (#2366)

* Fix mounting of packages from .venv not working due to over-eager module_mount_condition

* Adds test

* Fixes and debug logging

* Add test to deploy from within container (#2365)

* [auto-commit] [skip ci] Bump the build number

* Miscellaneous cleanup of `@app.cls` code (#2362)

* [auto-commit] [skip ci] Bump the build number

* Add _experimental_spawn function (#2354)

* Add _experimental_spawn function

* Add type to signature

* Address PR comments

* [auto-commit] [skip ci] Bump the build number

* Move the authentication check during running/deploy earlier (#2370)

* [auto-commit] [skip ci] Bump the build number

* Strict credential authentication in tests (#2368)

* Check credentials in unit tests

* Fix e2e_test

* Fix container_app_test

* Fix container_test

* Better event handler

* Fix token flow tests

* Fix client_test

* Fix grpc_utils_test

* Fix live_reload_test

* Fix cli_test

* Fix mounted_files_test

* Fix config_test

* Fix shutdown_test

* Fix image_test

* Fix? fork_test

* Use enums instead of hardcoded integers

* typo

* [auto-commit] [skip ci] Bump the build number

* Use unique server credentials in every unit test (#2372)

Use per-test credentials

* [auto-commit] [skip ci] Bump the build number

* use a container client for test_container_debug_snapshot (#2373)

* [auto-commit] [skip ci] Bump the build number

* Fix container app tests (part 2) – use the right client type (#2376)

Fix container app tests

* [auto-commit] [skip ci] Bump the build number

* Extend test

---------

Co-authored-by: Erik Bernhardsson <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Deven Navani <[email protected]>
Co-authored-by: Ryan Culbertson <[email protected]>
Co-authored-by: Erik Bernhardsson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants