summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/register.py2
-rw-r--r--service/test/unit/config/test_register.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/service/pixelated/register.py b/service/pixelated/register.py
index 2a87fa36..b8e6e4fc 100644
--- a/service/pixelated/register.py
+++ b/service/pixelated/register.py
@@ -62,7 +62,7 @@ def register(
def validate_username(username):
accepted_characters = '^[a-z0-9\-\_\.]*$'
- if not re.match(accepted_characters, username):
+ if not re.match(accepted_characters, username) or len(username) > 8:
raise ValueError
diff --git a/service/test/unit/config/test_register.py b/service/test/unit/config/test_register.py
index 8e1a71a4..b127ab86 100644
--- a/service/test/unit/config/test_register.py
+++ b/service/test/unit/config/test_register.py
@@ -13,6 +13,10 @@ class TestRegister(unittest.TestCase):
with self.assertRaises(ValueError):
validate_username('invalid@username')
+ def test_username_at_least_8_characters(self):
+ with self.assertRaises(ValueError):
+ validate_username('short')
+
def test_username_pass_when_valid(self):
try:
validate_username('a.valid_username-123')