core: make test user's password optional

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-23 19:06:44 +01:00
parent d785998c5a
commit 9835785864
2 changed files with 4 additions and 3 deletions

View File

@ -22,7 +22,7 @@ def create_test_flow(designation: FlowDesignation = FlowDesignation.STAGE_CONFIG
) )
def create_test_admin_user(name: Optional[str] = None) -> User: def create_test_admin_user(name: Optional[str] = None, set_password = False) -> User:
"""Generate a test-admin user""" """Generate a test-admin user"""
uid = generate_id(20) if not name else name uid = generate_id(20) if not name else name
group = Group.objects.create(name=uid, is_superuser=True) group = Group.objects.create(name=uid, is_superuser=True)
@ -31,6 +31,7 @@ def create_test_admin_user(name: Optional[str] = None) -> User:
name=uid, name=uid,
email=f"{uid}@goauthentik.io", email=f"{uid}@goauthentik.io",
) )
if set_password:
user.set_password(uid) user.set_password(uid)
group.users.add(user) group.users.add(user)
return user return user

View File

@ -49,7 +49,7 @@ class TestProviderLDAP(SeleniumTestCase):
def _prepare(self) -> User: def _prepare(self) -> User:
"""prepare user, provider, app and container""" """prepare user, provider, app and container"""
# set additionalHeaders to test later # set additionalHeaders to test later
user = create_test_admin_user() user = create_test_admin_user(set_password=True)
user.attributes["extraAttribute"] = "bar" user.attributes["extraAttribute"] = "bar"
user.save() user.save()