dataprovider: add naming rules

naming rules allow to support case insensitive usernames, trim trailing
and leading white spaces, and accept any valid UTF-8 characters in
usernames.

If you were enabling `skip_natural_keys_validation` now you need to
set `naming_rules` to `1`

Fixes #687

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-01-31 18:01:37 +01:00
parent fb2d59ec92
commit 02db00d008
13 changed files with 137 additions and 30 deletions

View File

@@ -1053,7 +1053,7 @@ func checkFolder(expected *vfs.BaseVirtualFolder, actual *vfs.BaseVirtualFolder)
return errors.New("folder ID mismatch")
}
}
if expected.Name != actual.Name {
if dataprovider.ConvertName(expected.Name) != actual.Name {
return errors.New("name mismatch")
}
if expected.MappedPath != actual.MappedPath {
@@ -1145,7 +1145,7 @@ func checkAdmin(expected, actual *dataprovider.Admin) error {
}
func compareAdminEqualFields(expected *dataprovider.Admin, actual *dataprovider.Admin) error {
if expected.Username != actual.Username {
if dataprovider.ConvertName(expected.Username) != actual.Username {
return errors.New("sername mismatch")
}
if expected.Email != actual.Email {
@@ -1605,7 +1605,7 @@ func compareUserFilePatternsFilters(expected *dataprovider.User, actual *datapro
}
func compareEqualsUserFields(expected *dataprovider.User, actual *dataprovider.User) error {
if expected.Username != actual.Username {
if dataprovider.ConvertName(expected.Username) != actual.Username {
return errors.New("username mismatch")
}
if expected.HomeDir != actual.HomeDir {