-
Notifications
You must be signed in to change notification settings - Fork 10
MNT: Remove deprecated NB_API_ALLOWED_ORIGINS variable #410 #540
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
Open
AviJxn
wants to merge
1
commit into
neurobagel:main
Choose a base branch
from
AviJxn:fix/remove-allowed-origins
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |||||
|
|
||||||
| from app import main | ||||||
| from app.api import env_settings | ||||||
| from app.api import utility as util | ||||||
| from app.main import settings | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -35,67 +34,6 @@ def test_start_app_without_environment_vars_fails( | |||||
| assert expected_msg in str(e_info.value) | ||||||
|
|
||||||
|
|
||||||
| def test_app_with_unset_allowed_origins( | ||||||
| test_app, | ||||||
| disable_auth, | ||||||
| set_temp_datasets_metadata_file, | ||||||
| monkeypatch, | ||||||
| caplog, | ||||||
| ): | ||||||
| """Tests that when the environment variable for allowed origins has not been set, a warning is raised and the app uses an empty list.""" | ||||||
| monkeypatch.setattr(settings, "allowed_origins", None) | ||||||
| expected_warning = "API was launched without providing any values for the NB_API_ALLOWED_ORIGINS environment variable" | ||||||
|
|
||||||
| with test_app: | ||||||
| pass | ||||||
|
|
||||||
| warnings = [ | ||||||
| record | ||||||
| for record in caplog.records | ||||||
| if record.levelno == logging.WARNING | ||||||
| ] | ||||||
|
|
||||||
| assert len(warnings) == 1 | ||||||
| assert expected_warning in warnings[0].getMessage() | ||||||
| assert util.parse_origins_as_list(settings.allowed_origins) == [] | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize( | ||||||
| "allowed_origins, parsed_origins", | ||||||
| [ | ||||||
| ("http://localhost:3000", ["http://localhost:3000"]), | ||||||
| ( | ||||||
| "http://localhost:3000 https://localhost:3000", | ||||||
| ["http://localhost:3000", "https://localhost:3000"], | ||||||
| ), | ||||||
| ( | ||||||
| " http://localhost:3000 https://localhost:3000 ", | ||||||
| ["http://localhost:3000", "https://localhost:3000"], | ||||||
| ), | ||||||
| ], | ||||||
| ) | ||||||
| def test_app_with_set_allowed_origins( | ||||||
| test_app, | ||||||
| monkeypatch, | ||||||
| allowed_origins, | ||||||
| parsed_origins, | ||||||
| disable_auth, | ||||||
| set_temp_datasets_metadata_file, | ||||||
| ): | ||||||
| """ | ||||||
| Test that when the environment variable for allowed origins has been explicitly set, | ||||||
| the app correctly parses it into a list. | ||||||
| """ | ||||||
| monkeypatch.setattr(settings, "allowed_origins", allowed_origins) | ||||||
|
|
||||||
| with test_app: | ||||||
| pass | ||||||
|
|
||||||
| assert set(parsed_origins).issubset( | ||||||
| util.parse_origins_as_list(settings.allowed_origins) | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| def fetched_configs_includes_neurobagel(disable_auth): | ||||||
|
||||||
| def fetched_configs_includes_neurobagel(disable_auth): | |
| def test_fetched_configs_includes_neurobagel(disable_auth): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With CORS middleware removed,
util.parse_origins_as_listappears to be unused (it’s currently only defined inapp/api/utility.py). The PR description says this helper was deleted, but it still exists; consider removing it to avoid dead code and to keep the implementation aligned with the PR description.