Usernames can't start with numbers

This commit is contained in:
Moxie Marlinspike committed 2019-11-20 12:36:22 -08:00
1 parent 523134f24b
commit 2b987e6e93
2 files changed
+13 -1

No files matched your search

@@ -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();
}
@@ -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 =