mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 21:20:08 -03:30
Fix broken tests after removing session authentication.
This commit is contained in:
@@ -130,6 +130,7 @@ class ApiV1ConfigView(APIView):
|
|||||||
|
|
||||||
class AuthTokenView(APIView):
|
class AuthTokenView(APIView):
|
||||||
|
|
||||||
|
authentication_classes = []
|
||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
serializer_class = AuthTokenSerializer
|
serializer_class = AuthTokenSerializer
|
||||||
model = AuthToken
|
model = AuthToken
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
|
||||||
# Python
|
# Python
|
||||||
|
import base64
|
||||||
import contextlib
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
@@ -175,7 +176,11 @@ class BaseTestMixin(object):
|
|||||||
auth = auth or self._current_auth
|
auth = auth or self._current_auth
|
||||||
if auth:
|
if auth:
|
||||||
if isinstance(auth, (list, tuple)):
|
if isinstance(auth, (list, tuple)):
|
||||||
client.login(username=auth[0], password=auth[1])
|
#client.login(username=auth[0], password=auth[1])
|
||||||
|
basic_auth = base64.b64encode('%s:%s' % (auth[0], auth[1]))
|
||||||
|
basic_auth = basic_auth.decode('ascii')
|
||||||
|
client_kwargs['HTTP_AUTHORIZATION'] = 'Basic %s' % basic_auth
|
||||||
|
client = Client(**client_kwargs)
|
||||||
elif isinstance(auth, basestring):
|
elif isinstance(auth, basestring):
|
||||||
client_kwargs['HTTP_AUTHORIZATION'] = 'Token %s' % auth
|
client_kwargs['HTTP_AUTHORIZATION'] = 'Token %s' % auth
|
||||||
client = Client(**client_kwargs)
|
client = Client(**client_kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user