mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Normalize unix usernames to be under 32char
JupyterHub usernames do not have this restriction, causing user creation to fail when usernames are too large.
This commit is contained in:
24
tests/test_normalize.py
Normal file
24
tests/test_normalize.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
Test functions for normalizing various kinds of values
|
||||
"""
|
||||
from tljh.normalize import generate_system_username
|
||||
|
||||
|
||||
def test_generate_username():
|
||||
"""
|
||||
Test generating system usernames from hub usernames
|
||||
"""
|
||||
usernames = {
|
||||
# Very short
|
||||
'jupyter-test': 'jupyter-test',
|
||||
# Very long
|
||||
'jupyter-aelie9sohjeequ9iemeipuimuoshahz4aitugiuteeg4ohioh5yuiha6aei7te5z': 'jupyter-aelie9sohjeequ9iem-4b726',
|
||||
# 26 characters, just below our cutoff for hashing
|
||||
'jupyter-abcdefghijklmnopq': 'jupyter-abcdefghijklmnopq',
|
||||
# 27 characters, just above our cutoff for hashing
|
||||
'jupyter-abcdefghijklmnopqr': 'jupyter-abcdefghijklmnopqr-e375e',
|
||||
|
||||
}
|
||||
for hub_user, system_user in usernames.items():
|
||||
assert generate_system_username(hub_user) == system_user
|
||||
assert len(system_user) <= 32
|
||||
Reference in New Issue
Block a user