fix: allow inactive users to submit support tickets (#26933)

This commit is contained in:
Syed Muhammad Dawoud Sheraz Ali
2021-03-10 19:43:49 +05:00
committed by GitHub
parent e797fec0df
commit 4d58626fd4
2 changed files with 18 additions and 1 deletions

View File

@@ -47,7 +47,16 @@ class ZendeskProxyTestCase(ApiTestCase):
}
return super(ZendeskProxyTestCase, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments
def test_post(self):
@ddt.data(
True, False
)
def test_post(self, user_activation_status):
"""
Test both active and inactive users can request Zendesk Proxy for the
submission of support tickets.
"""
self.user.is_active = user_activation_status
self.user.save()
with patch('requests.post', return_value=MagicMock(status_code=201)) as mock_post:
response = self.request_without_auth(
'post',

View File

@@ -3,6 +3,8 @@ Define request handlers used by the zendesk_proxy djangoapp
"""
import logging
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser
from rest_framework import status
from rest_framework.parsers import JSONParser
from rest_framework.response import Response
@@ -10,6 +12,7 @@ from rest_framework.throttling import UserRateThrottle
from rest_framework.views import APIView
from openedx.core.djangoapps.zendesk_proxy.utils import create_zendesk_ticket
from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser
logger = logging.getLogger(__name__)
REQUESTS_PER_HOUR = 50
@@ -32,6 +35,11 @@ class ZendeskPassthroughView(APIView):
"""
throttle_classes = (ZendeskProxyThrottle,)
parser_classes = (JSONParser,)
authentication_classes = (
JwtAuthentication,
BearerAuthenticationAllowInactiveUser,
SessionAuthenticationAllowInactiveUser,
)
def post(self, request):
"""