Skip to content

Commit

Permalink
Resolved #32
Browse files Browse the repository at this point in the history
checking that django.contrib.auth is in INSTALLED_APPS
  • Loading branch information
apragacz committed Mar 2, 2019
1 parent 0d38fb5 commit 69e301c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rest_registration/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class ErrorCode(object):
NO_TOKEN_AUTH_CONFIG = 'E005'
NO_TOKEN_AUTH_INSTALLED = 'E006'
INVALID_EMAIL_TEMPLATE_CONFIG = 'E007'
NO_AUTH_INSTALLED = 'E008'


@register()
@simple_check(
'django.contrib.auth is not in INSTALLED_APPS',
ErrorCode.NO_AUTH_INSTALLED,
)
def auth_installed_check():
return 'django.contrib.auth' in settings.INSTALLED_APPS


@register()
Expand Down Expand Up @@ -142,6 +152,7 @@ def implies(premise, conclusion):


__ALL_CHECKS__ = [
auth_installed_check,
reset_password_verification_url_check,
register_verification_url_check,
register_email_verification_url_check,
Expand Down
23 changes: 23 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ def test_checks_missing_token_auth_config(self):
ErrorCode.NO_TOKEN_AUTH_CONFIG,
])

@override_settings(
INSTALLED_APPS=(
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_registration',
),
REST_REGISTRATION={
'REGISTER_VERIFICATION_ENABLED': False,
'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
'RESET_PASSWORD_VERIFICATION_ENABLED': False,
},
)
def test_checks_missing_auth_installed(self):
errors = simulate_checks()
self.assert_error_codes_match(errors, [
ErrorCode.NO_AUTH_INSTALLED,
])

@override_settings(
INSTALLED_APPS=(
'django.contrib.admin',
Expand Down

0 comments on commit 69e301c

Please sign in to comment.