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"""
uid = generate_id(20) if not name else name
group = Group.objects.create(name=uid, is_superuser=True)
@ -31,7 +31,8 @@ def create_test_admin_user(name: Optional[str] = None) -> User:
name=uid,
email=f"{uid}@goauthentik.io",
)
user.set_password(uid)
if set_password:
user.set_password(uid)
group.users.add(user)
return user

View File

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