diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-03-30 10:22:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-30 10:22:23 +0200 |
| commit | 7330408ac36f893a4a11c668ba230b440ec09f41 (patch) | |
| tree | fb928c361adf71a85dc7efe5c4fdf33b2611cff6 /tests | |
| parent | b347dc63d5468564cbb7050461565f4f89032664 (diff) | |
Reverted "Refs #31949 -- Enabled @sensitive_variables to work with async functions."
This reverts commits 23cbed21876bf02f4600c0dac3a5277db5b2afbb and
203a15cadbf8d03b51df1b28d89b2e7ab4264973.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/view_tests/tests/test_debug.py | 43 | ||||
| -rw-r--r-- | tests/view_tests/views.py | 18 |
2 files changed, 4 insertions, 57 deletions
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py index d0bcc68032..15e69f6811 100644 --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -9,8 +9,6 @@ from io import StringIO from pathlib import Path from unittest import mock, skipIf, skipUnless -from asgiref.sync import async_to_sync, iscoroutinefunction - from django.core import mail from django.core.files.uploadedfile import SimpleUploadedFile from django.db import DatabaseError, connection @@ -41,7 +39,6 @@ from django.views.debug import ( from django.views.decorators.debug import sensitive_post_parameters, sensitive_variables from ..views import ( - async_sensitive_view, custom_exception_reporter_filter_view, index_page, multivalue_dict_key_error, @@ -1354,10 +1351,7 @@ class ExceptionReportTestMixin: Asserts that potentially sensitive info are displayed in the response. """ request = self.rf.post("/some_url/", self.breakfast_data) - if iscoroutinefunction(view): - response = async_to_sync(view)(request) - else: - response = view(request) + response = view(request) if check_for_vars: # All variables are shown. self.assertContains(response, "cooked_eggs", status_code=500) @@ -1377,10 +1371,7 @@ class ExceptionReportTestMixin: Asserts that certain sensitive info are not displayed in the response. """ request = self.rf.post("/some_url/", self.breakfast_data) - if iscoroutinefunction(view): - response = async_to_sync(view)(request) - else: - response = view(request) + response = view(request) if check_for_vars: # Non-sensitive variable's name and value are shown. self.assertContains(response, "cooked_eggs", status_code=500) @@ -1427,10 +1418,7 @@ class ExceptionReportTestMixin: with self.settings(ADMINS=[("Admin", "admin@fattie-breakie.com")]): mail.outbox = [] # Empty outbox request = self.rf.post("/some_url/", self.breakfast_data) - if iscoroutinefunction(view): - async_to_sync(view)(request) - else: - view(request) + view(request) self.assertEqual(len(mail.outbox), 1) email = mail.outbox[0] @@ -1463,10 +1451,7 @@ class ExceptionReportTestMixin: with self.settings(ADMINS=[("Admin", "admin@fattie-breakie.com")]): mail.outbox = [] # Empty outbox request = self.rf.post("/some_url/", self.breakfast_data) - if iscoroutinefunction(view): - async_to_sync(view)(request) - else: - view(request) + view(request) self.assertEqual(len(mail.outbox), 1) email = mail.outbox[0] @@ -1558,15 +1543,6 @@ class ExceptionReporterFilterTests( self.verify_safe_response(sensitive_view) self.verify_safe_email(sensitive_view) - def test_async_sensitive_request(self): - with self.settings(DEBUG=True): - self.verify_unsafe_response(async_sensitive_view) - self.verify_unsafe_email(async_sensitive_view) - - with self.settings(DEBUG=False): - self.verify_safe_response(async_sensitive_view) - self.verify_safe_email(async_sensitive_view) - def test_paranoid_request(self): """ No POST parameters and frame variables can be seen in the @@ -1914,17 +1890,6 @@ class NonHTMLResponseExceptionReporterFilter( with self.settings(DEBUG=False): self.verify_safe_response(sensitive_view, check_for_vars=False) - def test_async_sensitive_request(self): - """ - Sensitive POST parameters cannot be seen in the default - error reports for sensitive requests. - """ - with self.settings(DEBUG=True): - self.verify_unsafe_response(async_sensitive_view, check_for_vars=False) - - with self.settings(DEBUG=False): - self.verify_safe_response(async_sensitive_view, check_for_vars=False) - def test_paranoid_request(self): """ No POST parameters can be seen in the default error reports diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py index 97febdaf83..a9eeee3cd2 100644 --- a/tests/view_tests/views.py +++ b/tests/view_tests/views.py @@ -178,24 +178,6 @@ def sensitive_view(request): return technical_500_response(request, *exc_info) -@sensitive_variables("sauce") -@sensitive_post_parameters("bacon-key", "sausage-key") -async def async_sensitive_view(request): - # Do not just use plain strings for the variables' values in the code - # so that the tests don't return false positives when the function's source - # is displayed in the exception report. - cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA - sauce = "".join( # NOQA - ["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"] - ) - try: - raise Exception - except Exception: - exc_info = sys.exc_info() - send_log(request, exc_info) - return technical_500_response(request, *exc_info) - - @sensitive_variables() @sensitive_post_parameters() def paranoid_view(request): |
