From 5d442c2e6fa25fa45e783847f56f4e787ce959cb Mon Sep 17 00:00:00 2001 From: James Meakin <12661555+jmsmkn@users.noreply.github.com> Date: Thu, 16 May 2024 15:28:08 +0200 Subject: [PATCH] Add auth tokens --- scripts/pentest_fixtures.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/pentest_fixtures.py b/scripts/pentest_fixtures.py index f37897d377..795ba2cfa5 100644 --- a/scripts/pentest_fixtures.py +++ b/scripts/pentest_fixtures.py @@ -22,6 +22,7 @@ from django.core.files.uploadedfile import InMemoryUploadedFile from django.db.transaction import on_commit from faker import Faker +from knox.models import AuthToken from PIL import Image as PILImage from PIL import ImageDraw, ImageFont @@ -636,9 +637,12 @@ def _create_user(first_name, last_name, *, superuser=False): user.user_profile.receive_newsletter = True user.user_profile.save() + _, token = AuthToken.objects.create(user=user, expiry=None) + user_info = { "username": user.username, "password": users_password, + "api-token": token, } if superuser: