예제 #1
0
    def test_private_bundle_mbox_token_auth(self):
        self.client.logout()

        # create tokens for both users
        for user in [self.user, self.other_user]:
            view_utils.regenerate_token(user)

        def _get_auth_string(user):
            return 'Token {}'.format(str(user.profile.token))

        # Check we can view as owner
        auth_string = _get_auth_string(self.user)
        response = self.client.get(self.url, HTTP_AUTHORIZATION=auth_string)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, self.patches[0].name)

        # Check we can't view as another user
        auth_string = _get_auth_string(self.other_user)
        response = self.client.get(self.url, HTTP_AUTHORIZATION=auth_string)
        self.assertEqual(response.status_code, 404)
예제 #2
0
    def test_private_bundle_mbox_token_auth(self):
        self.client.logout()

        # create tokens for both users
        for user in [self.user, self.other_user]:
            view_utils.regenerate_token(user)

        def _get_auth_string(user):
            return 'Token {}'.format(str(user.profile.token))

        # Check we can view as owner
        auth_string = _get_auth_string(self.user)
        response = self.client.get(self.url, HTTP_AUTHORIZATION=auth_string)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, self.patches[0].name)

        # Check we can't view as another user
        auth_string = _get_auth_string(self.other_user)
        response = self.client.get(self.url, HTTP_AUTHORIZATION=auth_string)
        self.assertEqual(response.status_code, 404)
예제 #3
0
파일: user.py 프로젝트: Aleks1966/patchwork
def generate_token(request):
    utils.regenerate_token(request.user)
    return HttpResponseRedirect(reverse('user-profile'))
예제 #4
0
파일: user.py 프로젝트: alialnu/patchwork
def generate_token(request):
    utils.regenerate_token(request.user)
    return HttpResponseRedirect(reverse('user-profile'))