Skip to content

request with .force_athenticate() still giving 401 #8359

@Massakera

Description

@Massakera

Checklist

  • Raised initially as discussion #...
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.

I've been trying to implement a test in a view where my permission_class is (IsAuthenticated) but when I use force_authenticated(request,user=user) it still gives me 401 unauthorized. My testcase:

def test_final_result(self):
    user = User.objects.get(username='test1')
    story_id = Story.objects.get(storyName='testplanning').id
    room_id = PokerRoom.objects.get(name='planning').id
    request = self.client.post(reverse('finalvotes', kwargs={'pk': room_id, 'idStory': story_id}), {'finalResult': '2'}, format='json')
    force_authenticate(request, user=user)
    self.assertEqual(200,request.status_code) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions