For an application that uses SSO for login I have implemented a AuthBackend with Django Rest Framework. This custom AuthBackend class checks for the USERID present in the headers and based on that returns the user instance.
I have added permission classes to the views for verifying the authenticated users. In order to add unit tests to the code the APIClient must enable us to add custom header like {'FOO': 'BAR'}
The default class seems to be APIClient I have tried the following but none of them work:
class AccountsTests(APITestCase):
def test_user_is_authenticated(self):
...
headers = {'USERID': 'john.doe', 'FOO': 'BAR' }
self.client.get(url, headers) # Doesn't work
self.client.get(url, **headers) # Doesn't work
self.client.headers.update(headers) # Doesn't work
...