Skip to content

POST /register downcases capitals in usernames enforces behaviour that spec defines as optional #956

Open

Description

@timedoutuk

The spec for POST /_matrix/client/v3/register states that there are two options for handling invalid usernames (like non-lowercase ones):

  1. server MUST either map the provided username onto a user_id in a logical manner, or
  2. reject any username which does not comply to the grammar with M_INVALID_USERNAME.

However, the test fails any servers that do the second option:

  ❌ TestRegistration/parallel/POST_/register_downcases_capitals_in_usernames (40ms)
    apidoc_register_test.go:84: MatchResponse got status 400 want 200 - http://127.0.0.1:32872/_matrix/client/v3/register => {"errcode":"M_INVALID_USERNAME","error":"Username user-UPPER contains disallowed characters or spaces: identifier contains invalid characters"}

// sytest: POST /register downcases capitals in usernames
t.Run("POST /register downcases capitals in usernames", func(t *testing.T) {
t.Parallel()
reqBody, _ := startUIASession(t, unauthedClient, "user-UPPER", "sUp3rs3kr1t", nil)
res := unauthedClient.Do(t, "POST", []string{"_matrix", "client", "v3", "register"}, client.WithJSONBody(t, reqBody))
must.MatchResponse(t, res, match.HTTPResponse{
StatusCode: 200,
JSON: []match.JSON{
match.JSONKeyTypeEqual("access_token", gjson.String),
match.JSONKeyEqual("user_id", "@user-upper:hs1"),
},
})
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions