Strengths invalid characters detection in username
By doing re.fullmatch per ogayot's recommendation. Added a test case to validate it. The added test would fail without the fullmatch.
This commit is contained in:
parent
79205ed3ea
commit
888eb344a2
|
@ -160,7 +160,7 @@ class IdentityController(SubiquityController):
|
||||||
if username in self._system_reserved_names:
|
if username in self._system_reserved_names:
|
||||||
return UsernameValidation.SYSTEM_RESERVED
|
return UsernameValidation.SYSTEM_RESERVED
|
||||||
|
|
||||||
if not re.match(USERNAME_REGEX, username):
|
if not re.fullmatch(USERNAME_REGEX, username):
|
||||||
return UsernameValidation.INVALID_CHARS
|
return UsernameValidation.INVALID_CHARS
|
||||||
|
|
||||||
if len(username) > USERNAME_MAXLEN:
|
if len(username) > USERNAME_MAXLEN:
|
||||||
|
|
|
@ -1083,3 +1083,7 @@ class TestIdentityValidation(TestAPI):
|
||||||
resp = await inst.get('/identity/validate_username',
|
resp = await inst.get('/identity/validate_username',
|
||||||
username='01root')
|
username='01root')
|
||||||
self.assertEqual(resp, 'INVALID_CHARS')
|
self.assertEqual(resp, 'INVALID_CHARS')
|
||||||
|
|
||||||
|
resp = await inst.get('/identity/validate_username',
|
||||||
|
username='o#$%^&')
|
||||||
|
self.assertEqual(resp, 'INVALID_CHARS')
|
||||||
|
|
Loading…
Reference in New Issue