forked from security/hakurei
internal/validate: relocate from app
These are free of the dispatcher from internal/app. This change relocates them into their own package. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
30
internal/validate/username_test.go
Normal file
30
internal/validate/username_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package validate_test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"hakurei.app/internal/validate"
|
||||
)
|
||||
|
||||
func TestIsValidUsername(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("long", func(t *testing.T) {
|
||||
if validate.IsValidUsername(strings.Repeat("a", validate.Sysconf(validate.SC_LOGIN_NAME_MAX))) {
|
||||
t.Errorf("IsValidUsername unexpected true")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("regexp", func(t *testing.T) {
|
||||
if validate.IsValidUsername("0") {
|
||||
t.Errorf("IsValidUsername unexpected true")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
if !validate.IsValidUsername("alice") {
|
||||
t.Errorf("IsValidUsername unexpected false")
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user