def test_authenticate_remote_user_should_return_account_if_header_set( self): r = RequestFactory() request = r.get('/') request.META['REMOTE_USER'] = '******' with patch("nav.web.auth._config.getboolean", return_value=True): with patch("nav.web.auth.Account.objects.get", new=MagicMock(return_value=REMOTE_USER_ACCOUNT)): assert auth.authenticate_remote_user( request) == REMOTE_USER_ACCOUNT
def test_authenticate_remote_user_should_return_false_if_account_locked(self): r = RequestFactory() request = r.get('/') request.META['REMOTE_USER'] = '******' with patch("nav.web.auth._config.getboolean", return_value=True): with patch( "nav.web.auth.Account.objects.get", return_value=REMOTE_USER_ACCOUNT ): with patch("nav.web.auth.LogEntry.add_log_entry"): with patch("nav.web.auth.Account.locked", return_value=True): assert auth.authenticate_remote_user(request) == False
def test_authenticate_remote_user_should_return_none_if_header_not_set( self): r = RequestFactory() request = r.get('/') with patch("nav.web.auth._config.getboolean", return_value=True): assert auth.authenticate_remote_user(request) == None