'Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF'

def test_post_json_passing_basic_auth(self):

    credentials = (u'%s:%s' % (self.username, self.password))
    base64_credentials = base64.b64encode(credentials.encode(HTTP_HEADER_ENCODING)).decode(HTTP_HEADER_ENCODING)
    auth = (u'Basic    %s' % base64_credentials)
    response = self.csrf_client.post(u'/basic/', {u'example': u'example'}, format=u'json', HTTP_AUTHORIZATION=auth)
    assert (response.status_code == status.HTTP_200_OK)
