mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 08:16:47 +00:00
Usernames can't start with numbers
This commit is contained in:
1 parent
523134f24b
commit
2b987e6e93
2 files changed
+13
-1
No files matched your search
+1
-1
@@ -540,7 +540,7 @@ public class AccountController {
|
||||
|
||||
username = username.toLowerCase();
|
||||
|
||||
if (!username.matches("^[a-z0-9_]+$")) {
|
||||
if (!username.matches("^[a-z_][a-z0-9_]+$")) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -864,6 +864,18 @@ public class AccountControllerTest {
|
||||
assertThat(response.getStatus()).isEqualTo(400);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetInvalidPrefixUsername() {
|
||||
Response response =
|
||||
resources.getJerseyTest()
|
||||
.target("/v1/accounts/username/0n00bkiller")
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.put(Entity.text(""));
|
||||
|
||||
assertThat(response.getStatus()).isEqualTo(400);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetUsernameBadAuth() {
|
||||
Response response =
|
||||
|
||||
Reference in new issue
Block a user