-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deployment check that dummy provider is not configured (#3340)
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.core.checks import Error, register | ||
|
||
|
||
@register(deploy=True) | ||
def check_dummy_provider_is_not_used(app_configs, **kwargs): | ||
from django.conf import settings | ||
|
||
errors = [] | ||
|
||
if ( | ||
"dummy" in settings.SOCIALACCOUNT_PROVIDERS.keys() | ||
or "allauth.socialaccount.providers.dummy" in settings.INSTALLED_APPS | ||
): | ||
errors.append( | ||
Error( | ||
"The dummy social account provider is configured. This provider should only be used for testing purposes and not in production.", | ||
hint="Remove the dummy provider from SOCIALACCOUNT_PROVIDERS and INSTALLED_APPS in your settings.", | ||
id="grandchallenge.profiles.E001", | ||
) | ||
) | ||
|
||
return errors |
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from grandchallenge.profiles import check_dummy_provider_is_not_used | ||
|
||
|
||
def test_check_dummy_provider_is_not_used(settings): | ||
|
||
errors = check_dummy_provider_is_not_used(None) | ||
|
||
assert len(errors) == 1 | ||
assert errors[0].id == "grandchallenge.profiles.E001" | ||
assert ( | ||
errors[0].msg | ||
== "The dummy social account provider is configured. This provider should only be used for testing purposes and not in production." | ||
) | ||
|
||
settings.SOCIALACCOUNT_PROVIDERS = {"dummy": {}} | ||
settings.INSTALLED_APPS.remove("allauth.socialaccount.providers.dummy") | ||
|
||
errors = check_dummy_provider_is_not_used(None) | ||
|
||
assert len(errors) == 1 | ||
assert errors[0].id == "grandchallenge.profiles.E001" | ||
assert ( | ||
errors[0].msg | ||
== "The dummy social account provider is configured. This provider should only be used for testing purposes and not in production." | ||
) |