title: Django rest framework Authentcation Testing
body: <p>I'm trying to make a test case for authentication with JWT, in this case with <a href="https://github.com/GetBlimp/django-rest-framework-jwt" rel="noreferrer">django-rest-framework-jwt</a>, then, with <code>curl</code> I get the next, so:</p>
  <pre><code>curl -X POST -d &quot;email=testuser@test.com&amp;password=testing&quot; http://localhost:8000/api/auth/token/
  </code></pre>
  <p>Get:</p>
  <pre><code>{&quot;token&quot;:&quot;eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo0LCJlbWFpbCI6InRlc3R1c2VyQHRlc3QuY29tIiwiZXhwIjoxNDIyNTkxMTQ5LCJ1c2VybmFtZSI6InRlc3R1c2VyQHRlc3QuY29tIn0.OT8ggcZYWxcbSy0Vv8u5PA3QISIdarNXTVuvu4QQjnw&quot;}
  </code></pre>
  <p>But, when I run my test case:</p>
  <pre><code>class BaseTestCase(TestCase):
  
      def setUp(self):
          self.csrf_client = APIClient(enforce_csrf_checks=True)
          self.email = 'testuser@test.com'
          self.name = 'test user'
          self.password = 'testing'
          user = Usuario.objects.create_user(email=self.email, name=self.name, password=self.password)
          user.save()
          self.data = {
              'email': self.email,
              'password': self.password
          }
          self.url = '/api/auth/token/'
  
  
  class ObtainJSONWebTokenTests(BaseTestCase):
  
      def test_jwt_login_json(self):
          &quot;&quot;&quot;
          Ensure JWT login view using JSON POST works.
          &quot;&quot;&quot;
          client = APIClient(enforce_csrf_checks=True)
  
          response = client.post(self.url, self.data, format='json')
          self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
  
      def test_jwt_login_json_incomplete_creds(self):
          &quot;&quot;&quot;
          Ensure JWT login view using JSON POST fails
          if incomplete credentials are used.
          &quot;&quot;&quot;
          client = APIClient(enforce_csrf_checks=True)
  
          self.data = {
              'email': self.email
          }
          response = client.post(self.url, self.data, format='json')
          self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.data)
  </code></pre>
  <p>I got this:</p>
  <pre><code>Creating test database for alias 'default'...
  F.
  ======================================================================
  FAIL: test_jwt_login_json (user.tests.ObtainJSONWebTokenTests)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File &quot;/home/rizotas/Proyects/django/src/rescue/user/tests.py&quot;, line 34, in test_jwt_login_json
      self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
  AssertionError: 400 != 200 : ReturnDict([('non_field_errors', ['Unable to login with provided credentials.'])])
  
  ----------------------------------------------------------------------
  Ran 2 tests in 0.374s
  
  FAILED (failures=1)
  Destroying test database for alias 'default'...
  </code></pre>
  <p>any idea?</p>
  <p>Thanks so much!</p>
  <h3>Update:</h3>
  <p>my settings</p>
  <pre><code>INSTALLED_APPS = (
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      #'django.contrib.messages',
      'django.contrib.staticfiles',
      'rest_framework',
      'debug_toolbar',
      'debug_panel',
      ...)
  
  
  REST_FRAMEWORK = {
      'DEFAULT_PERMISSION_CLASSES': (
          'rest_framework.permissions.IsAuthenticated',
      ),
      'DEFAULT_AUTHENTICATION_CLASSES': (
          'rest_framework.authentication.SessionAuthentication',
          'rest_framework.authentication.BasicAuthentication',
         'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
      ),
      'TEST_REQUEST_DEFAULT_FORMAT': 'json',
      'TEST_REQUEST_RENDERER_CLASSES': (
          'rest_framework.renderers.MultiPartRenderer',
          'rest_framework.renderers.JSONRenderer',
          #'rest_framework.renderers.YAMLRenderer'
      )
  }
  </code></pre>