Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Remove obsolete create_session_cookie
Browse files Browse the repository at this point in the history
This was only used for session faking in the test suite, but has been
rendered obsolete by the parent commit.
  • Loading branch information
lunkwill42 committed Sep 16, 2024
1 parent e398579 commit 984516f
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions python/nav/web/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
"""
import logging

from django.conf import settings
from django.contrib.sessions.backends.db import SessionStore

from nav.models.profiles import Account


Expand Down Expand Up @@ -87,24 +84,3 @@ def authorization_not_required(fullpath):
if fullpath.startswith(url):
_logger.debug('authorization_not_required: %s', url)
return True


def create_session_cookie(username):
"""Creates an active session for username and returns the resulting
session cookie.
This is useful to fake login sessions during testing.
"""
user = Account.objects.get(login=username)
session = SessionStore()
session[ACCOUNT_ID_VAR] = user.id
session.save()

cookie = {
'name': settings.SESSION_COOKIE_NAME,
'value': session.session_key,
'secure': False,
'path': '/',
}
return cookie

0 comments on commit 984516f

Please sign in to comment.