aboutsummaryrefslogtreecommitdiff
path: root/internal/validate_test.go
diff options
context:
space:
mode:
authorMatthew Strapp <matt@mattstrapp.net>2024-01-25 14:17:20 -0600
committerGitHub <noreply@github.com>2024-01-25 21:17:20 +0100
commita4817f31c066fe82550f285d8662befac2468030 (patch)
tree537fa95ca07bc3dd9d4e390942980ab85d65d3f0 /internal/validate_test.go
parent00217a69d12aa65865966601504060f3b422dc93 (diff)
Allow + in MIDs as per MSC4009 (#3313)
This PR adds `+` to the username regex, per MSC4009. ### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below using a legally identifiable name](https://matrix-org.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately Signed-off-by: `Matt Strapp <matt@mattstrapp.net>`
Diffstat (limited to 'internal/validate_test.go')
-rw-r--r--internal/validate_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/validate_test.go b/internal/validate_test.go
index cd262613..1019102d 100644
--- a/internal/validate_test.go
+++ b/internal/validate_test.go
@@ -130,6 +130,11 @@ func Test_validateUsername(t *testing.T) {
domain: "localhost",
},
{
+ name: "special characters are allowed 3",
+ localpart: "+55555555555",
+ domain: "localhost",
+ },
+ {
name: "not all special characters are allowed",
localpart: "notallowed#", // contains #
domain: "localhost",
@@ -140,6 +145,16 @@ func Test_validateUsername(t *testing.T) {
},
},
{
+ name: "not all special characters are allowed 2",
+ localpart: "<notallowed", // contains <
+ domain: "localhost",
+ wantErr: ErrUsernameInvalid,
+ wantJSON: &util.JSONResponse{
+ Code: http.StatusBadRequest,
+ JSON: spec.InvalidUsername(ErrUsernameInvalid.Error()),
+ },
+ },
+ {
name: "username containing numbers",
localpart: "hello1337",
domain: "localhost",