Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_validate_user_disabled(test_input):
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.disabled)
def test_validate_user_debian(test_input):
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.debian)
def test_validate_user(test_input):
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.useradd)
def test_validate_user_contains_junk(test_input):
with pytest.raises(ValidationError) as e:
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.useradd)
assert str(e.value) == 'Username contains invalid characters.'
def test_validate_user_blacklist(test_input):
with pytest.raises(ValidationError) as e:
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.principal, 'root|admin.*|balrog|.+\'.*')
assert str(e.value) == 'Username contains invalid characters.'
def test_validate_user_too_long():
with pytest.raises(ValidationError) as e:
validate_user('a33characterusernameyoumustbenuts', USERNAME_VALIDATION_OPTIONS.useradd)
assert str(e.value) == 'Username is too long.'
def test_invalid_user_email(test_input):
with pytest.raises(ValidationError) as e:
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.email)
assert str(e.value) == 'Invalid email address.'
def test_validate_user_email(test_input):
validate_user(test_input, USERNAME_VALIDATION_OPTIONS.email)
def test_invalid_call_of_validate_user():
with pytest.raises(ValidationError) as e:
validate_user('test', None)
assert str(e.value) == 'Invalid username validator.'
def test_validate_user_debian_too_long():
with pytest.raises(ValidationError) as e:
validate_user('a33characterusernameyoumustbenuts', USERNAME_VALIDATION_OPTIONS.debian)
assert str(e.value) == 'Username is too long.'