fix: return username format error on registration

This commit is contained in:
richjohnrambo
2026-09-24 16:47:14 +08:00
parent d41956019a
commit 6453abdbd1
2 changed files with 25 additions and 4 deletions
+12
View File
@@ -71,6 +71,18 @@ func TestResolveRegistrationAccount(t *testing.T) {
}
}
func TestRegistrationAccountErrorParams(t *testing.T) {
params := registrationAccountErrorParams(errRegistrationUsernameInvalid)
if params["what"] != "username" || params["reason"] != "USERNAME_INVALID_FORMAT" {
t.Fatalf("got params=%v", params)
}
params = registrationAccountErrorParams(types.ErrPolicy)
if params["what"] != "account" || params["reason"] != "REGISTRATION_ACCOUNT_INVALID" {
t.Fatalf("got fallback params=%v", params)
}
}
func TestRegistrationSecretMatchesSelectedAccount(t *testing.T) {
if !registrationSecretMatches([]byte("alice:password:with-colon"), "alice") {
t.Fatal("matching account was rejected")