def test_no_auth_with_nonexistant_client(self): request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring( 'abc;123;mjumbewu;[email protected]').strip() auth = get_authed_user(request) assert_is_none(auth)
def test_no_auth_with_invalid_remote_auth_header_data(self): request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring( 'skittles').strip() auth = get_authed_user(request) assert_is_none(auth)
def test_no_auth_with_client_with_no_permissions(self): Client.objects.create(client_id='abc', client_secret='123', client_type=CONFIDENTIAL, url='http://www.example.com', redirect_uri='http://www.example.com') request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring('abc;123;mjumbewu;[email protected]').strip() auth = get_authed_user(request) assert_is_none(auth)
def test_auth_with_client_with_login_permissions(self): User = get_user_model() User.objects.create_user(username='******', email='*****@*****.**', password='******') client = Client.objects.create(client_id='abc', client_secret='123', client_type=CONFIDENTIAL, url='http://www.example.com', redirect_uri='http://www.example.com') ClientPermissions.objects.create(client=client, allow_remote_signin=True) request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring('abc;123;mjumbewu;[email protected]').strip() auth = get_authed_user(request) assert_is_not_none(auth)
def test_no_auth_with_client_with_no_permissions(self): User = get_user_model() user = User.objects.create_user(username='******', email='*****@*****.**', password='******') Application.objects.create(client_id='abc', client_secret='123', user_id=user.id, client_type=Application.CLIENT_CONFIDENTIAL, redirect_uris='http://www.example.com') request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring( 'abc;123;mjumbewu;[email protected]').strip() auth = get_authed_user(request) assert_is_none(auth)
def test_no_auth_with_non_remote_auth_header(self): request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Basic abcdefg' auth = get_authed_user(request) assert_is_none(auth)
def test_no_auth_with_blank_auth_header(self): request = RequestFactory().get('') request.META.pop('HTTP_AUTHORIZATION', None) auth = get_authed_user(request) assert_is_none(auth)
def test_no_auth_with_nonexistant_client(self): request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring('abc;123;mjumbewu;[email protected]').strip() auth = get_authed_user(request) assert_is_none(auth)
def test_no_auth_with_invalid_remote_auth_header_data(self): request = RequestFactory().get('') request.META['HTTP_AUTHORIZATION'] = 'Remote ' + base64.encodestring('skittles').strip() auth = get_authed_user(request) assert_is_none(auth)