Fix error messages and incorrect test

This commit is contained in:
Andrew Morgan 2018-07-06 11:21:35 +01:00
parent eb4adc7852
commit debd108ac5
2 changed files with 4 additions and 4 deletions

View file

@ -187,12 +187,12 @@ func validateUsername(username string) *util.JSONResponse {
} else if !validUsernameRegex.MatchString(username) { } else if !validUsernameRegex.MatchString(username) {
return &util.JSONResponse{ return &util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: jsonerror.InvalidUsername("User ID can only contain characters a-z, 0-9, or '_-./'"), JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./'"),
} }
} else if username[0] == '_' { // Regex checks its not a zero length string } else if username[0] == '_' { // Regex checks its not a zero length string
return &util.JSONResponse{ return &util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: jsonerror.InvalidUsername("User ID cannot start with a '_'"), JSON: jsonerror.InvalidUsername("Username cannot start with a '_'"),
} }
} }
return nil return nil
@ -208,7 +208,7 @@ func validateApplicationServiceUsername(username string) *util.JSONResponse {
} else if !validUsernameRegex.MatchString(username) { } else if !validUsernameRegex.MatchString(username) {
return &util.JSONResponse{ return &util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: jsonerror.InvalidUsername("User ID can only contain characters a-z, 0-9, or '_-./'"), JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./'"),
} }
} }
return nil return nil

View file

@ -168,7 +168,7 @@ func TestValidationOfApplicationServices(t *testing.T) {
// Create a fake application service // Create a fake application service
fakeID := "FakeAS" fakeID := "FakeAS"
fakeSenderLocalpart := "@_appservice_bot" fakeSenderLocalpart := "_appservice_bot"
fakeApplicationService := config.ApplicationService{ fakeApplicationService := config.ApplicationService{
ID: fakeID, ID: fakeID,
URL: "null", URL: "null",