Commit fcc21645 authored by Christos Stavrakakis's avatar Christos Stavrakakis

helpdesk: Use 'mock' library to bypass auth

Use mock to library to bypass astakos authentication in helpdesk views.
parent ad70649c
......@@ -78,16 +78,7 @@ class AuthClient(Client):
return super(AuthClient, self).request(**request)
class HelpdeskTests(TestCase):
"""
Helpdesk tests. Test correctness of permissions and returned data.
"""
fixtures = ['helpdesk_test']
def setUp(self):
def get_user_mock(request, *args, **kwargs):
def get_user_mock(request, *args, **kwargs):
request.user_uniq = None
request.user = None
if request.META.get('HTTP_X_AUTH_TOKEN', None) == '0000':
......@@ -99,12 +90,17 @@ class HelpdeskTests(TestCase):
'helpdesk'],
'auth_token': '0001'}
# mock the astakos authentication function
from snf_django.lib import astakos
astakos.get_user = get_user_mock
import astakosclient
astakosclient.AstakosClient = AstakosClientMock
@mock.patch("astakosclient.AstakosClient", new=AstakosClientMock)
@mock.patch("snf_django.lib.astakos.get_user", new=get_user_mock)
class HelpdeskTests(TestCase):
"""
Helpdesk tests. Test correctness of permissions and returned data.
"""
fixtures = ['helpdesk_test']
def setUp(self):
settings.SKIP_SSH_VALIDATION = True
settings.HELPDESK_ENABLED = True
self.client = AuthClient()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment