Usernames can't start with numbers
This commit is contained in:
parent
523134f24b
commit
2b987e6e93
|
@ -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 =
|
||||
|
|
Loading…
Reference in New Issue