From 75fa24315496bb0030ab8d085bab50fde475646f Mon Sep 17 00:00:00 2001 From: uchitsa Date: Wed, 7 Aug 2024 20:19:38 +0300 Subject: [PATCH 01/15] update signup account model for empty names --- .../typoreporter/web/model/SignupAccountModel.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java b/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java index b475a10b..32f0a224 100644 --- a/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java +++ b/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java @@ -4,13 +4,8 @@ import io.hexlet.typoreporter.domain.account.constraint.AccountUsername; import io.hexlet.typoreporter.service.dto.FieldMatchConsiderCase; import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; +import lombok.*; @Getter @Setter @@ -38,11 +33,9 @@ public class SignupAccountModel { @ToString.Exclude private String confirmPassword; - @NotBlank @Size(min = 1, max = 50) private String firstName; - @NotBlank @Size(min = 1, max = 50) private String lastName; } From 259a1b8960fe7724e6bb94f596b6d010ade9c122 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Thu, 15 Aug 2024 19:25:30 +0300 Subject: [PATCH 02/15] add test for signup account with empty names --- .../typoreporter/web/SignupControllerIT.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index d0b5ce1b..7fdd80ea 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -53,6 +53,7 @@ static void datasourceProperties(DynamicPropertyRegistry registry) { private static final String EMAIL_UPPER_CASE = "EMAIL_ADDRESS@GOOGLE.COM"; private static final String EMAIL_LOWER_CASE = EMAIL_UPPER_CASE.toLowerCase(); + private static final String EMPTY_NAME = ""; private final SignupAccountModel model = new SignupAccountModel( "model_upper_case", @@ -93,6 +94,22 @@ void createAccountWithIgnoreEmailCase() throws Exception { assertThat(accountRepository.count()).isEqualTo(1L); } + @Test + void createAccountWithEmptyNames() throws Exception { + model.setFirstName(EMPTY_NAME); + model.setLastName(EMPTY_NAME); + mockMvc.perform(post("/signup") + .param("username", model.getUsername()) + .param("email", model.getEmail()) + .param("password", model.getPassword()) + .param("confirmPassword", model.getConfirmPassword()) + .param("firstName", model.getFirstName()) + .param("lastName", model.getLastName()) + .with(csrf())) + .andReturn(); + assertThat(accountRepository.count()).isEqualTo(1L); + } + @Test void createAccountWithWrongEmailDomain() throws Exception { String userName = "testUser"; @@ -140,4 +157,5 @@ void signupInAccountWithBadEmail() throws Exception { var body = response.getResponse().getContentAsString(); assertThat(body).contains(String.format("The email "%s" is not valid", ACCOUNT_INCORRECT_EMAIL)); } + } From 0c12ef6c0fd51f4fb5dc581375fcf69b4bfd1885 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Thu, 15 Aug 2024 19:27:52 +0300 Subject: [PATCH 03/15] empty row --- src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index 7fdd80ea..15969006 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -157,5 +157,4 @@ void signupInAccountWithBadEmail() throws Exception { var body = response.getResponse().getContentAsString(); assertThat(body).contains(String.format("The email "%s" is not valid", ACCOUNT_INCORRECT_EMAIL)); } - } From 68b2c3c2732161688322ed660da18b143ab0d102 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Fri, 16 Aug 2024 14:21:14 +0300 Subject: [PATCH 04/15] fix createAccountWithEmptyNames test --- .../java/io/hexlet/typoreporter/web/SignupControllerIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index 15969006..ca70acc0 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -107,7 +107,7 @@ void createAccountWithEmptyNames() throws Exception { .param("lastName", model.getLastName()) .with(csrf())) .andReturn(); - assertThat(accountRepository.count()).isEqualTo(1L); + assertThat(accountRepository.findAccountByEmail(model.getEmail())).isNotEmpty(); } @Test From 5ed862f2fe2d2fd7cdd46e1d53a6f91a12ddcb3c Mon Sep 17 00:00:00 2001 From: uchitsa Date: Fri, 16 Aug 2024 14:22:17 +0300 Subject: [PATCH 05/15] fix lombok imports --- .../hexlet/typoreporter/web/model/SignupAccountModel.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java b/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java index 32f0a224..daa29773 100644 --- a/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java +++ b/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java @@ -5,7 +5,11 @@ import io.hexlet.typoreporter.service.dto.FieldMatchConsiderCase; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.Size; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; @Getter @Setter From 4382def94daf4664416457fb8376e89aa0068933 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Fri, 16 Aug 2024 14:23:23 +0300 Subject: [PATCH 06/15] fix min size to 0 for names --- .../io/hexlet/typoreporter/web/model/SignupAccountModel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java b/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java index daa29773..f91f1736 100644 --- a/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java +++ b/src/main/java/io/hexlet/typoreporter/web/model/SignupAccountModel.java @@ -37,9 +37,9 @@ public class SignupAccountModel { @ToString.Exclude private String confirmPassword; - @Size(min = 1, max = 50) + @Size(max = 50) private String firstName; - @Size(min = 1, max = 50) + @Size(max = 50) private String lastName; } From 194b85ee6ccfc74504c1ec1698f63f687ceefd81 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Sat, 17 Aug 2024 02:29:11 +0300 Subject: [PATCH 07/15] fix min size to 0 for names --- .../java/io/hexlet/typoreporter/domain/account/Account.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/hexlet/typoreporter/domain/account/Account.java b/src/main/java/io/hexlet/typoreporter/domain/account/Account.java index 66b9ecc9..007757a0 100644 --- a/src/main/java/io/hexlet/typoreporter/domain/account/Account.java +++ b/src/main/java/io/hexlet/typoreporter/domain/account/Account.java @@ -73,12 +73,10 @@ public class Account extends AbstractAuditingEntity implements Identifiable Date: Sat, 17 Aug 2024 02:43:32 +0300 Subject: [PATCH 08/15] update createAccountWithEmptyNames test --- .../typoreporter/web/SignupControllerIT.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index ca70acc0..f41cec35 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -95,19 +95,20 @@ void createAccountWithIgnoreEmailCase() throws Exception { } @Test - void createAccountWithEmptyNames() throws Exception { - model.setFirstName(EMPTY_NAME); - model.setLastName(EMPTY_NAME); + void createAccountWithEmptyNames() throws Exception { + String email = "testEmptyNames@test.ru"; + String firstName = EMPTY_NAME; + String lastName = EMPTY_NAME; mockMvc.perform(post("/signup") .param("username", model.getUsername()) - .param("email", model.getEmail()) + .param("email", email) .param("password", model.getPassword()) .param("confirmPassword", model.getConfirmPassword()) - .param("firstName", model.getFirstName()) - .param("lastName", model.getLastName()) + .param("firstName", firstName) + .param("lastName", lastName) .with(csrf())) .andReturn(); - assertThat(accountRepository.findAccountByEmail(model.getEmail())).isNotEmpty(); + assertThat(accountRepository.findAccountByEmail(email)).isNotEmpty(); } @Test From 166ff718a327a5cdb1819b965631aa011996125e Mon Sep 17 00:00:00 2001 From: uchitsa Date: Sat, 17 Aug 2024 03:02:01 +0300 Subject: [PATCH 09/15] update createAccountWithEmptyNames test --- .../java/io/hexlet/typoreporter/web/SignupControllerIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index f41cec35..0880071b 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -95,12 +95,13 @@ void createAccountWithIgnoreEmailCase() throws Exception { } @Test - void createAccountWithEmptyNames() throws Exception { + void createAccountWithEmptyNames() throws Exception { + String userName = "testEmptyNamesUser"; String email = "testEmptyNames@test.ru"; String firstName = EMPTY_NAME; String lastName = EMPTY_NAME; mockMvc.perform(post("/signup") - .param("username", model.getUsername()) + .param("username", userName) .param("email", email) .param("password", model.getPassword()) .param("confirmPassword", model.getConfirmPassword()) From 8816f2ec5ea91b2b823d015a4a847d3759de3572 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Mon, 19 Aug 2024 01:25:07 +0300 Subject: [PATCH 10/15] Update SignupControllerIT.java --- .../typoreporter/web/SignupControllerIT.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index 0880071b..633576b6 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -96,20 +96,18 @@ void createAccountWithIgnoreEmailCase() throws Exception { @Test void createAccountWithEmptyNames() throws Exception { - String userName = "testEmptyNamesUser"; - String email = "testEmptyNames@test.ru"; - String firstName = EMPTY_NAME; - String lastName = EMPTY_NAME; + String emptyNamesUser = "testEmptyNamesUser"; + String emptyNamesEmail = "testEmptyNames@test.ru"; mockMvc.perform(post("/signup") - .param("username", userName) - .param("email", email) + .param("username", emptyNamesUser) + .param("email", emptyNamesEmail) .param("password", model.getPassword()) .param("confirmPassword", model.getConfirmPassword()) - .param("firstName", firstName) - .param("lastName", lastName) + .param("firstName", EMPTY_NAME) + .param("lastName", EMPTY_NAME) .with(csrf())) .andReturn(); - assertThat(accountRepository.findAccountByEmail(email)).isNotEmpty(); + assertThat(accountRepository.findAccountByEmail(emptyNamesEmail)).isNotEmpty(); } @Test From 185c9824e9f48112ff8ad7c6fb968bd2e4089811 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Mon, 19 Aug 2024 01:36:42 +0300 Subject: [PATCH 11/15] Update UpdateProfile.java --- .../typoreporter/service/dto/account/UpdateProfile.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java b/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java index 9f16a1fc..2715e2db 100644 --- a/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java +++ b/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java @@ -20,11 +20,9 @@ public class UpdateProfile { message = "The email \"${validatedValue}\" is not valid") private String email; - @NotBlank - @Size(min = 1, max = 50) + @Size(max = 50) private String firstName; - @NotBlank - @Size(min = 1, max = 50) + @Size(max = 50) private String lastName; } From 4099d624af378a89e3402ca7f7c7de98008826d2 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Mon, 19 Aug 2024 01:45:04 +0300 Subject: [PATCH 12/15] Update SignupControllerIT.java --- .../java/io/hexlet/typoreporter/web/SignupControllerIT.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index 633576b6..b55aed42 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -98,11 +98,12 @@ void createAccountWithIgnoreEmailCase() throws Exception { void createAccountWithEmptyNames() throws Exception { String emptyNamesUser = "testEmptyNamesUser"; String emptyNamesEmail = "testEmptyNames@test.ru"; + String emptyNamesPassword = "P@$$w0rd"; mockMvc.perform(post("/signup") .param("username", emptyNamesUser) .param("email", emptyNamesEmail) - .param("password", model.getPassword()) - .param("confirmPassword", model.getConfirmPassword()) + .param("password", emptyNamesPassword) + .param("confirmPassword", emptyNamesPassword) .param("firstName", EMPTY_NAME) .param("lastName", EMPTY_NAME) .with(csrf())) From 133ac700528fb48a302d15f5a3c63bc065f01325 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Mon, 19 Aug 2024 01:52:20 +0300 Subject: [PATCH 13/15] Update SignupControllerIT.java --- .../java/io/hexlet/typoreporter/web/SignupControllerIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index b55aed42..eaf0e396 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -97,7 +97,7 @@ void createAccountWithIgnoreEmailCase() throws Exception { @Test void createAccountWithEmptyNames() throws Exception { String emptyNamesUser = "testEmptyNamesUser"; - String emptyNamesEmail = "testEmptyNames@test.ru"; + String emptyNamesEmail = "testemptynames@test.ru"; String emptyNamesPassword = "P@$$w0rd"; mockMvc.perform(post("/signup") .param("username", emptyNamesUser) From 0185d3a77a8ccb67a3f2eba4720558ffd47b25ed Mon Sep 17 00:00:00 2001 From: uchitsa Date: Mon, 19 Aug 2024 01:59:59 +0300 Subject: [PATCH 14/15] Update UpdateProfile.java --- .../hexlet/typoreporter/service/dto/account/UpdateProfile.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java b/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java index 2715e2db..262fdb4b 100644 --- a/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java +++ b/src/main/java/io/hexlet/typoreporter/service/dto/account/UpdateProfile.java @@ -2,7 +2,6 @@ import io.hexlet.typoreporter.domain.account.constraint.AccountUsername; import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; import lombok.Getter; import lombok.Setter; From a7e8a1fad0083da008bb802864dfc426254463f9 Mon Sep 17 00:00:00 2001 From: uchitsa Date: Wed, 28 Aug 2024 00:53:47 +0300 Subject: [PATCH 15/15] #286 update SignupControllerIT.java --- .../typoreporter/web/SignupControllerIT.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java index 03462f04..39f61c38 100644 --- a/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java +++ b/src/test/java/io/hexlet/typoreporter/web/SignupControllerIT.java @@ -55,7 +55,6 @@ static void datasourceProperties(DynamicPropertyRegistry registry) { private static final String EMAIL_UPPER_CASE = "EMAIL_ADDRESS@GOOGLE.COM"; private static final String EMAIL_LOWER_CASE = EMAIL_UPPER_CASE.toLowerCase(); - private static final String EMPTY_NAME = ""; private final SignupAccountModel model = new SignupAccountModel( "model_upper_case", @@ -106,19 +105,20 @@ void createAccountWithIgnoreEmailCase() throws Exception { @Test void createAccountWithEmptyNames() throws Exception { - String emptyNamesUser = "testEmptyNamesUser"; - String emptyNamesEmail = "testemptynames@test.ru"; - String emptyNamesPassword = "P@$$w0rd"; + String username = "testEmptyNamesUser"; + String email = "testemptynames@test.ru"; + String password = "P@$$w0rd"; + String emptyName = ""; mockMvc.perform(post("/signup") - .param("username", emptyNamesUser) - .param("email", emptyNamesEmail) - .param("password", emptyNamesPassword) - .param("confirmPassword", emptyNamesPassword) - .param("firstName", EMPTY_NAME) - .param("lastName", EMPTY_NAME) + .param("username", username) + .param("email", email) + .param("password", password) + .param("confirmPassword", password) + .param("firstName", emptyName) + .param("lastName", emptyName) .with(csrf())) .andReturn(); - assertThat(accountRepository.findAccountByEmail(emptyNamesEmail)).isNotEmpty(); + assertThat(accountRepository.findAccountByEmail(email)).isNotEmpty(); } @Test