예제 #1
0
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."
예제 #2
0
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."
예제 #3
0
def test_validate_user_debian_invalid(test_input):
    with pytest.raises(ValidationError) as e:
        validate_user(test_input, USERNAME_VALIDATION_OPTIONS.debian)
    assert str(e.value) == "Username contains invalid characters."
예제 #4
0
def test_invalid_call_of_validate_user():
    with pytest.raises(ValidationError) as e:
        validate_user("test", None)
    assert str(e.value) == "Invalid username validator."
예제 #5
0
def test_validate_user(test_input):
    validate_user(test_input, USERNAME_VALIDATION_OPTIONS.useradd)
예제 #6
0
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."
예제 #7
0
def test_validate_user_disabled(test_input):
    validate_user(test_input, USERNAME_VALIDATION_OPTIONS.disabled)
예제 #8
0
def test_validate_user_email(test_input):
    validate_user(test_input, USERNAME_VALIDATION_OPTIONS.email)
예제 #9
0
def test_validate_user_principal(test_input):
    validate_user(test_input, USERNAME_VALIDATION_OPTIONS.principal)
예제 #10
0
def test_validate_user_debian(test_input):
    validate_user(test_input, USERNAME_VALIDATION_OPTIONS.debian)
예제 #11
0
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.'
예제 #12
0
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.'