| 1 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | |
| 3 | package auth |
| 4 | |
| 5 | import "testing" |
| 6 | |
| 7 | func TestIsReserved(t *testing.T) { |
| 8 | t.Parallel() |
| 9 | yes := []string{"login", "logout", "settings", "api", "admin", "shithub", "explore"} |
| 10 | for _, n := range yes { |
| 11 | if !IsReserved(n) { |
| 12 | t.Errorf("expected %q to be reserved", n) |
| 13 | } |
| 14 | } |
| 15 | if !IsReserved("LOGIN") { |
| 16 | t.Error("reserved check should be case-insensitive") |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | func TestIsReserved_AllowsRegularUsernames(t *testing.T) { |
| 21 | t.Parallel() |
| 22 | no := []string{"alice", "bob-dev", "myproject1", "carol"} |
| 23 | for _, n := range no { |
| 24 | if IsReserved(n) { |
| 25 | t.Errorf("did not expect %q to be reserved", n) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 |