Added the ability to create a team with SSO services and added the ability to turn off email sign up.

Этот коммит содержится в:
JoramWilander
2015-08-28 08:37:55 -04:00
родитель db7e8c1288
Коммит f5fec3a157
30 изменённых файлов: 880 добавлений и 342 удалений

Просмотреть файл

@@ -150,3 +150,45 @@ func TestUserGetDisplayName(t *testing.T) {
t.Fatal("Display name should be nickname")
}
}
var usernames = []struct {
value string
expected bool
}{
{"spin-punch", true},
{"Spin-punch", false},
{"spin punch-", false},
{"spin_punch", true},
{"spin", true},
{"PUNCH", false},
{"spin.punch", true},
{"spin'punch", false},
{"spin*punch", false},
{"all", false},
}
func TestValidUsername(t *testing.T) {
for _, v := range usernames {
if IsValidUsername(v.value) != v.expected {
t.Errorf("expect %v as %v", v.value, v.expected)
}
}
}
func TestCleanUsername(t *testing.T) {
if CleanUsername("Spin-punch") != "spin-punch" {
t.Fatal("didn't clean name properly")
}
if CleanUsername("PUNCH") != "punch" {
t.Fatal("didn't clean name properly")
}
if CleanUsername("spin'punch") != "spin-punch" {
t.Fatal("didn't clean name properly")
}
if CleanUsername("spin") != "spin" {
t.Fatal("didn't clean name properly")
}
if len(CleanUsername("all")) != 27 {
t.Fatal("didn't clean name properly")
}
}