messages.add(Message.of(Validation.IS_TOO_SHORT_MESSAGE, LOGIN_PARAM, LOGIN_MIN_LENGTH));
} else if (login.length() > LOGIN_MAX_LENGTH) {
messages.add(Message.of(Validation.IS_TOO_LONG_MESSAGE, LOGIN_PARAM, LOGIN_MAX_LENGTH));
- } else if (!login.matches("\\A\\w[\\w\\.\\-_@\\s]+\\z")) {
+ } else if (!login.matches("\\A\\w[\\w\\.\\-_@]+\\z")) {
messages.add(Message.of("user.bad_login"));
}
}
}
}
+ @Test
+ public void fail_to_create_user_with_space_in_login() {
+ try {
+ userUpdater.create(NewUser.create()
+ .setLogin("mari us")
+ .setName("Marius")
+ .setEmail("marius@mail.com")
+ .setPassword("password"));
+ fail();
+ } catch (BadRequestException e) {
+ assertThat(e.errors().messages()).containsOnly(Message.of("user.bad_login"));
+ }
+ }
+
@Test
public void fail_to_create_user_with_too_short_login() {
try {
return this;
}
+ /**
+ * Spaces were authorized before SQ 5.4.
+ * For versions 5.4+ it's not possible to create a login with a space character.
+ */
public String getLogin() {
return login;
}