Skip to content

Commit 136e441

Browse files
authored
Add tests for allowed symbols in user identifiers (#983)
https://matrix.org/docs/spec/appendices#user-identifiers Signed-off-by: Bohdan Horbeshko <bodqhrohro@gmail.com>
1 parent 86f3ed8 commit 136e441

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/10apidoc/01register.pl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,37 @@
180180
};
181181
}
182182

183+
184+
foreach my $chr (split '', 'q3._=-/' ) {
185+
test "POST /register allows registration of usernames with '$chr'",
186+
# Note: this test relies on somewhat implementation-specific details,
187+
# in that it assumes that the `username` presented to `/register` maps
188+
# directly onto an MXID. In reality, a server is free to accept or reject
189+
# any `usernames` it wants, provided it maps those it accepts onto
190+
# valid MXIDs.
191+
requires => [ $main::API_CLIENTS[0],
192+
qw( can_register_dummy_flow ) ],
193+
194+
do => sub {
195+
my ( $http ) = @_;
196+
197+
my $reqbody = {
198+
auth => {
199+
type => "m.login.dummy",
200+
},
201+
username => 'chrtestuser'.$chr,
202+
password => "sUp3rs3kr1t",
203+
};
204+
205+
$http->do_request_json(
206+
method => "POST",
207+
uri => "/r0/register",
208+
209+
content => $reqbody,
210+
);
211+
};
212+
}
213+
183214
push our @EXPORT, qw( localpart_fixture );
184215

185216
my $next_anon_uid = 1;

0 commit comments

Comments
 (0)